(*exos_datamodel_event_cb)()

<< 点击显示目录 >>

主页  exOS使用助手 > exOS Automation Help > Development > Programming > exOS Communication API reference (exos_api.h) >

(*exos_datamodel_event_cb)()

数据模型事件的回调函数

调用语法

typedef void (*exos_datamodel_event_cb)(exos_datamodel_handle_t *datamodel, const EXOS_DATAMODEL_EVENT_TYPE event_type, void *info);

用户应定义一个具有以下原型的函数

 static void datamodelEvent(exos_datamodel_handle_t *datamodel, const EXOS_DATAMODEL_EVENT_TYPE event_type, void *info)
 {
 /..
 }

回调在 exos_datamodel_connect_ 函数中设置 , 该函数是根据特定数据模型结构生成的代码。

回调会触发以下 事件类型

EXOS_DATAMODEL_EVENT_CONNECTION_CHANGE:在数据模型/应用程序的状态发生变化时发生。在这种情况下,查询 数据模型->连接状态(datamodel->connection_state) 以获取连接的当前状态 是有意义 的 。  有关此主题的更多 信息, 请参阅主题 EXOS_CONNECTION_STATE。info 指针目前尚未使用,但已为未来事件预留。
 

EXOS_DATAMODEL_EVENT_SYNC_STATE_CHANGED 如果时间同步机制的状态从同步变为非同步,或反之亦然,则会触发该事件。附加信息通过 数据模型->sync_info 结构 收集 , 该结构具有以下属性
 

oin_sync 与 ExSyncInfo 功能块 中的 PrecisionReached 相同  ,基本上意味着网络时间同步有效。

omissed_ar_cycles与ExSyncInfo功能块 中的 MissedCycles 相同  ,它给出了 Linux DMR 进程错过 多少个 AR 运行周期的计数器  。

omissed_dmr_cycles 在每个周期中,Linux DMR 都会  发送一条同步消息,触发 exos_datamodel_process() 函数 的 执行  (该函数块用于接收同步消息)。如果应用程序错过了其中一条消息(未能  在 DMR 周期内  调用 exos_datamodel_process()),这个计数器就会增加。

回调在 exos_datamodel_process() 函数的上下文中调用  。


Callback function for datamodel events

Call syntax

typedef void (*exos_datamodel_event_cb)(exos_datamodel_handle_t *datamodel, const EXOS_DATAMODEL_EVENT_TYPE event_type, void *info);

The user should define a function with the following prototype

 static void datamodelEvent(exos_datamodel_handle_t *datamodel, const EXOS_DATAMODEL_EVENT_TYPE event_type, void *info)
 {
     /..
 }

The callback is setup in the exos_datamodel_connect_ function which is code generated to the specific datamodel structure.

The callback triggers the following event_type's

EXOS_DATAMODEL_EVENT_CONNECTION_CHANGE: comes at a state change of the datamodel / application. Here, it makes sense to query the datamodel->connection_state in order to get the current state of the connection. See the topic EXOS_CONNECTION_STATE for more on this topic. The info pointer is currently not used, but is reserved for future events.
 

EXOS_DATAMODEL_EVENT_SYNC_STATE_CHANGED should the time synchronization mechanism change its state from synchroized to non-synchronized or vice-versa, this event is triggered. The additional information is gathered through the datamodel->sync_info structure which has the following properties
 

oin_sync same as the PrecisionReached in the ExSyncInfo function block, basically meaning the nettime syncronization is valid.

omissed_ar_cycles same as the MissedCycles in the ExSyncInfo function block, which gives a counter on how many Automation Runtime cycles the Linux DMR process has missed.

omissed_dmr_cycles In each cycle, the Linux DMR sends out a synchronization message that triggers the execution of the exos_datamodel_process() function (which block for this synchronization message). Should the application miss one of these messages (fail to call exos_datamodel_process() within the cycle time of the DMR), this counter is increased.

The callback is called in the context of the exos_datamodel_process() function.