Main Content

Model DDS Input Events

DDS Blockset supports event-driven communication where a subscriber application thread waits for an event trigger before executing condition-based algorithms.

In Simulink, you configure DDS events at the input ports of your model and bind the event to a model partition that contains the response algorithm. You can trigger one or more events based on the flow of data into a root-level input port of a model subsystem. Using the Schedule Editor, you can specify a partition to execute in response to each event.

DDS Blockset supports input events for applications using RTI Connext®. In the generated code, the input event is implemented by using WaitSets and Conditions. The WaitSet wait() operation blocks execution of the application thread until an input event (or timeout) causes the user-defined condition to be true. For more information about WaitSets and Conditions, see RTI Connext documentation.

This table lists supported event types and maps DDS callback method names to the corresponding Simulink event name.

Event TypeDDS Method NameSimulink Event Trigger NameDescription
onDataAvailable

on_data_available

Input writeValue for input port updates.
onSampleLost

on_sample_lost

Input write lostInput port value update overwrites unprocessed data.
onDataDeadlineMissed

on_requested_deadline_missed

Input write timeoutInput port value does not update within a specified amount of time.

Model DDS Input Event

This section provides an example of configuring an existing DDS model as the response algorithm for a data available event.

  1. Create or open a model configured for DDS. The model should contain Take DDS Sample blocks, application logic, and Inport blocks configured as DDS data types. For more information, see Model DDS Applications.

    Model configured for DDS.

  2. Enclose the model in a subsystem.

    To enclose the model in a subsystem, select all blocks in the DDS model, right-click one of the highlighted elements, and select Create Subsystem from Selection. The DDS model is enclosed in a subsystem, and corresponding inport and outport blocks are added at the top level.

    Top-level model with DDS subsystem.

    For this example, name the subsystem On Data Available Handler.

  3. Configure the model to run tasks concurrently.

    On the Modeling tab, click Model Settings to open the configuration parameters:

    1. In the Configuration Parameters dialog box, on the Solver pane, click the arrow next to Solver details.

    2. Under Tasking and sample time options, select Allow tasks to execute concurrently on target.

    3. Click OK.

  4. Double-click the Inport block to open the Block Parameters dialog box and configure events.

    In the Block Parameters dialog box:

    1. Select the Execution tab.

    2. On the Execution tab, under Events, click the plus sign and select one of the event types:

      For this example, select Input Write.

      Block Parameters dialogue box to configure events on the input ports.

      Under Events, the Events spreadsheet contains event settings for that input port and lists the added events. You can add up to one of each event type. For an Input Write Timeout event, you enter the timeout duration in the Timeout column. The timeout duration is entered in seconds.

    3. Click OK. After adding the event, an event badge appears above the inport block.

  5. Use the Schedule Editor to configure the DDS subsystem as an aperiodic partition and then bind the event configured on the input port to the partition that executes on event occurrence.

    To configure the DDS subsystem:

    1. Open the Schedule Editor and click Manage Partitions to open the Manage Partitions pane.

    2. In the Manage Partitions pane, under Block Name, select On Data Available Handler, and then click the Schedule as aperiodic partition button.

      Manage Partitions pane of the Schedule Editor. The On Data Available Handler subsystem is selected. The Schedule as aperiodic partition button is highlighted.

    3. Click Update Diagram. The On_Data_Available_Handler partition displays in the Schedule Editor canvas.

      At this step, if you configured only one event and one partition, you see the Inport.InputWrite event bound to On_Data_Available_Handler. If the binding does not occur automatically in your model, continue with the next steps.

    4. Expand the Events tab. The input write event for the input port (Inport.InputWrite) is listed under Name.

    5. Manually bind the event to the partition by dragging the Inport.InputWrite event from the Events tab to the On_Data_Available_Handler partition shown in the Schedule Editor canvas.

      The Schedule Editor. The canvas shows the input event Inport.InputWrite bound to the partition On_Data_Available_Handler.

    6. Schedule additional events or behaviors as needed. See Schedule Editor for more information.

    7. Close the Schedule Editor and press Ctrl+D to update the model.

      The block diagram updates to reflect the binding of the Inport.InputWrite event to the aperiodic partition scheduled as atomic subsystem On Data Available Handler.

    DDS model with configured event.

For more information about creating and configuring partitions, see Create Partitions.

Modeling Pattern Considerations and Limitations

  • Modeling – Modeling DDS input events is only supported for DDS Blockset models using RTI Connext 6.0.1+.

  • Port Configuration – DDS Blockset requires that all ports must map to DDS and all input ports in models that configure input events must use Inport blocks.

See Also

| | | |

Related Topics