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 });