OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment that supports ordinary (i.e., non-delayed) and TLM connections.
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
oms::SystemTLM Class Reference

#include <SystemTLM.h>

Inheritance diagram for oms::SystemTLM:
oms::System

Public Member Functions

 ~SystemTLM ()
 
oms_status_enu_t exportToSSD_SimulationInformation (pugi::xml_node &node) const
 
oms_status_enu_t importFromSSD_SimulationInformation (const pugi::xml_node &node, const std::string &sspVersion)
 
oms_status_enu_t importFromSSD_SimulationInformationHelper (const pugi::xml_node &node)
 
oms_status_enu_t setSocketData (const std::string &address, int managerPort, int monitorPort)
 
oms_status_enu_t setPositionAndOrientation (const ComRef &cref, std::vector< double > x, std::vector< double > A)
 
oms_status_enu_t fetchInterfaces (const ComRef &cref, std::vector< std::string > &name, std::vector< int > &dimensions, std::vector< std::string > &domain)
 
oms_status_enu_t instantiate ()
 
oms_status_enu_t initialize ()
 
oms_status_enu_t terminate ()
 
oms_status_enu_t reset ()
 
oms_status_enu_t doStep ()
 
oms_status_enu_t stepUntil (double stopTime)
 
oms_status_enu_t connectToSockets (const oms::ComRef cref, std::string server)
 
void disconnectFromSockets (const oms::ComRef cref)
 
oms_status_enu_t updateInitialValues (const oms::ComRef cref)
 
oms_status_enu_t initializeSubSystem (ComRef cref)
 
oms_status_enu_t simulateSubSystem (ComRef cref, double stopTime)
 
void writeToSockets (oms::SystemWC *system, double time, Component *component)
 
void readFromSockets (SystemWC *system, double time, Component *component)
 
void sendValueToLogger (int varId, double time, double value)
 
int registerLogVariable ()
 
void registerLogVariables (System *system, ResultWriter &resultFile)
 
void sendValuesToLogger (System *system, double time)
 
oms_status_enu_t registerSignalsForResultFile (ResultWriter &resultFile)
 
oms_status_enu_t updateSignals (ResultWriter &resultFile)
 
- Public Member Functions inherited from oms::System
virtual ~System ()
 
virtual oms_status_enu_t setSolver (oms_solver_enu_t solver)
 
const ComRefgetCref () const
 
ComRef getFullCref () const
 
SystemgetSystem (const ComRef &cref)
 
ComponentgetComponent (const ComRef &cref)
 
VariablegetVariable (const ComRef &cref)
 
ElementgetElement ()
 
oms_status_enu_t listUnconnectedConnectors (char **contents) const
 
oms_system_enu_t getType () const
 
oms_status_enu_t addSubSystem (const ComRef &cref, oms_system_enu_t type)
 
oms_status_enu_t addSubModel (const ComRef &cref, const std::string &fmuPath)
 
oms_status_enu_t replaceSubModel (const ComRef &cref, const std::string &fmuPath, bool dryRun, int &warningCount)
 
bool isValidScalarVariable (Component *referenceComponent, Component *replacingComponent, Connection *connection, const ComRef &crefA, const ComRef &crefB, const ComRef &signalName, const std::string &path, std::vector< std::string > &warningList)
 
bool validCref (const ComRef &cref)
 
oms_status_enu_t exportToSSD (pugi::xml_node &node, Snapshot &snapshot, std::string variantName) const
 
oms_status_enu_t exportToSSV (Snapshot &snapshot) const
 
oms_status_enu_t importFromSnapshot (const pugi::xml_node &node, const std::string &sspVersion, const Snapshot &snapshot, std::string variantName)
 
void setGeometry (const ssd::ElementGeometry &geometry)
 
oms_status_enu_t addConnector (const ComRef &cref, oms_causality_enu_t causality, oms_signal_type_enu_t type)
 
ConnectorgetConnector (const ComRef &cref)
 
std::string getConnectorOwner (const ComRef &cref) const
 
Connector ** getConnectors ()
 
BusConnectorgetBusConnector (const ComRef &cref)
 
oms_status_enu_t addTLMConnection (const ComRef &crefA, const ComRef &crefB, double delay, double alpha, double linearimpedance, double angularimpedance)
 
oms_status_enu_t setTLMConnectionParameters (const ComRef &crefA, const ComRef &crefB, const oms_tlm_connection_parameters_t *parameters)
 
oms_status_enu_t addTLMBus (const ComRef &cref, oms_tlm_domain_t domain, const int dimensions, const oms_tlm_interpolation_t interpolation)
 
oms_status_enu_t addConnectorToTLMBus (const ComRef &busCref, const ComRef &connectorCref, const std::string type)
 
oms_status_enu_t deleteConnectorFromTLMBus (const ComRef &busCref, const ComRef &connectorCref)
 
oms_status_enu_t setTLMBusGeometry (const ComRef &cref, const oms::ssd::ConnectorGeometry *geometry)
 
TLMBusConnectorgetTLMBusConnector (const ComRef &cref)
 
TLMBusConnector ** getTLMBusConnectors ()
 
ConnectiongetConnection (const ComRef &crefA, const ComRef &crefB)
 
Connection ** getConnections (const ComRef &cref)
 
oms_status_enu_t addConnection (const ComRef &crefA, const ComRef &crefB, bool suppressUnitConversion=false)
 
oms_status_enu_t deleteConnection (const ComRef &crefA, const ComRef &crefB)
 
oms_status_enu_t setConnectorGeometry (const ComRef &cref, const oms::ssd::ConnectorGeometry *geometry)
 
oms_status_enu_t setConnectionGeometry (const ComRef &crefA, const ComRef &crefB, const oms::ssd::ConnectionGeometry *geometry)
 
oms_status_enu_t addBus (const ComRef &cref)
 
oms_status_enu_t newResources (const ComRef &cref, const std::string &ssvFilename, const std::string &ssmFilename="", bool externalresources=false)
 
oms_status_enu_t addConnectorToBus (const ComRef &busCref, const ComRef &connectorCref)
 
oms_status_enu_t deleteConnectorFromBus (const ComRef &busCref, const ComRef &connectorCref)
 
oms_status_enu_t setBusGeometry (const ComRef &cref, const oms::ssd::ConnectorGeometry *geometry)
 
oms_status_enu_t addExternalModel (const ComRef &cref, std::string path, std::string startscript)
 
oms_status_enu_t delete_ (const ComRef &cref)
 
oms_status_enu_t deleteAllConectionsTo (const ComRef &cref)
 
oms_status_enu_t deleteReferencesInSSD (const ComRef &cref, const std::string &filename)
 
oms_status_enu_t deleteResourcesInSSP (const std::string &filename)
 
bool isConnected (const ComRef &cref) const
 
ModelgetModel ()
 
SystemgetParentSystem () const
 
bool copyResources ()
 
void getAllResources (std::vector< std::string > &resources) const
 
std::map< ComRef, System * > & getSubSystems ()
 
std::map< ComRef, Component * > & getComponents ()
 
std::vector< Connection * > & getConnections ()
 
oms_status_enu_t updateDependencyGraphs ()
 
const DirectedGraphgetInitialUnknownsGraph ()
 
const DirectedGraphgetOutputsGraph ()
 
oms_status_enu_t exportDependencyGraphs (const std::string &pathInitialization, const std::string &pathEvent, const std::string &pathSimulation)
 
oms_status_enu_t setFaultInjection (const ComRef &signal, oms_fault_type_enu_t faultType, double faultValue)
 
double getTime () const
 
oms_status_enu_t getBoolean (const ComRef &cref, bool &value)
 
oms_status_enu_t getInteger (const ComRef &cref, int &value)
 
oms_status_enu_t getReal (const ComRef &cref, double &value)
 
oms_status_enu_t getString (const ComRef &cref, std::string &value)
 
oms_status_enu_t setBoolean (const ComRef &cref, bool value)
 
oms_status_enu_t setInteger (const ComRef &cref, int value)
 
oms_status_enu_t setReal (const ComRef &cref, double value)
 
