Skip to content

Commit

Permalink
Set IS-12 nmos resource with relevant nmos::type
Browse files Browse the repository at this point in the history
  • Loading branch information
lo-simon committed Oct 19, 2023
1 parent f8f5270 commit 264cfba
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Development/nmos-cpp-node/node_implementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ void node_implementation_init(nmos::node_model& model, nmos::experimental::contr
auto data = nmos::details::make_nc_worker(gain_control_class_id, oid, true, owner, role, value::string(user_label), description, touchpoints, runtime_property_constraints, true);
data[gain_value] = value::number(gain);

return nmos::control_protocol_resource{ nmos::is12_versions::v1_0, nmos::types::nc_object, std::move(data), true };
return nmos::control_protocol_resource{ nmos::is12_versions::v1_0, nmos::types::nc_worker, std::move(data), true };
};

// example to create a non-standard Example control class
Expand Down Expand Up @@ -1131,7 +1131,7 @@ void node_implementation_init(nmos::node_model& model, nmos::experimental::contr
data[object_sequence] = sequence;
}

return nmos::control_protocol_resource{ nmos::is12_versions::v1_0, nmos::types::nc_object, std::move(data), true };
return nmos::control_protocol_resource{ nmos::is12_versions::v1_0, nmos::types::nc_worker, std::move(data), true };
};


Expand Down
16 changes: 14 additions & 2 deletions Development/nmos/api_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,13 @@ namespace nmos
{ U("subscriptions"), nmos::types::subscription },
{ U("inputs"), nmos::types::input },
{ U("outputs"), nmos::types::output },
{ U("nc_object"), nmos::types::nc_object }
{ U("nc_block"), nmos::types::nc_block },
{ U("nc_worker"), nmos::types::nc_worker },
{ 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_receiver_monitor"), nmos::types::nc_receiver_monitor },
{ U("nc_receiver_monitor_protected"), nmos::types::nc_receiver_monitor_protected }
};
return types_from_resourceType.at(resourceType);
}
Expand All @@ -177,7 +183,13 @@ namespace nmos
{ nmos::types::grain, {} }, // subscription websocket grains aren't exposed via the Query API
{ nmos::types::input, U("inputs") },
{ nmos::types::output, U("outputs") },
{ nmos::types::nc_object, U("nc_object") }
{ nmos::types::nc_block, U("nc_block") },
{ nmos::types::nc_worker, U("nc_worker") },
{ 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_receiver_monitor, U("nc_receiver_monitor") },
{ nmos::types::nc_receiver_monitor_protected, U("nc_receiver_monitor_protected") }
};
return resourceTypes_from_type.at(type);
}
Expand Down
2 changes: 1 addition & 1 deletion Development/nmos/control_protocol_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace nmos
{
return [&resources](const resource& connection_resource)
{
auto found = find_control_protocol_resource(resources, connection_resource.id);
auto found = find_control_protocol_resource(resources, nmos::types::nc_receiver_monitor, connection_resource.id);
if (resources.end() != found && nc_receiver_monitor_class_id == details::parse_nc_class_id(nmos::fields::nc::class_id(found->data)))
{
// update receiver-monitor's connectionStatus propertry
Expand Down
8 changes: 4 additions & 4 deletions Development/nmos/control_protocol_resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace nmos

auto data = details::make_nc_block(nc_block_class_id, oid, true, owner, role, value::string(user_label), description, touchpoints, runtime_property_constraints, true, members);

return{ is12_versions::v1_0, types::nc_object, std::move(data), true };
return{ is12_versions::v1_0, types::nc_block, std::move(data), true };
}
}

Expand Down Expand Up @@ -51,7 +51,7 @@ namespace nmos
auto data = details::make_nc_device_manager(oid, root_block_oid, value::string(U("Device manager")), U("The device manager offers information about the product this device is representing"), value::null(), value::null(),
manufacturer, product, serial_number, value::null(), device_name, device_role, operational_state, nc_reset_cause::unknown);

return{ is12_versions::v1_0, types::nc_object, std::move(data), true };
return{ is12_versions::v1_0, types::nc_device_manager, std::move(data), true };
}

// See https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncclassmanager
Expand All @@ -61,7 +61,7 @@ namespace nmos

auto data = details::make_nc_class_manager(oid, root_block_oid, value::string(U("Class manager")), U("The class manager offers access to control class and data type descriptors"), value::null(), value::null(), control_protocol_state);

return{ is12_versions::v1_0, types::nc_object, std::move(data), true };
return{ is12_versions::v1_0, types::nc_class_manager, std::move(data), true };
}

// See https://specs.amwa.tv/nmos-control-feature-sets/branches/main/monitoring/#ncreceivermonitor
Expand All @@ -76,6 +76,6 @@ namespace nmos
data[nmos::fields::nc::payload_status] = value::number(payload_status);
data[nmos::fields::nc::payload_status_message] = value::string(payload_status_message);

return{ is12_versions::v1_0, types::nc_object, std::move(data), true };
return{ is12_versions::v1_0, types::nc_receiver_monitor, std::move(data), true };
}
}
4 changes: 2 additions & 2 deletions Development/nmos/control_protocol_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,9 @@ namespace nmos
}

// find the control protocol resource which is assoicated with the given IS-04/IS-05/IS-08 resource id
resources::const_iterator find_control_protocol_resource(resources& resources, const id& resource_id)
resources::const_iterator find_control_protocol_resource(resources& resources, type type, const id& resource_id)
{
return find_resource_if(resources, nmos::types::nc_object, [resource_id](const nmos::resource& resource)
return find_resource_if(resources, type, [resource_id](const nmos::resource& resource)
{
auto& touchpoints = resource.data.at(nmos::fields::nc::touchpoints);
if (!touchpoints.is_null() && touchpoints.is_array())
Expand Down
2 changes: 1 addition & 1 deletion Development/nmos/control_protocol_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace nmos
bool modify_control_protocol_resource(resources& resources, const id& id, std::function<void(resource&)> modifier, const web::json::value& notification_event);

// find the control protocol resource which is assoicated with the given IS-04/IS-05/IS-08 resource id
resources::const_iterator find_control_protocol_resource(resources& resources, const id& id);
resources::const_iterator find_control_protocol_resource(resources& resources, type type, const id& id);
}

#endif
5 changes: 3 additions & 2 deletions Development/nmos/control_protocol_ws_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,13 @@ namespace nmos
.set_path(ws_ncp_path)
.to_uri();

const utility::string_t control_protocol_resource_path;

const bool non_persistent = false;
value data = value_of({
{ nmos::fields::id, nmos::make_id() },
{ nmos::fields::max_update_rate_ms, 0 },
{ nmos::fields::resource_path, U('/') + nmos::resourceType_from_type(nmos::types::nc_object) },
{ nmos::fields::resource_path, control_protocol_resource_path },
{ nmos::fields::params, value_of({ { U("query.rql"), U("in(id,())") } }) },
{ nmos::fields::persist, non_persistent },
{ nmos::fields::secure, secure },
Expand All @@ -147,7 +149,6 @@ namespace nmos

const auto resource_path = nmos::fields::resource_path(subscription->data);
const auto topic = resource_path + U('/');
// source_id and flow_id are set per-message depending on the source, unlike Query WebSocket API
data[nmos::fields::message] = details::make_grain({}, {}, topic);

resource grain{ is12_versions::v1_0, nmos::types::grain, std::move(data), false };
Expand Down
1 change: 1 addition & 0 deletions Development/nmos/query_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ namespace nmos
}

// insert 'value changed', 'sequence item added', 'sequence item changed' or 'sequence item removed' notification events into all grains whose subscriptions match the specified version, type and "pre" or "post" values
// this is used for the IS-12 propertry changed event
void insert_notification_events(nmos::resources& resources, const nmos::api_version& version, const nmos::api_version& downgrade_version, const nmos::type& type, const web::json::value& pre, const web::json::value& post, const web::json::value& event)
{
using web::json::value;
Expand Down
14 changes: 10 additions & 4 deletions Development/nmos/type.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,26 @@ namespace nmos
// to a subscription is managed as a sub-resource of the subscription
const type grain{ U("grain") };

// the Control Protocol API resource type, see nmos/control_protcol_resources.h
const type nc_object{ U("nc_object") };

// all types ordered so that sub-resource types appear after super-resource types
// according to the guidelines on referential integrity
// see https://specs.amwa.tv/is-04/releases/v1.2.1/docs/4.1._Behaviour_-_Registration.html#referential-integrity
const std::vector<type> all{ nmos::types::node, nmos::types::device, nmos::types::source, nmos::types::flow, nmos::types::sender, nmos::types::receiver, nmos::types::subscription, nmos::types::grain, nmos::types::nc_object };
const std::vector<type> all{ nmos::types::node, nmos::types::device, nmos::types::source, nmos::types::flow, nmos::types::sender, nmos::types::receiver, nmos::types::subscription, nmos::types::grain };

// the Channel Mapping API resource types, see nmos/channelmapping_resources.h
const type input{ U("input") };
const type output{ U("output") };

// the System API global configuration resource type, see nmos/system_resources.h
const type global{ U("global") };

// the Control Protocol API resource type, see nmos/control_protcol_resources.h
const type nc_block{ U("nc_block") };
const type nc_worker{ U("nc_worker") };
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_receiver_monitor{ U("nc_receiver_monitor") };
const type nc_receiver_monitor_protected{ U("nc_receiver_monitor_protected") };
}
}

Expand Down

0 comments on commit 264cfba

Please sign in to comment.