DPsim
Loading...
Searching...
No Matches
TopologicalPowerComp.h
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
11#include <iostream>
12#include <memory>
13#include <typeinfo>
14#include <vector>
15
16#include <dpsim-models/IdentifiedObject.h>
17#include <dpsim-models/Logger.h>
18#include <dpsim-models/TopologicalNode.h>
19#include <dpsim-models/TopologicalTerminal.h>
20
21namespace CPS {
24class TopologicalPowerComp : public IdentifiedObject {
25public:
26 enum Behaviour { Initialization, MNASimulation, PFSimulation };
27
28protected:
30 UInt mNumTerminals = 0;
34 Logger::Log mSLog;
36 Logger::Level mLogLevel;
39 Behaviour mBehaviour = Behaviour::MNASimulation;
41 bool mParametersSet = false;
42
43public:
44 typedef std::shared_ptr<TopologicalPowerComp> Ptr;
45 typedef std::vector<Ptr> List;
46
48 TopologicalPowerComp(String uid, String name,
49 Logger::Level logLevel = Logger::Level::off)
50 : IdentifiedObject(uid, name),
51 /* We also want to set the CLI loglevel according to the logLevel
52 * std::max(Logger::Level::info, logLevel). But because of excessive
53 * logging to Level::info that is currently infeasible. */
54 mSLog(Logger::get(name, logLevel, Logger::Level::warn)),
55 mLogLevel(logLevel) {}
56
58 TopologicalPowerComp(String name, Logger::Level logLevel = Logger::Level::off)
59 : TopologicalPowerComp(name, name, logLevel) {}
60
62
64 virtual TopologicalNode::List topologicalNodes() = 0;
66 virtual TopologicalTerminal::List topologicalTerminals() = 0;
68 void setBehaviour(Behaviour behaviour) {
69 mBehaviour = behaviour;
70 if (mBehaviour == Behaviour::Initialization)
71 SPDLOG_LOGGER_INFO(mSLog, "Set component behaviour to Initialization");
72 else if (mBehaviour == Behaviour::PFSimulation)
73 SPDLOG_LOGGER_INFO(mSLog, "Set component behaviour to PFSimulation");
74 else if (mBehaviour == Behaviour::MNASimulation)
75 SPDLOG_LOGGER_INFO(mSLog, "Set component behaviour to MNASimulation");
76 else
77 SPDLOG_LOGGER_WARN(mSLog,
78 "Set component behaviour not fully supported yet");
79 }
80};
81} // namespace CPS
String uid()
Returns unique id.
UInt mNumTerminals
Determines the number of Terminals which can be connected to network Nodes.
Logger::Level mLogLevel
Component logger control for internal variables.
UInt mNumVirtualNodes
Determines the number of virtual or internal Nodes.
bool mParametersSet
Flag indicating that parameters are set via setParameters() function.
Logger::Log mSLog
Component logger.
virtual ~TopologicalPowerComp()
Destructor - does not do anything.
virtual TopologicalTerminal::List topologicalTerminals()=0
Returns terminal that are part of the component.
TopologicalPowerComp(String name, Logger::Level logLevel=Logger::Level::off)
Basic constructor that takes name and log level and sets the UID to name as well.
void setBehaviour(Behaviour behaviour)
Set behavior of component, e.g. initialization.
virtual TopologicalNode::List topologicalNodes()=0
Returns nodes connected to this component.
TopologicalPowerComp(String uid, String name, Logger::Level logLevel=Logger::Level::off)
Basic constructor that takes UID, name and log level.