oms_status_enu_t setString (const ComRef &cref, const std::string &value)
 
oms_status_enu_t setUnit (const ComRef &cref, const std::string &value)
 
oms_status_enu_t getReals (const std::vector< ComRef > &crefs, std::vector< double > &values)
 
oms_status_enu_t setReals (const std::vector< ComRef > &crefs, std::vector< double > values)
 
oms_status_enu_t setRealInputDerivatives (const ComRef &cref, int order, double value)
 
oms_status_enu_t getDirectionalDerivative (const ComRef &unknownCref, const ComRef &knownCref, double &value)
 
oms_status_enu_t getState (const ComRef &cref)
 
oms_status_enu_t setState (const ComRef &cref)
 
oms_status_enu_t freeState (const ComRef &cref)
 
oms_status_enu_t rename (const ComRef &newCref)
 rename the system itself More...
 
oms_status_enu_t rename (const ComRef &cref, const ComRef &newCref)
 rename any component within the system More...
 
oms_status_enu_t renameConnections (const ComRef &cref, const ComRef &newCref)
 
oms_status_enu_t renameConnectors ()
 
bool isTopLevelSystem () const
 
oms_status_enu_t addSignalsToResults (const char *regex)
 
oms_status_enu_t removeSignalsFromResults (const char *regex)
 
void getTolerance (double *absoluteTolerance, double *relativeTolerance) const
 
void getStepSize (double *initialStepSize, double *minimumStepSize, double *maximumStepSize) const
 
oms_status_enu_t setTolerance (double absoluteTolerance, double relativeTolerance)
 
oms_status_enu_t setFixedStepSize (double stepSize)
 
oms_status_enu_t setVariableStepSize (double initialStepSize, double minimumStepSize, double maximumStepSize)
 
double getMaximumStepSize ()
 
oms_solver_enu_t getSolver ()
 
AlgLoopgetAlgLoop (const int systemNumber)
 
oms_status_enu_t addAlgLoop (scc_t SCC, const int algLoopNum, DirectedGraph &graph, bool supportsDirectionalDerivatives)
 
oms_status_enu_t updateAlgebraicLoops (const std::vector< scc_t > &sortedConnections, DirectedGraph &graph)
 
oms_status_enu_t solveAlgLoop (DirectedGraph &graph, int loopNumber)
 
bool useThreadPool ()
 
ctpl::thread_pool & getThreadPool ()
 
std::string getUniqueID () const
 
void forceLoopsToBeUpdated ()
 
void getFilteredSignals (std::vector< Connector > &filteredSignals) const
 
bool supportsDirectionalDerivatives (int i, DirectedGraph &graph)
 returns true if all FMUs support providesDirectionalDerivative More...
 
ValuesgetValues ()
 

Static Public Member Functions

static SystemNewSystem (const oms::ComRef &cref, Model *parentModel, System *parentSystem)
 
- Static Public Member Functions inherited from oms::System
static SystemNewSystem (const ComRef &cref, oms_system_enu_t type, Model *parentModel, System *parentSystem)
 

Protected Member Functions

 SystemTLM (const ComRef &cref, Model *parentModel, System *parentSystem)
 
 SystemTLM (SystemTLM const &copy)
 not implemented More...
 
SystemTLMoperator= (SystemTLM const &copy)
 not implemented More...
 
- Protected Member Functions inherited from oms::System
 System (const ComRef &cref, oms_system_enu_t type, Model *parentModel, System *parentSystem, oms_solver_enu_t solverMethod)
 
 System (System const &copy)
 not implemented More...
 
Systemoperator= (System const &copy)
 not implemented More...
 

Private Member Functions

double interpolate (double t1, double t2, double x1, double x2, double t)
 

Private Attributes

void * model
 
std::string address = ""
 
int desiredManagerPort =0
 
int desiredMonitorPort =0
 
int actualManagerPort =0
 
int actualMonitorPort =0
 
std::vector< ComRefconnectedsubsystems
 
std::map< System *, TLMPlugin * > plugins
 
std::vector< ComRefinitializedsubsystems
 
std::mutex pluginsMutex
 
std::mutex setConnectedMutex
 
std::mutex setInitializedMutex
 
std::map< System *, std::mutex > socketMutexes
 
std::mutex logMutex
 
int numLogVars = 0
 
std::map< int, std::vector< std::pair< double, double > > > logBuffer
 
double nextLogTime
 
double logTime
 
double logStep = 1e-2
 
std::map< TLMBusConnector *, int > busLogIds
 
std::map< Connector *, int > connectorLogIds
 
std::string singleModel
 

Additional Inherited Members

- Public Attributes inherited from oms::System
std::map< std::string, filesystem::path > fmuGuid
 
- Protected Attributes inherited from oms::System
double time
 
DirectedGraph initializationGraph
 dependency graph, with all connections, solved at initialization More...
 
DirectedGraph eventGraph
 filtered dependency graph, without parameters, solved at event mode More...
 
DirectedGraph simulationGraph
 filtered dependency graph, with connections of type Real, solved at continuous time mode; More...
 
Clock clock
 
unsigned int clock_id
 
oms_solver_enu_t solverMethod = oms_solver_none
 
double absoluteTolerance = 1e-4
 
double relativeTolerance = 1e-4
 
double minimumStepSize
 
double maximumStepSize
 
double initialStepSize
 
std::unordered_map< unsigned int, unsigned int > resultFileMapping
 
std::unordered_map< ComRef, bool > exportConnectors
 

Constructor & Destructor Documentation

◆ ~SystemTLM()

oms::SystemTLM::~SystemTLM ( )

◆ SystemTLM() [1/2]

oms::SystemTLM::SystemTLM ( const ComRef cref,
Model parentModel,
System parentSystem 
)
protected

◆ SystemTLM() [2/2]

oms::SystemTLM::SystemTLM ( SystemTLM const &  copy)
protected

not implemented

Member Function Documentation

◆ connectToSockets()

oms_status_enu_t oms::SystemTLM::connectToSockets ( const oms::ComRef  cref,
std::string  server 
)

◆ disconnectFromSockets()

void oms::SystemTLM::disconnectFromSockets ( const oms::ComRef  cref)

◆ doStep()

oms_status_enu_t oms::SystemTLM::doStep ( )
virtual

Implements oms::System.

◆ exportToSSD_SimulationInformation()

oms_status_enu_t oms::SystemTLM::exportToSSD_SimulationInformation ( pugi::xml_node &  node) const
virtual

Implements oms::System.

◆ fetchInterfaces()

oms_status_enu_t oms::SystemTLM::fetchInterfaces ( const ComRef cref,
std::vector< std::string > &  name,
std::vector< int > &  dimensions,
std::vector< std::string > &  domain 
)

◆ importFromSSD_SimulationInformation()

oms_status_enu_t oms::SystemTLM::importFromSSD_SimulationInformation ( const pugi::xml_node &  node,
const std::string &  sspVersion 
)
virtual

Implements oms::System.

◆ importFromSSD_SimulationInformationHelper()

oms_status_enu_t oms::SystemTLM::importFromSSD_SimulationInformationHelper ( const pugi::xml_node &  node)

◆ initialize()

oms_status_enu_t oms::SystemTLM::initialize ( )
virtual

Implements oms::System.

◆ initializeSubSystem()

oms_status_enu_t oms::SystemTLM::initializeSubSystem ( oms::ComRef  cref)

◆ instantiate()

oms_status_enu_t oms::SystemTLM::instantiate ( )
virtual

Implements oms::System.

◆ interpolate()

double oms::SystemTLM::interpolate ( double  t1,
double  t2,
double  x1,
double  x2,
double  t 
)
inlineprivate

◆ NewSystem()

oms::System * oms::SystemTLM::NewSystem ( const oms::ComRef cref,
oms::Model parentModel,
oms::System parentSystem 
)
static

◆ operator=()

SystemTLM& oms::SystemTLM::operator= ( SystemTLM const &  copy)
protected

not implemented

◆ readFromSockets()

