From cd2e148c2441ee78eedc972bd2b665205f3a08da Mon Sep 17 00:00:00 2001 From: "Jonathan Thorpe (Sony)" Date: Wed, 22 May 2024 18:10:54 +0100 Subject: [PATCH 1/7] Add status-reporting data types (cherry picked from commit 40f42deffaf8d8f57f1692bac980b256472eeac8) --- .../nmos/control_protocol_handlers.cpp | 2 +- .../nmos/control_protocol_resource.cpp | 70 +++++++++++++++++-- Development/nmos/control_protocol_resource.h | 10 +++ Development/nmos/control_protocol_resources.h | 4 +- Development/nmos/control_protocol_state.cpp | 7 +- Development/nmos/control_protocol_typedefs.h | 60 ++++++++++++++-- 6 files changed, 140 insertions(+), 13 deletions(-) diff --git a/Development/nmos/control_protocol_handlers.cpp b/Development/nmos/control_protocol_handlers.cpp index 522bcc96..1fb5fdb4 100644 --- a/Development/nmos/control_protocol_handlers.cpp +++ b/Development/nmos/control_protocol_handlers.cpp @@ -80,7 +80,7 @@ namespace nmos // update receiver-monitor's connectionStatus and payloadStatus properties const auto active = nmos::fields::master_enable(nmos::fields::endpoint_active(connection_resource.data)); - const web::json::value connection_status = active ? nc_connection_status::connected : nc_connection_status::disconnected; + const web::json::value connection_status = active ? nc_connection_status::healthy : nc_connection_status::inactive; const web::json::value payload_status = active ? nc_payload_status::payload_ok : nc_payload_status::undefined; // hmm, maybe updating connectionStatusMessage and payloadStatusMessage too diff --git a/Development/nmos/control_protocol_resource.cpp b/Development/nmos/control_protocol_resource.cpp index 83ccaad0..b9b972dd 100644 --- a/Development/nmos/control_protocol_resource.cpp +++ b/Development/nmos/control_protocol_resource.cpp @@ -2024,20 +2024,22 @@ namespace nmos return details::make_nc_datatype_typedef(U("Version code in semantic versioning format"), U("NcVersionCode"), false, U("NcString"), value::null()); } + // Monitoring datatype defintions + // // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncconnectionstatus web::json::value make_nc_connection_status_datatype() { using web::json::value; auto items = value::array(); - web::json::push_back(items, details::make_nc_enum_item_descriptor(U("This is the value when there is no receiver"), U("Undefined"), 0)); - web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Connected to a stream"), U("Connected"), 1)); - web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Not connected to a stream"), U("Disconnected"), 2)); - web::json::push_back(items, details::make_nc_enum_item_descriptor(U("A connection error was encountered"), U("ConnectionError"), 3)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Inactive"), U("Inactive"), 0)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Active and healthy"), U("Healthy"), 1)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Active and partially healthy"), U("PartiallyHealthy"), 2)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Active and unhealthy"), U("Unhealthy"), 3)); return details::make_nc_datatype_descriptor_enum(U("Connection status enum data typee"), U("NcConnectionStatus"), items, value::null()); } - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncpayloadstatus + // ****************** web::json::value make_nc_payload_status_datatype() { using web::json::value; @@ -2049,4 +2051,62 @@ namespace nmos web::json::push_back(items, details::make_nc_enum_item_descriptor(U("A payload error was encountered"), U("PayloadError"), 3)); return details::make_nc_datatype_descriptor_enum(U("Connection status enum data typee"), U("NcPayloadStatus"), items, value::null()); } + // *********************** + // TOO: link + web::json::value make_nc_overall_status_datatype() + { + using web::json::value; + + auto items = value::array(); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("The overall status is healthy"), U("Healthy"), 1)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("The overall status is partially healthy"), U("PartiallyHealthy"), 2)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("The overall status is unhealthy"), U("Unhealthy"), 3)); + return details::make_nc_datatype_descriptor_enum(U("Overall status enum data type"), U("NcOverallStatus"), items, value::null()); + } + // TOO: link + web::json::value make_nc_link_status_datatype() + { + using web::json::value; + + auto items = value::array(); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("All the associated network interfaces are down"), U("AllDown"), 1)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Some of the associated network interfaces are down"), U("SomeDown"), 2)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("All the associated network interfaces are up"), U("AllUp"), 3)); + return details::make_nc_datatype_descriptor_enum(U("Link status enum data type"), U("NcLinkStatus"), items, value::null()); + } + // TOO: link + web::json::value make_nc_synchronization_status_datatype() + { + using web::json::value; + + auto items = value::array(); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Feature not in use"), U("NotUsed"), 0)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Locked from baseband"), U("BasebandLocked"), 1)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Partially locked from baseband"), U("BasebandPartiallyLocked"), 2)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Partially locked from network"), U("NetworkLocked"), 3)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Locked from network"), U("NetworkPartiallyLocked"), 4)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Not locked"), U("NotLocked"), 5)); + return details::make_nc_datatype_descriptor_enum(U("Synchronization status enum data type"), U("NcSynchronizationStatus"), items, value::null()); + } + // TOO: link + web::json::value make_nc_stream_status_datatype() + { + using web::json::value; + + auto items = value::array(); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Inactive"), U("Inactive"), 0)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Active and healthy"), U("Healthy"), 1)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Active and partially healthy"), U("PartiallyHealthy"), 2)); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Active and unhealthy"), U("Unhealthy"), 3)); + return details::make_nc_datatype_descriptor_enum(U("Stream status enum data type"), U("NcStreamStatus"), items, value::null()); + } + // TOO: link + web::json::value make_nc_method_result_counter_datatype() + { + using web::json::value; + + auto fields = value::array(); + web::json::push_back(fields, details::make_nc_field_descriptor(U("Counter value"), nmos::fields::nc::value, U("NcUint64"), false, false, value::null())); + return details::make_nc_datatype_descriptor_struct(U("Counter method result"), U("NcMethodResultCounter"), fields, U("NcMethodResult"), value::null()); + } } diff --git a/Development/nmos/control_protocol_resource.h b/Development/nmos/control_protocol_resource.h index 5f341949..6b1da957 100644 --- a/Development/nmos/control_protocol_resource.h +++ b/Development/nmos/control_protocol_resource.h @@ -428,6 +428,16 @@ namespace nmos web::json::value make_nc_connection_status_datatype(); // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncpayloadstatus web::json::value make_nc_payload_status_datatype(); + // TOO: link + web::json::value make_nc_overall_status_datatype(); + // TOO: link + web::json::value make_nc_link_status_datatype(); + // TOO: link + web::json::value make_nc_synchronization_status_datatype(); + // TOO: link + web::json::value make_nc_stream_status_datatype(); + // TOO: link + web::json::value make_nc_method_result_counter_datatype(); } #endif diff --git a/Development/nmos/control_protocol_resources.h b/Development/nmos/control_protocol_resources.h index 4ad7d85d..99da8f47 100644 --- a/Development/nmos/control_protocol_resources.h +++ b/Development/nmos/control_protocol_resources.h @@ -29,14 +29,14 @@ namespace nmos // // create Receiver Monitor resource control_protocol_resource make_receiver_monitor(nc_oid oid, bool constant_oid, nmos::nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints = web::json::value::null(), const web::json::value& runtime_property_constraints = web::json::value::null(), bool enabled = true, - nc_connection_status::status connection_status = nc_connection_status::status::undefined, + nc_connection_status::status connection_status = nc_connection_status::status::inactive, const utility::string_t& connection_status_message = U(""), nc_payload_status::status payload_status = nc_payload_status::status::undefined, const utility::string_t& payload_status_message = U("") ); // create Receiver Monitor Protected resource control_protocol_resource make_receiver_monitor_protected(nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints = web::json::value::null(), bool enabled = true, - nc_connection_status::status connection_status = nc_connection_status::status::undefined, + nc_connection_status::status connection_status = nc_connection_status::status::inactive, const utility::string_t& connection_status_message = U(""), nc_payload_status::status payload_status = nc_payload_status::status::undefined, const utility::string_t& payload_status_message = U(""), diff --git a/Development/nmos/control_protocol_state.cpp b/Development/nmos/control_protocol_state.cpp index dd4b1911..88b209b7 100644 --- a/Development/nmos/control_protocol_state.cpp +++ b/Development/nmos/control_protocol_state.cpp @@ -393,7 +393,12 @@ namespace nmos // Monitoring feature set // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#datatypes { U("NcConnectionStatus"), {make_nc_connection_status_datatype()} }, - { U("NcPayloadStatus"), {make_nc_payload_status_datatype()} } + { U("NcPayloadStatus"), {make_nc_payload_status_datatype()} }, + { U("NcOverallStatus"), {make_nc_overall_status_datatype() } }, + { U("NcLinkStatus"), {make_nc_link_status_datatype() } }, + { U("NcSynchronizationStatus"), {make_nc_synchronization_status_datatype() } }, + { U("NcStreamStatus"), {make_nc_stream_status_datatype() } }, + { U("NcMethodResultCounter"), {make_nc_method_result_counter_datatype() } } }; } diff --git a/Development/nmos/control_protocol_typedefs.h b/Development/nmos/control_protocol_typedefs.h index 7afcefed..b65b2782 100644 --- a/Development/nmos/control_protocol_typedefs.h +++ b/Development/nmos/control_protocol_typedefs.h @@ -104,10 +104,10 @@ namespace nmos { enum status { - undefined = 0, // This is the value when there is no receiver - connected = 1, // Connected to a stream - disconnected = 2, // Not connected to a stream - connection_error = 3 // A connection error was encountered + inactive = 0, // Inactive + healthy = 1, // Active and healthy + partially_healthy = 2, // Active and partially healthy + unhealthy = 3 // Active and unhealthy }; } @@ -124,6 +124,58 @@ namespace nmos }; } + // NcOverallStatus + // TODO: link + namespace nc_overall_status + { + enum status + { + healthy = 1, // // The overall status is healthy + partially_unhealthy = 2,// The overall status is partially healthy + unhealthy = 3 // The overall status is unhealthy + }; + } + + //NcLinkStatus + // TODO: link + namespace nc_link_status + { + enum status + { + all_down = 1, // All the associated network interfaces are down + some_down = 2, // Some of the associated network interfaces are down + all_up = 3 // All the associated network interfaces are up + }; + } + + //NcSynchronizationStatus + // TODO: link + namespace nc_synchronization_status + { + enum status + { + not_used = 0, // Feature not in use + baseband_locked = 1, // Locked from baseband + baseband_partially_locked = 2, // Partially locked from baseband + network_locked = 3, // Partially locked from network + network_partially_locked = 4, // Partially locked from network + not_locked = 5 // Not locked + }; + } + + //NcStreamStatus + // TODO: add link + namespace nc_stream_status + { + enum status + { + inactive = 0, // Inactive + healthy = 1, // Active and healthy + partially_healthy = 2, // Active and partially healthy + unhealthy = 3 // Active and unhealthy + }; + } + // NcElementId // See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncelementid struct nc_element_id From 69f50b0b22c1c0f742b197f1e7becb4aacf0e89b Mon Sep 17 00:00:00 2001 From: "Jonathan Thorpe (Sony)" Date: Fri, 24 May 2024 17:07:08 +0100 Subject: [PATCH 2/7] Create NcStatusMonitor and update NcReceiverMonitor (cherry picked from commit 7965892827d9fc1aac5f84ff44a5e818c78e8f8c) # Conflicts: # Development/nmos/control_protocol_methods.cpp # Development/nmos/control_protocol_methods.h --- Development/nmos/api_utils.cpp | 4 +- .../nmos/control_protocol_handlers.cpp | 6 +- Development/nmos/control_protocol_methods.cpp | 19 +++++ Development/nmos/control_protocol_methods.h | 8 ++ .../nmos/control_protocol_resource.cpp | 79 ++++++++++--------- Development/nmos/control_protocol_resource.h | 19 ++--- .../nmos/control_protocol_resources.cpp | 15 +--- Development/nmos/control_protocol_resources.h | 19 ++--- Development/nmos/control_protocol_state.cpp | 27 ++++--- Development/nmos/control_protocol_typedefs.h | 44 +++++------ Development/nmos/json_fields.h | 11 ++- Development/nmos/type.h | 2 +- 12 files changed, 137 insertions(+), 116 deletions(-) diff --git a/Development/nmos/api_utils.cpp b/Development/nmos/api_utils.cpp index 899d759d..21894f43 100644 --- a/Development/nmos/api_utils.cpp +++ b/Development/nmos/api_utils.cpp @@ -168,8 +168,8 @@ namespace nmos { U("nc_manager"), nmos::types::nc_manager }, { U("nc_device_manager"), nmos::types::nc_device_manager }, { U("nc_class_manager"), nmos::types::nc_class_manager }, + { U("nc_status_monitor"), nmos::types::nc_status_monitor }, { U("nc_receiver_monitor"), nmos::types::nc_receiver_monitor }, - { U("nc_receiver_monitor_protected"), nmos::types::nc_receiver_monitor_protected }, { U("nc_ident_beacon"), nmos::types::nc_ident_beacon } }; return types_from_resourceType.at(resourceType); @@ -195,8 +195,8 @@ namespace nmos { nmos::types::nc_manager, U("nc_manager") }, { nmos::types::nc_device_manager, U("nc_device_manager") }, { nmos::types::nc_class_manager, U("nc_class_manager") }, + { nmos::types::nc_status_monitor, U("nc_status_monitor") }, { nmos::types::nc_receiver_monitor, U("nc_receiver_monitor") }, - { nmos::types::nc_receiver_monitor_protected, U("nc_receiver_monitor_protected") }, { nmos::types::nc_ident_beacon, U("nc_ident_beacon") } }; return resourceTypes_from_type.at(type); diff --git a/Development/nmos/control_protocol_handlers.cpp b/Development/nmos/control_protocol_handlers.cpp index 1fb5fdb4..79eb1429 100644 --- a/Development/nmos/control_protocol_handlers.cpp +++ b/Development/nmos/control_protocol_handlers.cpp @@ -81,20 +81,20 @@ namespace nmos const auto active = nmos::fields::master_enable(nmos::fields::endpoint_active(connection_resource.data)); const web::json::value connection_status = active ? nc_connection_status::healthy : nc_connection_status::inactive; - const web::json::value payload_status = active ? nc_payload_status::payload_ok : nc_payload_status::undefined; + const web::json::value stream_status = active ? nc_stream_status::healthy : nc_stream_status::inactive; // hmm, maybe updating connectionStatusMessage and payloadStatusMessage too const auto property_changed_event = make_property_changed_event(nmos::fields::nc::oid(found->data), { { nc_receiver_monitor_connection_status_property_id, nc_property_change_type::type::value_changed, connection_status }, - { nc_receiver_monitor_payload_status_property_id, nc_property_change_type::type::value_changed, payload_status } + { nc_receiver_monitor_stream_status_property_id, nc_property_change_type::type::value_changed, stream_status } }); modify_control_protocol_resource(resources, found->id, [&](nmos::resource& resource) { resource.data[nmos::fields::nc::connection_status] = connection_status; - resource.data[nmos::fields::nc::payload_status] = payload_status; + resource.data[nmos::fields::nc::stream_status] = stream_status; }, property_changed_event); } diff --git a/Development/nmos/control_protocol_methods.cpp b/Development/nmos/control_protocol_methods.cpp index d9d78129..ed411644 100644 --- a/Development/nmos/control_protocol_methods.cpp +++ b/Development/nmos/control_protocol_methods.cpp @@ -625,4 +625,23 @@ namespace nmos return details::make_nc_method_result_error({ nc_method_status::parameter_error }, U("name not found")); } + + // NcReceiverMonitor methods + web::json::value get_lost_packets(nmos::resources&, const nmos::resource&, const web::json::value&, bool, get_control_protocol_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, slog::base_gate&) + { + // this will need to be defined in a user defined handler + return details::make_nc_method_result({ nc_method_status::ok }); + } + + web::json::value get_late_packets(nmos::resources&, const nmos::resource&, const web::json::value&, bool, get_control_protocol_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, slog::base_gate&) + { + // this will need to be defined in a user defined handler + return details::make_nc_method_result({ nc_method_status::ok }); + } + + web::json::value reset_packet_counters(nmos::resources&, const nmos::resource&, const web::json::value&, bool, get_control_protocol_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, slog::base_gate&) + { + // this will need to be defined in a user defined handler + return details::make_nc_method_result({ nc_method_status::ok }); + } } diff --git a/Development/nmos/control_protocol_methods.h b/Development/nmos/control_protocol_methods.h index 957f9362..22ab870b 100644 --- a/Development/nmos/control_protocol_methods.h +++ b/Development/nmos/control_protocol_methods.h @@ -42,6 +42,14 @@ namespace nmos web::json::value get_control_class(nmos::resources&, const nmos::resource&, const web::json::value& arguments, bool is_deprecated, get_control_protocol_class_descriptor_handler get_control_protocol_class_descriptor, slog::base_gate& gate); // Get a single datatype descriptor web::json::value get_datatype(nmos::resources&, const nmos::resource&, const web::json::value& arguments, bool is_deprecated, get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype, slog::base_gate& gate); + + // NcReceiverMonitor methods implementation + // Gets the lost packets + web::json::value get_lost_packets(nmos::resources&, const nmos::resource&, const web::json::value&, bool, get_control_protocol_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, slog::base_gate&); + // Gets the late packets + web::json::value get_late_packets(nmos::resources&, const nmos::resource&, const web::json::value&, bool, get_control_protocol_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, slog::base_gate&); + // Resets the packet counters + web::json::value reset_packet_counters(nmos::resources&, const nmos::resource&, const web::json::value&, bool, get_control_protocol_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, slog::base_gate&); } #endif diff --git a/Development/nmos/control_protocol_resource.cpp b/Development/nmos/control_protocol_resource.cpp index b9b972dd..d2c7a20e 100644 --- a/Development/nmos/control_protocol_resource.cpp +++ b/Development/nmos/control_protocol_resource.cpp @@ -739,16 +739,21 @@ namespace nmos } // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor - web::json::value make_receiver_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, - nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_payload_status::status payload_status, const utility::string_t& payload_status_message) + web::json::value make_receiver_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& grand_master_clock_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message) { using web::json::value; auto data = make_nc_worker(class_id, oid, constant_oid, owner, role, value::string(user_label), description, touchpoints, runtime_property_constraints, enabled); + + data[nmos::fields::nc::link_status] = value::number(link_status); + data[nmos::fields::nc::link_status_message] = value::string(link_status_message); data[nmos::fields::nc::connection_status] = value::number(connection_status); data[nmos::fields::nc::connection_status_message] = value::string(connection_status_message); - data[nmos::fields::nc::payload_status] = value::number(payload_status); - data[nmos::fields::nc::payload_status_message] = value::string(payload_status_message); + data[nmos::fields::nc::synchronization_status] = value::number(synchronization_status); + data[nmos::fields::nc::synchronization_status_message] = value::string(synchronization_status_message); + data[nmos::fields::nc::grand_master_clock_id] = value::string(grand_master_clock_id); + data[nmos::fields::nc::stream_status] = value::number(stream_status); + data[nmos::fields::nc::stream_status_message] = value::string(stream_status_message); return data; } @@ -1155,49 +1160,60 @@ namespace nmos return value::array(); } - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor - web::json::value make_nc_receiver_monitor_properties() + // TODO: add link + web::json::value make_nc_status_monitor_properties() { using web::json::value; auto properties = value::array(); - web::json::push_back(properties, details::make_nc_property_descriptor(U("Connection status property"), nc_receiver_monitor_connection_status_property_id, nmos::fields::nc::connection_status, U("NcConnectionStatus"), true, false, false, false, value::null())); - web::json::push_back(properties, details::make_nc_property_descriptor(U("Connection status message property"), nc_receiver_monitor_connection_status_message_property_id, nmos::fields::nc::connection_status_message, U("NcString"), true, true, false, false, value::null())); - web::json::push_back(properties, details::make_nc_property_descriptor(U("Payload status property"), nc_receiver_monitor_payload_status_property_id, nmos::fields::nc::payload_status, U("NcPayloadStatus"), true, false, false, false, value::null())); - web::json::push_back(properties, details::make_nc_property_descriptor(U("Payload status message property"), nc_receiver_monitor_payload_status_message_property_id, nmos::fields::nc::payload_status_message, U("NcString"), true, true, false, false, value::null())); + web::json::push_back(properties, details::make_nc_property_descriptor(U("Overall status property"), nc_status_monitor_overall_status_property_id, nmos::fields::nc::overall_status, U("NcOverallStatus"), true, false, false, false, value::null())); + web::json::push_back(properties, details::make_nc_property_descriptor(U("Overall status message property"), nc_status_monitor_overall_status_message_property_id, nmos::fields::nc::overall_status_message, U("NcString"), true, true, false, false, value::null())); return properties; } - web::json::value make_nc_receiver_monitor_methods() + web::json::value make_nc_status_monitor_methods() { using web::json::value; return value::array(); } - web::json::value make_nc_receiver_monitor_events() + web::json::value make_nc_status_monitor_events() { using web::json::value; return value::array(); } - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitorprotected - web::json::value make_nc_receiver_monitor_protected_properties() + // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor + web::json::value make_nc_receiver_monitor_properties() { using web::json::value; auto properties = value::array(); - web::json::push_back(properties, details::make_nc_property_descriptor(U("Indicates if signal protection is active"), nc_receiver_monitor_protected_signal_protection_status_property_id, nmos::fields::nc::signal_protection_status, U("NcBoolean"), true, false, false, false, value::null())); + web::json::push_back(properties, details::make_nc_property_descriptor(U("Link status property"), nc_receiver_monitor_link_status_property_id, nmos::fields::nc::link_status, U("NcLinkStatus"), true, false, false, false, value::null())); + web::json::push_back(properties, details::make_nc_property_descriptor(U("Link status message property"), nc_receiver_monitor_link_status_message_property_id, nmos::fields::nc::link_status_message, U("NcString"), true, true, false, false, value::null())); + web::json::push_back(properties, details::make_nc_property_descriptor(U("Connection status property"), nc_receiver_monitor_connection_status_property_id, nmos::fields::nc::connection_status, U("NcConnectionStatus"), true, false, false, false, value::null())); + web::json::push_back(properties, details::make_nc_property_descriptor(U("Connection status message property"), nc_receiver_monitor_connection_status_message_property_id, nmos::fields::nc::connection_status_message, U("NcString"), true, true, false, false, value::null())); + web::json::push_back(properties, details::make_nc_property_descriptor(U("Synchronization status property"), nc_receiver_monitor_synchronization_status_property_id, nmos::fields::nc::synchronization_status, U("NcSynchronizationStatus"), true, false, false, false, value::null())); + web::json::push_back(properties, details::make_nc_property_descriptor(U("Synchronization status message property"), nc_receiver_monitor_synchronization_status_message_property_id, nmos::fields::nc::synchronization_status_message, U("NcString"), true, true, false, false, value::null())); + web::json::push_back(properties, details::make_nc_property_descriptor(U("Grand master clock id property"), nc_receiver_monitor_synchronization_grand_master_clock_id_property_id, nmos::fields::nc::grand_master_clock_id, U("NcString"), true, true, false, false, value::null())); + web::json::push_back(properties, details::make_nc_property_descriptor(U("Stream status property"), nc_receiver_monitor_stream_status_property_id, nmos::fields::nc::stream_status, U("NcStreamStatus"), true, false, false, false, value::null())); + web::json::push_back(properties, details::make_nc_property_descriptor(U("Stream status message property"), nc_receiver_monitor_stream_status_message_property_id, nmos::fields::nc::stream_status_message, U("NcString"), true, true, false, false, value::null())); return properties; } - web::json::value make_nc_receiver_monitor_protected_methods() + web::json::value make_nc_receiver_monitor_methods() { using web::json::value; - return value::array(); + auto methods = value::array(); + web::json::push_back(methods, details::make_nc_method_descriptor(U("Gets the lost packets"), nc_receiver_monitor_get_lost_packets_method_id, U("GetLostPackets"), U("NcMethodResultCounter"), value::array(), false)); + web::json::push_back(methods, details::make_nc_method_descriptor(U("Gets the late packets"), nc_receiver_monitor_get_late_packets_method_id, U("GetLatePackets"), U("NcMethodResultCounter"), value::array(), false)); + web::json::push_back(methods, details::make_nc_method_descriptor(U("Resets the packet counters"), nc_receiver_monitor_reset_packet_counters_method_id, U("ResetPacketCounters"), U("NcMethodResult"), value::array(), false)); + + return methods; } - web::json::value make_nc_receiver_monitor_protected_events() + web::json::value make_nc_receiver_monitor_events() { using web::json::value; @@ -1285,20 +1301,20 @@ namespace nmos } // Monitoring feature set control classes - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor - web::json::value make_nc_receiver_monitor_class() + // TODO: link + web::json::value make_nc_status_monitor_class() { using web::json::value; - return details::make_nc_class_descriptor(U("NcReceiverMonitor class descriptor"), nc_receiver_monitor_class_id, U("NcReceiverMonitor"), make_nc_receiver_monitor_properties(), make_nc_receiver_monitor_methods(), make_nc_receiver_monitor_events()); + return details::make_nc_class_descriptor(U("NcStatusMonitor class descriptor"), nc_status_monitor_class_id, U("NcStatusMonitor"), make_nc_status_monitor_properties(), make_nc_status_monitor_methods(), make_nc_status_monitor_events()); } - - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitorprotected - web::json::value make_nc_receiver_monitor_protected_class() + + // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor + web::json::value make_nc_receiver_monitor_class() { using web::json::value; - return details::make_nc_class_descriptor(U("NcReceiverMonitorProtected class descriptor"), nc_receiver_monitor_protected_class_id, U("NcReceiverMonitorProtected"), make_nc_receiver_monitor_protected_properties(), make_nc_receiver_monitor_protected_methods(), make_nc_receiver_monitor_protected_events()); + return details::make_nc_class_descriptor(U("NcReceiverMonitor class descriptor"), nc_receiver_monitor_class_id, U("NcReceiverMonitor"), make_nc_receiver_monitor_properties(), make_nc_receiver_monitor_methods(), make_nc_receiver_monitor_events()); } // Primitive datatypes @@ -2038,19 +2054,6 @@ namespace nmos web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Active and unhealthy"), U("Unhealthy"), 3)); return details::make_nc_datatype_descriptor_enum(U("Connection status enum data typee"), U("NcConnectionStatus"), items, value::null()); } - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncpayloadstatus - // ****************** - web::json::value make_nc_payload_status_datatype() - { - using web::json::value; - - auto items = value::array(); - web::json::push_back(items, details::make_nc_enum_item_descriptor(U("This is the value when there's no connection"), U("Undefined"), 0)); - web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Payload is being received without errors and is the correct type"), U("PayloadOK"), 1)); - web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Payload is being received but is of an unsupported type"), U("PayloadFormatUnsupported"), 2)); - web::json::push_back(items, details::make_nc_enum_item_descriptor(U("A payload error was encountered"), U("PayloadError"), 3)); - return details::make_nc_datatype_descriptor_enum(U("Connection status enum data typee"), U("NcPayloadStatus"), items, value::null()); - } // *********************** // TOO: link web::json::value make_nc_overall_status_datatype() diff --git a/Development/nmos/control_protocol_resource.h b/Development/nmos/control_protocol_resource.h index 6b1da957..c74fec5a 100644 --- a/Development/nmos/control_protocol_resource.h +++ b/Development/nmos/control_protocol_resource.h @@ -178,8 +178,7 @@ namespace nmos web::json::value make_nc_worker(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled); // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor - web::json::value make_receiver_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, - nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_payload_status::status payload_status, const utility::string_t& payload_status_message); + web::json::value make_receiver_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& grand_master_clock_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message); // See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncmanager web::json::value make_nc_manager(const nc_class_id& class_id, nc_oid oid, bool constant_oid, const web::json::value& owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints); @@ -236,8 +235,6 @@ namespace nmos web::json::value make_nc_ident_beacon_class(); // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor web::json::value make_nc_receiver_monitor_class(); - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitorprotected - web::json::value make_nc_receiver_monitor_protected_class(); // control classes proprties/methods/events // See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncobject @@ -264,17 +261,17 @@ namespace nmos web::json::value make_nc_class_manager_properties(); web::json::value make_nc_class_manager_methods(); web::json::value make_nc_class_manager_events(); + + // Monitoring feature set control classes + // TODO: link + web::json::value make_nc_status_monitor_properties(); + web::json::value make_nc_status_monitor_methods(); + web::json::value make_nc_status_monitor_events(); // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor web::json::value make_nc_receiver_monitor_properties(); web::json::value make_nc_receiver_monitor_methods(); web::json::value make_nc_receiver_monitor_events(); - // Monitoring feature set control classes - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitorprotected - web::json::value make_nc_receiver_monitor_protected_properties(); - web::json::value make_nc_receiver_monitor_protected_methods(); - web::json::value make_nc_receiver_monitor_protected_events(); - // Identification feature set control classes // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/identification/#ncidentbeacon web::json::value make_nc_ident_beacon_properties(); @@ -426,8 +423,6 @@ namespace nmos // // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncconnectionstatus web::json::value make_nc_connection_status_datatype(); - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncpayloadstatus - web::json::value make_nc_payload_status_datatype(); // TOO: link web::json::value make_nc_overall_status_datatype(); // TOO: link diff --git a/Development/nmos/control_protocol_resources.cpp b/Development/nmos/control_protocol_resources.cpp index 0fde54c3..f48d2db5 100644 --- a/Development/nmos/control_protocol_resources.cpp +++ b/Development/nmos/control_protocol_resources.cpp @@ -67,23 +67,12 @@ namespace nmos // // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor control_protocol_resource make_receiver_monitor(nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, - nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_payload_status::status payload_status, const utility::string_t& payload_status_message) + nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& grand_master_clock_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message) { - auto data = details::make_receiver_monitor(nc_receiver_monitor_class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints, enabled, connection_status, connection_status_message, payload_status, payload_status_message); + auto data = details::make_receiver_monitor(nc_receiver_monitor_class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints, enabled, link_status, link_status_message, connection_status, connection_status_message, synchronization_status, synchronization_status_message, grand_master_clock_id, stream_status, stream_status_message); return{ is12_versions::v1_0, types::nc_receiver_monitor, std::move(data), true }; } - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitorprotected - control_protocol_resource make_receiver_monitor_protected(nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, - nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_payload_status::status payload_status, const utility::string_t& payload_status_message, bool signal_protection_status) - { - using web::json::value; - - auto data = details::make_receiver_monitor(nc_receiver_monitor_protected_class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints, enabled, connection_status, connection_status_message, payload_status, payload_status_message); - data[nmos::fields::nc::signal_protection_status] = value::boolean(signal_protection_status); - - return{ is12_versions::v1_0, types::nc_receiver_monitor_protected, std::move(data), true }; - } // Identification feature set control classes // diff --git a/Development/nmos/control_protocol_resources.h b/Development/nmos/control_protocol_resources.h index 99da8f47..26804f91 100644 --- a/Development/nmos/control_protocol_resources.h +++ b/Development/nmos/control_protocol_resources.h @@ -29,18 +29,15 @@ namespace nmos // // create Receiver Monitor resource control_protocol_resource make_receiver_monitor(nc_oid oid, bool constant_oid, nmos::nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints = web::json::value::null(), const web::json::value& runtime_property_constraints = web::json::value::null(), bool enabled = true, + nc_link_status::status link_status = nc_link_status::all_up, + const utility::string_t& link_status_message = U(""), nc_connection_status::status connection_status = nc_connection_status::status::inactive, - const utility::string_t& connection_status_message = U(""), - nc_payload_status::status payload_status = nc_payload_status::status::undefined, - const utility::string_t& payload_status_message = U("") - ); - // create Receiver Monitor Protected resource - control_protocol_resource make_receiver_monitor_protected(nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints = web::json::value::null(), bool enabled = true, - nc_connection_status::status connection_status = nc_connection_status::status::inactive, - const utility::string_t& connection_status_message = U(""), - nc_payload_status::status payload_status = nc_payload_status::status::undefined, - const utility::string_t& payload_status_message = U(""), - bool signal_protection_status = true + const utility::string_t& connection_status_message = U(""), + nc_synchronization_status::status synchronization_status = nc_synchronization_status::not_used, + const utility::string_t& synchronization_status_message = U(""), + const utility::string_t& grand_master_clock_id = U(""), + nc_stream_status::status stream_status = nc_stream_status::inactive, + const utility::string_t& stream_status_message = U("") ); // Identification feature set control classes diff --git a/Development/nmos/control_protocol_state.cpp b/Development/nmos/control_protocol_state.cpp index 88b209b7..c845555c 100644 --- a/Development/nmos/control_protocol_state.cpp +++ b/Development/nmos/control_protocol_state.cpp @@ -299,22 +299,28 @@ namespace nmos to_vector(make_nc_ident_beacon_events())) }, // Monitoring feature set // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#control-classes + // NcStatusMonitor + { nc_status_monitor_class_id, make_control_class_descriptor(U("NcStatusMonitor class descriptor"), nc_status_monitor_class_id, U("NcStatusMonitor"), + // NcReceiverMonitor properties + to_vector(make_nc_status_monitor_properties()), + // NcReceiverMonitor methods + to_methods_vector(make_nc_status_monitor_methods(), {}), + // NcReceiverMonitor events + to_vector(make_nc_status_monitor_events())) }, // NcReceiverMonitor { nc_receiver_monitor_class_id, make_control_class_descriptor(U("NcReceiverMonitor class descriptor"), nc_receiver_monitor_class_id, U("NcReceiverMonitor"), // NcReceiverMonitor properties to_vector(make_nc_receiver_monitor_properties()), // NcReceiverMonitor methods - to_methods_vector(make_nc_receiver_monitor_methods(), {}), + to_methods_vector(make_nc_receiver_monitor_methods(), + { + // link NcReceiverMonitor method_ids with method functions + { nc_receiver_monitor_get_lost_packets_method_id, get_lost_packets }, + { nc_receiver_monitor_get_late_packets_method_id, get_late_packets }, + { nc_receiver_monitor_reset_packet_counters_method_id, reset_packet_counters } + }), // NcReceiverMonitor events - to_vector(make_nc_receiver_monitor_events())) }, - // NcReceiverMonitorProtected - { nc_receiver_monitor_protected_class_id, make_control_class_descriptor(U("NcReceiverMonitorProtected class descriptor"), nc_receiver_monitor_protected_class_id, U("NcReceiverMonitorProtected"), - // NcReceiverMonitorProtected properties - to_vector(make_nc_receiver_monitor_protected_properties()), - // NcReceiverMonitorProtected methods - to_methods_vector(make_nc_receiver_monitor_protected_methods(), {}), - // NcReceiverMonitorProtected events - to_vector(make_nc_receiver_monitor_protected_events())) } + to_vector(make_nc_receiver_monitor_events())) } }; // setup the standard datatypes @@ -393,7 +399,6 @@ namespace nmos // Monitoring feature set // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#datatypes { U("NcConnectionStatus"), {make_nc_connection_status_datatype()} }, - { U("NcPayloadStatus"), {make_nc_payload_status_datatype()} }, { U("NcOverallStatus"), {make_nc_overall_status_datatype() } }, { U("NcLinkStatus"), {make_nc_link_status_datatype() } }, { U("NcSynchronizationStatus"), {make_nc_synchronization_status_datatype() } }, diff --git a/Development/nmos/control_protocol_typedefs.h b/Development/nmos/control_protocol_typedefs.h index b65b2782..e8e79347 100644 --- a/Development/nmos/control_protocol_typedefs.h +++ b/Development/nmos/control_protocol_typedefs.h @@ -111,19 +111,6 @@ namespace nmos }; } - // NcPayloadStatus - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncpayloadstatus - namespace nc_payload_status - { - enum status - { - undefined = 0, // This is the value when there's no connection. - payload_ok = 1, // Payload is being received without errors and is the correct type - payload_format_unsupported = 2, // Payload is being received but is of an unsupported type - payloadError = 3 // A payload error was encountered - }; - } - // NcOverallStatus // TODO: link namespace nc_overall_status @@ -223,6 +210,11 @@ namespace nmos // See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncclassmanager const nc_method_id nc_class_manager_get_control_class_method_id(3, 1); const nc_method_id nc_class_manager_get_datatype_method_id(3, 2); + // NcMethodIds for NcReceiverMonitor + // TODO: link + const nc_method_id nc_receiver_monitor_get_lost_packets_method_id(4, 1); + const nc_method_id nc_receiver_monitor_get_late_packets_method_id(4, 2); + const nc_method_id nc_receiver_monitor_reset_packet_counters_method_id(4, 3); // NcPropertyId // See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncpropertyid @@ -260,14 +252,20 @@ namespace nmos // See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncclassmanager const nc_property_id nc_class_manager_control_classes_property_id(3, 1); const nc_property_id nc_class_manager_datatypes_property_id(3, 2); + // NcPropertyIds for NcStatusMonitor + const nc_property_id nc_status_monitor_overall_status_property_id(3, 1); + const nc_property_id nc_status_monitor_overall_status_message_property_id(3, 2); // NcPropertyids for NcReceiverMonitor // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor - const nc_property_id nc_receiver_monitor_connection_status_property_id(3, 1); - const nc_property_id nc_receiver_monitor_connection_status_message_property_id(3, 2); - const nc_property_id nc_receiver_monitor_payload_status_property_id(3, 3); - const nc_property_id nc_receiver_monitor_payload_status_message_property_id(3, 4); - // NcPropertyids for NcReceiverMonitorProtected - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitorprotected + const nc_property_id nc_receiver_monitor_link_status_property_id(4, 1); + const nc_property_id nc_receiver_monitor_link_status_message_property_id(4, 2); + const nc_property_id nc_receiver_monitor_connection_status_property_id(4, 3); + const nc_property_id nc_receiver_monitor_connection_status_message_property_id(4, 4); + const nc_property_id nc_receiver_monitor_synchronization_status_property_id(4, 5); + const nc_property_id nc_receiver_monitor_synchronization_status_message_property_id(4, 6); + const nc_property_id nc_receiver_monitor_synchronization_grand_master_clock_id_property_id(4, 7); + const nc_property_id nc_receiver_monitor_stream_status_property_id(4, 8); + const nc_property_id nc_receiver_monitor_stream_status_message_property_id(4, 9); const nc_property_id nc_receiver_monitor_protected_signal_protection_status_property_id(4, 1); // NcPropertyids for NcIdentBeacon // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/identification/#ncidentbeacon @@ -319,11 +317,11 @@ namespace nmos // See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncclassmanager const nc_class_id nc_class_manager_class_id({ 1, 3, 2 }); // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/identification/#ncidentbeacon - const nc_class_id nc_ident_beacon_class_id({ 1, 2, 2 }); + const nc_class_id nc_ident_beacon_class_id({ 1, 2, 1 }); + // TODO: link + const nc_class_id nc_status_monitor_class_id({ 1, 2, 2 }); // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor - const nc_class_id nc_receiver_monitor_class_id({ 1, 2, 3 }); - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitorprotected - const nc_class_id nc_receiver_monitor_protected_class_id({ 1, 2, 3, 1 }); + const nc_class_id nc_receiver_monitor_class_id({ 1, 2, 2, 1 }); // NcTouchpoint // See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#nctouchpoint diff --git a/Development/nmos/json_fields.h b/Development/nmos/json_fields.h index 7374c5a9..075da370 100644 --- a/Development/nmos/json_fields.h +++ b/Development/nmos/json_fields.h @@ -332,10 +332,17 @@ namespace nmos const web::json::field_as_string io_id{ U("ioId") }; const web::json::field_as_integer connection_status{ U("connectionStatus") }; // NcConnectionStatus const web::json::field_as_string connection_status_message{ U("connectionStatusMessage") }; - const web::json::field_as_integer payload_status{ U("payloadStatus") }; // NcPayloadStatus - const web::json::field_as_string payload_status_message{ U("payloadStatusMessage") }; + const web::json::field_as_integer link_status{ U("linkStatus") }; // NcLinkStatus + const web::json::field_as_string link_status_message{ U("linkStatusMessage") }; + const web::json::field_as_integer synchronization_status{ U("synchronizationStatus") }; // NcSynchronizationStatus + const web::json::field_as_string synchronization_status_message{ U("synchronizationStatusMessage") }; + const web::json::field_as_string grand_master_clock_id{ U("grandMasterClockId") }; const web::json::field_as_bool signal_protection_status{ U("signalProtectionStatus") }; + const web::json::field_as_integer stream_status{ U("streamStatus") }; // NcStreamStatus + const web::json::field_as_string stream_status_message{ U("streamStatusMessage") }; const web::json::field_as_bool active{ U("active") }; + const web::json::field_as_integer overall_status{ U("overallStatus") }; + const web::json::field_as_string overall_status_message{ U("overallStatusMessage") }; } // NMOS Parameter Registers diff --git a/Development/nmos/type.h b/Development/nmos/type.h index 8da37f68..a0e7ae6e 100644 --- a/Development/nmos/type.h +++ b/Development/nmos/type.h @@ -46,8 +46,8 @@ namespace nmos const type nc_manager{ U("nc_manager") }; const type nc_device_manager{ U("nc_device_manager") }; const type nc_class_manager{ U("nc_class_manager") }; + const type nc_status_monitor{ U("nc_status_monitor") }; const type nc_receiver_monitor{ U("nc_receiver_monitor") }; - const type nc_receiver_monitor_protected{ U("nc_receiver_monitor_protected") }; const type nc_ident_beacon{ U("nc_ident_beacon") }; } } From 9a37db2c2bd8132b0f55c499de5247f191366d95 Mon Sep 17 00:00:00 2001 From: "Jonathan Thorpe (Sony)" Date: Tue, 11 Jun 2024 09:06:18 +0100 Subject: [PATCH 3/7] Add BCP-008-01 method handlers --- .../nmos-cpp-node/node_implementation.cpp | 40 ++++++++++++++++++- Development/nmos/node_server.h | 6 +++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/Development/nmos-cpp-node/node_implementation.cpp b/Development/nmos-cpp-node/node_implementation.cpp index f12cca15..d3b8b5fd 100644 --- a/Development/nmos-cpp-node/node_implementation.cpp +++ b/Development/nmos-cpp-node/node_implementation.cpp @@ -1714,6 +1714,41 @@ nmos::control_protocol_property_changed_handler make_node_implementation_control }; } +// Example Receiver Status Monitor callback for get_lost_packets method +nmos::experimental::control_protocol_method_handler make_node_implementation_get_lost_packet_method_handler() +{ + return [&](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) + { + // Implement polling of lost packet count here + uint16_t lost_packet_count(0); + return nmos::details::make_nc_method_result({ nmos::nc_method_status::ok }, lost_packet_count); + }; +} + +// Example Receiver Status Monitor callback for get_late_packets method +nmos::experimental::control_protocol_method_handler make_node_implementation_get_late_packet_method_handler() +{ + return [&](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) + { + // Implement polling of late packet count here + uint16_t late_packet_count(0); + return nmos::details::make_nc_method_result({ nmos::nc_method_status::ok }, late_packet_count); + }; +} + +// Example Receiver Status Monitor callback for reset_packet_counters method +nmos::experimental::control_protocol_method_handler make_node_implementation_reset_packet_counters_method_handler() +{ + return [&](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) + { + // Implement reset of lost and late packet counters + return nmos::details::make_nc_method_result({ nmos::nc_method_status::ok }); + }; +} + + + + namespace impl { nmos::interlace_mode get_interlace_mode(const nmos::settings& settings) @@ -1868,5 +1903,8 @@ nmos::experimental::node_implementation make_node_implementation(nmos::node_mode .on_connection_activated(make_node_implementation_connection_activation_handler(model, gate)) .on_validate_channelmapping_output_map(make_node_implementation_map_validator()) // may be omitted if not required .on_channelmapping_activated(make_node_implementation_channelmapping_activation_handler(gate)) - .on_control_protocol_property_changed(make_node_implementation_control_protocol_property_changed_handler(gate)); // may be omitted if IS-12 not required + .on_control_protocol_property_changed(make_node_implementation_control_protocol_property_changed_handler(gate)) // may be omitted if IS-12 not required + .on_get_lost_packet(make_node_implementation_get_lost_packet_method_handler()) + .on_get_late_packet(make_node_implementation_get_late_packet_method_handler()) + .on_reset_packet_counters(make_node_implementation_reset_packet_counters_method_handler()); } diff --git a/Development/nmos/node_server.h b/Development/nmos/node_server.h index 25a15d4b..8aabdcc5 100644 --- a/Development/nmos/node_server.h +++ b/Development/nmos/node_server.h @@ -82,6 +82,9 @@ namespace nmos node_implementation& on_get_control_datatype_descriptor(nmos::get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype_descriptor) { this->get_control_protocol_datatype_descriptor = std::move(get_control_protocol_datatype_descriptor); return *this; } node_implementation& on_get_control_protocol_method_descriptor(nmos::get_control_protocol_method_descriptor_handler get_control_protocol_method_descriptor) { this->get_control_protocol_method_descriptor = std::move(get_control_protocol_method_descriptor); return *this; } node_implementation& on_control_protocol_property_changed(nmos::control_protocol_property_changed_handler control_protocol_property_changed) { this->control_protocol_property_changed = std::move(control_protocol_property_changed); return *this; } + node_implementation& on_get_lost_packet(experimental::control_protocol_method_handler get_lost_packet_method_handler) { this->get_lost_packet_method_handler = std::move(get_lost_packet_method_handler); return *this; } + node_implementation& on_get_late_packet(experimental::control_protocol_method_handler get_late_packet_method_handler) { this->get_late_packet_method_handler = std::move(get_late_packet_method_handler); return *this; } + node_implementation& on_reset_packet_counters(experimental::control_protocol_method_handler reset_packet_counters_method_handler) { this->reset_packet_counters_method_handler = std::move(reset_packet_counters_method_handler); return *this; } // deprecated, use on_validate_connection_resource_patch node_implementation& on_validate_merged(nmos::details::connection_resource_patch_validator validate_merged) { return on_validate_connection_resource_patch(std::move(validate_merged)); } @@ -124,6 +127,9 @@ namespace nmos nmos::get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype_descriptor; nmos::get_control_protocol_method_descriptor_handler get_control_protocol_method_descriptor; nmos::control_protocol_property_changed_handler control_protocol_property_changed; + experimental::control_protocol_method_handler get_lost_packet_method_handler; + experimental::control_protocol_method_handler get_late_packet_method_handler; + experimental::control_protocol_method_handler reset_packet_counters_method_handler; }; // Construct a server instance for an NMOS Node, implementing the IS-04 Node API, IS-05 Connection API, IS-07 Events API From e970fa618bad2513e8e2a4947e570acecf894e96 Mon Sep 17 00:00:00 2001 From: "Jonathan Thorpe (Sony)" Date: Tue, 11 Jun 2024 09:50:25 +0100 Subject: [PATCH 4/7] Add nc_status_monitor base class instantiation to Receiver Monitor --- Development/nmos/control_protocol_resource.cpp | 16 ++++++++++++++-- Development/nmos/control_protocol_resource.h | 4 +++- Development/nmos/control_protocol_resources.cpp | 4 ++-- Development/nmos/control_protocol_resources.h | 2 ++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Development/nmos/control_protocol_resource.cpp b/Development/nmos/control_protocol_resource.cpp index d2c7a20e..e73a092e 100644 --- a/Development/nmos/control_protocol_resource.cpp +++ b/Development/nmos/control_protocol_resource.cpp @@ -738,12 +738,24 @@ namespace nmos return data; } - // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor - web::json::value make_receiver_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& grand_master_clock_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message) + // TODO: add link + web::json::value make_nc_status_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_overall_status::status overall_status, const utility::string_t& overall_status_message) { using web::json::value; auto data = make_nc_worker(class_id, oid, constant_oid, owner, role, value::string(user_label), description, touchpoints, runtime_property_constraints, enabled); + data[nmos::fields::nc::overall_status] = value::number(overall_status); + data[nmos::fields::nc::overall_status_message] = value::string(overall_status_message); + + return data; + } + + // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor + web::json::value make_receiver_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_overall_status::status overall_status, const utility::string_t& overall_status_message, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& grand_master_clock_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message) + { + using web::json::value; + + auto data = make_nc_status_monitor(class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints, enabled, overall_status, overall_status_message); data[nmos::fields::nc::link_status] = value::number(link_status); data[nmos::fields::nc::link_status_message] = value::string(link_status_message); diff --git a/Development/nmos/control_protocol_resource.h b/Development/nmos/control_protocol_resource.h index c74fec5a..28b08b7d 100644 --- a/Development/nmos/control_protocol_resource.h +++ b/Development/nmos/control_protocol_resource.h @@ -177,8 +177,10 @@ namespace nmos // See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncworker web::json::value make_nc_worker(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled); + // TODO: add link + web::json::value make_nc_status_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_overall_status::status overall_status, const utility::string_t& overall_status_message); // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor - web::json::value make_receiver_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& grand_master_clock_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message); + web::json::value make_receiver_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_overall_status::status overall_status, const utility::string_t& overall_status_message, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& grand_master_clock_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message); // See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncmanager web::json::value make_nc_manager(const nc_class_id& class_id, nc_oid oid, bool constant_oid, const web::json::value& owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints); diff --git a/Development/nmos/control_protocol_resources.cpp b/Development/nmos/control_protocol_resources.cpp index f48d2db5..ff409282 100644 --- a/Development/nmos/control_protocol_resources.cpp +++ b/Development/nmos/control_protocol_resources.cpp @@ -67,9 +67,9 @@ namespace nmos // // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor control_protocol_resource make_receiver_monitor(nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, - nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& grand_master_clock_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message) + nc_overall_status::status overall_status, const utility::string_t& overall_status_message, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& grand_master_clock_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message) { - auto data = details::make_receiver_monitor(nc_receiver_monitor_class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints, enabled, link_status, link_status_message, connection_status, connection_status_message, synchronization_status, synchronization_status_message, grand_master_clock_id, stream_status, stream_status_message); + auto data = details::make_receiver_monitor(nc_receiver_monitor_class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints, enabled, overall_status, overall_status_message, link_status, link_status_message, connection_status, connection_status_message, synchronization_status, synchronization_status_message, grand_master_clock_id, stream_status, stream_status_message); return{ is12_versions::v1_0, types::nc_receiver_monitor, std::move(data), true }; } diff --git a/Development/nmos/control_protocol_resources.h b/Development/nmos/control_protocol_resources.h index 26804f91..8cd03605 100644 --- a/Development/nmos/control_protocol_resources.h +++ b/Development/nmos/control_protocol_resources.h @@ -29,6 +29,8 @@ namespace nmos // // create Receiver Monitor resource control_protocol_resource make_receiver_monitor(nc_oid oid, bool constant_oid, nmos::nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints = web::json::value::null(), const web::json::value& runtime_property_constraints = web::json::value::null(), bool enabled = true, + nc_overall_status::status overall_status = nc_overall_status::healthy, + const utility::string_t& overall_status_message = U(""), nc_link_status::status link_status = nc_link_status::all_up, const utility::string_t& link_status_message = U(""), nc_connection_status::status connection_status = nc_connection_status::status::inactive, From 667ea4f408f45be4dddf0b59bc720c60a6990c2e Mon Sep 17 00:00:00 2001 From: "Jonathan Thorpe (Sony)" Date: Tue, 11 Jun 2024 09:50:54 +0100 Subject: [PATCH 5/7] Add Receiver Monitor method handlers --- Development/nmos-cpp-node/main.cpp | 2 +- Development/nmos/control_protocol_methods.cpp | 6 ++-- Development/nmos/control_protocol_methods.h | 6 ++-- Development/nmos/control_protocol_state.cpp | 29 ++++++++++++++++--- Development/nmos/control_protocol_state.h | 2 +- .../nmos/test/control_protocol_test.cpp | 4 +-- 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/Development/nmos-cpp-node/main.cpp b/Development/nmos-cpp-node/main.cpp index e4b420fa..38ea366d 100644 --- a/Development/nmos-cpp-node/main.cpp +++ b/Development/nmos-cpp-node/main.cpp @@ -138,7 +138,7 @@ int main(int argc, char* argv[]) .on_request_authorization_code(nmos::experimental::make_request_authorization_code_handler(gate)); // may be omitted, only required for OAuth client which is using the Authorization Code Flow to obtain the access token } - nmos::experimental::control_protocol_state control_protocol_state(node_implementation.control_protocol_property_changed); + nmos::experimental::control_protocol_state control_protocol_state(node_implementation.get_lost_packet_method_handler, node_implementation.get_late_packet_method_handler, node_implementation.reset_packet_counters_method_handler, node_implementation.control_protocol_property_changed); if (0 <= nmos::fields::control_protocol_ws_port(node_model.settings)) { node_implementation diff --git a/Development/nmos/control_protocol_methods.cpp b/Development/nmos/control_protocol_methods.cpp index ed411644..cf6a73dd 100644 --- a/Development/nmos/control_protocol_methods.cpp +++ b/Development/nmos/control_protocol_methods.cpp @@ -627,19 +627,19 @@ namespace nmos } // NcReceiverMonitor methods - web::json::value get_lost_packets(nmos::resources&, const nmos::resource&, const web::json::value&, bool, get_control_protocol_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, slog::base_gate&) + web::json::value get_lost_packets(nmos::resources&, const nmos::resource&, const web::json::value&, bool, slog::base_gate&) { // this will need to be defined in a user defined handler return details::make_nc_method_result({ nc_method_status::ok }); } - web::json::value get_late_packets(nmos::resources&, const nmos::resource&, const web::json::value&, bool, get_control_protocol_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, slog::base_gate&) + web::json::value get_late_packets(nmos::resources&, const nmos::resource&, const web::json::value&, bool, slog::base_gate&) { // this will need to be defined in a user defined handler return details::make_nc_method_result({ nc_method_status::ok }); } - web::json::value reset_packet_counters(nmos::resources&, const nmos::resource&, const web::json::value&, bool, get_control_protocol_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, slog::base_gate&) + web::json::value reset_packet_counters(nmos::resources&, const nmos::resource&, const web::json::value&, bool, slog::base_gate&) { // this will need to be defined in a user defined handler return details::make_nc_method_result({ nc_method_status::ok }); diff --git a/Development/nmos/control_protocol_methods.h b/Development/nmos/control_protocol_methods.h index 22ab870b..50086404 100644 --- a/Development/nmos/control_protocol_methods.h +++ b/Development/nmos/control_protocol_methods.h @@ -45,11 +45,11 @@ namespace nmos // NcReceiverMonitor methods implementation // Gets the lost packets - web::json::value get_lost_packets(nmos::resources&, const nmos::resource&, const web::json::value&, bool, get_control_protocol_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, slog::base_gate&); + web::json::value get_lost_packets(nmos::resources&, const nmos::resource&, const web::json::value&, bool, slog::base_gate&); // Gets the late packets - web::json::value get_late_packets(nmos::resources&, const nmos::resource&, const web::json::value&, bool, get_control_protocol_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, slog::base_gate&); + web::json::value get_late_packets(nmos::resources&, const nmos::resource&, const web::json::value&, bool, slog::base_gate&); // Resets the packet counters - web::json::value reset_packet_counters(nmos::resources&, const nmos::resource&, const web::json::value&, bool, get_control_protocol_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, slog::base_gate&); + web::json::value reset_packet_counters(nmos::resources&, const nmos::resource&, const web::json::value&, bool, slog::base_gate&); } #endif diff --git a/Development/nmos/control_protocol_state.cpp b/Development/nmos/control_protocol_state.cpp index c845555c..0a0ab3ee 100644 --- a/Development/nmos/control_protocol_state.cpp +++ b/Development/nmos/control_protocol_state.cpp @@ -178,9 +178,30 @@ namespace nmos return get_datatype(resources, resource, arguments, is_deprecated, get_control_protocol_datatype_descriptor, gate); }; } + nmos::experimental::control_protocol_method_handler make_nc_get_lost_packets(experimental::control_protocol_method_handler get_lost_packet_method_handler) + { + return [get_lost_packet_method_handler](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) + { + return get_lost_packet_method_handler(resources, resource, arguments, is_deprecated, gate); + }; + } + nmos::experimental::control_protocol_method_handler make_nc_get_late_packets(experimental::control_protocol_method_handler get_late_packet_method_handler) + { + return [get_late_packet_method_handler](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) + { + return get_late_packet_method_handler(resources, resource, arguments, is_deprecated, gate); + }; + } + nmos::experimental::control_protocol_method_handler make_nc_reset_packet_counters(experimental::control_protocol_method_handler reset_packet_counters_method_handler) + { + return [reset_packet_counters_method_handler](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) + { + return reset_packet_counters_method_handler(resources, resource, arguments, is_deprecated, gate); + }; + } } - control_protocol_state::control_protocol_state(control_protocol_property_changed_handler property_changed) + control_protocol_state::control_protocol_state(experimental::control_protocol_method_handler get_lost_packet_method_handler, experimental::control_protocol_method_handler get_late_packet_method_handler, experimental::control_protocol_method_handler reset_packet_couter_method_handler, control_protocol_property_changed_handler property_changed) { using web::json::value; @@ -315,9 +336,9 @@ namespace nmos to_methods_vector(make_nc_receiver_monitor_methods(), { // link NcReceiverMonitor method_ids with method functions - { nc_receiver_monitor_get_lost_packets_method_id, get_lost_packets }, - { nc_receiver_monitor_get_late_packets_method_id, get_late_packets }, - { nc_receiver_monitor_reset_packet_counters_method_id, reset_packet_counters } + { nc_receiver_monitor_get_lost_packets_method_id, details::make_nc_get_lost_packets(get_lost_packet_method_handler)}, + { nc_receiver_monitor_get_late_packets_method_id, details::make_nc_get_late_packets(get_late_packet_method_handler)}, + { nc_receiver_monitor_reset_packet_counters_method_id, details::make_nc_reset_packet_counters(reset_packet_couter_method_handler)} }), // NcReceiverMonitor events to_vector(make_nc_receiver_monitor_events())) } diff --git a/Development/nmos/control_protocol_state.h b/Development/nmos/control_protocol_state.h index b49d4e50..66b18b1d 100644 --- a/Development/nmos/control_protocol_state.h +++ b/Development/nmos/control_protocol_state.h @@ -58,7 +58,7 @@ namespace nmos nmos::read_lock read_lock() const { return nmos::read_lock{ mutex }; } nmos::write_lock write_lock() const { return nmos::write_lock{ mutex }; } - control_protocol_state(control_protocol_property_changed_handler property_changed); + control_protocol_state(experimental::control_protocol_method_handler get_lost_packet_method_handler = nullptr, experimental::control_protocol_method_handler get_late_packet_method_handler = nullptr, experimental::control_protocol_method_handler reset_packet_couter_method_handler = nullptr, control_protocol_property_changed_handler property_changed = nullptr); // insert control class descriptor, false if class descriptor already inserted bool insert(const experimental::control_class_descriptor& control_class_descriptor); diff --git a/Development/nmos/test/control_protocol_test.cpp b/Development/nmos/test/control_protocol_test.cpp index 7150accd..25364f65 100644 --- a/Development/nmos/test/control_protocol_test.cpp +++ b/Development/nmos/test/control_protocol_test.cpp @@ -676,7 +676,7 @@ BST_TEST_CASE(testFindProperty) const auto invalid_property_id = nmos::nc_property_id(1000, 1000); const auto invalid_class_id = nmos::nc_class_id({ 1000, 1000 }); - nmos::experimental::control_protocol_state control_protocol_state(nullptr); + nmos::experimental::control_protocol_state control_protocol_state; auto get_control_protocol_class_descriptor = nmos::make_get_control_protocol_class_descriptor_handler(control_protocol_state); { @@ -773,7 +773,7 @@ BST_TEST_CASE(testConstraints) const auto struct_datatype = nmos::details::make_nc_datatype_descriptor_struct(U("struct datatype"), U("structDatatype"), fields, value::null()); // no datatype constraints for struct datatype // setup datatypes in control_protocol_state - nmos::experimental::control_protocol_state control_protocol_state(nullptr); + nmos::experimental::control_protocol_state control_protocol_state; control_protocol_state.insert(nmos::experimental::datatype_descriptor{ no_constraints_int16_datatype }); control_protocol_state.insert(nmos::experimental::datatype_descriptor{ no_constraints_int32_datatype }); control_protocol_state.insert(nmos::experimental::datatype_descriptor{ no_constraints_int64_datatype }); From 06df2622ec726d286c42bb0f4fa57cec46977d0d Mon Sep 17 00:00:00 2001 From: "Jonathan Thorpe (Sony)" Date: Fri, 28 Jun 2024 12:25:23 +0100 Subject: [PATCH 6/7] Refactor user defined handlers --- Development/nmos-cpp-node/main.cpp | 2 +- .../nmos-cpp-node/node_implementation.cpp | 18 ++--- Development/nmos/control_protocol_handlers.h | 6 ++ Development/nmos/control_protocol_state.cpp | 69 +++++++++++++++---- Development/nmos/control_protocol_state.h | 2 +- Development/nmos/node_server.h | 12 ++-- 6 files changed, 78 insertions(+), 31 deletions(-) diff --git a/Development/nmos-cpp-node/main.cpp b/Development/nmos-cpp-node/main.cpp index 38ea366d..7f1a18e9 100644 --- a/Development/nmos-cpp-node/main.cpp +++ b/Development/nmos-cpp-node/main.cpp @@ -138,7 +138,7 @@ int main(int argc, char* argv[]) .on_request_authorization_code(nmos::experimental::make_request_authorization_code_handler(gate)); // may be omitted, only required for OAuth client which is using the Authorization Code Flow to obtain the access token } - nmos::experimental::control_protocol_state control_protocol_state(node_implementation.get_lost_packet_method_handler, node_implementation.get_late_packet_method_handler, node_implementation.reset_packet_counters_method_handler, node_implementation.control_protocol_property_changed); + nmos::experimental::control_protocol_state control_protocol_state(node_implementation.get_lost_packet_counters, node_implementation.get_late_packet_counters, node_implementation.reset_packet_counters, node_implementation.control_protocol_property_changed); if (0 <= nmos::fields::control_protocol_ws_port(node_model.settings)) { node_implementation diff --git a/Development/nmos-cpp-node/node_implementation.cpp b/Development/nmos-cpp-node/node_implementation.cpp index d3b8b5fd..17d53709 100644 --- a/Development/nmos-cpp-node/node_implementation.cpp +++ b/Development/nmos-cpp-node/node_implementation.cpp @@ -1715,9 +1715,9 @@ nmos::control_protocol_property_changed_handler make_node_implementation_control } // Example Receiver Status Monitor callback for get_lost_packets method -nmos::experimental::control_protocol_method_handler make_node_implementation_get_lost_packet_method_handler() +nmos::get_lost_packet_counters_handler make_node_implementation_get_lost_packet_counters_handler() { - return [&](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) + return [&]() { // Implement polling of lost packet count here uint16_t lost_packet_count(0); @@ -1726,9 +1726,9 @@ nmos::experimental::control_protocol_method_handler make_node_implementation_get } // Example Receiver Status Monitor callback for get_late_packets method -nmos::experimental::control_protocol_method_handler make_node_implementation_get_late_packet_method_handler() +nmos::get_late_packet_counters_handler make_node_implementation_get_late_packet_counters_handler() { - return [&](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) + return [&]() { // Implement polling of late packet count here uint16_t late_packet_count(0); @@ -1737,9 +1737,9 @@ nmos::experimental::control_protocol_method_handler make_node_implementation_get } // Example Receiver Status Monitor callback for reset_packet_counters method -nmos::experimental::control_protocol_method_handler make_node_implementation_reset_packet_counters_method_handler() +nmos::reset_packet_counters_handler make_node_implementation_reset_packet_counters_handler() { - return [&](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) + return [&]() { // Implement reset of lost and late packet counters return nmos::details::make_nc_method_result({ nmos::nc_method_status::ok }); @@ -1904,7 +1904,7 @@ nmos::experimental::node_implementation make_node_implementation(nmos::node_mode .on_validate_channelmapping_output_map(make_node_implementation_map_validator()) // may be omitted if not required .on_channelmapping_activated(make_node_implementation_channelmapping_activation_handler(gate)) .on_control_protocol_property_changed(make_node_implementation_control_protocol_property_changed_handler(gate)) // may be omitted if IS-12 not required - .on_get_lost_packet(make_node_implementation_get_lost_packet_method_handler()) - .on_get_late_packet(make_node_implementation_get_late_packet_method_handler()) - .on_reset_packet_counters(make_node_implementation_reset_packet_counters_method_handler()); + .on_get_lost_packet_counters(make_node_implementation_get_lost_packet_counters_handler()) + .on_get_late_packet_counters(make_node_implementation_get_late_packet_counters_handler()) + .on_reset_packet_counters(make_node_implementation_reset_packet_counters_handler()); } diff --git a/Development/nmos/control_protocol_handlers.h b/Development/nmos/control_protocol_handlers.h index 0dcd8478..51126484 100644 --- a/Development/nmos/control_protocol_handlers.h +++ b/Development/nmos/control_protocol_handlers.h @@ -36,6 +36,12 @@ namespace nmos // this callback should not throw exceptions, as the relevant property will already has been changed and those changes will not be rolled back typedef std::function control_protocol_property_changed_handler; + // Receiver status callbacks + // these callbacks should not throw exceptions + typedef std::function get_lost_packet_counters_handler; + typedef std::function get_late_packet_counters_handler; + typedef std::function reset_packet_counters_handler; + namespace experimental { // control method handler definition diff --git a/Development/nmos/control_protocol_state.cpp b/Development/nmos/control_protocol_state.cpp index 0a0ab3ee..49eff7e9 100644 --- a/Development/nmos/control_protocol_state.cpp +++ b/Development/nmos/control_protocol_state.cpp @@ -1,5 +1,6 @@ #include "nmos/control_protocol_state.h" +#include "cpprest/http_utils.h" #include "nmos/control_protocol_methods.h" #include "nmos/control_protocol_resource.h" @@ -178,30 +179,69 @@ namespace nmos return get_datatype(resources, resource, arguments, is_deprecated, get_control_protocol_datatype_descriptor, gate); }; } - nmos::experimental::control_protocol_method_handler make_nc_get_lost_packets(experimental::control_protocol_method_handler get_lost_packet_method_handler) + nmos::experimental::control_protocol_method_handler make_nc_get_lost_packet_counters_handler(get_lost_packet_counters_handler get_lost_packet_counters) { - return [get_lost_packet_method_handler](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) + return [get_lost_packet_counters](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) { - return get_lost_packet_method_handler(resources, resource, arguments, is_deprecated, gate); + // Delegate to user defined handler + auto result = nmos::details::make_nc_method_result_error({ nmos::nc_method_status::method_not_implemented }, U("not implemented")); + + if (get_lost_packet_counters) + { + result = get_lost_packet_counters(); + + const auto& status = nmos::fields::nc::status(result); + if (!web::http::is_error_status_code((web::http::status_code)status) && is_deprecated) + { + return nmos::details::make_nc_method_result({ nmos::nc_method_status::method_deprecated }, nmos::fields::nc::value(result)); + } + } + return result; }; } - nmos::experimental::control_protocol_method_handler make_nc_get_late_packets(experimental::control_protocol_method_handler get_late_packet_method_handler) + nmos::experimental::control_protocol_method_handler make_nc_get_late_packet_counters_handler(get_late_packet_counters_handler get_late_packet_counters) { - return [get_late_packet_method_handler](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) + return [get_late_packet_counters](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) { - return get_late_packet_method_handler(resources, resource, arguments, is_deprecated, gate); + // Delegate to user defined handler + auto result = nmos::details::make_nc_method_result_error({ nmos::nc_method_status::method_not_implemented }, U("not implemented")); + + if (get_late_packet_counters) + { + result = get_late_packet_counters(); + + const auto& status = nmos::fields::nc::status(result); + if (!web::http::is_error_status_code((web::http::status_code)status) && is_deprecated) + { + return nmos::details::make_nc_method_result({ nmos::nc_method_status::method_deprecated }, nmos::fields::nc::value(result)); + } + } + return result; }; } - nmos::experimental::control_protocol_method_handler make_nc_reset_packet_counters(experimental::control_protocol_method_handler reset_packet_counters_method_handler) + nmos::experimental::control_protocol_method_handler make_nc_reset_packet_counters_handler(reset_packet_counters_handler reset_packet_counters) { - return [reset_packet_counters_method_handler](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) + return [reset_packet_counters](nmos::resources& resources, const nmos::resource& resource, const web::json::value& arguments, bool is_deprecated, slog::base_gate& gate) { - return reset_packet_counters_method_handler(resources, resource, arguments, is_deprecated, gate); + // Delegate to user defined handler + auto result = nmos::details::make_nc_method_result_error({ nmos::nc_method_status::method_not_implemented }, U("not implemented")); + + if (reset_packet_counters) + { + result = reset_packet_counters(); + + const auto& status = nmos::fields::nc::status(result); + if (!web::http::is_error_status_code((web::http::status_code)status) && is_deprecated) + { + return nmos::details::make_nc_method_result({ nmos::nc_method_status::method_deprecated }, nmos::fields::nc::value(result)); + } + } + return result; }; } } - control_protocol_state::control_protocol_state(experimental::control_protocol_method_handler get_lost_packet_method_handler, experimental::control_protocol_method_handler get_late_packet_method_handler, experimental::control_protocol_method_handler reset_packet_couter_method_handler, control_protocol_property_changed_handler property_changed) + control_protocol_state::control_protocol_state(get_lost_packet_counters_handler get_lost_packet_counters, get_late_packet_counters_handler get_late_packet_counters, reset_packet_counters_handler reset_packet_counters, control_protocol_property_changed_handler property_changed) { using web::json::value; @@ -336,9 +376,9 @@ namespace nmos to_methods_vector(make_nc_receiver_monitor_methods(), { // link NcReceiverMonitor method_ids with method functions - { nc_receiver_monitor_get_lost_packets_method_id, details::make_nc_get_lost_packets(get_lost_packet_method_handler)}, - { nc_receiver_monitor_get_late_packets_method_id, details::make_nc_get_late_packets(get_late_packet_method_handler)}, - { nc_receiver_monitor_reset_packet_counters_method_id, details::make_nc_reset_packet_counters(reset_packet_couter_method_handler)} + { nc_receiver_monitor_get_lost_packet_counters_method_id, details::make_nc_get_lost_packet_counters_handler(get_lost_packet_counters)}, + { nc_receiver_monitor_get_late_packet_counters_method_id, details::make_nc_get_late_packet_counters_handler(get_late_packet_counters)}, + { nc_receiver_monitor_reset_packet_counters_method_id, details::make_nc_reset_packet_counters_handler(reset_packet_counters)} }), // NcReceiverMonitor events to_vector(make_nc_receiver_monitor_events())) } @@ -424,7 +464,8 @@ namespace nmos { U("NcLinkStatus"), {make_nc_link_status_datatype() } }, { U("NcSynchronizationStatus"), {make_nc_synchronization_status_datatype() } }, { U("NcStreamStatus"), {make_nc_stream_status_datatype() } }, - { U("NcMethodResultCounter"), {make_nc_method_result_counter_datatype() } } + { U("NcPacketCounter"), {make_nc_packet_counter_datatype() } }, + { U("NcMethodResultCounters"), {make_nc_method_result_counters_datatype() } } }; } diff --git a/Development/nmos/control_protocol_state.h b/Development/nmos/control_protocol_state.h index 66b18b1d..453b513a 100644 --- a/Development/nmos/control_protocol_state.h +++ b/Development/nmos/control_protocol_state.h @@ -58,7 +58,7 @@ namespace nmos nmos::read_lock read_lock() const { return nmos::read_lock{ mutex }; } nmos::write_lock write_lock() const { return nmos::write_lock{ mutex }; } - control_protocol_state(experimental::control_protocol_method_handler get_lost_packet_method_handler = nullptr, experimental::control_protocol_method_handler get_late_packet_method_handler = nullptr, experimental::control_protocol_method_handler reset_packet_couter_method_handler = nullptr, control_protocol_property_changed_handler property_changed = nullptr); + control_protocol_state(get_lost_packet_counters_handler get_lost_packet_counters = nullptr, get_late_packet_counters_handler get_late_packet_counters = nullptr, reset_packet_counters_handler reset_packet_counters = nullptr, control_protocol_property_changed_handler property_changed = nullptr); // insert control class descriptor, false if class descriptor already inserted bool insert(const experimental::control_class_descriptor& control_class_descriptor); diff --git a/Development/nmos/node_server.h b/Development/nmos/node_server.h index 8aabdcc5..55ddbe5a 100644 --- a/Development/nmos/node_server.h +++ b/Development/nmos/node_server.h @@ -82,9 +82,9 @@ namespace nmos node_implementation& on_get_control_datatype_descriptor(nmos::get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype_descriptor) { this->get_control_protocol_datatype_descriptor = std::move(get_control_protocol_datatype_descriptor); return *this; } node_implementation& on_get_control_protocol_method_descriptor(nmos::get_control_protocol_method_descriptor_handler get_control_protocol_method_descriptor) { this->get_control_protocol_method_descriptor = std::move(get_control_protocol_method_descriptor); return *this; } node_implementation& on_control_protocol_property_changed(nmos::control_protocol_property_changed_handler control_protocol_property_changed) { this->control_protocol_property_changed = std::move(control_protocol_property_changed); return *this; } - node_implementation& on_get_lost_packet(experimental::control_protocol_method_handler get_lost_packet_method_handler) { this->get_lost_packet_method_handler = std::move(get_lost_packet_method_handler); return *this; } - node_implementation& on_get_late_packet(experimental::control_protocol_method_handler get_late_packet_method_handler) { this->get_late_packet_method_handler = std::move(get_late_packet_method_handler); return *this; } - node_implementation& on_reset_packet_counters(experimental::control_protocol_method_handler reset_packet_counters_method_handler) { this->reset_packet_counters_method_handler = std::move(reset_packet_counters_method_handler); return *this; } + node_implementation& on_get_lost_packet_counters(nmos::get_lost_packet_counters_handler get_lost_packet_counters) { this->get_lost_packet_counters = std::move(get_lost_packet_counters); return *this; } + node_implementation& on_get_late_packet_counters(nmos::get_late_packet_counters_handler get_late_packet_counters) { this->get_late_packet_counters = std::move(get_late_packet_counters); return *this; } + node_implementation& on_reset_packet_counters(nmos::reset_packet_counters_handler reset_packet_counters) { this->reset_packet_counters = std::move(reset_packet_counters); return *this; } // deprecated, use on_validate_connection_resource_patch node_implementation& on_validate_merged(nmos::details::connection_resource_patch_validator validate_merged) { return on_validate_connection_resource_patch(std::move(validate_merged)); } @@ -127,9 +127,9 @@ namespace nmos nmos::get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype_descriptor; nmos::get_control_protocol_method_descriptor_handler get_control_protocol_method_descriptor; nmos::control_protocol_property_changed_handler control_protocol_property_changed; - experimental::control_protocol_method_handler get_lost_packet_method_handler; - experimental::control_protocol_method_handler get_late_packet_method_handler; - experimental::control_protocol_method_handler reset_packet_counters_method_handler; + nmos::get_lost_packet_counters_handler get_lost_packet_counters; + nmos::get_late_packet_counters_handler get_late_packet_counters; + nmos::reset_packet_counters_handler reset_packet_counters; }; // Construct a server instance for an NMOS Node, implementing the IS-04 Node API, IS-05 Connection API, IS-07 Events API From 4e373200dd2b5904e77d1247f5f0730c9f5e1443 Mon Sep 17 00:00:00 2001 From: "Jonathan Thorpe (Sony)" Date: Fri, 28 Jun 2024 12:25:42 +0100 Subject: [PATCH 7/7] Update datatypes to latest version of spec --- .../nmos/control_protocol_resource.cpp | 27 +++++++++++++------ Development/nmos/control_protocol_resource.h | 16 ++++++----- .../nmos/control_protocol_resources.cpp | 4 +-- Development/nmos/control_protocol_resources.h | 2 +- Development/nmos/control_protocol_typedefs.h | 6 ++--- Development/nmos/json_fields.h | 2 +- 6 files changed, 35 insertions(+), 22 deletions(-) diff --git a/Development/nmos/control_protocol_resource.cpp b/Development/nmos/control_protocol_resource.cpp index e73a092e..2578f1fb 100644 --- a/Development/nmos/control_protocol_resource.cpp +++ b/Development/nmos/control_protocol_resource.cpp @@ -751,7 +751,7 @@ namespace nmos } // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor - web::json::value make_receiver_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_overall_status::status overall_status, const utility::string_t& overall_status_message, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& grand_master_clock_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message) + web::json::value make_receiver_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_overall_status::status overall_status, const utility::string_t& overall_status_message, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& synchronization_source_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message) { using web::json::value; @@ -763,7 +763,7 @@ namespace nmos data[nmos::fields::nc::connection_status_message] = value::string(connection_status_message); data[nmos::fields::nc::synchronization_status] = value::number(synchronization_status); data[nmos::fields::nc::synchronization_status_message] = value::string(synchronization_status_message); - data[nmos::fields::nc::grand_master_clock_id] = value::string(grand_master_clock_id); + data[nmos::fields::nc::synchronization_source_id] = value::string(synchronization_source_id); data[nmos::fields::nc::stream_status] = value::number(stream_status); data[nmos::fields::nc::stream_status_message] = value::string(stream_status_message); @@ -1208,7 +1208,7 @@ namespace nmos web::json::push_back(properties, details::make_nc_property_descriptor(U("Connection status message property"), nc_receiver_monitor_connection_status_message_property_id, nmos::fields::nc::connection_status_message, U("NcString"), true, true, false, false, value::null())); web::json::push_back(properties, details::make_nc_property_descriptor(U("Synchronization status property"), nc_receiver_monitor_synchronization_status_property_id, nmos::fields::nc::synchronization_status, U("NcSynchronizationStatus"), true, false, false, false, value::null())); web::json::push_back(properties, details::make_nc_property_descriptor(U("Synchronization status message property"), nc_receiver_monitor_synchronization_status_message_property_id, nmos::fields::nc::synchronization_status_message, U("NcString"), true, true, false, false, value::null())); - web::json::push_back(properties, details::make_nc_property_descriptor(U("Grand master clock id property"), nc_receiver_monitor_synchronization_grand_master_clock_id_property_id, nmos::fields::nc::grand_master_clock_id, U("NcString"), true, true, false, false, value::null())); + web::json::push_back(properties, details::make_nc_property_descriptor(U("Grand master clock id property"), nc_receiver_monitor_synchronization_synchronization_source_id_property_id, nmos::fields::nc::synchronization_source_id, U("NcString"), true, true, false, false, value::null())); web::json::push_back(properties, details::make_nc_property_descriptor(U("Stream status property"), nc_receiver_monitor_stream_status_property_id, nmos::fields::nc::stream_status, U("NcStreamStatus"), true, false, false, false, value::null())); web::json::push_back(properties, details::make_nc_property_descriptor(U("Stream status message property"), nc_receiver_monitor_stream_status_message_property_id, nmos::fields::nc::stream_status_message, U("NcString"), true, true, false, false, value::null())); @@ -1219,8 +1219,8 @@ namespace nmos using web::json::value; auto methods = value::array(); - web::json::push_back(methods, details::make_nc_method_descriptor(U("Gets the lost packets"), nc_receiver_monitor_get_lost_packets_method_id, U("GetLostPackets"), U("NcMethodResultCounter"), value::array(), false)); - web::json::push_back(methods, details::make_nc_method_descriptor(U("Gets the late packets"), nc_receiver_monitor_get_late_packets_method_id, U("GetLatePackets"), U("NcMethodResultCounter"), value::array(), false)); + web::json::push_back(methods, details::make_nc_method_descriptor(U("Gets the lost packet counters"), nc_receiver_monitor_get_lost_packet_counters_method_id, U("GetLostPacketCounters"), U("NcMethodResultCounters"), value::array(), false)); + web::json::push_back(methods, details::make_nc_method_descriptor(U("Gets the late packet counters"), nc_receiver_monitor_get_late_packet_counters_method_id, U("GetLatePacketCounters"), U("NcMethodResultCounters"), value::array(), false)); web::json::push_back(methods, details::make_nc_method_descriptor(U("Resets the packet counters"), nc_receiver_monitor_reset_packet_counters_method_id, U("ResetPacketCounters"), U("NcMethodResult"), value::array(), false)); return methods; @@ -2073,6 +2073,7 @@ namespace nmos using web::json::value; auto items = value::array(); + web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Inactive"), U("Inactive"), 0)); web::json::push_back(items, details::make_nc_enum_item_descriptor(U("The overall status is healthy"), U("Healthy"), 1)); web::json::push_back(items, details::make_nc_enum_item_descriptor(U("The overall status is partially healthy"), U("PartiallyHealthy"), 2)); web::json::push_back(items, details::make_nc_enum_item_descriptor(U("The overall status is unhealthy"), U("Unhealthy"), 3)); @@ -2115,13 +2116,23 @@ namespace nmos web::json::push_back(items, details::make_nc_enum_item_descriptor(U("Active and unhealthy"), U("Unhealthy"), 3)); return details::make_nc_datatype_descriptor_enum(U("Stream status enum data type"), U("NcStreamStatus"), items, value::null()); } - // TOO: link - web::json::value make_nc_method_result_counter_datatype() + // TODO: link + web::json::value make_nc_packet_counter_datatype() { using web::json::value; auto fields = value::array(); + web::json::push_back(fields, details::make_nc_field_descriptor(U("Counter name"), nmos::fields::nc::name, U("NcString"), false, false, value::null())); web::json::push_back(fields, details::make_nc_field_descriptor(U("Counter value"), nmos::fields::nc::value, U("NcUint64"), false, false, value::null())); - return details::make_nc_datatype_descriptor_struct(U("Counter method result"), U("NcMethodResultCounter"), fields, U("NcMethodResult"), value::null()); + return details::make_nc_datatype_descriptor_struct(U("Packet counter data type"), U("NcPacketCounter"), fields, value::null()); + } + // TOO: link + web::json::value make_nc_method_result_counters_datatype() + { + using web::json::value; + + auto fields = value::array(); + web::json::push_back(fields, details::make_nc_field_descriptor(U("Counters"), nmos::fields::nc::value, U("NcPacketCounter"), false, true, value::null())); + return details::make_nc_datatype_descriptor_struct(U("Counter method result"), U("NcMethodResultCounters"), fields, U("NcMethodResult"), value::null()); } } diff --git a/Development/nmos/control_protocol_resource.h b/Development/nmos/control_protocol_resource.h index 28b08b7d..4c34590a 100644 --- a/Development/nmos/control_protocol_resource.h +++ b/Development/nmos/control_protocol_resource.h @@ -180,7 +180,7 @@ namespace nmos // TODO: add link web::json::value make_nc_status_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_overall_status::status overall_status, const utility::string_t& overall_status_message); // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor - web::json::value make_receiver_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_overall_status::status overall_status, const utility::string_t& overall_status_message, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& grand_master_clock_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message); + web::json::value make_receiver_monitor(const nc_class_id& class_id, nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, nc_overall_status::status overall_status, const utility::string_t& overall_status_message, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& synchronization_source_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message); // See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncmanager web::json::value make_nc_manager(const nc_class_id& class_id, nc_oid oid, bool constant_oid, const web::json::value& owner, const utility::string_t& role, const web::json::value& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints); @@ -425,16 +425,18 @@ namespace nmos // // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncconnectionstatus web::json::value make_nc_connection_status_datatype(); - // TOO: link + // TODO: link web::json::value make_nc_overall_status_datatype(); - // TOO: link + // TODO: link web::json::value make_nc_link_status_datatype(); - // TOO: link + // TODO: link web::json::value make_nc_synchronization_status_datatype(); - // TOO: link + // TODO: link web::json::value make_nc_stream_status_datatype(); - // TOO: link - web::json::value make_nc_method_result_counter_datatype(); + // TODO: link + web::json::value make_nc_packet_counter_datatype(); + // TODO: link + web::json::value make_nc_method_result_counters_datatype(); } #endif diff --git a/Development/nmos/control_protocol_resources.cpp b/Development/nmos/control_protocol_resources.cpp index ff409282..a0247e22 100644 --- a/Development/nmos/control_protocol_resources.cpp +++ b/Development/nmos/control_protocol_resources.cpp @@ -67,9 +67,9 @@ namespace nmos // // See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor control_protocol_resource make_receiver_monitor(nc_oid oid, bool constant_oid, nc_oid owner, const utility::string_t& role, const utility::string_t& user_label, const utility::string_t& description, const web::json::value& touchpoints, const web::json::value& runtime_property_constraints, bool enabled, - nc_overall_status::status overall_status, const utility::string_t& overall_status_message, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& grand_master_clock_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message) + nc_overall_status::status overall_status, const utility::string_t& overall_status_message, nc_link_status::status link_status, const utility::string_t& link_status_message, nc_connection_status::status connection_status, const utility::string_t& connection_status_message, nc_synchronization_status::status synchronization_status, const utility::string_t& synchronization_status_message, const utility::string_t& synchronization_source_id, nc_stream_status::status stream_status, const utility::string_t& stream_status_message) { - auto data = details::make_receiver_monitor(nc_receiver_monitor_class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints, enabled, overall_status, overall_status_message, link_status, link_status_message, connection_status, connection_status_message, synchronization_status, synchronization_status_message, grand_master_clock_id, stream_status, stream_status_message); + auto data = details::make_receiver_monitor(nc_receiver_monitor_class_id, oid, constant_oid, owner, role, user_label, description, touchpoints, runtime_property_constraints, enabled, overall_status, overall_status_message, link_status, link_status_message, connection_status, connection_status_message, synchronization_status, synchronization_status_message, synchronization_source_id, stream_status, stream_status_message); return{ is12_versions::v1_0, types::nc_receiver_monitor, std::move(data), true }; } diff --git a/Development/nmos/control_protocol_resources.h b/Development/nmos/control_protocol_resources.h index 8cd03605..71fd66cf 100644 --- a/Development/nmos/control_protocol_resources.h +++ b/Development/nmos/control_protocol_resources.h @@ -37,7 +37,7 @@ namespace nmos const utility::string_t& connection_status_message = U(""), nc_synchronization_status::status synchronization_status = nc_synchronization_status::not_used, const utility::string_t& synchronization_status_message = U(""), - const utility::string_t& grand_master_clock_id = U(""), + const utility::string_t& synchronization_source_id = U(""), nc_stream_status::status stream_status = nc_stream_status::inactive, const utility::string_t& stream_status_message = U("") ); diff --git a/Development/nmos/control_protocol_typedefs.h b/Development/nmos/control_protocol_typedefs.h index e8e79347..8d0a724c 100644 --- a/Development/nmos/control_protocol_typedefs.h +++ b/Development/nmos/control_protocol_typedefs.h @@ -212,8 +212,8 @@ namespace nmos const nc_method_id nc_class_manager_get_datatype_method_id(3, 2); // NcMethodIds for NcReceiverMonitor // TODO: link - const nc_method_id nc_receiver_monitor_get_lost_packets_method_id(4, 1); - const nc_method_id nc_receiver_monitor_get_late_packets_method_id(4, 2); + const nc_method_id nc_receiver_monitor_get_lost_packet_counters_method_id(4, 1); + const nc_method_id nc_receiver_monitor_get_late_packet_counters_method_id(4, 2); const nc_method_id nc_receiver_monitor_reset_packet_counters_method_id(4, 3); // NcPropertyId @@ -263,7 +263,7 @@ namespace nmos const nc_property_id nc_receiver_monitor_connection_status_message_property_id(4, 4); const nc_property_id nc_receiver_monitor_synchronization_status_property_id(4, 5); const nc_property_id nc_receiver_monitor_synchronization_status_message_property_id(4, 6); - const nc_property_id nc_receiver_monitor_synchronization_grand_master_clock_id_property_id(4, 7); + const nc_property_id nc_receiver_monitor_synchronization_synchronization_source_id_property_id(4, 7); const nc_property_id nc_receiver_monitor_stream_status_property_id(4, 8); const nc_property_id nc_receiver_monitor_stream_status_message_property_id(4, 9); const nc_property_id nc_receiver_monitor_protected_signal_protection_status_property_id(4, 1); diff --git a/Development/nmos/json_fields.h b/Development/nmos/json_fields.h index 075da370..db30150d 100644 --- a/Development/nmos/json_fields.h +++ b/Development/nmos/json_fields.h @@ -336,7 +336,7 @@ namespace nmos const web::json::field_as_string link_status_message{ U("linkStatusMessage") }; const web::json::field_as_integer synchronization_status{ U("synchronizationStatus") }; // NcSynchronizationStatus const web::json::field_as_string synchronization_status_message{ U("synchronizationStatusMessage") }; - const web::json::field_as_string grand_master_clock_id{ U("grandMasterClockId") }; + const web::json::field_as_string synchronization_source_id{ U("synchronizationSourceId") }; const web::json::field_as_bool signal_protection_status{ U("signalProtectionStatus") }; const web::json::field_as_integer stream_status{ U("streamStatus") }; // NcStreamStatus const web::json::field_as_string stream_status_message{ U("streamStatusMessage") };