Main Content

Merge Message Connections Using Adapter Block

This example shows how to use a Merge block to route messages between software components in a software architecture. A Merge block is an Adapter block preconfigured to merge message and signal connections.

Open the model.

systemcomposer.openModel('MergeMessagesfromSoftwareComponents');

In this model, message-based communication is constructed between three software components: two send components, Component1 and Component2 create messages and send them to a receive component, Component3.

Outbound connections from Component1 and Component2 merge using an Adapter block configured as a Merge block to connect to Component3.

A FIFO queue is used as a message buffer between the components.

Component1 is linked to the Simulink® behavior model swMergeSend1 that generates messages with value 1 in every 0.1 sample time.

Constant block with value 1 creates a signal that is converted to a message via a Send block to output a message.

Component2 is linked to the Simulink behavior swMergeSend2 that generates messages with value 2 in every 0.3 sample time.

Constant block with value 2 creates a signal that is converted to a message via a Send block to output a message.

Component3 is linked to the Simulink behavior swMergeReceive that receives messages and converts them to signals. The In Bus Element port block is used to configure the queue outside the component as a FIFO queue of capacity 100.

In Bus Element port block with a message is converted to a signal via a Receive block to output a signal to the Scope block.

Simulate the model. Observe that the Scope block in swMergeReceive displays the values received from both components.

The Scope block displays the message values received from both Send components.

See Also

| |

Related Topics