Professional Documents
Culture Documents
Simulator Bridge Developers Guide
Simulator Bridge Developers Guide
aveva.com
© 2020 AVEVA Group plc and its subsidiaries. All rights reserved.
No part of this documentation shall be reproduced, stored in a retrieval system, or transmitted by any means,
electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of AVEVA.
No liability is assumed with respect to the use of the information contained herein.
Although precaution has been taken in the preparation of this documentation, AVEVA assumes no responsibility
for errors or omissions. The information in this documentation is subject to change without notice and does not
represent a commitment on the part of AVEVA. The software described in this documentation is furnished under
a license agreement. This software may be used or copied only in accordance with the terms of such license
agreement.
ArchestrA, Aquis, Avantis, Citect, DYNSIM, eDNA, EYESIM, InBatch, InduSoft, InStep, IntelaTrac, InTouch, OASyS,
PIPEPHASE, PRiSM, PRO/II, PROVISION, ROMeo, SIM4ME, SimCentral, SimSci, Skelta, SmartGlance, Spiral
Software, Termis, WindowMaker, WindowViewer, and Wonderware are trademarks of AVEVA and/or its
subsidiaries. An extensive listing of AVEVA trademarks can be found at: https://sw.aveva.com/legal. All other
brands may be trademarks of their respective owners.
Publication date: Tuesday, September 29, 2020
Contact Information
AVEVA Group plc
High Cross
Madingley Road
Cambridge
CB3 0HB. UK
https://sw.aveva.com/
For information on how to contact sales and customer training, see https://sw.aveva.com/contact.
For information on how to contact technical support, see https://sw.aveva.com/support.
Table of Contents
1 INTRODUCTION .......................................................................................................... 1
3.10 CLEANUPPASTMESSAGES......................................................................................... 12
TOC-II
3.12 SAMPLE PROGRAM – BRIDGE FRONT-END MANAGEMENT ........................................ 14
5.5 INTRODUCTION............................................................................................................ 37
TOC-IV
5.8.4 Return Value ........................................................................................................ 46
TOC-VI
7.4.7 Get Active Scenario Data ..................................................................................... 75
9.3.4 97
TOC-VIII
9.3.10 Add a new run TPR Exercise .............................................................................. 100
9.3.13 Gets the MAX number used for TPMs ................................................................. 102
9.4.25 Set the list of Dynamic points for an Exercise ..................................................... 113
9.4.26 Get the list of Dynamic Points for an Exercise .................................................... 115
9.4.29 Set the list of Config points for an Exercise ......................................................... 117
9.4.30 Get the list of Config Points for an Exercise ....................................................... 118
TOC-X
9.4.42 Get Instructor for an Exercise ............................................................................ 121
The Simulator Bridge provides a single simulator communication interface between a customer
simulator and the SimSci dynamic Simulation Executive, known as either the SIM4ME/Dynamic
Simulation Suite (SIM4ME/DSS) SimExec or simply the SimExec.
In the integrated simulation environment, the Simulator Bridge’s API and runtime environment
gives the third party, or ‘customer,’ simulator these capabilities:
• Exchange simulation data between the SimExec and other simulation engines, such
as FSIM Plus®, DYNSIM®, ABSIM, etc.
• Take complete control of the SimExec and drive it as a simulation sub-system. In this
situation, the SimExec becomes the “slave” to the driving simulator that acts as the “master.”
The Simulator Bridge is designed with Object Oriented Technologies (OOT) and implemented in
standard C++. This guide details the development of an application using OOT and C++.
The Simulator Bridge is delivered with an easy to use software package called the “Simulator
Bridge Development Kit” (SBDK). SBDK contains the necessary runtime environment, library
and include files that are used by the compiler, linker and application programs. The end user
should use Visual Studio 2003 (English) or a later of Visual Studio to customize the connection to
the third party simulator.
The SimExec is the core piece of this distributed system. It not only integrates the capabilities of
numerous SimSci simulation products into a single environment, but also provides capability for
splitting OTS tasks between multiple processors and/or multiple computers. The environment
appears seamless to the user.
Numerous SimSci simulation products can be integrated into the environment, such as:
The diagram below describes the architecture of a SimExec based simulation system.
DYNSIM TRISIM
Baltran Pl
FSIM
Third Party Pl
SBDK
Simulator SimExec
ABSIM
GUI
The two distributed bridge components are coupled together by the communication channel in the
Simulator Bridge runtime environment.
The bridge front-end publishes a set of methods to interface programmatically with the customer
simulator. Using these APIs, the customer can develop software that joins their simulator with the
bridge front-end, hence with the SimExec in the SimSci system.
(Slave) (Master)
SimExec
Simulator Bridge
Simulator Bridge
Servant
The Simulator Bridge front-end APIs can be divided into the following groups:
Bridge management APIs Creates the bridge front-end object, starts and stops the bridge
communication.
Simulation control APIs Provides operating mode change, simulation process state
control, snapshot save/restore, individual point data
manipulation, etc.
Bulk data transfer APIs Provides data router management, router configuration,
sending/retrieving data in bulk via a router, etc.
Note: The remainder of document will use the term “Simulator Bridge” or just “Bridge” to refer
the “Simulator Bridge front-end.” This is the only portion of the Simulator Bridge that is exposed
to the developer.
4 Architecture Overview
2.3 Bridge Software Structure
The bridge (front-end) interface consists of four major classes and six support classes. The class
structure for the bridge is as follows:
The SIM4MEProxy class is the main implementation class of the bridge. It acts as a front-end
delegate for the SimExec. It provides methods for bridge management and SimExec control and
launches these objects when asked:
• SIM4MEDataRouter
• SIM4MEMalfunctionProxy
• SIM4ScenarioProxy
• SIM4TPMProxy
The SIM4MEProxy class also launches an instance of the SIM4MEReportClient Messages class
which allows the user to receive client messages generated by the SIM4ME application.
The SIM4MEDataRouter class is the data transfer interface of the bridge that provides data
routing and delivery.
1. Malfunction: This class acts on a single malfunction that was acquired through the
SIM4MEMalfunctionProxy object.
The SIM4MEScenarioProxy is the interface between the SimSci scenario infrastructure and
the bridged application. It provides access to scenario features, such as record and playback,
found in the SimSci software. This class includes three support classes:
The class diagram shown in Figure 1 on the next page reveals the internal structure of the bridge
software.
The remainder of this document covers the usage of the SIM4MEProxy class, the
SIM4MEDataRouter class, the SIM4MEMalfunctionProxy class, the SIM4MEScenarioProxy
class, the SIM4METPMProxy class, and all their supporting classes. The declarations of the
classes are in the header files: SIM4MEProxy.h,SIM4MEDataRouter.h.,
SIM4MEMalfunctionProxy.h, SIM4MEScenarioProxy.h, and SIM4METPMProxy. These files
are discussed in the
Appendices.
SIM4MEDataRouter 1:1
9 methods
20 methods 12 methods
SIM4MEReportClientMessages
6 methods 1:1
1:1
SIM4MEScenarioListener
1:1 13 mrthods
SIM4MEMalfunctionProxy 1:1
16 methods
1:1
SIM4MEPlaybackListener
1 method
7 methods 18 methods
1:n
1:n 1:n Scenario
Malfunction
10 methods Exercise 7 methods
42 methods
6 Architecture Overview
3 Bridge Management APIs
3.1 Creation
The SIME4MEProxy provides a factory pattern method that can be used to generate an instance
of this class.
3.1.1 Prototype
static SIM4MEProxy* createSIM4MEProxy ();
3.1.2 Parameters
None
3.2 Startup
The start() method activates the simulator bridge. It initializes the proxy object and sets up
the communication between the proxy and the bridge servant on the target SimExec.
3.2.1 Prototype
bool start(int& argc, char* argv[])
3.2.2 Parameters
• FALSE on failure
The arguments of this method are in the format of program command line. They should provide
necessary information for the initialization of bridge communication, such as CORBA naming
service, SimExec name and hosts name.
Note: CORBA is the underlying platform of the Simulator Bridge. The Simulator Bridge front-
end and servant find each other via the CORBA naming service. They also exchange messages
and data through the CORBA RPC mechanism. However, the bridge software package
argc = 12
where
ORBInitRef The ORB initial reference argument specifies the CORBA naming
service
3.3.1 Prototype
bool remoteStart(int& argc, char* argv[])
3.3.2 Parameters
• FALSE on failure
The arguments of this method are in the format of program command line. They should provide
necessary information for the initialization of bridge communication and simulation startup, such
as CORBA naming service, SimExec name and hosts name and simulation information.
argc = 20
where
simfullpath Full path name for s4m file used to load the specified simulation
ORBInitRef ORB initial reference argument specifies the CORBA naming service
3.4 Shutdown
The shutdown() method closes the communication between the proxy and bridge servant on
the target SimExec, it also destroys the proxy itself and all the data routers that have been created.
3.4.1 Prototype
void shutdown()
3.5.1 Prototype
void remoteShutdown()
3.5.2 Parameters
None
3.6.1 Prototype
SimMode getSimMode()
3.6.2 Parameters
None
enum SimMode
FROZEN,
RUNNING,
IC_RESET,
BACKTRACK_RESET,
SHUTDOWN,
SINGLE_STEP,
ENGINE_ERR,
UNKNOWN
};
server will call the methods on this object respective to the each message type generated on the
server.
3.7.1 Prototype
void
enableClientMessages(SIM4MEReportClientMessages* obj)
3.7.2 Parameters
obj – This object is the listener inherited from the SIM4MEReportClientMessages
object defined in the SIM4MEProxy.h file.
3.8.1 Prototype
void disableClientMessages(long id);
3.9 getPastMessages
This method will return all the messages that have been generated since the simulation started.
The SIM4MEControlDemo.cpp example code in the SBDK demonstrates how to use the
cleanupPastMessages and getPastMessages methods.
3.9.1 Prototype
long getPastMessages(char*** messages);
3.9.2 Parameters
Messages – An array of strings of messages
3.10 cleanupPastMessages
This method is used to clean up the messages in memory passed by the getPastMessages method.
This method is required since in Microsoft Windows systems memory objects created in a dll
need to be released in the dll. The SIM4MEControlDemo.cpp example code in the SBDK
demonstrates how to use the cleanupPastMessages and getPastMessages methods.
3.10.1 Prototype
void cleanupPastMessages(long numMessages, char*** messages);
3.10.2 Parameters
numMessages – This value is the number of messages returned by the getPastMessages
method.
messages – This value are the message data items passed by the getPastMessages nethod
Return Value
None
3.11.1 Prototype
void startEventLog(bool start);
3.11.2 Parameters
start – A true value will start the event logging and a false value will stop the event
logging.
Each of these methods will also receive the text messages that were sent to the executive. This
class also has two other methods getID and setID to get and receive this objects ID.
// DLL import
#include <SimulatorBridge/Published/SimulatorBridge_exports.h>
#include <SimulatorBridge/Published/SIM4MEProxy.h>
//
//
//
// exit if fails
//
return EXIT_FAILURE;
//
//
//
// return
return ret;
• Click OK
• Click on C++ Source File and check the Add to project check box
• A blank window will be created. Now copy the source code listed in the Source Code
section above into Sample34.cpp window
5. Click OK
4. Click OK
9. Click OK
6. Click OK
Click on Build sample34.exe under Build menu (or press F7). The build process should generate
server.exe with no errors. If there are errors, go through the steps again and fix them before
proceeding.
3. Set the Executable for Debug Session to C:\ Program Files \ SIMSCI \ SimulatorBridge \ bin \
windows \ Sample34_dbg.exe
4. Click OK
8. Under Output File Name, enter C: \ Program Files \ SIMSCI \ SimulatorBridge \ bin \
windows \ Sample34_dbg.exe
9. Click OK
Start your DYNSIM or FSIM Plus session that this bridge demo program will attach to. You’ll
need the following information in order to enter the run arguments. To do this, enter your
username and password (e.g. simsci simsci), but click on Options before completing the login.
Record the following information from the Options pane:
Example:
1. Click on Settings under Project menu and ensure that Win32 Release is selected
4. Click OK
Press <Control>-F5 to start the program in a DOS window. Observe following messages on the
console window.
proxy created
proxy started
proxy shutdown
proxy created
proxy start failed
1. Make sure all files copied from the SBDK CD are writable
7. Click OK
10. Build
1. Click on Settings under Project menu and ensure that Win32 Release is selected.
4. Run
3.13 Logger
The Simulator Bridge logger can be used to provide information, warnings, errors and other
generic messages for the user. There are 2 command line arguments that are required for this
feature.
• NOLOG – no logging
4.1.1 Prototype
bool executeSIM4MECommand (
4.1.2 Parameters
The command and its arguments are in string format for flexibility. Currently supported
commands and their arguments are listed in the following table. These commands are
designed to allow complete control over the SimExec by an external customer simulator.
When the customer simulator wants to relinquish its control of the SimExec, it should send an
"EXIT_SLAVE_MODE" command with no argument.
The binding-unbinding process described above is carried out in following code sample.
//
//
//
// exit if fails
//
return EXIT_FAILURE;
//
//
The following UML state diagram shows how the simulator mode changes upon the
commands that are received.
After the SimExec is turned into a slave, its simulation process is under the control of the external
“master” simulator.
The SimExec process can be placed into any of the following modes:
RUNNING The running state means the simulator is processing data and executing the
simulation logic.
FROZEN The frozen state means the simulator isn’t performing any tasks.
SINGLE-STEP The single-step state means the simulator runs for one time step, then freezes
until the next RUN command is received.
The three commands are designed to control the state changes: “RUN,” “FREEZE” and
“SINGLE-STEP.” Each of these commands takes no argument. Their usage is explained in the
examples below:
The simulation process starts to run. If the process is in the SINGLE-STEP state, it would run for
one step and then freeze until next RUN command.
The simulation process would toggle between the “FROZEN” and “SINGLE-STEP” states.
The following UML state diagram shows the process state changes.
RUN
SINGLE-STEP
Simulator Synchronization
The runtime execution control is executed as a series of single step commands, each followed by
a semaphore wait. The wait returns after all SimExecutive and engine processing has completed.
REPEAT:
The following code sample is a skeleton implementation of the scheme described above.
proxy->simulationSynchronization();
proxy->executeSIM4MECommand("FREEZE", "");
proxy->executeSIM4MECommand("EXIT_SYNC_MODE", "");
proxy->executeSIM4MECommand("EXIT_SLAVE_MODE", "");
Continuous Operation
The runtime execution control is achieved by a continuous RUN commend to the SimExec,
interrupted by semaphore wait statements after each step. This means a control thread is kept
alive in the bridge and the simulation master has to communicate with it in a thread safe way (not
illustrated).
REPEAT:
The following code sample is a skeleton implementation of the scheme described above.
// loop stopper
while (!stopped)
proxy->simulationSynchronization();
proxy->executeSIM4MECommand("FREEZE", "");
proxy->executeSIM4MECommand("EXIT_SYNC_MODE", "");
proxy->executeSIM4MECommand("EXIT_SLAVE_MODE", "");
Asynchronous Operation
It is possible to communicate with the SimExec using either of the above techniques without
waiting for the simulationSynchronization() call to return.
4.3.3 Prototype
void simulationSynchronization()
4.3.4 Parameters
None
This method does not have any arguments and does not return any values. The caller of this
method does not need to know anything about the semaphore. It is recommended that the caller
should implement the synchronization mechanism within a separate thread in the adapter and
manage the frequency of synchronization between the adapter and the Simulation Executive.
In the SimExec, there are two kinds of snapshots: initial condition (IC) and backtrack.
The differences between the two depend on the following:
1. How the snapshot is initiated. (An IC is typically triggered by a user action, while a backtrack
is typically triggered by a scheduler that routinely causes a numbered backtrack to be
written.)
2. How the snapshot action affects the simulation process. (Taking an IC switches the
simulation to the FROZEN state, while taking a Backtrack doesn’t change the simulation
state.)
All snapshots are designated by their given names when taken. Usually the name of
backtrack snapshot is an integral number.
Note: The SimExec has a backtrack scheduler that normally saves a backtrack
periodically. The default rate is every minute. However, this backtrack scheduler is
stopped when the SimExec is in slave mode. In this situation, the master simulator must
provide its own backtrack scheduler who issues a SAVE_BKT command periodically.
The “SAVE_IC” and “SAVE_BKT” commands can be used to trigger a snapshot saving
action in the SimExec. A name for the snapshot must be given as the argument. If a
snapshot with the same name already exists, it will be overwritten.
The following examples show how to save the snapshot as an initial condition (IC) with
name “ic_name” and how to save a backtrack snapshot with number “1001.”
This example brings the simulation back to of state when backtrack snapshot 1001 is
taken.
The following examples show how to delete the snapshot as an initial condition (IC) with
name “ic_name” and how to delete a backtrack snapshot with number “1001.”
The master simulator may change the SimExec real time rate when it is in the RUNNING state or
FROZEN state, using the “SET_REAL_TIME_RATE” command as shown in this example.
The argument of this command should represent the rate (“350”). Once the speed is set, the
simulation goes on with the new speed until changed.
Simulation speed is saved within a snapshot (IC or Backtrack), and will be restored to the saved
value if the snapshot is reloaded.
The argument of this command (i.e. –“test”) should be the name of the simulation that was
opened by the bridge application.
A data point is uniquely identified by its “path” in the SimExec name space. Generally, the path
is made up of the point name and an optional naming context string in front of it. The “/” sign is
used to separated context and name strings.
FSIMEngine_name/compound_X:Block_X.point_X
The compound_X:Block_X.point_X string is the name of the point, following the Foxboro
naming convention. The “FSIMEngine_name” is the context of the point in the SimExec
naming space. It is the name of the FSIM engine that controls the point.
If the point name is sufficient to distinguish this point apart from other points in the system, the
context string can be omitted from the path. In the above example, the path of a Foxboro control
point can simply be:
compound_X:Block_X.point_X
A STATIC data point represents a value that cannot be changed while the simulation is running,
therefore it is not saved in Initial Conditions or Backtracks. The value of a static point can only
be changed by reconfiguring the simulation, which is not supported when using the bridge. An
example of a static point is the Tank Wall Thickness parameter of a Tank object.
A DYNAMIC data point represents a value that can be changed while the simulation is running.
The values of dynamic points are saved in Initial Conditions and Backtracks. An example of a
dynamic point is the Tank Fluid Temperature parameter of a Tank object.
The Simulator Bridge provides APIs for accessing and changing the value of a DYNAMIC data
point.
5.3.1 Prototypes
bool
setAnalogPointValue(
bool
getAnalogPointValue(
analog_value_t& value,
bool
setDiscretePointValue(
bool
getDiscretePointValue(
discrete_value_t& value,
5.3.2 Parameters
Argument Type Description
value analog_value_t Data value of the point. For analog value, the
type is analog_value_t; for discrete
Uom const char* Unit of measure, volts, feet, degrees, MW, etc.
If the string is empty, it is assumed that the
value is in the internal units of measure.
5.3.3 Return
TRUE on success, FALSE on failure.
Note: Since data can be represented in different types, programming aliases are used for
implementation flexibility. In the current C++ implementation, the data type aliases are
defined in the SIM4MEDataRouter.h header file.
This sample keeps increasing the value of analog point DEMO:B1.POINT and toggling the state
of discrete point DEMO:B3.FBCIN_1.
//-----------------------------------------------------------------------------
#include <iostream>
#include <SimulatorBridge/Published/SIM4MEProxy.h>
int main(
int argc,
char* argv[])
return EXIT_FAILURE;
discrete_value_t d_value = 0;
while (true && (a_value <= 40.0)) // Terminate after a few cycles
try
a_value += 20;
break;
try
std::cout << "d_value = " << (d_value ? "TRUE" : "FALSE") << endl;
d_value = !d_value;
break;
::nap (1000);
// return
return ret;
• By bundling the transfer of many values together into a single transfer call.
In the following sections, we will cover the fundamental concepts of simulation data transfer,
how to create and configure a router, and the techniques to exchange data between the SimExec
and the router APIs.
5.6.1 Information
The SIM4MEDataRouter.h header file defines several data structures to retain the
information about the entities involved in data transfer, such as:
5.6.2 Data
Data is a re-interpretable representation of information in a formalized (numerical)
manner suitable for communication, interpretation or processing.
In order to transfer data between simulators, the bridge data transfer APIs identify data
using its location and value. The location of data tells where to retrieve or send data,
while the value of the data tells how to use it. Data location is also called point (see
definition below), so data is also called “point data.”
Possible data types used in bridge data transfer are: analog, discrete and undefined. These
types are designated in the enumeration SimDataType.
enum SimDataType
ANALOG_DATA,
UNDEFINED_DATA
};
Value Type
Value type determines the operations that may be performed on a value. For example, analog
double-precision values and analog single-precision values have different rounding
behaviors.
The bridge data transfer API represents analog data values in single-precision float-point
type, and discrete data values in boolean type.
In most common CPUs, the FPU does all operations internally in an extended precision
(often 80 bits, i.e. long double) unless specifically instructed to use less precision (e.g.,
use an fmuls instruction vs. fmul). In many cases the single, double, and extended
precision operations take the same amount of time (e.g., 1-1-1 clocks per pipeline stage
w/3 stages).
CPUs often can load the float and convert to double for free (in same instruction), and
store double converted to float for free (in same instruction). Therefore using single-
precision or double-precision value in calculating operations costs the same.
5.6.5 Point
A point is an abstract location in the simulation environment, which stores data that
represents values.
For the bridge data transfer API, point is the source or destination of data. Data structure
SimPointInfo provides the information about a point.
struct SimPointInfo
char* pointPath;
SimDataType dataType;
char* uom;
};
where the pointPath data member tells the bridge where to locate the data, data type
and unit of measure tells the bridge about the nature the data, therefore, how to interpret
the data.
struct AnalogPointDataInfo
SimPointInfo* pointInfo;
analog_value_t dataValue;
};
Discrete data:
struct DiscretePointDataInfo
SimPointInfo* pointInfo;
discrete_value_t dataValue;
};
5.7.2 Prototype
SIM4MEDataRouter::
specifyDataTransferInfo (
int analogPointNo,
int discretePointNo,
SIM4ME_DiscretePointDataTransferInfo dlist[])
5.7.3 Parameters
Argument Type Description
Note: Make sure that the analogPointNo and discretePointNo are dynamically calculated
at runtime based on the size of alist and dlist respectively
struct SIM4ME_AnalogPointDataTransferInfo
SimPointInfo* SIM4ME_PointInfo;
float period;
analog_value_t tolerance;
char* convMethod;
analog_value_t min_scale;
analog_value_t max_scale;
analog_value_t low_limit;
analog_value_t hi_limit;
bool toSIM4ME;
};
struct SIM4ME_DiscretePointDataTransferInfo
SimPointInfo* SIM4MEPointInfo;
float period;
char* equationString;
char* setCriteria;
float setThreshold;
char* resetCriteria;
float resetThreshold;
char* true_state;
char* false_state;
bool toSIM4ME;
};
"NOT_DEFINED",
"EQUAL",
"NOT_EQUAL",
"LESS_THAN",
"LESS_THAN_OR_EQUAL",
"GREATER_THAN",
"GREATER_THAN_OR_EQUAL"
"NOT_DEFINED",
"EQUAL",
"NOT_EQUAL",
"LESS_THAN",
"LESS_THAN_OR_EQUAL",
"GREATER_THAN",
"GREATER_THAN_OR_EQUAL"
Note: Unlike analog values, digital values are treated differently based on the direction of
data transfer.
For Discrete Input (toSIM4ME = true), the value is set TRUE (1) when it meets a SET
test, and FALSE (0) when it meets a RESET test. The test results are determined by
setCriteria and setThreshold or resetCriteria and resetThreshold.
For Discrete Output (toSIM4ME = false), the value always comes from the control
system as a TRUE or FALSE.
5.8.2 Prototype
SIM4MEDataRouter *
getSIM4MEDataRouter()
5.8.3 Parameters
None
5.8.6 Prototype
bool start ()
5.8.7 Parameters
None
If the start () method returns TRUE, then the router’s “updating methods” can be invoked
to transfer data.
5.8.10 Prototype
void stop ()
5.8.11 Parameters
None
#include <SimulatorBridge/Published/SIM4MEProxy.h>
SIM4MEDataRouter * router = 0;
* Create a SIM4ME proxy instance and connect the proxy to the SIM4ME
*/
/**
*/
/**
*/
/**
*/
/**
*/
/**
*/
5.9.2 Prototypes
AnalogPointDataInfo*
updateAnalogData(int& analogPointNo)
DiscretePointDataInfo*
updateDiscreteData(int& discretePointNo)
5.9.3 Parameters
analogPointNo number of analog points in the return list
Note: When the methods are called for the first time, all data values are transferred.
To prevent developers from dealing with implementation specific exceptions, the class
SIM4ME_DataTransferException is used to encapsulate the exceptions from the
underlying implementation, such as a CORBA exception, as much as possible:
class SIM4ME_DataTransferException
public:
};
The data updating method generally tries its best to handle any exception raised during
data transfer. If an exception can’t be handled, it will try to convert it to a
SIM4ME_DataTransferException and throw it to the caller. The caller should
treat the exception as a fatal error and stop using the methods to retrieve data. The
program behavior is undefined if a caller keeps invoking the methods after an exception.
2. At the bottom of the while loop, the memory of the return arrays is freed.
/**
*/
int updatedAnalogPoint = 0;
int updatedDiscretePoint = 0;
DiscretePointDataInfo* discreteUpdate = 0;
while (true)
/**
*/
try
cerr << "exception during data transfer: " << ex1.reason_ << endl;
break;
/**
*/
*/
/**
*/
router->cleanupAnalogData(analogUpdate);
router->cleanupDiscreteData(discreteUpdate);
/**
*/
::nap (1000);
5.10.2 Prototype
void
updatePointData(
5.10.3 Parameters
analogPointNo number of analog points in the analog input array
None
The program behavior is undefined if caller keeps invoking the method after it raises an
exception.
Only analog type data is used this example, they are listed the table below.
TCN1.L
Sample
DEMO:B1.POINT
Data
transfer
Program
(Customer
DEMO:B2.OUT
VCN1.OP
5) Note the VCN1.OP value changes in the DOS window – the valve is opened
Note: in the code, the optional engine name (FSIMEngine) is used in the point path.
#include <iostream>
#include <SimulatorBridge/Published/SIM4MEProxy.h>
int main(
int argc,
char* argv[])
/**
* Create a SIM4ME proxy instance and connect the proxy to the SIM4ME
*/
return EXIT_FAILURE;
/**
*/
/**
*/
int analogPointNo = 4;
SIM4ME_AnalogPointDataTransferInfo* alist =
new SIM4ME_AnalogPointDataTransferInfo[analogPointNo];
fsim_ai->dataType = ANALOG_DATA;
asc_ai->dataType = ANALOG_DATA;
asc_ao->dataType = ANALOG_DATA;
/**
*/
int discretePointNo = 0;
SIM4ME_DiscretePointDataTransferInfo* dlist = 0;
/**
*/
discretePointNo,
alist,
dlist);
/**
*/
/**
*/
int updatedAnalogPoint = 0;
int updatedDiscretePoint = 0;
AnalogPointDataInfo* analogUpdate = 0;
DiscretePointDataInfo* discreteUpdate = 0;
while (true)
/**
*/
cerr << "exception during data transfer: " << ex1.reason_ << endl;
break;
/**
*/
AnalogPointDataInfo* aValues =
new AnalogPointDataInfo[updatedAnalogPoint];
/**
*/
aValues[j].pointInfo = analogUpdate[j].pointInfo;
aValues[j].dataValue = analogUpdate[j].dataValue;
aValues[j].pointInfo = asc_ai;
/**
*/
DiscretePointDataInfo* dValues =
new DiscretePointDataInfo[updatedDiscretePoint];
/**
*/
/**
*/
try
updatedAnalogPoint,
updatedDiscretePoint,
aValues,
dValues);
cerr << "exception during data transfer: " << ex1.reason_ << endl;
break;
/**
*/
router->cleanupAnalogData(analogUpdate);
router->cleanupDiscreteData(discreteUpdate);
delete[] aValues;
delete[] dValues;
/**
*/
::nap (1000);
/**
*/
// return
return ret;
Currently the Simulation Executive is capable of recording operator actions from an FSIM Plus
application, from a TRISIM Plus application that is using Wonderware In-Touch GUI as the
Operator Input station , or any other engine that supports the scenario recording interface
(logEngineAction and performEngine). The Simulation Executive will also record malfunction
activations and deactivations from the SIM4ME Instructor station GUI.
// Malfunction Records
// Trisim Records
// Time of Day,Simulation Time, TRISIM Plus, Engine Name, Point Name Value
// INTOUCH Records
//
/**
*/
return EXIT_FAILURE;
else
return EXIT_FAILURE;
proxy->registerCallbackFunc(function);
char *record = /* Get this record from somewhere where it was saved by bridge application
….
proxy-> replayLogEntry(record);
Prototype
Parameters
1) const char* simulationName – The name of the simulation that you wish to retrieve
scenarios for.
struct ScenarioData
char* simulation;
/* Id of the Scenario */
long scenarioID;
char* scenarioName;
char* authorName;
char* description;
bool isProtected;
char* creationDate;
char* authorID;
bool isActive;
};
Parameters
long scenarioID – The ID number of the scenario that you wish to manipulate.
Return Value
The return value for this method is a scenario object which will
be described further in later sections of this document.
Prototype
void createScenario(ScenarioData scenData, const char* scenarioScript)
Parameters
Return Value
None
Prototype
void deleteScenario(long scenarioID)
Parameters
long scenarioID – The ID number of the scenario that you wish to delete.
Return Value
None
Prototype
Void addScenarioListener(SIM4MEScenarioListener* listener)
Parameters
6. long getListenerID()
Return Value
None
Prototype
void removeScenarioListener(long listenerID)
Parameters
long listenerID – The ID number of the scenario listenerID you wish to remove
Return Value
None
Prototype
long getNextID()
Parameters
None
Return Value
Prototype
void setRecordMode(const char* mode)
Parameters
None
Prototype
char* getRecordMode()
Parameters
None
Return Value
Prototype
bool saveRecording(ScenarioData scenData)
Parameters
ScenarioData - Scenario data structure used to configure the scenario in the scenario
database
Return Value
Prototype
void addPlaybackListener(SIM4MEPlaybackListener* listener)
Return Value
None
Prototype
void removePlaybackListener(SIM4MEPlaybackListener* Listener)
Parameters
Return Value
None
Prototype
void runScenario( const char* userName )
Parameters
Const char* userName – The username to display while running the scenario
None
Prototype
void stopScenario()
Parameters
None
Return Value
None
Prototype
void pauseScenario()
Parameters
None
Return Value
None
Prototype
void resumeScenario()
Parameters
None
Return Value
None
Prototype
void saveScenario(ScenarioData scenData,const char* scenarioScript)
Parameters
Return Value
None
Prototype
char* loadScenario()
Parameters
None
Return Value
Prototype
ActiveScenarioData getActiveScenarioData()
Parameters
None
Returns the following data structure which defines the active scenario data:
struct ActiveScenarioData
/* Id of the scenario */
long scenarioID;
char* status;
};
Prototype
long getScenarioID()
Parameters
None
Return Value
Prototype
char* getScenarioName()
Parameters
None
Return Value
Prototype
bool isActive()
Parameters
None
Return Value
Prototype
bool isPaused()
Parameters
None
Return Value
Prototype
void setRunMode (SCE_RUN_MODE mode)
Parameters
SCE_RUN_MODE mode
None
Prototype
SCE_RUN_MODE getRunMode()
Parameters
None
Return Value
SCE_RUN_MODE
Prototype
MalfuctionableObjectsList getMalfunctionableObjects(const char*
enginename, long& count)
Parameters
const char* engineName The name of the engine from which to retrieve
malfunctions
Return Value
struct MalfunctionableObjects
char* modelObjectEngine;
char* modelObjectName;
};
Prototype
long getNewListClientID()
Parameters
None
Return Value
Unique ID number
This method builds and caches the malfunction list into a vector indexed from 0, to size-1,
where size is returned from this method. The cache is not rebuilt until this method is called
again (either with different, or the same criteria). For each unique listClientID, this method
implements an independent cached malfunction list.
bool includePreDefined,
bool includeActive,
long listClientID)
Parameters
const char* system Name of system, if this string is an empty string, then the list
will include all malfunctions in the entire simulation
bool includePreDefined If true, predefines will be included in the list, if false, they will
not
Long listClientID unique client id, used to identify the list built for the specific
client
Return Value
Prototype
MalfunctionData*
Parameters
long index Index number into the cached list
long listClientID ID of the list client, used to determine which cached list to
look in for the returned malfunction data
Return Value
struct MalfunctionData
char* system;
/* number of malfunction */
long number;
bool type;
char* description;
char* modelObjectName;
/* failure mode ID */
long failureModeID;
/* delay flag */
bool delayFlag;
/* delay time */
float delayTime;
double matureValue;
double lowLimit;
double highLimit;
long matureState;
bool engageFlag;
bool disengageFlag;
double disengageRate;
bool oscFlag;
long oscType;
long oscAmpType;
double oscAmp;
float oscPeriod;
bool chatFlag;
float chatOnTime;
float chatOffTime;
bool setTriggerFlag;
char* setTriggerEquationString;
bool resetTriggerFlag;
bool isActive;
};
Prototype
MalstatusList* getMalStatus(long listClientID, long& count)
Parameters
long listClientID ID of the list client, used to determine which cached list
to look in
Return Value
struct Malstatus
char* moName;
long status;
};
Prototype
Malfunction* getMalfunction(MalfunctionData malfData)
Parameters
Prototype
Malfunction* getMalfunctionFromPredefined(MalfunctionData
malfData)
Parameters
MalfunctionData A malfunction data structure
Return Value
Prototype
Void releaseMalfunction(long id)
Parameters
Long id The unique ID for the malfunction
Return Value
None
Prototype
Malfunction* getActiveMalfunction(char* malfName)
Parameters
The implementation of this method searches all attached simulation engines, until the
malfunctionable name is found, then returns the information from that object.
Prototype
FailureModeInformation* getFailureModes(const char*
malfunctionableName)
Parameters
char* malfunctionableName Name of the malfunctionable object
Return Value
Returns failure mode information. The following structure defines the failure mode
information.
struct FailureModeInformation
char* modelObjectName;
char* modelObjectClass;
char* modelObjectDesc;
long num_analog_failures;
AnalogFailureModeList anaFailureModes;
long num_discrete_failures;
DiscreteFailureModeList disFailureModes;
};
Prototype
MalfunctionData* getPreDefined(const char* system,long malfNumber)
Parameters
System Name of system (optional, if left blank, the entire simulation
will be searched for the malfunction). Note that the
malfunction number for a pre-defined is unique within the
simulation, not the system.
Return Value
Prototype
bool isTherePreDefined(const char* system, long malfNumber)
Parameters
System Name of system (optional, if left blank, the entire simulation
will be searched for the malfunction) Note that the
malfunction number for a pre-defined is unique within the
simulation, not the system.
Return Value
Prototype
void deletePreDefined(const char* system,long malfNumber)
Parameters
System Name of system (optional, if left blank, the entire simulation
will be searched for the malfunction) Note that the
malfunction number for a pre-defined is unique within the
simulation, not the system.
Return Value
None
Prototype
long getNextPreDefinedMalfNumber()
Parameters
None
Return Value
Prototype
Void addMalfunctionListener(SIM4MEMalfunctionListener* listener);
Parameters
SIM4MEMalfunctionListener * listener This object is created by the user to
capture malfunction events. This
object has following 7 methods
associated with it:
Return Value
None
Prototype
void removeMalfunctionListener(long listenerID)
Parameters
long listenerID The ID number of the malfunction listenerID you
wish to remove
Return Value
None
Prototype
void deactivateAll()
Parameters
None
Return Value
None
Prototype
void setInitData(MalfunctionData* malfData)
Parameters
MalfunctionData malfdata This structure is used to define the malfunction to
the SIM4ME system.
Return Value
None
Prototype
MalfunctionData* getInitData()
Parameters
MalfunctionData malfdata This structure is used to define the malfunction to
the SIM4ME system.
Return Value
None
Prototype
void savePredefined()
None
Return Value
None
Prototype
Void loadPreDefined(const char* system,long malfNumber)
Parameters
* const char* system system (optional)
Return Value
None
Prototype
void activate()
Parameters
None
Return Value
None
Prototype
void deactivate()
None
Return Value
None
Prototype
bool isActive()
Parameters
None
Return Value
Prototype
ActiveMalfunctionData* getActiveMalfunctionData()
Parameters
None
Return Value
struct ActiveMalfunctionData
/* status */
long status;
float delayTimeRemaining;
double currentAnalogState;
long currentDiscreteState;
char* currentDiscreteStateLabel;
8.4.9 Get ID
This method returns the malfunction ID.
Prototype
long getID()
Parameters
None
Return Value
Prototype
char* getName()
Parameters
None
Return Value
Exercise
setNumber
getNumber
setDescription
getDescription
setICNum
getICNum
setStudent
getStudent
setScoringEquation
getScoringEquation
SIM4METPMProxy setScore
getScore
getExercise setComment
getAllExercises getComment
getNumExercisesAll setTrends
getNumExercisesAllUsers getTrends
getNumExercisesConfig setStartTime
getNumExercisesUser getStartTime
getExerciseRow 1:n setStopTime
addConfigExercise setStopTime n
addRunExercise setDuration
deleteExercise getDuration
releaseExercise setTPRDate
getMaxTPRNum getTPRDate
tprExists setDynamicPointList
getNumActiveExercises getDynamicPointList
getActiveExerciseRow addConfigPoint
addActiveExercise deleteConfigPoint
removeActiveExercise setConfigPointList
exportToCSVFile
getConfigPointList
getResults
start
stop
save
saveAs
getTPRID
getIDNumber
getNumPoints
getConfigRow
getDynamicRow
setInstructor
getInstructor
Prototype
Exercise*
getExercise(
Parameters
Return Value
Prototype
ExerciseItem*
getAllExercises(
long& count)
Parameters
struct ExerciseItem
/* exercise number */
long number;
/* exercise description */
char* description;
/* student name */
char* student;
/* date */
char* tprDate;
/* start time */
double startTime;
/* stop time */
double stopTime;
/* duration */
double duration;
/* unique tpr id */
long tprId;
/* instructor Name */
char* instructor;
};
Prototype
long
getNumExercisesAll(
Parameters
Return Value
9.3.4
Prototype
long getNumExercisesAllUsers(
Parameters
Return Value
getNumExercisesConfig (
Parameters
Return Value
Prototype
long
getNumExercisesUser (
Parameters
Return Value
Parameters
Return Value
Prototype
Exercise*
addConfigExercise(
Parameters
Return Value
Prototype
Exercise*
addRunExercise(
Return Value
Prototype
bool
deleteExercise(
Parameters
Return Value
Prototype
void
releaseExercise(
Parameters
Return Value
None
Prototype
long
getMaxTPRNum(
Parameters
Prototype
bool
tprExists(
Parameters
Return Value
Prototype
long getNumActiveExercises()
Parameters
Return Value
Prototype
ActiveExerciseItem*
Parameters
Return Value
An ActiveExerciseItem object
struct ActiveExerciseItem
/* exercise number */
long number;
/* student name */
char* student;
/* unique id */
long id;
/* index */
long index;
};
Prototype
void addActiveExercise(const ActiveExerciseItem activeExercise)
Parameters
activeExecise – An ActiveExerciseItem structure.
None
Prototype
void removeActiveExercise(const long tprid)
Parameters
Return Value
None
Prototype
void
exportToCSVFile(
Parameters
Return Value
None
Prototype
void setNumber( const long number )
Parameters
Return Value
None
Prototype
Long getNumber();
Parameters
None
Return Value
Prototype
void setDescription(const char* description)
Parameters
description
None
Prototype
char* getDescription()
Parameters
None
Return Value
Prototype
void setICNum( const char* icnum)
Parameters
IC Number
Return Value
None
Prototype
char* getICNum()
Parameters
None
Return Value
Prototype
void setStudent(const char* student)
Parameters
Student name
Return Value
None
Prototype
char* getStudent()
Parameters
None
Return Value
Prototype
Void setScoringEquation( const long scoringEquation)
Parameters
Return Value
None
Parameters
None
Return Value
Prototype
void setScore(const double score)
Parameters
Return Value
None
Prototype
double getScore()
Parameters
None
Return Value
Prototype
void setComment(const char* comment)
Return Value
None
Prototype
char* getComment()
Parameters
None
Return Value
Prototype
void setTrends(const char* trends)
Parameters
Return Value
None
Prototype
char* getTrends()
Parameters
None
Prototype
void setStartTime(const double startTime)
Parameters
Return Value
None
Prototype
double getStartTime()
Parameters
None
Return Value
Prototype
void setStopTime(const double stopTime)
Parameters
Return Value
None
Prototype
double getStopTime()
Parameters
None
Return Value
Prototype
void setDuration(const double duration)
Parameters
Return Value
None
Prototype
double getDuration()
Parameters
None
Return Value
Parameters
Return Value
None
Prototype
char* setTPRDate()
Parameters
None
Return Value
Prototype
void setDynamicPointList(const long count,
DynamicPointItem** theList)
Parameters
struct DynamicPointItem
/* name of point */
char* name;
double minLimit;
/* maximum limit */
double maxLimit;
double highTime;
double lowTime;
long highExc;
long lowExc;
double highVal;
double lowVal;
/* point score */
double score;
/* index */
long index;
double weight;
double score1;
double score2;
double score3;
double score4;
double highArea;
double lowArea;
double minDev;
double maxDev;
double maxTime;
char* max_limit_point;
char* min_limit_point;
long boundsFail;
double failTime;
};
Return Value
None
Prototype
DynamicPointItem* getDynamicPointList(long& count) = 0;
Parameters
None
Prototype
bool addConfigPoint(const ConfigPointItem configPoint)
Parameters
ConfigPointItem
struct ConfigPointItem
/* name of point */
char* name;
/* minimum limit */
double minLimit;
/* maximum limit */
double maxLimit;
/* index */
long index;
double weight;
double minDev;
double maxDev;
char* min_limit_point;
/* fail if outside HH or LL */
bool bounds_fail;
};
Return Value
Prototype
DynamicPointItem* getDynamicPointList(long& count) = 0;
Parameters
None
Return Value
Prototype
void setConfigPointList(const long count,
ConfigPointItem** theList)
Parameters
Return Value
None
Prototype
ConfigPointItem* getConfigPointList(long& count)
Parameters
None
Return Value
Prototype
void getResults()
Parameters
None
Return Value
None
Prototype
bool start()
Parameters
None
Return Value
Prototype
bool stop()
Parameters
None
Return Value
Prototype
bool save()
Parameters
None
Return Value
Prototype
bool saveAs(const long newNumber)
Parameters
Return Value
Parameters
None
Return Value
Prototype
long getIDNumber()
Parameters
None
Return Value
The id number
Prototype
long getNumPoints()
Parameters
None
Return Value
• ConfigPointItem
Parameters
Return Value
Prototype
• DynamicPointItem
Parameters
Return Value
Prototype
void setInstructor(const char* instructor)
Parameters
Return Value
None
Parameters
None
Return Value
10.1 Overview
The Simulator Bridge Development Kit (SBDK) is the software package for developing the
bridge integration applications. It contains the necessary runtime environment, library, and
include files that are used by the compiler, linker and application programs.
This section describes the files and directories in the SBDK. The following chart shows the
organization of directories on the Windows platforms:
$SBDK_ROOT
+-- include
| |
| +-- SimulatorBridge
| |
$SBDK_ROOT is the root directory of the SBDK software installation, for example, C:\Program
Files\SIMSCI\SimulatorBridge. It contains copyright, license, and README files.
Lib Library file for linking with the The LIB should contain an entry for this
simulator bridge libraries folder or the linker should use it with
/LIBPATH option
TAO_CosNaming14.dll
TAO_IORTable14.dll
TAO_PortableServer14.dll
TAO_CodeSet14.dll
TAO_CosNaming14.dll
TAO_CosNaming_Serv14.dll
TAO_CosNaming_Skel14.dll
TAO_IORMessaging14.dll
TAO_Valuetype14.dll
Note: CORBA is used extensively through the SimSci dynamic simulation solution. It is
also the underlying platform on which the Simulator Bridge is built. The Simulator Bridge
front-end and servant find each other through CORBA naming service, and exchange
messages and data via CORBA RPC mechanism. However, the bridge software package
encapsulates the CORBA specific implementation, so the user does not need to know
CORBA to use the bridge.
For the Windows platform, SimBridgeEngine.dll has the concrete implementation of the
SIM4MEProxy and SIM4MEDataRouter classes. To use these classes in an application, the
SimBridge.lib, under directory $SBDK_ROOT\lib, must be linked to resolve the load
address of the classes.
The $SBDK_ROOT\lib directory path should be added to the linker search path: $LIB
(Windows). Another approach is to give the directory path to linker as an additional library path,
for instance, in Visual C++, add the lib file name to the project Setting dialog box, on the Link
tab, under Input category, in the Additional Library Path edit field.
The $SBDK_ROOT\include directory contains headers files that declare the Simulator Bridge
APIs (SIM4MEProxy.h and SIM4MEDataRouter.h interfaces), which should be included in the
application source code. Also, there is a SimulatorBridge_exports.h file that enables the customer
application import functions, data, and objects to and from a DLL.
The $SBDK_ROOT\include should be put in the compiler’s include search path. An example
of how the application program can include the files is:
#include <SimulatorBridge/Published/SIM4MEDataRouter.h>
#include <SimulatorBridge/Published/SIM4MEProxy.h>
#include <SimulatorBridge/Published/SIM4MEMalfunctionProxy.h>
#include <SimulatorBridge/Published/SIM4MEScenarioProxy.h>
#include <SimulatorBridge/Published/SIM4METPMProxy.h>
#include <SimulatorBridge/Published/SimulatorBridge_exports.h>
The $SBDK_ROOT\SimBridgeDemo directory contains sample code that demonstrates the use
of the Simulator Bridge development kit. In this directory and the it’s windows sub-directory the
user will find eight projects that demonstrate the use of different aspects of the developer’s kit.
The user can build the demonstration executables by running the Microsoft project files found in
the windows sub-directory. A sample SIM4ME simulation file (SBtest.s4m) and a batch
command file (SB_ControlDemo.bat) is also included in the SimBridgeDemo directory to drive
the demonstration code. The user will need to slightly modify the batch command file so that it
will run on his system.
The following nine executables demonstrate the following features in the Simulator Bridge:
1) DataTransferDemo – This demo shows how to send and receive data to a SIM4ME
application using a SIM4MEDataRouter object. This program connects to a running
simulation.
2) RetrieveDataDemo – This demo shows how to receive data from a running SIM4ME
application using a SIM4MEDataRouter object. This program connects to a running
simulation.
3) SendDataDemo – This demo shows how to send data to a running SIM4ME application
using a SIM4MEDataRouter object. This program connects to a running simulation.
4) SetDataValueDemo – This demo shows how to send and receive data to a simulation
using the get and set methods on the simulation proxy object. This program connects to a
running simulation.
6) SyncronizationDemo – This demo shows the user how to make synchronization calls on
the simulation proxy object. The program connects to a running simulation
7) MalfunctionDemo – The demo shows how to make calls to SIM4ME proxy object to
retrieve the SIM4MEMalfunctionProxy object. Once this object is retrieved then the user
can make calls to control malfunctions in the simulation. Like the
SIM4MEControlDemo, this demo opens and starts a simulation.
8) ScenarioDemo – The demo shows how to make calls to the SIM4ME proxy object to
retrieve the SIM4MEScenarioProxy object. Once this object is retrieved then the user
can make calls to control scenarios in the simulation. Like the SIM4MEControlDemo,
this demo opens and starts a simulation.
9) TPMDemo – The demo shows how to make calls to the SIM4ME proxy object to
retrieve the SIM4METPMProxy object. Once this object is retrieved then the user can
make calls to control TPM exercises in the simulation. Like the SIM4MEControlDemo,
this demo opens and starts a simulation.
The standard names for the conversion functions used by ESSCOR is FOXSCI<nn>_<tt> where
<nn> is the SCI value contained in the block’s definition and <tt> is the data type associated with
the I/O point. Allowable data types are FL, 16, and 32, for floating-point, 16-bit integer, and 32-
bit integer, respectively.
For example, if SCI = 3 (Linear 12800 to 64000 raw counts), the FOXSCI methods name can be:
Do not attempt to manually generate the list of SCI conversion types for FSIM Plus. Instead, use
the automatic cross reference generation tool found within the DYNSIM GUI that is a
prerequisite install for FSIM Plus. The FSIM Plus Getting Start Guide provides a demonstration
that includes creating a dummy process model, loading controls, and generating the cross
reference list. Export the Cross Reference list and merge it into the simulator bridge application.