OMSimulatorLib

This library is the core of OMSimulator and provides a C interface that can easily be utilized to handle co-simulation scenarios.

C-API

setLoggingInterval

Set the logging interval of the simulation.

oms_status_enu_t oms_setLoggingInterval(const char* cref, double loggingInterval);

newModel

Creates a new and yet empty composite model.

oms_status_enu_t oms_newModel(const char* cref);

setLoggingLevel

Enables/Disables debug logging (logDebug and logTrace).

0 default, 1 default+debug, 2 default+debug+trace

void oms_setLoggingLevel(int logLevel);

getVersion

Returns the library’s version string.

const char* oms_getVersion();

export

Exports a composite model to a SPP file.

oms_status_enu_t oms_export(const char* cref, const char* filename);

getBoolean

Get boolean value of given signal.

oms_status_enu_t oms_getBoolean(const char* cref, bool* value);

getTLMVariableTypes

Gets the type of an TLM variable.

oms_status_enu_t oms_getTLMVariableTypes(oms_tlm_domain_t domain, const int dimensions, const oms_tlm_interpolation_t interpolation, char ***types, char ***descriptions);

addBus

Adds a bus to a given component.

oms_status_enu_t oms_addBus(const char* cref);

deleteConnectorFromBus

Deletes a connector from a given bus.

oms_status_enu_t oms_deleteConnectorFromBus(const char* busCref, const char* connectorCref);

setConnectorGeometry

Set geometry information to a given connector.

oms_status_enu_t oms_setConnectorGeometry(const char* cref, const ssd_connector_geometry_t* geometry);

stepUntil

Simulates a composite model until a given time value.

oms_status_enu_t oms_stepUntil(const char* cref, double stopTime);

simulate_realtime

Experimental feature for (soft) real-time simulation.

oms_status_enu_t experimental_simulate_realtime(const char* ident);

setStartTime

Set the start time of the simulation.

oms_status_enu_t oms_setStartTime(const char* cref, double startTime);

instantiate

Instantiates a given composite model.

oms_status_enu_t oms_instantiate(const char* cref);

getSubModelPath

Returns the path of a given component.

oms_status_enu_t oms_getSubModelPath(const char* cref, char** path);

RunFile

Simulates a single FMU or SSP model.

oms_status_enu_t oms_RunFile(const char* filename);

setFixedStepSize

Sets the fixed step size. Can be used for the communication step size of co-simulation systems and also for the integrator step size in model exchange systems.

oms_status_enu_t oms_setFixedStepSize(const char* cref, double stepSize);

deleteConnection

Deletes the connection between connectors crefA and crefB.

oms_status_enu_t oms_deleteConnection(const char* crefA, const char* crefB);

The two arguments crefA and crefB get swapped automatically if necessary.

getTLMBus

Gets the TLM bus objects of the given TLM bus cref.

oms_status_enu_t oms_getTLMBus(const char* cref, oms_tlmbusconnector_t** tlmBusConnector);

setResultFile

Set the result file of the simulation.

oms_status_enu_t oms_setResultFile(const char* cref, const char* filename, int bufferSize);

setSolver

Sets the solver method for the given system.

oms_status_enu_t oms_setSolver(const char* cref, oms_solver_enu_t solver);

exportDependencyGraphs

Export the dependency graphs of a given model to dot files.

oms_status_enu_t oms_exportDependencyGraphs(const char* cref, const char* initialization, const char* simulation);

addExternalModel

Adds an external model to a TLM system.

oms_status_enu_t oms_addExternalModel(const char* cref, const char* path, const char* startscript);

addTLMConnection

Connects two TLM connectors.

oms_status_enu_t oms_addTLMConnection(const char* crefA, const char* crefB, double delay, double alpha, double linearimpedance, double angularimpedance);

importFile

Imports a composite model from a SSP file.

oms_status_enu_t oms_importFile(const char* filename, char** cref);

