OMSimulatorLib
The OMSimulator project is a FMI-based co-simulation environment that supports ordinary (i.e., non-delayed) and TLM connections.
Connector.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_CONNECTOR_H_
33 #define _OMS_CONNECTOR_H_
34 
35 #include "ComRef.h"
36 #include "ssd/ConnectorGeometry.h"
37 #include "Types.h"
38 
39 #include <string>
40 
41 #include <pugixml.hpp>
42 
43 namespace oms
44 {
48  class Connector : protected oms_connector_t
49  {
50  public:
52  Connector(oms_causality_enu_t causality, oms_signal_type_enu_t type, const oms::ComRef& name, double height);
53  ~Connector();
54 
55  // you have to free the memory yourself
56  static Connector* NewConnector(const pugi::xml_node& node, const std::string& sspVersion);
57 
58  oms_status_enu_t exportToSSD(pugi::xml_node& root) const;
59  static std::string getTypeString(const pugi::xml_node& node, const std::string& sspVersion);
60 
61  // methods to copy the object
62  Connector(const Connector& rhs);
63  Connector& operator=(const Connector& rhs);
64 
65  operator std::string() const {return std::string(name);}
66 
67  void setName(const oms::ComRef& name);
68  void setGeometry(const oms::ssd::ConnectorGeometry* newGeometry);
69 
70  const oms_causality_enu_t getCausality() const {return causality;}
71  const oms_signal_type_enu_t getType() const {return type;}
72  const oms::ComRef getName() const {return oms::ComRef(name);}
73  const oms::ssd::ConnectorGeometry* getGeometry() const {return reinterpret_cast<oms::ssd::ConnectorGeometry*>(geometry);}
74  Connector addPrefix(const ComRef& prefix) const;
75 
76  bool isInput() const { return oms_causality_input == causality; }
77  bool isOutput() const { return oms_causality_output == causality; }
78  bool isParameter() const { return oms_causality_parameter == causality; }
80 
81  bool isTypeReal() const { return oms_signal_type_real == type; }
82  bool isTypeInteger() const { return oms_signal_type_integer == type || oms_signal_type_enum == type; }
83  bool isTypeBoolean() const { return oms_signal_type_boolean == type; }
84 
85  private:
86  friend bool operator==(const Connector& v1, const Connector& v2);
87  friend bool operator!=(const Connector& v1, const Connector& v2);
88  };
89 
90  bool operator==(const Connector& v1, const Connector& v2);
91  bool operator!=(const Connector& v1, const Connector& v2);
92 }
93 
94 #endif
static std::string getTypeString(const pugi::xml_node &node, const std::string &sspVersion)
Definition: Connector.cpp:150
ssd_connector_geometry_t * geometry
Geometry information of the connector.
Definition: Types.h:385
const oms::ssd::ConnectorGeometry * getGeometry() const
Definition: Connector.h:73
oms_causality_enu_t
Definition: Types.h:61
Connector & operator=(const Connector &rhs)
Definition: Connector.cpp:244
oms_status_enu_t
Definition: Types.h:43
const oms_causality_enu_t getCausality() const
Definition: Connector.h:70
friend bool operator==(const Connector &v1, const Connector &v2)
bool isTypeBoolean() const
Definition: Connector.h:83
~Connector()
Definition: Connector.cpp:80
const oms::ComRef getName() const
Definition: Connector.h:72
char * name
Name of the connector.
Definition: Types.h:384
ComRef - component reference.
Definition: ComRef.h:43
bool isParameter() const
Definition: Connector.h:78
calculated parameter
Definition: Types.h:65
Connector.
Definition: Connector.h:48
bool isInput() const
Definition: Connector.h:76
Definition: Types.h:137
oms_status_enu_t exportToSSD(pugi::xml_node &root) const
Definition: Connector.cpp:183
Definition: Types.h:138
Connector addPrefix(const ComRef &prefix) const
Definition: Connector.cpp:285
void setGeometry(const oms::ssd::ConnectorGeometry *newGeometry)
Definition: Connector.cpp:273
oms_signal_type_enu_t
Definition: Types.h:135
Definition: Types.h:140
Definition: AlgLoop.h:44
static Connector * NewConnector(const pugi::xml_node &node, const std::string &sspVersion)
Definition: Connector.cpp:86
bool isTypeReal() const
Definition: Connector.h:81
friend bool operator!=(const Connector &v1, const Connector &v2)
Signal: input, output, and parameter.
Definition: Types.h:381
bool isCalculatedParameter() const
Definition: Connector.h:79
oms_causality_enu_t causality
input/output/parameter
Definition: Types.h:382
bool isTypeInteger() const
Definition: Connector.h:82
void setName(const oms::ComRef &name)
Definition: Connector.cpp:263
Connector(oms_causality_enu_t causality, oms_signal_type_enu_t type, const oms::ComRef &name)
Definition: Connector.cpp:38
output
Definition: Types.h:63
input
Definition: Types.h:62
Definition: Types.h:136
Definition: ConnectorGeometry.h:45
const oms_signal_type_enu_t getType() const
Definition: Connector.h:71
bool isOutput() const
Definition: Connector.h:77
oms_signal_type_enu_t type
Type of the connector.
Definition: Types.h:383
parameter
Definition: Types.h:64