Simulating a Behavior with Interaction

If prepared for, you can execute and modify interactively the behavior of the components in a diagram.

By modifying the behavior, you can provide your own input into a simulation.

Interaction is limited to 2D only; if your model includes 3D, this is displayed, but you cannot interact with it.

When simulating interactively, you have access to the Signal Monitor window that is otherwise used in the Functional & Logical Design app.

The command is used for models with 2D diagrams containing interactive elements, which can be manipulated during simulation. Several types of interactive element exist (push buttons, sliders, text, etc.) exist. The following elements from the UserInteraction library are supported by this command:

Element Comment on Usage
UserInteraction.Inputs.NumericInputIO Input field to specify a numeric value. Click the field to specify a value, press Enter to validate the change.
UserInteraction.Inputs.Slider Slider to specify a numeric value.
Important: You must click the wanted position. Dragging is not supported.
UserInteraction.Inputs.Knob Knob to specify a numeric value.
Important: You must click the wanted position. Dragging is not supported.
UserInteraction.Inputs.TrigButton Button to specify a Boolean signal to "on". Click to activate.
UserInteraction.Inputs.ToggleButton Button to toggle a Boolean signal. Click to toggle.

The interactive elements are created using specific Modelica annotations. This means that other elements using the same annotations in the same way are also supported.

In this scenario you open, simulate, and modify interactively the model example UserInteraction.Examples.TestInteraction to see the three first elements in the table in work.

Note: To see the Boolean elements in work, you can open UserInteraction.Examples.TestBooleanInteraction instead.


Before you begin: To open the model and specify a suitable stop time of the simulation, do the following:
  • Open the model example UserInteraction.Examples.TestInteraction the following way:
    • Open the library UserInteraction by using search. See Open with Search.
    • Expand the library in the Package Browser and double-click UserInteraction.Examples.TestInteraction to open it.
  • Display the Simulation Setup dialog box. See Setting up a Simulation. In the General tab, specify the Stop time to 60s to have enough time to work with the example while it simulates.
  1. To simulate with interaction, you must, in the simulation setup, the General tab, activate the option Interactive simulation.

    For more information about reaching the simulation setup, see Setting up a Simulation.

  2. From the Behavior Authoring section of the action bar, click Simulate .

    Tip: You can also access this command from the Simulation section of the action bar.

    • A window containing a status bar appears. The status bar shows the progress of the simulation calculations, including the simulation time. This window closes when the simulation calculations are completed.
    • The Messages Reporting window appears in the diagram area, as a window or as an icon.
    • The Signal Monitor window appears. See Step 4.
    • The Experience Player toolbar is displayed.

      • Jump to begin : Stops the simulation animation and resets the timer to zero.
      • Pause : Pauses the simulation.
      • Play Step Forward : Plays the simulation animation one step at a time.
      • Play Forward : Plays the simulation animation from the current position.
      • Play Interval Forward : Plays the simulation animation one interval at a time (define the interval in the field using the arrows or by entering a number).
    • The Simulation Options dialog box appears, as a dialog box or minimized as an icon to the right in the tab.
    Important: To display the two last items in the list above, animation must be started. It may be started automatically after simulation, depending on the value of the preference Start animation after simulation. If the items are not displayed, you can start animation by replaying the simulation. To do that, from the Simulation section of the action bar, click Replay Animation .

    (To specify the above preference Start animation after simulation, select Me > Preferences > App Preferences > 3D Modeling > Systems Modeling and Execution > Dymola Behavior Modeling , the Results tab. For more information, see Native Apps Preferences Guide: Results.)

  3. In the Simulation Options dialog box, specify your preferences for the animation. See Managing Simulation Options Using the Simulation Options Dialog Box.

    Important: For this scenario, make sure that the Real time option is activated.

  4. From the Experience Player, click Play Forward .
  5. Interact using the elements described in the three first rows in the table above.

    Note: The input value field in this demo is specified to only handle values in the range 0–10.

    Tip: The Signal Monitor window gives you a number of options in addition to displaying the values of the signal dynamically. Some examples:
    • Plot variables
    • Work with watchlists
    • Apply breakpoints.

    Note: Displaying Modelica classes in dockable panes and the related feature of displaying values in those panels are not supported.

    For more information about the Signal Monitor window, see:

    • For the features of it: Functional & Logical Design User´s Guide: Reference Information: Virtual Execution Windows: Signal Monitor Window.
    • For the handling of it: Functional & Logical Design User´s Guide: Performing a Virtual Execution: Working with the Signal Monitor.

  6. To end the simulation, do any of the following:
    • In the action bar, click Simulate .
    • Close the Experience Player toolbar.
      Note: The Experience Player toolbar must be undocked by dragging to be able to close it.
    • Close the Signal Monitor window.
    The following is the result:
    • The simulation is ended.
    • The Experience Player toolbar is closed.
    • The Signal Monitor window is closed.