setReal

Set real value of given signal.

oms_status_enu_t oms_setReal(const char* cref, double value);

deleteConnectorFromTLMBus

Deletes a connector from a given TLM bus.

oms_status_enu_t oms_deleteConnectorFromTLMBus(const char* busCref, const char* connectorCref);

setBusGeometry

oms_status_enu_t oms_setBusGeometry(const char* bus, const ssd_connector_geometry_t* geometry);

setVariableStepSize

Sets the step size parameters for methods with stepsize control.

oms_status_enu_t oms_getVariableStepSize(const char* cref, double* initialStepSize, double* minimumStepSize, double* maximumStepSize);

setStopTime

Set the stop time of the simulation.

oms_status_enu_t oms_setStopTime(const char* cref, double stopTime);

setBoolean

Set boolean value of given signal.

oms_status_enu_t oms_setBoolean(const char* cref, bool value);

list

Lists the SSD representation of a given model, system, or component.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn’t need to call free.

oms_status_enu_t oms_list(const char* cref, char** contents);

getInteger

Get integer value of given signal.

oms_status_enu_t oms_getInteger(const char* cref, int* value);

getStopTime

Get the stop time from the model.

oms_status_enu_t oms_getStopTime(const char* cref, double* stopTime);

getReal

Get real value.

oms_status_enu_t oms_getReal(const char* cref, double* value);

addConnectorToTLMBus

Adds a connector to a TLM bus.

oms_status_enu_t oms_addConnectorToTLMBus(const char* busCref, const char* connectorCref, const char *type);

copySystem

Copies a system.

oms_status_enu_t oms_copySystem(const char* source, const char* target);

addSystem

Adds a (sub-)system to a model or system.

oms_status_enu_t oms_addSystem(const char* cref, oms_system_enu_t type);

setMaxLogFileSize

Sets maximum log file size in MB. If the file exceeds this limit, the logging will continue on stdout.

void oms_setMaxLogFileSize(const unsigned long size);

terminate

Terminates a given composite model.

oms_status_enu_t oms_terminate(const char* cref);

setTempDirectory

Set new temp directory.

oms_status_enu_t oms_setTempDirectory(const char* newTempDir);

extractFMIKind

Extracts the FMI kind of a given FMU from the file system.

oms_status_enu_t oms_extractFMIKind(const char* filename, oms_fmi_kind_enu_t* kind);

setTLMConnectionParameters

Simulates a composite model in its own thread.

oms_status_enu_t oms_setTLMConnectionParameters(const char* crefA, const char* crefB, const oms_tlm_connection_parameters_t* parameters);

getModelState

Gets the model state of the given model cref.

oms_status_enu_t oms_getModelState(const char* cref, oms_modelState_enu_t* modelState);

getFixedStepSize

Gets the fixed step size. Can be used for the communication step size of co-simulation systems and also for the integrator step size in model exchange systems.

oms_status_enu_t oms_getFixedStepSize(const char* cref, double* stepSize);

setCommandLineOption

Sets special flags.

oms_status_enu_t oms_setCommandLineOption(const char* cmd);

Available flags:

info:    Usage: OMSimulator [Options|Lua script]
info:    Options:
           <filename>                  FMU or SSP file
           --clearAllOptions           Reset all flags to default values
           --fetchAllVars=<arg>        
           --help [ -h ]               Displays the help text
           --ignoreInitialUnknowns=<arg>  Ignore the initial unknowns from the modelDesction.xml
           --intervals=<arg> [ -i ]    Specifies the number of communication points (arg > 1)
           --logFile=<arg> [ -l ]      Specifies the logfile (stdout is used if no log file is specified)
           --logLevel=<arg>            0 default, 1 default+debug, 2 default+debug+trace
           --mode=<arg> [ -m ]         Forces a certain FMI mode iff the FMU provides cs and me [arg: cs (default) or me]
           --progressBar=<arg>         
           --resultFile=<arg> [ -r ]   Specifies the name of the output result file
           --setInputDerivatives=<arg>  
           --solver                    Specifies the integration method (internal, euler, cvode)
           --startTime=<arg> [ -s ]    Specifies the start time
           --stopTime=<arg> [ -t ]     Specifies the stop time
           --suppressPath=<arg>        
           --tempDir=<arg>             Specifies the temp directory
           --timeout=<arg>             Specifies the maximum allowed time in seconds for running a simulation (0 disables)
           --tolerance=<arg>           Specifies the relative tolerance
           --version [ -v ]            Displays version information
           --wallTime=<arg>            Add wall time information for to the result file
           --workingDir=<arg>          Specifies the working directory

