OMSimulatorLib The OMSimulator project is a FMI-based co-simulation environment.

Loading...
Searching...
No Matches
Connector.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_CONNECTOR_H_
37#define _OMS_CONNECTOR_H_
38
39#include "ComRef.h"
40#include "ssd/ConnectorGeometry.h"
41#include "OMSimulator/Types.h"
42
43#include <string>
44#include <map>
45
46#include <pugixml.hpp>
47
48 namespace oms
49{
53 class Connector : protected oms_connector_t
54 {
55 public:
56 Connector(oms_causality_enu_t causality, oms_signal_type_enu_t type, const oms::ComRef& name, const oms::ComRef& owner);
57 Connector(oms_causality_enu_t causality, oms_signal_type_enu_t type, const oms::ComRef& name, const oms::ComRef& owner, double height);
58 ~Connector();
59
60 // methods to copy the object
61 Connector(const Connector& rhs);
62 Connector& operator=(const Connector& rhs);
63
64 // you have to free the memory yourself
65 static Connector* NewConnector(const pugi::xml_node& node, const std::string& sspVersion, const oms::ComRef& owner);
66
67 oms_status_enu_t exportToSSD(pugi::xml_node& root) const;
68 static std::string getTypeString(const pugi::xml_node& node, const std::string& sspVersion);
69 std::string getTypeString() const;
70 std::string getCausalityString() const;
71
72 operator std::string() const {return std::string(name);}
73
74 void setName(const oms::ComRef& name);
75 void setOwner(const oms::ComRef& owner);
76 void setGeometry(const oms::ssd::ConnectorGeometry* newGeometry);
77 oms_status_enu_t setExportName(const std::string & exportName) { this->exportName = exportName; return oms_status_ok;};
78 oms_status_enu_t setAliasName(const std::string & aliasName) { this->aliasName = aliasName; return oms_status_ok;}; // to be used in the result file to avoid name conflicts
79 oms_status_enu_t setNumericType(oms_signal_numeric_type_enu_t numericType) { this->numericType = numericType; return oms_status_ok; }
80 oms_signal_numeric_type_enu_t getNumericType() const { return this->numericType; }
81 std::string getExportName() const { return this->exportName; }
82 std::string getAliasName() const { return this->aliasName; }
83
84 std::map<std::string, std::map<std::string, std::string>> connectorUnits;
85 std::map<std::string, std::string> enumerationName;
86
87 const oms_causality_enu_t getCausality() const {return causality;}
88 const oms_signal_type_enu_t getType() const {return type;}
89 const oms::ComRef getOwner() const {return oms::ComRef(owner);}
90 const oms::ComRef getName() const {return oms::ComRef(name);}
91 const oms::ComRef getFullName() const {return getOwner() + getName();}
92 const oms::ssd::ConnectorGeometry* getGeometry() const {return reinterpret_cast<oms::ssd::ConnectorGeometry*>(geometry);}
93 Connector addPrefix(const ComRef& prefix) const;
94
95 bool isInput() const { return oms_causality_input == causality; }
96 bool isOutput() const { return oms_causality_output == causality; }
97 bool isParameter() const { return oms_causality_parameter == causality; }
98 bool isCalculatedParameter() const { return oms_causality_calculatedParameter == causality; }
99
100 bool isTypeBoolean() const { return oms_signal_type_boolean == type; }
101 bool isTypeInteger() const { return oms_signal_type_integer == type || oms_signal_type_enum == type; }
102 bool isTypeReal() const { return oms_signal_type_real == type; }
103 bool isTypeString() const { return oms_signal_type_string == type; }
104
105 private:
106 friend bool operator==(const Connector& v1, const Connector& v2);
107 friend bool operator!=(const Connector& v1, const Connector& v2);
108 std::string exportName = "";
109 std::string aliasName = "";
110 oms_signal_numeric_type_enu_t numericType = oms_signal_numeric_type_none;
111 };
112
113 bool operator==(const Connector& v1, const Connector& v2);
114 bool operator!=(const Connector& v1, const Connector& v2);
115}
116
117#endif
ComRef.h
ConnectorGeometry.h
oms::ComRef
ComRef - component reference.
Definition ComRef.h:51
oms::Connector
Connector.
Definition Connector.h:54
oms::Connector::exportToSSD
oms_status_enu_t exportToSSD(pugi::xml_node &root) const
Definition Connector.cpp:215
oms::Connector::connectorUnits
std::map< std::string, std::map< std::string, std::string > > connectorUnits
single entry map which contains unit as key and BaseUnits as value for a connector
Definition Connector.h:84
oms::Connector::getCausality
const oms_causality_enu_t getCausality() const
Definition Connector.h:87
oms::Connector::NewConnector
static Connector * NewConnector(const pugi::xml_node &node, const std::string &sspVersion, const oms::ComRef &owner)
Definition Connector.cpp:128
oms::Connector::getType
const oms_signal_type_enu_t getType() const
Definition Connector.h:88
oms::Connector::getName
const oms::ComRef getName() const
Definition Connector.h:90
oms::Connector::getOwner
const oms::ComRef getOwner() const
Definition Connector.h:89
oms::Connector::isTypeReal
bool isTypeReal() const
Definition Connector.h:102
oms::Connector::setName
void setName(const oms::ComRef &name)
Definition Connector.cpp:270
oms::Connector::addPrefix
Connector addPrefix(const ComRef &prefix) const
Definition Connector.cpp:302
oms::Connector::isTypeString
bool isTypeString() const
Definition Connector.h:103
oms::Connector::getExportName
std::string getExportName() const
Definition Connector.h:81
oms::Connector::setOwner
void setOwner(const oms::ComRef &owner)
Definition Connector.cpp:280
oms::Connector::setNumericType
oms_status_enu_t setNumericType(oms_signal_numeric_type_enu_t numericType)
Definition Connector.h:79
oms::Connector::operator!=
friend bool operator!=(const Connector &v1, const Connector &v2)
oms::Connector::enumerationName
std::map< std::string, std::string > enumerationName
single entry map which contains connector name as key and enumerationName as value for a connector of...
Definition Connector.h:85
oms::Connector::~Connector
~Connector()
Definition Connector.cpp:85
oms::Connector::getNumericType
oms_signal_numeric_type_enu_t getNumericType() const
Definition Connector.h:80
oms::Connector::isTypeInteger
bool isTypeInteger() const
Definition Connector.h:101
oms::Connector::numericType
oms_signal_numeric_type_enu_t numericType
numeric type for the connector for FMI 3.0
Definition Connector.h:110
oms::Connector::isCalculatedParameter
bool isCalculatedParameter() const
Definition Connector.h:98
oms::Connector::getCausalityString
std::string getCausalityString() const
Definition Connector.cpp:346
oms::Connector::getAliasName
std::string getAliasName() const
Definition Connector.h:82
oms::Connector::isInput
bool isInput() const
Definition Connector.h:95
oms::Connector::getGeometry
const oms::ssd::ConnectorGeometry * getGeometry() const
Definition Connector.h:92
oms::Connector::operator==
friend bool operator==(const Connector &v1, const Connector &v2)
oms::Connector::isTypeBoolean
bool isTypeBoolean() const
Definition Connector.h:100
oms::Connector::getTypeString
std::string getTypeString() const
Definition Connector.cpp:319
oms::Connector::isParameter
bool isParameter() const
Definition Connector.h:97
oms::Connector::operator=
Connector & operator=(const Connector &rhs)
Definition Connector.cpp:106
oms::Connector::setGeometry
void setGeometry(const oms::ssd::ConnectorGeometry *newGeometry)
Definition Connector.cpp:290
oms::Connector::getFullName
const oms::ComRef getFullName() const
Definition Connector.h:91
oms::Connector::setExportName
oms_status_enu_t setExportName(const std::string &exportName)
Definition Connector.h:77
oms::Connector::isOutput
bool isOutput() const
Definition Connector.h:96
oms::Connector::setAliasName
oms_status_enu_t setAliasName(const std::string &aliasName)
Definition Connector.h:78
oms::Connector::exportName
std::string exportName
name to be used in result file
Definition Connector.h:108
oms::Connector::aliasName
std::string aliasName
connector name defined in the ssp file
Definition Connector.h:109
oms::ssd::ConnectorGeometry
Definition ConnectorGeometry.h:50
oms
Definition AlgLoop.h:49
oms::operator==
bool operator==(const ComRef &lhs, const ComRef &rhs)
Definition ComRef.cpp:214
oms::operator!=
bool operator!=(const ComRef &lhs, const ComRef &rhs)
Definition ComRef.cpp:219