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-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 "OMSimulator/Types.h"
38
39#include <string>
40#include <map>
41
42#include <pugixml.hpp>
43
44 namespace oms
45{
49 class Connector : protected oms_connector_t
50 {
51 public:
52 Connector(oms_causality_enu_t causality, oms_signal_type_enu_t type, const oms::ComRef& name, const oms::ComRef& owner);
53 Connector(oms_causality_enu_t causality, oms_signal_type_enu_t type, const oms::ComRef& name, const oms::ComRef& owner, double height);
54 ~Connector();
55
56 // methods to copy the object
57 Connector(const Connector& rhs);
58 Connector& operator=(const Connector& rhs);
59
60 // you have to free the memory yourself
61 static Connector* NewConnector(const pugi::xml_node& node, const std::string& sspVersion, const oms::ComRef& owner);
62
63 oms_status_enu_t exportToSSD(pugi::xml_node& root) const;
64 static std::string getTypeString(const pugi::xml_node& node, const std::string& sspVersion);
65 std::string getTypeString() const;
66 std::string getCausalityString() const;
67
68 operator std::string() const {return std::string(name);}
69
70 void setName(const oms::ComRef& name);
71 void setOwner(const oms::ComRef& owner);
72 void setGeometry(const oms::ssd::ConnectorGeometry* newGeometry);
73 oms_status_enu_t setExportName(const std::string & exportName) { this->exportName = exportName; return oms_status_ok;};
74 std::string getExportName() const { return this->exportName; }
75
76 std::map<std::string, std::map<std::string, std::string>> connectorUnits;
77 std::map<std::string, std::string> enumerationName;
78
79 const oms_causality_enu_t getCausality() const {return causality;}
80 const oms_signal_type_enu_t getType() const {return type;}
81 const oms::ComRef getOwner() const {return oms::ComRef(owner);}
82 const oms::ComRef getName() const {return oms::ComRef(name);}
83 const oms::ComRef getFullName() const {return getOwner() + getName();}
84 const oms::ssd::ConnectorGeometry* getGeometry() const {return reinterpret_cast<oms::ssd::ConnectorGeometry*>(geometry);}
85 Connector addPrefix(const ComRef& prefix) const;
86
87 bool isInput() const { return oms_causality_input == causality; }
88 bool isOutput() const { return oms_causality_output == causality; }
89 bool isParameter() const { return oms_causality_parameter == causality; }
90 bool isCalculatedParameter() const { return oms_causality_calculatedParameter == causality; }
91
92 bool isTypeBoolean() const { return oms_signal_type_boolean == type; }
93 bool isTypeInteger() const { return oms_signal_type_integer == type || oms_signal_type_enum == type; }
94 bool isTypeReal() const { return oms_signal_type_real == type; }
95 bool isTypeString() const { return oms_signal_type_string == type; }
96
97 private:
98 friend bool operator==(const Connector& v1, const Connector& v2);
99 friend bool operator!=(const Connector& v1, const Connector& v2);
100 std::string exportName;
101 };
102
103 bool operator==(const Connector& v1, const Connector& v2);
104 bool operator!=(const Connector& v1, const Connector& v2);
105}
106
107#endif
ComRef.h
ConnectorGeometry.h
oms::ComRef
ComRef - component reference.
Definition ComRef.h:47
oms::Connector
Connector.
Definition Connector.h:50
oms::Connector::exportToSSD
oms_status_enu_t exportToSSD(pugi::xml_node &root) const
Definition Connector.cpp:211
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:76
oms::Connector::getCausality
const oms_causality_enu_t getCausality() const
Definition Connector.h:79
oms::Connector::NewConnector
static Connector * NewConnector(const pugi::xml_node &node, const std::string &sspVersion, const oms::ComRef &owner)
Definition Connector.cpp:124
oms::Connector::getType
const oms_signal_type_enu_t getType() const
Definition Connector.h:80
oms::Connector::getName
const oms::ComRef getName() const
Definition Connector.h:82
oms::Connector::getOwner
const oms::ComRef getOwner() const
Definition Connector.h:81
oms::Connector::isTypeReal
bool isTypeReal() const
Definition Connector.h:94
oms::Connector::setName
void setName(const oms::ComRef &name)
Definition Connector.cpp:263
oms::Connector::addPrefix
Connector addPrefix(const ComRef &prefix) const
Definition Connector.cpp:295
oms::Connector::isTypeString
bool isTypeString() const
Definition Connector.h:95
oms::Connector::getExportName
std::string getExportName() const
Definition Connector.h:74
oms::Connector::setOwner
void setOwner(const oms::ComRef &owner)
Definition Connector.cpp:273
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:77
oms::Connector::~Connector
~Connector()
Definition Connector.cpp:81
oms::Connector::isTypeInteger
bool isTypeInteger() const
Definition Connector.h:93
oms::Connector::isCalculatedParameter
bool isCalculatedParameter() const
Definition Connector.h:90
oms::Connector::getCausalityString
std::string getCausalityString() const
Definition Connector.cpp:339
oms::Connector::isInput
bool isInput() const
Definition Connector.h:87
oms::Connector::getGeometry
const oms::ssd::ConnectorGeometry * getGeometry() const
Definition Connector.h:84
oms::Connector::operator==
friend bool operator==(const Connector &v1, const Connector &v2)
oms::Connector::isTypeBoolean
bool isTypeBoolean() const
Definition Connector.h:92
oms::Connector::getTypeString
std::string getTypeString() const
Definition Connector.cpp:312
oms::Connector::isParameter
bool isParameter() const
Definition Connector.h:89
oms::Connector::operator=
Connector & operator=(const Connector &rhs)
Definition Connector.cpp:102
oms::Connector::setGeometry
void setGeometry(const oms::ssd::ConnectorGeometry *newGeometry)
Definition Connector.cpp:283
oms::Connector::getFullName
const oms::ComRef getFullName() const
Definition Connector.h:83
oms::Connector::setExportName
oms_status_enu_t setExportName(const std::string &exportName)
Definition Connector.h:73
oms::Connector::isOutput
bool isOutput() const
Definition Connector.h:88
oms::Connector::exportName
std::string exportName
name to be used in result file
Definition Connector.h:100
oms::ssd::ConnectorGeometry
Definition ConnectorGeometry.h:46
oms
Definition AlgLoop.h:45
oms::operator==
bool operator==(const ComRef &lhs, const ComRef &rhs)
Definition ComRef.cpp:210
oms::operator!=
bool operator!=(const ComRef &lhs, const ComRef &rhs)
Definition ComRef.cpp:215