Synchronize Co-Simulation with Simulink using Sockets and MEX S-Functions

3 次查看(过去 30 天)
Dear Community,
I would like to setup a Co-Simulation between different Simulink instances running either on the same or different PCs. The communication is established using TCP sockets and MEX S-Functions. A promising approach using ZeroMQ sockets has been published here:
An exemplary setup is show in the image below, where a regular (Simulink) model with 3 systems is exchanging messages (signals) between one another is shown on the left and a distributed Co-simulation of the same overall system on the right. The orange rectangles represent end-to-end connections, e.g. sockets.
My basic question is: How to implement a kind of blocking mode, so that e.g. System 1 stops the simulation until msg A and msg C reach System 2 and System 3 respectively, are processed there, and the reponse from System 3 (msg D) has been received back? I would assume that something very similar to the "blocking mode" from Instrument Control Toolbox' "TCP/IP Receive" block would do the job:
Is this going in the right direction? And if so, how can this "blocking", e.g. waiting until the next full message from e.g. a socket is received, be implemented in a MEX S-Function?
Any help / input would be appreciated!
PS: The assumption here is that the Instrument Control Toolbox is not available and / or a "self-made" implementation, e.g. with the above mentioned ZeroMQ library, is prefered!

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Naming Conventions 的更多信息

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by