OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment.
Loading...
Searching...
No Matches
ComponentTable.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenModelica.
3 *
4 * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC),
5 * c/o Linköpings universitet, Department of Computer and Information Science,
6 * SE-58183 Linköping, Sweden.
7 *
8 * All rights reserved.
9 *
10 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF AGPL VERSION 3 LICENSE OR
11 * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8.
12 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13 * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GNU AGPL
14 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
15 *
16 * The OpenModelica software and the OSMC (Open Source Modelica Consortium)
17 * Public License (OSMC-PL) are obtained from OSMC, either from the above
18 * address, from the URLs:
19 * http://www.openmodelica.org or
20 * https://github.com/OpenModelica/ or
21 * http://www.ida.liu.se/projects/OpenModelica,
22 * and in the OpenModelica distribution.
23 *
24 * GNU AGPL version 3 is obtained from:
25 * https://www.gnu.org/licenses/licenses.html#GPL
26 *
27 * This program is distributed WITHOUT ANY WARRANTY; without
28 * even the implied warranty of MERCHANTABILITY or FITNESS
29 * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
30 * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
31 *
32 * See the full OSMC Public License conditions for more details.
33 *
34 */
35
36#ifndef _OMS_COMPONENT_TABLE_H_
37#define _OMS_COMPONENT_TABLE_H_
38
39#include "Component.h"
40#include "ComRef.h"
41#include "ResultReader.h"
42#include "ResultWriter.h"
43#include "SignalDerivative.h"
44#include "Snapshot.h"
45#include <map>
46#include <pugixml.hpp>
47#include <string>
48#include <unordered_map>
49#include <vector>
50
51namespace oms
52{
54 {
55 public:
57
58 static Component* NewComponent(const oms::ComRef& cref, System* parentSystem, const std::string& path);
59 static Component* NewComponent(const pugi::xml_node& node, System* parentSystem, const std::string& sspVersion, const Snapshot& snapshot);
60
61 oms_status_enu_t exportToSSD(pugi::xml_node& node, Snapshot& snapshot, std::string variantName) const;
62 oms_status_enu_t exportToSSVTemplate(pugi::xml_node& ssvNode) {return oms_status_ok;}
63 oms_status_enu_t exportToSSMTemplate(pugi::xml_node& ssmNode) {return oms_status_ok;}
64 oms_status_enu_t instantiate();
65 oms_status_enu_t initialize() {return oms_status_ok;}
66 oms_status_enu_t terminate() {return oms_status_ok;}
67 oms_status_enu_t reset();
68
69 oms_status_enu_t stepUntil(double stopTime) {time = stopTime; return oms_status_ok;}
70 oms_status_enu_t setTime(double time) {this->time = time; return oms_status_ok;}
71
73 // All ComponentTable signals are interpolated series values (see getReal/getInteger/getBoolean below).
74 oms_status_enu_t getVariableType(const ComRef& cref, oms_signal_type_enu_t& type) {type = oms_signal_type_real; return oms_status_ok;}
75 oms_status_enu_t getReal(const ComRef& cref, double& value);
76 oms_status_enu_t getRealOutputDerivative(const ComRef& cref, SignalDerivative& value);
77 oms_status_enu_t getInteger(const ComRef& cref, int& value);
78 oms_status_enu_t getBoolean(const ComRef& cref, bool& value);
79
80 oms_status_enu_t registerSignalsForResultFile(ResultWriter& resultFile);
81 oms_status_enu_t updateSignals(ResultWriter& resultWriter);
82 oms_status_enu_t addSignalsToResults(const char* regex);
83 oms_status_enu_t removeSignalsFromResults(const char* regex);
84
85 bool getCanGetAndSetState() {return true;}
86 oms_status_enu_t saveState();
87 oms_status_enu_t freeState();
88 oms_status_enu_t restoreState();
89
90 void getFilteredSignals(std::vector<Connector>& filteredSignals) const;
91
92 protected:
93 ComponentTable(const ComRef& cref, System* parentSystem, const std::string& path);
94
95 // stop the compiler generating methods copying the object
98
99 private:
101 std::unordered_map<ComRef, ResultReader::Series*> series;
102 std::unordered_map<ComRef, bool> exportSeries;
103 std::unordered_map<unsigned int /*result file var ID*/, unsigned int /*allVariables ID*/> resultFileMapping;
104 double time;
106 size_t lastIndex = 0;
107 };
108}
109
110#endif
#define logError_NotImplemented
Definition Logging.h:111
ComRef - component reference.
Definition ComRef.h:51
Definition ComponentTable.h:54
ResultReader * resultReader
Definition ComponentTable.h:100
std::unordered_map< ComRef, ResultReader::Series * > series
Definition ComponentTable.h:101
~ComponentTable()
Definition ComponentTable.cpp:51
oms_status_enu_t restoreState()
Definition ComponentTable.cpp:433
oms_status_enu_t removeSignalsFromResults(const char *regex)
Definition ComponentTable.cpp:407
static Component * NewComponent(const oms::ComRef &cref, System *parentSystem, const std::string &path)
Definition ComponentTable.cpp:61
oms_status_enu_t getInteger(const ComRef &cref, int &value)
Definition ComponentTable.cpp:239
oms_status_enu_t getBoolean(const ComRef &cref, bool &value)
Definition ComponentTable.cpp:280
oms_status_enu_t getVariableType(const ComRef &cref, oms_signal_type_enu_t &type)
Definition ComponentTable.h:74
oms_status_enu_t exportToSSVTemplate(pugi::xml_node &ssvNode)
Definition ComponentTable.h:62
oms_status_enu_t setTime(double time)
Definition ComponentTable.h:70
oms_status_enu_t getRealOutputDerivative(const ComRef &cref, SignalDerivative &value)
Definition ComponentTable.cpp:321
oms_status_enu_t exportToSSMTemplate(pugi::xml_node &ssmNode)
Definition ComponentTable.h:63
oms_status_enu_t initialize()
Definition ComponentTable.h:65
ComponentTable(ComponentTable const &copy)
not implemented
double time
Definition ComponentTable.h:104
oms_status_enu_t reset()
Definition ComponentTable.cpp:191
oms_status_enu_t addSignalsToResults(const char *regex)
Definition ComponentTable.cpp:392
ComponentTable & operator=(ComponentTable const &copy)
not implemented
double storedTime
Definition ComponentTable.h:105
oms_status_enu_t exportToSSD(pugi::xml_node &node, Snapshot &snapshot, std::string variantName) const
Definition ComponentTable.cpp:168
oms_status_enu_t updateSignals(ResultWriter &resultWriter)
Definition ComponentTable.cpp:376
Variable * getVariable(const ComRef &cref)
Definition ComponentTable.h:72
std::unordered_map< unsigned int, unsigned int > resultFileMapping
Definition ComponentTable.h:103
void getFilteredSignals(std::vector< Connector > &filteredSignals) const
Definition ComponentTable.cpp:439
oms_status_enu_t freeState()
Definition ComponentTable.cpp:428
oms_status_enu_t stepUntil(double stopTime)
Definition ComponentTable.h:69
oms_status_enu_t terminate()
Definition ComponentTable.h:66
oms_status_enu_t saveState()
Definition ComponentTable.cpp:422
oms_status_enu_t registerSignalsForResultFile(ResultWriter &resultFile)
Definition ComponentTable.cpp:359
std::unordered_map< ComRef, bool > exportSeries
Definition ComponentTable.h:102
bool getCanGetAndSetState()
Definition ComponentTable.h:85
oms_status_enu_t getReal(const ComRef &cref, double &value)
Definition ComponentTable.cpp:197
oms_status_enu_t instantiate()
Definition ComponentTable.cpp:185
size_t lastIndex
Definition ComponentTable.h:106
Definition Component.h:65
std::string path
resource file (fmu, mat)
Definition Component.h:192
ComRef cref
Definition Component.h:190
System * parentSystem
Definition Component.h:189
oms_component_enu_t type
Definition Component.h:191
Definition ResultReader.h:45
Definition ResultWriter.h:73
Definition SignalDerivative.h:46
Definition Snapshot.h:51
Definition System.h:66
Definition Variable.h:50
Definition AlgLoop.h:49