WSMLink`
WSMLink`

WSMRealTimeSimulate

WSMRealTimeSimulate["mmodel"]

launches a simulation of mmodel synchronized with real time.

WSMRealTimeSimulate["mmodel",tmax]

simulates from 0 to tmax.

WSMRealTimeSimulate["mmodel",vars,]

stores only simulation data for the variables vars.

Details and Options

  • WSMRealTimeSimulate returns a WSMSimulationConnection object.
  • By default, the simulation will continue until stopped.
  • WSMRealTimeSimulate takes the same arguments and options as WSMSimulate, with the following addition:
  • RefreshRate Automaticcommunications per second
  • With Method ->{"opt1"val1,}, the following opti can be used:
  • "IP"Automaticinterfaces to listen on
    "Port"Automaticport to listen on
    "WriteSimulationData"Falsewrite results to file
  • Possible options for "IP" are:
  • Automaticlisten on local host
    Alllisten on all interfaces
    "ip"listen on ip
  • Possible options for "Port" are:
  • Automaticautomatically choose a port
    portlisten on port

Examples

open allclose all

Basic Examples  (3)

Load Wolfram System Modeler Link:

Launch a simulation in real time:

Stop the simulation:

Launch a simulation for 10 seconds:

Stop the simulation:

Scope  (3)

Launch a simulation that listens on all interfaces:

Stop the simulation:

Launch a simulation that listens on 127.0.0.1:50000:

Stop the simulation:

Launch a simulation, writing simulation data for specific variables to a result file:

After starting the simulation, retrieve a simulation data object:

Plot the variables from the simulation data:

Stop the simulation:

Options  (2)

RefreshRate  (1)

Set the communication interval with RefreshRate, communicating twice a second:

Method  (1)

Launch a simulation, writing simulation data to a result file:

After starting the simulation, retrieve a simulation data object:

Plot variables from the simulation data, which updates as the simulation is running:

Stop the simulation:

Applications  (4)

Start a simulation of a tank with liquid flowing in and out:

Define a target tank level:

Set simulation inputs using a basic real-time proportional controller:

Plot the tank level in real time:

Use a gauge to visualize simulation variables:

Start the simulation:

Stop the simulation:

Use a dynamic diagram to illustrate the behavior of a simulation:

Start the simulation:

Keep track of the highest value three variables have taken:

Define a function called on every new data point, updating the maximum values:

Create a plot with a line at the highest value for each variable:

Start the simulation:

Properties & Relations  (1)

The result of WSMRealTimeSimulate is a WSMSimulationConnection:

The connection can be used for control, as well as retrieving data and information:

Start and pause the simulation:

Check the simulation state:

Retrieve the current values of variables x1 through x5:

Stop the simulation:

Possible Issues  (1)

Simulation data is not saved by default:

Turn on writing of simulation data: