OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment that supports ordinary (i.e., non-delayed) and TLM connections.
ExternalModel.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_EXTERNAL_MODEL_H_
33 #define _OMS_EXTERNAL_MODEL_H_
34 
35 #include "Component.h"
36 #include "ComRef.h"
37 #include "Element.h"
38 #include "Option.h"
39 #include "ResultWriter.h"
40 #include "Types.h"
41 #include "Variable.h"
42 #include <vector>
43 #include <map>
44 
45 namespace oms
46 {
47  class ExternalModel : public Component
48  {
49  public:
51  static ExternalModel* NewComponent(const oms::ComRef& cref, System* parentSystem, const std::string& path, const std::string& startscript);
52 
53  oms_status_enu_t setRealParameter(const std::string& var, double value);
54  oms_status_enu_t getRealParameter(const std::string& var, double& value);
55  const std::string& getStartScript() const {return startscript;}
56  const std::map<std::string, oms::Option<double>>& getRealParameters() const {return realParameters;}
57 
58  oms_status_enu_t exportToSSD(pugi::xml_node& node) const;
63 
65 
68  oms_status_enu_t addSignalsToResults(const char* regex);
69  oms_status_enu_t removeSignalsFromResults(const char* regex);
70 
71  protected:
72  ExternalModel(const oms::ComRef& cref, System* parentSystem, const std::string& path, const std::string& startscript);
73 
74  // stop the compiler generating methods copying the object
75  ExternalModel(ExternalModel const& copy);
76  ExternalModel& operator=(ExternalModel const& copy);
77 
78  private:
79  std::string startscript;
80  std::map<std::string, oms::Option<double>> realParameters;
81  };
82 }
83 
84 #endif
oms_status_enu_t updateDependencyGraphs()
Definition: ExternalModel.h:64
oms_status_enu_t initialize()
Definition: ExternalModel.cpp:118
~ExternalModel()
Definition: ExternalModel.cpp:47
Definition: ResultWriter.h:67
System * parentSystem
Definition: Component.h:126
oms_status_enu_t registerSignalsForResultFile(ResultWriter &resultFile)
Definition: ExternalModel.cpp:133
oms_status_enu_t instantiate()
Definition: ExternalModel.cpp:113
std::string startscript
Definition: ExternalModel.h:79
std::string path
Definition: Component.h:129
oms_status_enu_t updateSignals(ResultWriter &resultWriter)
Definition: ExternalModel.cpp:138
oms_status_enu_t
Definition: Types.h:43
oms_status_enu_t addSignalsToResults(const char *regex)
Definition: ExternalModel.cpp:143
oms_status_enu_t setRealParameter(const std::string &var, double value)
Definition: ExternalModel.cpp:63
oms_status_enu_t exportToSSD(pugi::xml_node &node) const
Definition: ExternalModel.cpp:89
ExternalModel(const oms::ComRef &cref, System *parentSystem, const std::string &path, const std::string &startscript)
Definition: ExternalModel.cpp:42
Definition: ExternalModel.h:47
oms_status_enu_t terminate()
Definition: ExternalModel.cpp:123
Definition: Types.h:47
ComRef - component reference.
Definition: ComRef.h:43
Definition: Component.h:54
const std::map< std::string, oms::Option< double > > & getRealParameters() const
Definition: ExternalModel.h:56
oms_status_enu_t removeSignalsFromResults(const char *regex)
Definition: ExternalModel.cpp:148
Definition: BusConnector.h:15
std::map< std::string, oms::Option< double > > realParameters
Definition: ExternalModel.h:80
ComRef cref
Definition: Component.h:127
static ExternalModel * NewComponent(const oms::ComRef &cref, System *parentSystem, const std::string &path, const std::string &startscript)
Definition: ExternalModel.cpp:51
oms_status_enu_t reset()
Definition: ExternalModel.cpp:128
Definition: System.h:58
const std::string & getStartScript() const
Definition: ExternalModel.h:55
oms_status_enu_t getRealParameter(const std::string &var, double &value)
Definition: ExternalModel.cpp:76
ExternalModel & operator=(ExternalModel const &copy)
not implemented