Merge Message Lines Using a Message Merge Block
This example shows how to use a Message Merge block to route messages. In this example, message-based communication is constructed between two components: a Send component creates messages and sends them to a Receive component. A Queue block is used as a message buffer between the components and is configured as a FIFO queue with capacity
100. For information about how to create message communication between components, see Establish Message Send and Receive Interfaces Between Software Components.
In this example, the Send component has two algorithms that generate data that is converted to messages using two Send blocks. The Message Merge block combines two message lines into a single message line.
You can prepare this model to generate C++ code for each component. The generated code contains necessary software interfaces that allow you to connect with an operating system or message middleware. For more information, see Generate C++ Messages to Communicate Data Between Simulink and an Operating System or Middleware (Embedded Coder).
Simulate the Model and Review Results
Simulate the model. Observe the Scope block that displays the output. The value changes between
8 based on the two Constant blocks in the Send components.
- Use Virtual Buses with Message Elements for Component Communication
- Generate C++ Messages to Communicate Data Between Simulink and an Operating System or Middleware (Embedded Coder)
- Establish Message Send and Receive Interfaces Between Software Components
- Model an Ethernet Communication Network with CSMA/CD Protocol
- Simulink Messages Overview