reset

Reset the composite model after a simulation run.

The FMUs go into the same state as after instantiation.

oms_status_enu_t oms_reset(const char* cref);

delete

Deletes a connector, component, system, or model object.

oms_status_enu_t oms_delete(const char* cref);

simulate_asynchronous

Simulates a composite model in its own thread.

oms_status_enu_t oms_simulate_asynchronous(const char* cref, void (*cb)(const char* cref, double time, oms_status_enu_t status));

getVariableStepSize

Gets the step size parameters.

oms_status_enu_t oms_getVariableStepSize(const char* cref, double* initialStepSize, double* minimumStepSize, double* maximumStepSize);

getBus

Gets the bus object.

oms_status_enu_t oms_getBus(const char* cref, oms_busconnector_t** busConnector);

setTLMSocketData

Sets data for TLM socket communication.

oms_status_enu_t oms_setTLMSocketData(const char* cref, const char* address, int managerPort, int monitorPort);

setElementGeometry

Set geometry information to a given component.

oms_status_enu_t oms_setElementGeometry(const char* cref, const ssd_element_geometry_t* geometry);

getConnector

Gets the connector object of the given connector cref.

oms_status_enu_t oms_getConnector(const char* cref, oms_connector_t** connector);

getElements

Get list of all sub-components of a given component reference.

oms_status_enu_t oms_getElements(const char* cref, oms_element_t*** elements);

addConnectorToBus

Adds a connector to a bus.

oms_status_enu_t oms_addConnectorToBus(const char* busCref, const char* connectorCref);

cancelSimulation_asynchronous

Cancels a running asynchronous simulation.

oms_status_enu_t oms_cancelSimulation_asynchronous(const char* cref);

addConnection

Adds a new connection between connectors A and B. The connectors need to be specified as fully qualified component references, e.g., “model.system.component.signal”.

oms_status_enu_t oms_addConnection(const char* crefA, const char* crefB);

The two arguments crefA and crefB get swapped automatically if necessary.

setSignalFilter

oms_status_enu_t oms_setSignalFilter(const char* cref, const char* regex);

importString

Imports a composite model from a string.

oms_status_enu_t oms_importString(const char* contents, char** cref);

simulate_asynchronous

Adds a TLM bus.

oms_status_enu_t oms_addTLMBus(const char* cref, oms_tlm_domain_t domain, const int dimensions, const oms_tlm_interpolation_t interpolation);

getConnections

Get list of all connections from a given component.

oms_status_enu_t oms_getConnections(const char* cref, oms_connection_t*** connections);

addSignalsToResults

Add all variables that match the given regex to the result file.

oms_status_enu_t oms_addSignalsToResults(const char* cref, const char* regex);

The second argument, i.e. regex, is considered as a regular expression (C++11). “.*” and “(.)*” can be used to hit all variables.

rename

Renames a model, system, or component.

oms_status_enu_t oms_rename(const char* cref, const char* newCref);

getFMUInfo

Returns FMU specific information.

oms_status_enu_t oms_getFMUInfo(const char* cref, const oms_fmu_info_t** fmuInfo);

setTLMBusGeometry

oms_status_enu_t oms_setTLMBusGeometry(const char* bus, const ssd_connector_geometry_t* geometry);

getElement

Get element information of a given component reference.

oms_status_enu_t oms_getElement(const char* cref, oms_element_t** element);

compareSimulationResults

This function compares a given signal of two result files within absolute and relative tolerances.

int oms_compareSimulationResults(const char* filenameA, const char* filenameB, const char* var, double relTol, double absTol);

setInteger

Set integer value of given signal.

oms_status_enu_t oms_setInteger(const char* cref, int value);

addSubModel

Adds a component to a system.

oms_status_enu_t oms_addSubModel(const char* cref, const char* fmuPath);

listUnconnectedConnectors

Lists all unconnected connectors of a given system.

Memory is allocated for contents. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn’t need to call free.

oms_status_enu_t oms_listUnconnectedConnectors(const char* cref, char** contents);

getComponentType

Gets the type of the given component.

oms_status_enu_t oms_getComponentType(const char* cref, oms_component_enu_t* type);

setConnectionGeometry

oms_status_enu_t oms_setConnectionGeometry(const char* crefA, const char* crefB, const ssd_connection_geometry_t* geometry);

getSystemType

Gets the type of the given system.

oms_status_enu_t oms_getSystemType(const char* cref, oms_system_enu_t* type);

addConnector

Adds a connector to a given component.

oms_status_enu_t oms_addConnector(const char* cref, oms_causality_enu_t causality, oms_signal_type_enu_t type);

initialize

Initializes a composite model.

oms_status_enu_t oms_initialize(const char* cref);

getSolver

Gets the selected solver method of the given system.

oms_status_enu_t oms_getSolver(const char* cref, oms_solver_enu_t* solver);

setLogFile

Redirects logging output to file or std streams. The warning/error counters are reset.

filename=”” to redirect to std streams and proper filename to redirect to file.

oms_status_enu_t oms_setLogFile(const char* filename);

parseModelName

Parses the model name from a given SSD representation.

Memory is allocated for ident. The caller is responsible to free it using the C-API. The Lua and Python bindings take care of the memory and the caller doesn’t need to call free.

oms_status_enu_t oms_parseModelName(const char* contents, char** cref);

setActivationRatio

Experimental feature for setting the activation ratio of FMUs for experimenting with multi-rate master algorithms.

oms_status_enu_t experimental_setActivationRatio(const char* cref, int k);

removeSignalsFromResults

Removes all variables that match the given regex to the result file.

oms_status_enu_t oms_removeSignalsFromResults(const char* cref, const char* regex);

The second argument, i.e. regex, is considered as a regular expression (C++11). “.*” and “(.)*” can be used to hit all variables.

getStartTime

Get the start time from the model.

oms_status_enu_t oms_getStartTime(const char* cref, double* startTime);

setWorkingDirectory

Set a new working directory.

oms_status_enu_t oms_setWorkingDirectory(const char* newWorkingDir);

simulate

Simulates a composite model.

oms_status_enu_t oms_simulate(const char* cref);

setTolerance

Sets the tolerance for a given model, system, or component.

oms_status_enu_t oms_setTolerance(const char* cref, double absoluteTolerance, double relativeTolerance);

setLoggingCallback

Sets a callback function for the logging system.

void oms_setLoggingCallback(void (*cb)(oms_message_type_enu_t type, const char* message));

freeMemory

Free the memory allocated by some other API. Pass the object for which memory is allocated.

void oms_freeMemory(void* obj);

getTolerance

Gets the tolerance of a given system or component.

oms_status_enu_t oms_getTolerance(const char* cref, double* absoluteTolerance, double* relativeTolerance);

setTLMPositionAndOrientation

Sets initial position and orientation for a TLM 3D interface.

oms_status_enu_t oms_setTLMPositionAndOrientation(cref, x1, x2, x3, A11, A12, A13, A21, A22, A23, A31, A32, A33);