OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment that supports ordinary (i.e., non-delayed) and TLM connections.
ComponentTable.h
Go to the documentation of this file.
1 /*
2  * This file is part of OpenModelica.
3  *
4  * Copyright (c) 1998-CurrentYear, 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 GPL VERSION 3 LICENSE OR
11  * THIS OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.2.
12  * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES
13  * RECIPIENT'S ACCEPTANCE OF THE OSMC PUBLIC LICENSE OR THE GPL VERSION 3,
14  * ACCORDING TO RECIPIENTS CHOICE.
15  *
16  * The OpenModelica software and the Open Source Modelica
17  * Consortium (OSMC) Public License (OSMC-PL) are obtained
18  * from OSMC, either from the above address,
19  * from the URLs: http://www.ida.liu.se/projects/OpenModelica or
20  * http://www.openmodelica.org, and in the OpenModelica distribution.
21  * GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
22  *
23  * This program is distributed WITHOUT ANY WARRANTY; without
24  * even the implied warranty of MERCHANTABILITY or FITNESS
25  * FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
26  * IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF OSMC-PL.
27  *
28  * See the full OSMC Public License conditions for more details.
29  *
30  */
31 
32 #ifndef _OMS_COMPONENT_TABLE_H_
33 #define _OMS_COMPONENT_TABLE_H_
34 
35 #include "Component.h"
36 #include "ComRef.h"
37 #include "ResultReader.h"
38 #include "ResultWriter.h"
39 #include "SignalDerivative.h"
40 #include <fmilib.h>
41 #include <map>
42 #include <pugixml.hpp>
43 #include <string>
44 #include <unordered_map>
45 #include <vector>
46 
47 namespace oms
48 {
49  class ComponentTable : public Component
50  {
51  public:
53 
54  static Component* NewComponent(const oms::ComRef& cref, System* parentSystem, const std::string& path);
55  static Component* NewComponent(const pugi::xml_node& node, System* parentSystem, const std::string& sspVersion);
56 
57  oms_status_enu_t exportToSSD(pugi::xml_node& node, pugi::xml_node& ssvNode) const;
58  oms_status_enu_t exportToSSVTemplate(pugi::xml_node& ssvNode) {return oms_status_ok;}
59  oms_status_enu_t exportToSSMTemplate(pugi::xml_node& ssmNode) {return oms_status_ok;}
64 
65  oms_status_enu_t stepUntil(double stopTime) {time = stopTime; return oms_status_ok;}
66 
67  Variable* getVariable(const ComRef& cref) {logError_NotImplemented; return NULL;}
68  oms_status_enu_t getReal(const ComRef& cref, double& value);
70  oms_status_enu_t getInteger(const ComRef& cref, int& value);
71  oms_status_enu_t getBoolean(const ComRef& cref, bool& value);
72 
75  oms_status_enu_t addSignalsToResults(const char* regex);
76  oms_status_enu_t removeSignalsFromResults(const char* regex);
77 
78  bool getCanGetAndSetState() {return true;}
82 
83  protected:
84  ComponentTable(const ComRef& cref, System* parentSystem, const std::string& path);
85 
86  // stop the compiler generating methods copying the object
87  ComponentTable(ComponentTable const& copy);
89 
90  private:
92  std::unordered_map<ComRef, ResultReader::Series*> series;
93  std::unordered_map<ComRef, bool> exportSeries;
94  std::unordered_map<unsigned int /*result file var ID*/, unsigned int /*allVariables ID*/> resultFileMapping;
95  double time;
96  double storedTime;
97  };
98 }
99 
100 #endif
oms_status_enu_t getRealOutputDerivative(const ComRef &cref, SignalDerivative &value)
Definition: ComponentTable.cpp:281
oms_status_enu_t instantiate()
Definition: ComponentTable.cpp:180
Definition: Types.h:44
Definition: ResultWriter.h:68
oms_status_enu_t registerSignalsForResultFile(ResultWriter &resultFile)
Definition: ComponentTable.cpp:304
System * parentSystem
Definition: Component.h:143
oms_status_enu_t addSignalsToResults(const char *regex)
Definition: ComponentTable.cpp:337
std::unordered_map< ComRef, bool > exportSeries
Definition: ComponentTable.h:93
Definition: Variable.h:44
double storedTime
Definition: ComponentTable.h:96
ComponentTable(const ComRef &cref, System *parentSystem, const std::string &path)
Definition: ComponentTable.cpp:41
double time
Definition: ComponentTable.h:95
oms_status_enu_t saveState()
Definition: ComponentTable.cpp:367
oms_status_enu_t getBoolean(const ComRef &cref, bool &value)
Definition: ComponentTable.cpp:250
std::string path
resource file (fmu, mat)
Definition: Component.h:146
oms_status_enu_t
Definition: Types.h:43
ResultReader * resultReader
Definition: ComponentTable.h:91
oms_status_enu_t initialize()
Definition: ComponentTable.h:61
oms_status_enu_t exportToSSD(pugi::xml_node &node, pugi::xml_node &ssvNode) const
Definition: ComponentTable.cpp:163
std::unordered_map< ComRef, ResultReader::Series * > series
Definition: ComponentTable.h:92
oms_status_enu_t restoreState()
Definition: ComponentTable.cpp:378
oms_status_enu_t reset()
Definition: ComponentTable.cpp:186
ComRef - component reference.
Definition: ComRef.h:43
Definition: Component.h:56
oms_status_enu_t updateSignals(ResultWriter &resultWriter)
Definition: ComponentTable.cpp:321
oms_status_enu_t exportToSSVTemplate(pugi::xml_node &ssvNode)
Definition: ComponentTable.h:58
std::unordered_map< unsigned int, unsigned int > resultFileMapping
Definition: ComponentTable.h:94
static Component * NewComponent(const oms::ComRef &cref, System *parentSystem, const std::string &path)
Definition: ComponentTable.cpp:56
Definition: AlgLoop.h:44
Definition: ResultReader.h:40
#define logError_NotImplemented
Definition: Logging.h:142
ComRef cref
Definition: Component.h:144
oms_status_enu_t getReal(const ComRef &cref, double &value)
Definition: ComponentTable.cpp:192
~ComponentTable()
Definition: ComponentTable.cpp:46
bool getCanGetAndSetState()
Definition: ComponentTable.h:78
oms_status_enu_t exportToSSMTemplate(pugi::xml_node &ssmNode)
Definition: ComponentTable.h:59
oms_status_enu_t terminate()
Definition: ComponentTable.h:62
oms_status_enu_t freeState()
Definition: ComponentTable.cpp:373
oms_status_enu_t stepUntil(double stopTime)
Definition: ComponentTable.h:65
Definition: System.h:67
ComponentTable & operator=(ComponentTable const &copy)
not implemented
oms_status_enu_t getInteger(const ComRef &cref, int &value)
Definition: ComponentTable.cpp:219
oms_status_enu_t removeSignalsFromResults(const char *regex)
Definition: ComponentTable.cpp:352
Definition: ComponentTable.h:49
Variable * getVariable(const ComRef &cref)
Definition: ComponentTable.h:67
Definition: SignalDerivative.h:41