WSMLink`
WSMLink`

WSMSimulationConnection

WSMSimulationConnection[]

represents a connection to a SystemModeler simulation.

Details

  • A WSMSimulationConnection is typically created by functions such as WSMRealTimeSimulate and WSMRealTimeConnect.
  • In standard output format, status and control buttons for the simulation are displayed.
  • WSMSimulationConnection[][Properties] gives a list of possible properties.
  • Simulation properties are obtained from WSMSimulationConnection[]["property"].
  • Properties of the simulation:
  • "StopTime"simulation stop time
    "ModelName"name of simulation model
    "IP"IP address of the simulation
    "Port"port of the simulation
  • Properties related to simulation state:
  • "State"current simulation state
    "Time"current simulation time
    "NumberOfEvents"number of events generated
    "NumberOfEvaluations"number of evaluations performed
  • Possible simulation states from the property "State" are:
  • "Unknown"unknown state
    "NotStarted"initial state, simulation time is 0
    "Running"simulation time is increasing
    "Paused"simulation time is paused
    "Disconnected"the Wolfram Language is disconnected from the simulation
  • Properties related to variable names:
  • "VariableNames"list of all variable names
    "ParameterNames"list of parameter names
    "InputVariables"list of input variables
  • Properties related to simulation control:
  • "Start"start or resume simulation
    "Pause"pause simulation
    "Stop"stop simulation
    "Close"disconnect the Wolfram Language from the simulation
  • Properties related to simulation data:
  • {"v1","v2",}list of variable values vi
    "SimulationData"WSMSimulationData object
    "Diagram"dynamic diagram of model
    {"Diagram","c1","c2",}dynamic diagram of component "c1.c2" in model

Examples

open allclose all

Basic Examples  (4)

Load Wolfram SystemModeler Link:

Launch a simulation of the NewtonCradle model:

Show a real-time plot of the last 3 seconds of variables x1 through x5:

Start the simulation:

Stop the simulation:

Launch a simulation of the "HelloWorld" model:

Start the simulation:

Pause the simulation:

Show the simulation time:

Stop the simulation:

Launch with a simulation time of 20 seconds:

Check the stop time:

Dynamically show the value of the variable x in the simulation:

Start the simulation and watch the variable change:

Scope  (6)

Launch a simulation of the "NewtonCradle" model:

Show the stop time of the simulation:

Show the full model name:

Show the IP and port the simulation is running on:

Stop the simulation:

Launch a simulation of the "NewtonCradle" model:

Show the state of the simulation:

Start the simulation, let it run for 2 seconds, and pause it:

Show the number of evaluations and the number of events so far:

Stop the simulation:

Launch a simulation of a water tank:

Show the names of variables in the simulation:

The list of parameters:

The list of input variables:

Stop the simulation:

Launch a simulation of the "NewtonCradle" model:

Get the current values of two variables:

Stop the simulation:

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

Run the simulation for 5 seconds:

Retrieve a WSMSimulationData object:

Plot variables from the simulation data:

Stop the simulation:

Launch a simulation of a multiple-tank system:

Run the simulation for 5 seconds:

Get the dynamic diagram showing the level of the three tanks:

Show an updating view of the dynamic diagram:

Stop the simulation:

Properties & Relations  (1)

WSMRealTimeSimulate returns a WSMSimulationConnection object:

Connecting to an existing simulation gives the same type of object:

Stop the simulation: