Logo
UNICENS V2.1.0-3491
User Manual and API Reference
Manager

Introduction

The Manager is an optional component that automatically handles the following tasks:

  • Force the network to available state
  • Re-initialization of nodes if necessary
  • Automatically starts the NodeDiscovery and the RoutingManagement
  • Automatically handles the NodeDiscovery tasks according to a preset list of nodes
  • Automatically announces nodes as available/not available to the RoutingManagement

If the application uses a dynamic approach for the RoutingManagement it is recommended to use the function Ucs_Rm_SetRouteActive() together with Manager component.

Enable the Manager in the initialization structure.

init_data.mgr.enabled = true;
Note
Since the manager already handles a set of tasks that may also be done by hand it is necessary to enable the Manager and to not access the API which as handles by the Manager.

Do not access the following functions if the Manager is enabled:

The following callback functions will not work if the Manager is enabled:

 See also API Reference, section Manager.

Declaration of Nodes and Routes

The application must define a set of structures that are required as input for the Manager. Basically the application must provide a list of nodes and a list of routes.

Note
It is important that each node in the "list of nodes" has a valid pointer to a node signature. Within the node signature the node_address attribute must be set to the value as set in the "identification string" of the respective node (INIC). Each node must be configured with a unique node_address. Other values inside the identification string are not evaluated by the Manager.

The code below shows a setup of two nodes and one route for synchronous streaming. Since the route is initialized as "active" it is automatically created as soon as both nodes are available. The application does not need to activate this route at a certain time.

/*------------------------------------------------------------------------------------------------*/
/* Nodes */
/*------------------------------------------------------------------------------------------------*/
#define APP_NODES_NUM 2U
static Ucs_Signature_t signature201 = {0x201U /*node_address*/};
static Ucs_Signature_t signature205 = {0x205U /*node_address*/};
static Ucs_Rm_Node_t app_nodes[APP_NODES_NUM] = {{&signature201, NULL, 0U}, {&signature205, NULL, 0U}};
/*------------------------------------------------------------------------------------------------*/
/* Routes */
/*------------------------------------------------------------------------------------------------*/
/* Specification of XRM JOB OUT */
static Ucs_Xrm_UsbSocket_t Xrm_Usb_Socket_In = {UCS_XRM_RC_TYPE_USB_SOCKET, &Xrm_Usb_Port_1,
0x01U/*endpoint*/, 0x0007U /*frames*/ };
static Ucs_Xrm_SyncCon_t Xrm_Sync_Conn_Src = {UCS_XRM_RC_TYPE_SYNC_CON, &Xrm_Usb_Socket_In,
&Xrm_Most_Sckt_Out, UCS_SYNC_MUTE_MODE_NO_MUTING, 0U };
/* Specification of XRM JOB IN */
static Ucs_Xrm_UsbSocket_t Xrm_Usb_Socket_Out = {UCS_XRM_RC_TYPE_USB_SOCKET, &Xrm_Usb_Port_2,
0x81U/*endpoint*/, 0x0007U /*frames*/ };
static Ucs_Xrm_SyncCon_t Xrm_Sync_Conn_Sink = {UCS_XRM_RC_TYPE_SYNC_CON, &Xrm_Most_Sckt_In,
&Xrm_Usb_Socket_Out, UCS_SYNC_MUTE_MODE_NO_MUTING, 0U };
/* Specification of the XRM jobs lists */
static Ucs_Xrm_ResObject_t * xrm_job_out[] = { &Xrm_Most_Sckt_Out, &Xrm_Usb_Port_1, &Xrm_Usb_Socket_In,
&Xrm_Sync_Conn_Src, NULL };
static Ucs_Xrm_ResObject_t * xrm_job_in [] = { &Xrm_Most_Sckt_In, &Xrm_Usb_Port_2, &Xrm_Usb_Socket_Out,
&Xrm_Sync_Conn_Sink, NULL };
/* Source and Sink Endpoints */
static Ucs_Rm_EndPoint_t endpoint_src = { UCS_RM_EP_SOURCE, &xrm_job_out[0], &app_nodes[0] };
static Ucs_Rm_EndPoint_t endpoint_sink = { UCS_RM_EP_SINK, &xrm_job_in[0], &app_nodes[1] };
/* Routes Specification */
#define APP_ROUTES_NUM 1U
static Ucs_Rm_Route_t app_routes[APP_ROUTES_NUM] = { {&endpoint_src, &endpoint_sink, true /*is_active*/, 66U} };

Initialization

The code below shows a possible initialization sequence of the Application Message Service.

void App_Initialize(void)
{
Ucs_InitData_t init_data;
Ucs_SetDefaultConfig(&init_data);
init_data.mgr.enabled = true;
init_data.mgr.report_fptr = &App_OnMgrReport;
init_data.mgr.packet_bw = 52U;
init_data.mgr.nodes_list_ptr = &app_nodes[0];
init_data.mgr.nodes_list_size = APP_NODES_NUM;
init_data.mgr.routes_list_ptr = &app_routes[0];
init_data.mgr.routes_list_size = APP_ROUTES_NUM;
/* ... further initialization ... */
Ucs_Init(&init_data, &App_OnInitResult);
}
 See also Getting Started, section Initialization.

Status Reports

If the application logic requires information about the availability of nodes, it is possible to register an optional callback function mgr.report_fptr. See also the initialization code above. The following code shows an implementation of this function.

static void App_OnMgrReport(Ucs_MgrReport_t code, uint16_t node_address, Ucs_Rm_Node_t *node_ptr, void *user_ptr)
{
(void)printf("App_OnMgrReport(): code=%d, node_addr=0x%04X, node_ptr=%p\n", code, node_address, node_ptr);
}