<< 点击显示目录 >> 主页 exOS使用助手 > exOS Automation Help > Development > Programming > exOS Communication API reference (exos_api.h) > exos_datamodel_disconnect() |
断开数据模型与数据集消息路由器的连接
EXOS_ERROR_CODE exos_datamodel_disconnect(exos_datamodel_handle_t *datamodel);
与 数据集消息路由器 的 连接 是 通过代码生成的 exos_datamodel_connect_() 建立的 ,而连接则是通过 exos_datamodel_disconnect()终止的。这将在删除回调指令之前触发数据模型上的 EXOS_STATE_DISCONNECTED 事件。
现在,这意味着所有内部 ZMQ 套接字都已关闭,调用此函数后,应用程序和服务器之间不会再有数据传输。不过,在关闭之前,应用程序会向 数据集消息路由器发送一条断开连接消息 ,这样在关闭与远程系统的数据集连接之前,就不必等待连接超时了。
•datamodel:数据模型句柄,以指针形式给出
如果该函数是从远程站(即远程系统中的应用程序)调用的,且远程系统中没有其他应用程序连接到该数据模型实例,则本地应用程序会收到 EXOS_STATE_DISCONNECTED 事件,但其与本地 数据集消息路由器的连接 会保持,这意味着一旦连接恢复,本地应用程序就会收到 EXOS_STATE_CONNECTED 事件,而无需调用其他 API 函数。
当调用 exos_datamodel_disconnect()时,分配给数据模型的所有数据集都会自动断开连接(并接收相应的 EXOS_STATE_DISCONNECTED 事件)。这意味着在断开整个数据集之前,无需单独断开每个数据集的连接。
Disconnect a datamodel from the Dataset Message Router
EXOS_ERROR_CODE exos_datamodel_disconnect(exos_datamodel_handle_t *datamodel);
Whereas a connection to the Dataset Message Router is established with the code-generated exos_datamodel_connect_(), the connection is terminated with the exos_datamodel_disconnect(). This triggers the EXOS_STATE_DISCONNECTED event on the datamodel before removing the callback instruction.
Now this means all internal ZMQ sockets are closed and there is no data transfer between the application and the server after this function has been called. Before closing, however, the application sends a disconnection message to the Dataset Message Router that it does not have to wait for the connection to timeout before closing the dataset connection to the remote system.
•datamodel: datamodel handle, given as a pointer
In case this function is called from the remote station (i.e. an application on the remote system) and the remote system has no other applications connected to this datamodel instance, the local application receives an EXOS_STATE_DISCONNECTED event, but its connection to the local Dataset Message Router remains, meaning as soon as the connection is back up again, the local application receives an EXOS_STATE_CONNECTED event without having to call additional API functions.
All datasets assigned to the datamodel will be automatically disconnected (and receive a respective EXOS_STATE_DISCONNECTED event) when calling the exos_datamodel_disconnect(). This means there is no need to disconnect each dataset individually before disconnecting the entire dataset.