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
51 namespace oms
52{
53 class ComponentTable : public Component
54 {
55 public:
56 ~ComponentTable();
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
72 Variable* getVariable(const ComRef& cref) {logError_NotImplemented; return NULL;}
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
96 ComponentTable(ComponentTable const& copy);
97 ComponentTable& operator=(ComponentTable const& copy);
98
99 private:
100 ResultReader* resultReader;
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;
105 double storedTime;
106 size_t lastIndex = 0;
107 };
108}
109
110#endif
ComRef.h
Component.h
logError_NotImplemented
#define logError_NotImplemented
Definition Logging.h:111
ResultReader.h
ResultWriter.h
SignalDerivative.h
Snapshot.h
oms::ComRef
ComRef - component reference.
Definition ComRef.h:51
oms::ComponentTable
Definition ComponentTable.h:54
oms::ComponentTable::resultReader
ResultReader * resultReader
Definition ComponentTable.h:100
oms::ComponentTable::series
std::unordered_map< ComRef, ResultReader::Series * > series
Definition ComponentTable.h:101
oms::ComponentTable::~ComponentTable
~ComponentTable()
Definition ComponentTable.cpp:51
oms::ComponentTable::restoreState
oms_status_enu_t restoreState()
Definition ComponentTable.cpp:433
oms::ComponentTable::removeSignalsFromResults
oms_status_enu_t removeSignalsFromResults(const char *regex)
Definition ComponentTable.cpp:407
oms::ComponentTable::NewComponent
static Component * NewComponent(const oms::ComRef &cref, System *parentSystem, const std::string &path)
Definition ComponentTable.cpp:61
oms::ComponentTable::getInteger
oms_status_enu_t getInteger(const ComRef &cref, int &value)
Definition ComponentTable.cpp:239
oms::ComponentTable::getBoolean
oms_status_enu_t getBoolean(const ComRef &cref, bool &value)
Definition ComponentTable.cpp:280
oms::ComponentTable::getVariableType
oms_status_enu_t getVariableType(const ComRef &cref, oms_signal_type_enu_t &type)
Definition ComponentTable.h:74
oms::ComponentTable::exportToSSVTemplate
oms_status_enu_t exportToSSVTemplate(pugi::xml_node &ssvNode)
Definition ComponentTable.h:62
oms::ComponentTable::setTime
oms_status_enu_t setTime(double time)
Definition ComponentTable.h:70
oms::ComponentTable::getRealOutputDerivative
oms_status_enu_t getRealOutputDerivative(const ComRef &cref, SignalDerivative &value)
Definition ComponentTable.cpp:321
oms::ComponentTable::exportToSSMTemplate
oms_status_enu_t exportToSSMTemplate(pugi::xml_node &ssmNode)
Definition ComponentTable.h:63
oms::ComponentTable::initialize
oms_status_enu_t initialize()
Definition ComponentTable.h:65
oms::ComponentTable::ComponentTable
ComponentTable(ComponentTable const &copy)
not implemented
oms::ComponentTable::time
double time
Definition ComponentTable.h:104
oms::ComponentTable::reset
oms_status_enu_t reset()
Definition ComponentTable.cpp:191
oms::ComponentTable::addSignalsToResults
oms_status_enu_t addSignalsToResults(const char *regex)
Definition ComponentTable.cpp:392
oms::ComponentTable::operator=
ComponentTable & operator=(ComponentTable const &copy)
not implemented
oms::ComponentTable::storedTime
double storedTime
Definition ComponentTable.h:105
oms::ComponentTable::exportToSSD
oms_status_enu_t exportToSSD(pugi::xml_node &node, Snapshot &snapshot, std::string variantName) const
Definition ComponentTable.cpp:168
oms::ComponentTable::updateSignals
oms_status_enu_t updateSignals(ResultWriter &resultWriter)
Definition ComponentTable.cpp:376
oms::ComponentTable::getVariable
Variable * getVariable(const ComRef &cref)
Definition ComponentTable.h:72
oms::ComponentTable::resultFileMapping
std::unordered_map< unsigned int, unsigned int > resultFileMapping
Definition ComponentTable.h:103
oms::ComponentTable::getFilteredSignals
void getFilteredSignals(std::vector< Connector > &filteredSignals) const
Definition ComponentTable.cpp:439
oms::ComponentTable::freeState
oms_status_enu_t freeState()
Definition ComponentTable.cpp:428
oms::ComponentTable::stepUntil
oms_status_enu_t stepUntil(double stopTime)
Definition ComponentTable.h:69
oms::ComponentTable::terminate
oms_status_enu_t terminate()
Definition ComponentTable.h:66
oms::ComponentTable::saveState
oms_status_enu_t saveState()
Definition ComponentTable.cpp:422
oms::ComponentTable::registerSignalsForResultFile
oms_status_enu_t registerSignalsForResultFile(ResultWriter &resultFile)
Definition ComponentTable.cpp:359
oms::ComponentTable::exportSeries
std::unordered_map< ComRef, bool > exportSeries
Definition ComponentTable.h:102
oms::ComponentTable::getCanGetAndSetState
bool getCanGetAndSetState()
Definition ComponentTable.h:85
oms::ComponentTable::getReal
oms_status_enu_t getReal(const ComRef &cref, double &value)
Definition ComponentTable.cpp:197
oms::ComponentTable::instantiate
oms_status_enu_t instantiate()
Definition ComponentTable.cpp:185
oms::ComponentTable::lastIndex
size_t lastIndex
Definition ComponentTable.h:106
oms::Component
Definition Component.h:65
oms::Component::path
std::string path
resource file (fmu, mat)
Definition Component.h:192
oms::Component::cref
ComRef cref
Definition Component.h:190
oms::Component::parentSystem
System * parentSystem
Definition Component.h:189
oms::Component::type
oms_component_enu_t type
Definition Component.h:191
oms::ResultReader
Definition ResultReader.h:45
oms::ResultWriter
Definition ResultWriter.h:73
oms::SignalDerivative
Definition SignalDerivative.h:46
oms::Snapshot
Definition Snapshot.h:51
oms::System
Definition System.h:66
oms::Variable
Definition Variable.h:50
oms
Definition AlgLoop.h:49