void oms::SystemTLM::readFromSockets ( SystemWC system,
double  time,
Component component 
)

◆ registerLogVariable()

int oms::SystemTLM::registerLogVariable ( )

◆ registerLogVariables()

void oms::SystemTLM::registerLogVariables ( oms::System system,
ResultWriter resultFile 
)

◆ registerSignalsForResultFile()

oms_status_enu_t oms::SystemTLM::registerSignalsForResultFile ( ResultWriter resultFile)
virtual

Reimplemented from oms::System.

◆ reset()

oms_status_enu_t oms::SystemTLM::reset ( )
virtual

Implements oms::System.

◆ sendValuesToLogger()

void oms::SystemTLM::sendValuesToLogger ( oms::System system,
double  time 
)

◆ sendValueToLogger()

void oms::SystemTLM::sendValueToLogger ( int  varId,
double  time,
double  value 
)

◆ setPositionAndOrientation()

oms_status_enu_t oms::SystemTLM::setPositionAndOrientation ( const ComRef cref,
std::vector< double >  x,
std::vector< double >  A 
)

◆ setSocketData()

oms_status_enu_t oms::SystemTLM::setSocketData ( const std::string &  address,
int  managerPort,
int  monitorPort 
)

◆ simulateSubSystem()

oms_status_enu_t oms::SystemTLM::simulateSubSystem ( oms::ComRef  cref,
double  stopTime 
)

◆ stepUntil()

oms_status_enu_t oms::SystemTLM::stepUntil ( double  stopTime)
virtual

Implements oms::System.

◆ terminate()

oms_status_enu_t oms::SystemTLM::terminate ( )
virtual

Implements oms::System.

◆ updateInitialValues()

oms_status_enu_t oms::SystemTLM::updateInitialValues ( const oms::ComRef  cref)

◆ updateSignals()

oms_status_enu_t oms::SystemTLM::updateSignals ( oms::ResultWriter resultFile)
virtual

Reimplemented from oms::System.

◆ writeToSockets()

void oms::SystemTLM::writeToSockets ( oms::SystemWC system,
double  time,
Component component 
)

Member Data Documentation

◆ actualManagerPort

int oms::SystemTLM::actualManagerPort =0
private

◆ actualMonitorPort

int oms::SystemTLM::actualMonitorPort =0
private

◆ address

std::string oms::SystemTLM::address = ""
private

◆ busLogIds

std::map<TLMBusConnector*, int> oms::SystemTLM::busLogIds
private

◆ connectedsubsystems

std::vector<ComRef> oms::SystemTLM::connectedsubsystems
private

◆ connectorLogIds

std::map<Connector*, int> oms::SystemTLM::connectorLogIds
private

◆ desiredManagerPort

int oms::SystemTLM::desiredManagerPort =0
private

◆ desiredMonitorPort

int oms::SystemTLM::desiredMonitorPort =0
private

◆ initializedsubsystems

std::vector<ComRef> oms::SystemTLM::initializedsubsystems
private

◆ logBuffer

std::map<int, std::vector<std::pair<double,double> > > oms::SystemTLM::logBuffer
private

◆ logMutex

std::mutex oms::SystemTLM::logMutex
private

◆ logStep

double oms::SystemTLM::logStep = 1e-2
private

◆ logTime

double oms::SystemTLM::logTime
private

◆ model

void* oms::SystemTLM::model
private

◆ nextLogTime

double oms::SystemTLM::nextLogTime
private

◆ numLogVars

int oms::SystemTLM::numLogVars = 0
private

◆ plugins

std::map<System*, TLMPlugin*> oms::SystemTLM::plugins
private

◆ pluginsMutex

std::mutex oms::SystemTLM::pluginsMutex
private

◆ setConnectedMutex

std::mutex oms::SystemTLM::setConnectedMutex
private

◆ setInitializedMutex

std::mutex oms::SystemTLM::setInitializedMutex
private

◆ singleModel

std::string oms::SystemTLM::singleModel
private

◆ socketMutexes

std::map<System*, std::mutex> oms::SystemTLM::socketMutexes
private

The documentation for this class was generated from the following files: