DDE Communication with Dymosim

This section describes communication between a DDE client and Dymosim.

DDE communication with Dymosim is possible only when a simulation has been executed in real time.

Related Topics
svefordbm-t-Execute.htm#t-ExecutewiththeCommand-RealTime

Establishing a DDE Connection with Dymosim

This section describes how to establish a DDE connection between a client and the Dymosim application using the WM_DDE_INITIATE message.

The WM_DDE_INITIATE message must be sent with the application name (dymosim) plus any topic.

MATLAB example: channel=ddeinit('dymosim', 'any topic here')

After the simulation finishes or is stopped, Dymosim will send a WM_DDE_TERMINATE message to all connected clients.

A client can terminate the connection by sending the same message.

MATLAB example: ddeterm(channel)

Simulator Commands

This section lists the commands which can be sent to Dymosim using WM_DDE_EXECUTE messages.

Command Action
run Starts simulation (if simulation is not started automatically), or resume simulation after a pause command.
stop Stops simulation. Has no effect if simulation not yet started.
pause Pauses simulation. The simulation is temporarily halted until a run command is given. Note that DDE requests are handled while pausing.
logon Enables logging to file.
logoff Disables logging to file.

MATLAB example: ddeexec(channel, 'run')

Setting Parameters

This section lists the parameters which can be set in Dymosim using WM_DDE_POKE messages.

The WM_DDE_POKE message includes the name of the parameter and its new value (the string representation of a number).

There are four special variables (see table below).

When a simulation is started, simulation parameters, auxiliary variables and states may also be set. However, these are not set immediately, but only at certain points in the simulation that allow for updates. Hence, when a client makes a request (for example for a variable), an update from another or the same client may be pending. Any such pending update value will be reported in the response.

Variable Values
realtime_ Set to 1 to enable realtime mode, or to 0 to disable realtime mode.
tscale_

The scale factor between simulated time and real time.

In realtime mode the simulator will maintain the relationship: real-time = tscale_ * simulated-time:

abstol_ Absolute tolerance for hot-linked variables (default 0), see later.
reltol_ Relative tolerance for hot-linked variables (default 0), see later.

Requesting Parameters

This section lists the parameters which can be requested from Dymosim using WM_DDE_REQUEST messages.

When a WM_DDE_REQUEST message with the name of a parameter is received by Dymosim it responds by returning the current value of the variable (the string representation of a number), or zero if no such variable exists.

In addition to the four special variables listed in Setting Parameters, there are another three variables that can be requested (see table below).

When a simulation is started, simulation parameters, auxiliary variables and states may also be requested.

The value returned is the current value at the last accepted output point.

Variable Values
delayed_ Number of seconds the simulation was delayed at the last accepted output point.
status_

State of the DDE server. The state is composed as the Boolean OR of the following parts:

1 simulation started (running)

10 simulation paused

100 current simulation time = 0

For example: 11 indicates that the simulation is started but paused at a simulation time greater than 0.

time_ Current simulation time in seconds.

MATLAB example: ddereq(channel, 'time_')

Hot-linking Variables

This section describes how variables can be hot-linked using WM_DDE_ADVISE messages.

When a variable is hot-linked, it will be sent to the client at output points when a significant change its value has occurred.

A significant change of a variable is determined from absolute and relative tolerances (which can be set by the DDE client) as follows:

where x0 = value last sent to client and x = current value

The variable is sent to the client when changed is true at an output point. The variable is also sent at the first output point following the hot-link operation.

Dymosim counts the number of links to a variable, and any corresponding "unlink" messages. Updates for the variable are sent while the link count is greater than zero.

MATLAB example: ddeadv(channel, 'time_', 't=[t x];', 'x')

DDE Limitations

This section describes the limitations of the Dynamic Behavior Modeling workbench with regard to DDE.


  • Dymosim cannot be created as a DLL when DDE is selected.
  • The use of Godess solvers is not supported with DDE. The execution setup will disable Godess solvers when DDE is selected, and if a Godess solver is already selected, you will be prompted with the option of selecting another solver or skipping DDE.
  • When a client requests data from the DDE server, it specifies the desired data format. Dymosim will only support the following clipboard formats:
    • Plain text (used typically by MATLAB).
    • XITable (used typically by Microsoft Office Excel.