This is a Custom Function for dSPACE ConfigurationDesk to synchronize multiple application processes. The base for this Custom Function is interprocess communication via System V message queues.
The function consists of two ports: Send Trigger and Event Port. For the implementation at least two Simulink Models are needed: one that controls the syncronisation and one or more Models that are being syncronised.
For each Model that should be syncronised, two instances of the Custom Function should be created. Each instance should have the same paramter Key. One of the instances should be placed in the Simulink Model, that controls the syncronisation, the second instance should be placed in the Simulink Model that shall be syncronised. The Simulink Model that controls the syncronisation, should only have Send Trigger Ports, the other Simulink Models should only have Event Ports.
- Create a directory "CustomFunctions" in your ConfigurationDesk Project directory. Paste the includes of this repo in the newly created directory. With a right click in the Tab Functions of ConfigurationDesk, select "Reload Custom Functions". The Custom Function should appear:
- With a right click on the Application Process Sync create a new instance of the function by selecting "New" (1). In the Model-Function View of ConfigurationDesk drag the unconnected function instance on the Simulink Model in the Model-Function Mapping Tab (2). With a right click on the instance function (Application Process Sync (1)) select Propagade to Simulink Model (3).
Note: For each Model that needs to be syncronised, two instances should be created. One instance should be dragged and dropped into the Simulink Model that controls the syncronisation process and the second instance in the Model that shall be syncronised.
- For the two corresponding instances created in the step 2, set parameter Key in the Properties Tab of the Custom Function instances. Corresponding instances should always have the same Key parameter.
4a. The Simulink Model that controls the syncronisation should only have a Send Trigger Port from each Custom Function instance. For that in the Signal Chain View with a right click on the generated Model Port Block delete the Event Port from Application. Then manually delete it from Simulink Block.
With the propagation of the function to Simulink Model, a Runnable Task was created for the Event Port. As Event Port is not used in this case, the task can be deleted in the Tasks View, with a right click by selecting "Delete from Application"
4b. The Simulink Models that are being syncronised should only have Event Port. Similarly to step 4a, delete Send Trigger Model Port Block and corresponding Simulink Block. Created Runnable Task should not be deleted in this case.
5a. In the Simulink Model controlling the syncronisation, Send Trigger should be connected to a constant block, which will be set from ControlDesk. Only when the value of the constant block is 1, the syncronisation is activated. If there are two models that should be syncronised, the same constant block shall be used:
5b. In the Simulink Models that should be syncronised, Event Port should be connected to a Function-Call Subsystem, which can be found in the Simulink library. The behavioural model should be placed into this subsystem and will be active only when the Event Port is triggered.