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 Automatic communications per second - With Method ->{"opt1"val1,…}, the following opti can be used:
-
"IP" Automatic interfaces to listen on "Port" Automatic port to listen on "WriteSimulationData" False write results to file - Possible options for "IP" are:
-
Automatic listen on local host All listen on all interfaces "ip" listen on ip - Possible options for "Port" are:
-
Automatic automatically choose a port port listen on port
Examples
open allclose allBasic Examples (3)
Scope (3)
Launch a simulation that listens on all interfaces:
Launch a simulation that listens on 127.0.0.1:50000:
Launch a simulation, writing simulation data for specific variables to a result file:
After starting the simulation, retrieve a simulation data object:
Options (2)
RefreshRate (1)
Set the communication interval with RefreshRate, communicating twice a second:
Applications (4)
Start a simulation of a tank with liquid flowing in and out:
Set simulation inputs using a basic real-time proportional controller:
Plot the tank level in real time:
Use a gauge to visualize simulation variables:
Use a dynamic diagram to illustrate the behavior of a 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:
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: