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

Loading...
Searching...
No Matches
Connection.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_CONNECTION_H_
33#define _OMS_CONNECTION_H_
34
35#include "ComRef.h"
36#include "Connector.h"
37#include "ssd/ConnectionGeometry.h"
38#include "OMSimulator/Types.h"
39
40#include <string>
41
42 namespace oms
43{
45 // * \brief Connection
46 // * /
47 class Connection : protected oms_connection_t
48 {
49 public:
50 Connection(const oms::ComRef& conA, const oms::ComRef& conB, bool suppressUnitConversion=false, oms_connection_type_enu_t type=oms_connection_single);
51 ~Connection();
52
53 // methods to copy the object
54 Connection(const Connection& rhs);
55 Connection& operator=(const Connection& rhs);
56
57 oms_status_enu_t exportToSSD(pugi::xml_node& root) const;
58
59 const oms::ComRef getSignalA() const {return oms::ComRef(conA);}
60 const oms::ComRef getSignalB() const {return oms::ComRef(conB);}
61
62 const oms::ssd::ConnectionGeometry* getGeometry() const {return reinterpret_cast<oms::ssd::ConnectionGeometry*>(geometry);}
63 void setGeometry(const oms::ssd::ConnectionGeometry* newGeometry, bool inverse=false);
64
65 oms_connection_type_enu_t getType() const {return type;}
66
67 bool isEqual(const oms::Connection& connection) const;
68 bool isEqual(const oms::ComRef& signalA, const oms::ComRef& signalB) const;
69 bool isStrictEqual(const oms::ComRef& signalA, const oms::ComRef& signalB) const;
70 bool containsSignal(const oms::ComRef& signal) const;
71 bool containsSignalB(const oms::ComRef& signal) const;
72
73 bool getSuppressUnitConversion() {return suppressUnitConversion;}
77 static bool isValid(const ComRef& crefA, const ComRef& crefB, const Connector& conA, const Connector& conB);
78 static bool isValidExportConnectorName(const Connector& conA, const Connector& conB);
79
80 static bool isValidUnits(const ComRef& crefA, const ComRef& crefB, const Connector& conA, const Connector& conB);
81 static void getSIUnits(const Connector& connector, std::map<std::string, std::string>& baseUnits);
82 oms_status_enu_t rename(const oms::ComRef& cref, const oms::ComRef& newCref);
83 private:
84 friend bool operator==(const Connection& lhs, const Connection& rhs);
85 friend bool operator!=(const Connection& lhs, const Connection& rhs);
86 };
87
88 inline bool operator==(const Connection& lhs, const Connection& rhs) {return lhs.isEqual(rhs);}
89 inline bool operator!=(const Connection& lhs, const Connection& rhs) {return !(lhs == rhs);}
90}
91
92#endif
ComRef.h
ConnectionGeometry.h
Connector.h
oms::ComRef
ComRef - component reference.
Definition ComRef.h:47
oms::Connection
**
Definition Connection.h:48
oms::Connection::containsSignal
bool containsSignal(const oms::ComRef &signal) const
Definition Connection.cpp:164
oms::Connection::getType
oms_connection_type_enu_t getType() const
Definition Connection.h:65
oms::Connection::getSIUnits
static void getSIUnits(const Connector &connector, std::map< std::string, std::string > &baseUnits)
Definition Connection.cpp:262
oms::Connection::isValidUnits
static bool isValidUnits(const ComRef &crefA, const ComRef &crefB, const Connector &conA, const Connector &conB)
Definition Connection.cpp:246
oms::Connection::operator!=
friend bool operator!=(const Connection &lhs, const Connection &rhs)
Definition Connection.h:89
oms::Connection::exportToSSD
oms_status_enu_t exportToSSD(pugi::xml_node &root) const
Definition Connection.cpp:112
oms::Connection::isEqual
bool isEqual(const oms::Connection &connection) const
Definition Connection.cpp:157
oms::Connection::isStrictEqual
bool isStrictEqual(const oms::ComRef &signalA, const oms::ComRef &signalB) const
"A->B" is not strict equal "B->A"
Definition Connection.cpp:147
oms::Connection::getGeometry
const oms::ssd::ConnectionGeometry * getGeometry() const
Definition Connection.h:62
oms::Connection::rename
oms_status_enu_t rename(const oms::ComRef &cref, const oms::ComRef &newCref)
Definition Connection.cpp:278
oms::Connection::getSignalB
const oms::ComRef getSignalB() const
Definition Connection.h:60
oms::Connection::operator==
friend bool operator==(const Connection &lhs, const Connection &rhs)
Definition Connection.h:88
oms::Connection::getSuppressUnitConversion
bool getSuppressUnitConversion()
Definition Connection.h:73
oms::Connection::setGeometry
void setGeometry(const oms::ssd::ConnectionGeometry *newGeometry, bool inverse=false)
Definition Connection.cpp:138
oms::Connection::getSignalA
const oms::ComRef getSignalA() const
Definition Connection.h:59
oms::Connection::operator=
Connection & operator=(const Connection &rhs)
Definition Connection.cpp:85
oms::Connection::containsSignalB
bool containsSignalB(const oms::ComRef &signal) const
Definition Connection.cpp:169
oms::Connection::isValidExportConnectorName
static bool isValidExportConnectorName(const Connector &conA, const Connector &conB)
Definition Connection.cpp:213
oms::Connection::~Connection
~Connection()
Definition Connection.cpp:61
oms::Connection::isValid
static bool isValid(const ComRef &crefA, const ComRef &crefB, const Connector &conA, const Connector &conB)
Checks a connection based on SSP-1.0 connection table.
Definition Connection.cpp:174
oms::Connector
Connector.
Definition Connector.h:50
oms::ssd::ConnectionGeometry
Definition ConnectionGeometry.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