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-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_CONNECTION_H_
37#define _OMS_CONNECTION_H_
38
39#include "ComRef.h"
40#include "Connector.h"
41#include "ssd/ConnectionGeometry.h"
42#include "OMSimulator/Types.h"
43
44#include <string>
45
46 namespace oms
47{
49 // * \brief Connection
50 // * /
51 class Connection : protected oms_connection_t
52 {
53 public:
54 Connection(const oms::ComRef& conA, const oms::ComRef& conB, bool suppressUnitConversion=false, oms_connection_type_enu_t type=oms_connection_single);
55 ~Connection();
56
57 // methods to copy the object
58 Connection(const Connection& rhs);
59 Connection& operator=(const Connection& rhs);
60
61 oms_status_enu_t exportToSSD(pugi::xml_node& root) const;
62
63 const oms::ComRef getSignalA() const {return oms::ComRef(conA);}
64 const oms::ComRef getSignalB() const {return oms::ComRef(conB);}
65
66 const oms::ssd::ConnectionGeometry* getGeometry() const {return reinterpret_cast<oms::ssd::ConnectionGeometry*>(geometry);}
67 void setGeometry(const oms::ssd::ConnectionGeometry* newGeometry, bool inverse=false);
68
69 const oms_linear_transformation_t getLinearTransformation() const { return linearTransformation; }
70 void setLinearTransformation(double factor, double offset);
71
72 oms_connection_type_enu_t getType() const {return type;}
73
74 bool isEqual(const oms::Connection& connection) const;
75 bool isEqual(const oms::ComRef& signalA, const oms::ComRef& signalB) const;
76 bool isStrictEqual(const oms::ComRef& signalA, const oms::ComRef& signalB) const;
77 bool containsSignal(const oms::ComRef& signal) const;
78 bool containsSignalB(const oms::ComRef& signal) const;
79
80 bool getSuppressUnitConversion() {return suppressUnitConversion;}
84 static bool isValid(const ComRef& crefA, const ComRef& crefB, const Connector& conA, const Connector& conB);
85 static bool isValidExportConnectorName(const Connector& conA, const Connector& conB);
86
87 static bool isValidUnits(const ComRef& crefA, const ComRef& crefB, const Connector& conA, const Connector& conB);
88 static void getSIUnits(const Connector& connector, std::map<std::string, std::string>& baseUnits);
89 oms_status_enu_t rename(const oms::ComRef& cref, const oms::ComRef& newCref);
90 private:
91 friend bool operator==(const Connection& lhs, const Connection& rhs);
92 friend bool operator!=(const Connection& lhs, const Connection& rhs);
93 };
94
95 inline bool operator==(const Connection& lhs, const Connection& rhs) {return lhs.isEqual(rhs);}
96 inline bool operator!=(const Connection& lhs, const Connection& rhs) {return !(lhs == rhs);}
97}
98
99#endif
ComRef.h
ConnectionGeometry.h
Connector.h
oms::ComRef
ComRef - component reference.
Definition ComRef.h:51
oms::Connection
**
Definition Connection.h:52
oms::Connection::containsSignal
bool containsSignal(const oms::ComRef &signal) const
Definition Connection.cpp:182
oms::Connection::getType
oms_connection_type_enu_t getType() const
Definition Connection.h:72
oms::Connection::getSIUnits
static void getSIUnits(const Connector &connector, std::map< std::string, std::string > &baseUnits)
Definition Connection.cpp:280
oms::Connection::isValidUnits
static bool isValidUnits(const ComRef &crefA, const ComRef &crefB, const Connector &conA, const Connector &conB)
Definition Connection.cpp:264
oms::Connection::operator!=
friend bool operator!=(const Connection &lhs, const Connection &rhs)
Definition Connection.h:96
oms::Connection::exportToSSD
oms_status_enu_t exportToSSD(pugi::xml_node &root) const
Definition Connection.cpp:123
oms::Connection::getLinearTransformation
const oms_linear_transformation_t getLinearTransformation() const
Definition Connection.h:69
oms::Connection::isEqual
bool isEqual(const oms::Connection &connection) const
Definition Connection.cpp:175
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:165
oms::Connection::getGeometry
const oms::ssd::ConnectionGeometry * getGeometry() const
Definition Connection.h:66
oms::Connection::rename
oms_status_enu_t rename(const oms::ComRef &cref, const oms::ComRef &newCref)
Definition Connection.cpp:296
oms::Connection::getSignalB
const oms::ComRef getSignalB() const
Definition Connection.h:64
oms::Connection::operator==
friend bool operator==(const Connection &lhs, const Connection &rhs)
Definition Connection.h:95
oms::Connection::getSuppressUnitConversion
bool getSuppressUnitConversion()
Definition Connection.h:80
oms::Connection::setLinearTransformation
void setLinearTransformation(double factor, double offset)
Definition Connection.cpp:158
oms::Connection::setGeometry
void setGeometry(const oms::ssd::ConnectionGeometry *newGeometry, bool inverse=false)
Definition Connection.cpp:149
oms::Connection::getSignalA
const oms::ComRef getSignalA() const
Definition Connection.h:63
oms::Connection::operator=
Connection & operator=(const Connection &rhs)
Definition Connection.cpp:95
oms::Connection::containsSignalB
bool containsSignalB(const oms::ComRef &signal) const
Definition Connection.cpp:187
oms::Connection::isValidExportConnectorName
static bool isValidExportConnectorName(const Connector &conA, const Connector &conB)
Definition Connection.cpp:231
oms::Connection::~Connection
~Connection()
Definition Connection.cpp:70
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:192
oms::Connector
Connector.
Definition Connector.h:54
oms::ssd::ConnectionGeometry
Definition ConnectionGeometry.h:50
oms
Definition AlgLoop.h:52
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