DPsim
Loading...
Searching...
No Matches
Base_Ph1_Switch.h
Go to the documentation of this file.
1/* Copyright 2017-2021 Institute for Automation of Complex Power Systems,
2 * EONERC, RWTH Aachen University
3 *
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
7 *********************************************************************************/
8
9#pragma once
10
13
14namespace CPS {
15namespace Base {
16namespace Ph1 {
18class Switch {
19protected:
21
22public:
29
30 explicit Switch(CPS::AttributeList::Ptr attributeList)
31 : mOpenResistance(attributeList->create<Real>("R_open")),
32 mClosedResistance(attributeList->create<Real>("R_closed")),
33 mIsClosed(attributeList->create<Bool>("is_closed")){};
34
35 virtual ~Switch() = default;
36
38 void setParameters(Real openResistance, Real closedResistance,
39 Bool closed = false) {
40 **mOpenResistance = openResistance;
41 **mClosedResistance = closedResistance;
42 **mIsClosed = closed;
43 }
44
49 virtual void closeSwitch() { **mIsClosed = true; }
50
55 virtual void openSwitch() { **mIsClosed = false; }
56
58 void close() { closeSwitch(); }
60 void open() { openSwitch(); }
62 Bool isClosed() { return **mIsClosed; }
63};
64} // namespace Ph1
65} // namespace Base
66} // namespace CPS
AttributePointer< Attribute< T > > Ptr
Definition Attribute.h:249
std::shared_ptr< AttributeList > Ptr
void close()
Close switch.
const Attribute< Real >::Ptr mClosedResistance
Resistance if switch is closed [ohm].
Switch(CPS::AttributeList::Ptr attributeList)
Bool isClosed()
Check if switch is closed.
const Attribute< Real >::Ptr mOpenResistance
Resistance if switch is open [ohm].
virtual void closeSwitch()
virtual void openSwitch()
const Attribute< Bool >::Ptr mIsClosed
Defines if Switch is open or closed.
void setParameters(Real openResistance, Real closedResistance, Bool closed=false)
virtual ~Switch()=default
void open()
Open switch.
double Real
Definition Definitions.h:62
bool Bool
Definition Definitions.h:64