Skip to content

Commit

Permalink
Create NcStatusMonitor and update NcReceiverMonitor
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-r-thorpe committed May 24, 2024
1 parent 40f42de commit 7965892
Show file tree
Hide file tree
Showing 12 changed files with 175 additions and 154 deletions.
4 changes: 2 additions & 2 deletions Development/nmos/api_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions Development/nmos/control_protocol_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
95 changes: 57 additions & 38 deletions Development/nmos/control_protocol_methods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,60 +569,79 @@ namespace nmos

// 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_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype_descriptor, control_protocol_property_changed_handler, slog::base_gate& gate)
{
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...
{
// note, model mutex is already locked by the outer function, so access to control_protocol_resources is OK...

const auto& name = nmos::fields::nc::name(arguments); // name of datatype
const auto& include_inherited = nmos::fields::nc::include_inherited(arguments); // If set the descriptor would contain all inherited elements
const auto& name = nmos::fields::nc::name(arguments); // name of datatype
const auto& include_inherited = nmos::fields::nc::include_inherited(arguments); // If set the descriptor would contain all inherited elements

slog::log<slog::severities::more_info>(gate, SLOG_FLF) << "Get a single datatype descriptor: " << "name: " << name;
slog::log<slog::severities::more_info>(gate, SLOG_FLF) << "Get a single datatype descriptor: " << "name: " << name;

if (name.empty())
{
// empty name
return details::make_nc_method_result_error({ nc_method_status::parameter_error }, U("empty name to do GetDatatype"));
}
if (name.empty())
{
// empty name
return details::make_nc_method_result_error({ nc_method_status::parameter_error }, U("empty name to do GetDatatype"));
}

const auto& datatype = get_control_protocol_datatype_descriptor(name);
if (datatype.descriptor.size())
{
auto descriptor = datatype.descriptor;
const auto& datatype = get_control_protocol_datatype_descriptor(name);
if (datatype.descriptor.size())
{
auto descriptor = datatype.descriptor;

if (include_inherited)
if (include_inherited)
{
const auto& type = nmos::fields::nc::type(descriptor);
if (nc_datatype_type::Struct == type)
{
const auto& type = nmos::fields::nc::type(descriptor);
if (nc_datatype_type::Struct == type)
{
auto descriptor_ = descriptor;
auto descriptor_ = descriptor;

for (;;)
for (;;)
{
const auto& parent_type = descriptor_.at(nmos::fields::nc::parent_type);
if (!parent_type.is_null())
{
const auto& parent_type = descriptor_.at(nmos::fields::nc::parent_type);
if (!parent_type.is_null())
const auto& parent_datatype = get_control_protocol_datatype_descriptor(parent_type.as_string());
if (parent_datatype.descriptor.size())
{
const auto& parent_datatype = get_control_protocol_datatype_descriptor(parent_type.as_string());
if (parent_datatype.descriptor.size())
{
descriptor_ = parent_datatype.descriptor;
descriptor_ = parent_datatype.descriptor;

const auto& fields = nmos::fields::nc::fields(descriptor_);
for (const auto& field : fields)
{
web::json::push_back(descriptor.at(nmos::fields::nc::fields), field);
}
const auto& fields = nmos::fields::nc::fields(descriptor_);
for (const auto& field : fields)
{
web::json::push_back(descriptor.at(nmos::fields::nc::fields), field);
}
}
else
{
break;
}
}
else
{
break;
}
}
}

return details::make_nc_method_result({ is_deprecated ? nmos::nc_method_status::method_deprecated : nc_method_status::ok }, descriptor);
}

return details::make_nc_method_result_error({ nc_method_status::parameter_error }, U("name not found"));
return details::make_nc_method_result({ is_deprecated ? nmos::nc_method_status::method_deprecated : nc_method_status::ok }, descriptor);
}

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 });
}
}
8 changes: 8 additions & 0 deletions Development/nmos/control_protocol_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, get_control_protocol_datatype_descriptor_handler, control_protocol_property_changed_handler, 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_class_descriptor_handler, get_control_protocol_datatype_descriptor_handler get_control_protocol_datatype, control_protocol_property_changed_handler, 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
Loading

0 comments on commit 7965892

Please sign in to comment.