Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
ControlElementContainer Class Reference

Class that can contain all control elements. Can identify (using RTTI) the elements from a generic list and store them separately. More...

#include <ControlElementContainer.h>

Public Member Functions

virtual void FillContainer (ControlEditor *editor)
 
virtual void FillContainer (std::vector< std::shared_ptr< ControlElement > > controlElementList, std::vector< std::shared_ptr< ConnectionLine > > connectionLineList)
 
virtual void GetContainerCopy (std::vector< std::shared_ptr< ControlElement > > &controlElementList, std::vector< std::shared_ptr< ConnectionLine > > &connectionLineList)
 
virtual void ClearContainer ()
 
std::vector< std::shared_ptr< ControlElement > > GetControlElementsList () const
 
std::vector< std::shared_ptr< ConnectionLine > > GetConnectionLineList () const
 
std::vector< Constant * > GetConstantList () const
 
std::vector< Exponential * > GetExponentialList () const
 
std::vector< Gain * > GetGainList () const
 
std::vector< IOControl * > GetIOControlList () const
 
std::vector< Limiter * > GetLimiterList () const
 
std::vector< Multiplier * > GetMultiplierList () const
 
std::vector< RateLimiter * > GetRateLimiterList () const
 
std::vector< Sum * > GetSumList () const
 
std::vector< TransferFunction * > GetTFList () const
 
std::vector< Divider * > GetDividerList () const
 
std::vector< MathExpression * > GetMathExprList () const
 

Protected Attributes

std::vector< std::shared_ptr< ControlElement > > m_ctrlElementsList
 
std::vector< std::shared_ptr< ConnectionLine > > m_cLineList
 
std::vector< Constant * > m_constantList
 
std::vector< Exponential * > m_exponentialList
 
std::vector< Gain * > m_gainList
 
std::vector< IOControl * > m_ioControlList
 
std::vector< Limiter * > m_limiterList
 
std::vector< Multiplier * > m_multiplierList
 
std::vector< RateLimiter * > m_rateLimiterList
 
std::vector< Sum * > m_sumList
 
std::vector< TransferFunction * > m_tfList
 
std::vector< Divider * > m_dividerList
 
std::vector< MathExpression * > m_mathExprList
 

Detailed Description

Class that can contain all control elements. Can identify (using RTTI) the elements from a generic list and store them separately.

Author
Thales Lima Oliveira thale.nosp@m.s@uf.nosp@m.u.br
Date
05/10/2017

Definition at line 47 of file ControlElementContainer.h.

Constructor & Destructor Documentation

◆ ControlElementContainer()

ControlElementContainer::ControlElementContainer ( )

Definition at line 26 of file ControlElementContainer.cpp.

27{
28 ClearContainer();
29}

◆ ~ControlElementContainer()

ControlElementContainer::~ControlElementContainer ( )

Definition at line 30 of file ControlElementContainer.cpp.

31{
32 //for (auto* cElement : m_cLineList) delete cElement;
33 //for (auto* cElement : m_constantList) delete cElement;
34 //for (auto* cElement : m_exponentialList) delete cElement;
35 //for (auto* cElement : m_gainList) delete cElement;
36 //for (auto* cElement : m_ioControlList) delete cElement;
37 //for (auto* cElement : m_limiterList) delete cElement;
38 //for (auto* cElement : m_multiplierList) delete cElement;
39 //for (auto* cElement : m_rateLimiterList) delete cElement;
40 //for (auto* cElement : m_sumList) delete cElement;
41 //for (auto* cElement : m_tfList) delete cElement;
42 //for (auto* cElement : m_dividerList) delete cElement;
43 //for (auto* cElement : m_mathExprList) delete cElement;
44 //ClearContainer();
45}

Member Function Documentation

◆ ClearContainer()

void ControlElementContainer::ClearContainer ( )
virtual

Definition at line 89 of file ControlElementContainer.cpp.

90{
91 m_cLineList.clear();
92 m_constantList.clear();
93 m_exponentialList.clear();
94 m_gainList.clear();
95 m_ioControlList.clear();
96 m_limiterList.clear();
97 m_multiplierList.clear();
98 m_rateLimiterList.clear();
99 m_sumList.clear();
100 m_tfList.clear();
101 m_dividerList.clear();
102 m_mathExprList.clear();
103}

◆ FillContainer() [1/2]

void ControlElementContainer::FillContainer ( ControlEditor editor)
virtual

Definition at line 46 of file ControlElementContainer.cpp.

47{
48 ClearContainer();
49 m_ctrlElementsList = editor->GetControlElementList();
50 m_cLineList = editor->GetConnectionLineList();
51
52 for (auto& cElement : m_ctrlElementsList) {
53 if (Constant* constant = dynamic_cast<Constant*>(cElement.get())) {
54 m_constantList.push_back(constant);
55 }
56 else if (Exponential* exponential = dynamic_cast<Exponential*>(cElement.get())) {
57 m_exponentialList.push_back(exponential);
58 }
59 else if (Gain* gain = dynamic_cast<Gain*>(cElement.get())) {
60 m_gainList.push_back(gain);
61 }
62 else if (IOControl* ioControl = dynamic_cast<IOControl*>(cElement.get())) {
63 m_ioControlList.push_back(ioControl);
64 }
65 else if (Limiter* limiter = dynamic_cast<Limiter*>(cElement.get())) {
66 m_limiterList.push_back(limiter);
67 }
68 else if (Multiplier* multiplier = dynamic_cast<Multiplier*>(cElement.get())) {
69 m_multiplierList.push_back(multiplier);
70 }
71 else if (RateLimiter* rateLimiter = dynamic_cast<RateLimiter*>(cElement.get())) {
72 m_rateLimiterList.push_back(rateLimiter);
73 }
74 else if (Sum* sum = dynamic_cast<Sum*>(cElement.get())) {
75 m_sumList.push_back(sum);
76 }
77 else if (TransferFunction* tf = dynamic_cast<TransferFunction*>(cElement.get())) {
78 m_tfList.push_back(tf);
79 }
80 else if (Divider* divider = dynamic_cast<Divider*>(cElement.get())) {
81 m_dividerList.push_back(divider);
82 }
83 else if (MathExpression* mathExpr = dynamic_cast<MathExpression*>(cElement.get())) {
84 m_mathExprList.push_back(mathExpr);
85 }
86 }
87}
A control element that provides a constant value.
Definition Constant.h:37
Control element that divides two inputs.
Definition Divider.h:33
Generates an output following an exponential function.
Definition Exponential.h:33
Provide an output multiplying the input by a constant.
Definition Gain.h:37
Provides the communication with the power element.
Definition IOControl.h:43
Limits the input value by superior and inferior values.
Definition Limiter.h:33
A generic math expression block that can perform math and conditional operations with the inputs.
Multiplies two inputs.
Definition Multiplier.h:33
Limits the rising and/or falling rate.
Definition RateLimiter.h:33
Sum the all inputs (can choose the input signal).
Definition Sum.h:34
Calculates the time response by a frequency domain transfer function.

◆ FillContainer() [2/2]

void ControlElementContainer::FillContainer ( std::vector< std::shared_ptr< ControlElement > >  controlElementList,
std::vector< std::shared_ptr< ConnectionLine > >  connectionLineList 
)
virtual

Definition at line 105 of file ControlElementContainer.cpp.

107{
108 ClearContainer();
109 m_ctrlElementsList = controlElementList;
110 m_cLineList = connectionLineList;
111
112 for (auto it = controlElementList.begin(), itEnd = controlElementList.end(); it != itEnd; ++it) {
113 if (Constant* constant = dynamic_cast<Constant*>(it->get())) {
114 m_constantList.push_back(constant);
115 }
116 else if (Exponential* exponential = dynamic_cast<Exponential*>(it->get())) {
117 m_exponentialList.push_back(exponential);
118 }
119 else if (Gain* gain = dynamic_cast<Gain*>(it->get())) {
120 m_gainList.push_back(gain);
121 }
122 else if (IOControl* ioControl = dynamic_cast<IOControl*>(it->get())) {
123 m_ioControlList.push_back(ioControl);
124 }
125 else if (Limiter* limiter = dynamic_cast<Limiter*>(it->get())) {
126 m_limiterList.push_back(limiter);
127 }
128 else if (Multiplier* multiplier = dynamic_cast<Multiplier*>(it->get())) {
129 m_multiplierList.push_back(multiplier);
130 }
131 else if (RateLimiter* rateLimiter = dynamic_cast<RateLimiter*>(it->get())) {
132 m_rateLimiterList.push_back(rateLimiter);
133 }
134 else if (Sum* sum = dynamic_cast<Sum*>(it->get())) {
135 m_sumList.push_back(sum);
136 }
137 else if (TransferFunction* tf = dynamic_cast<TransferFunction*>(it->get())) {
138 m_tfList.push_back(tf);
139 }
140 else if (Divider* divider = dynamic_cast<Divider*>(it->get())) {
141 m_dividerList.push_back(divider);
142 }
143 else if (MathExpression* mathExpr = dynamic_cast<MathExpression*>(it->get())) {
144 m_mathExprList.push_back(mathExpr);
145 }
146 }
147}

◆ GetConnectionLineList()

std::vector< std::shared_ptr< ConnectionLine > > ControlElementContainer::GetConnectionLineList ( ) const
inline

Definition at line 61 of file ControlElementContainer.h.

61{ return m_cLineList; }

◆ GetConstantList()

std::vector< Constant * > ControlElementContainer::GetConstantList ( ) const
inline

Definition at line 62 of file ControlElementContainer.h.

62{ return m_constantList; }

◆ GetContainerCopy()

void ControlElementContainer::GetContainerCopy ( std::vector< std::shared_ptr< ControlElement > > &  controlElementList,
std::vector< std::shared_ptr< ConnectionLine > > &  connectionLineList 
)
virtual

Definition at line 149 of file ControlElementContainer.cpp.

151{
152 controlElementList.clear();
153 connectionLineList.clear();
154
155 std::map<Element*, Element*> cLineMap;
156 std::map<Element*, Element*> cElementMap;
157
158 // Copy connection lines
159 for (auto& cLine : m_cLineList) {
160 ConnectionLine* copyLine = static_cast<ConnectionLine*>(cLine->GetCopy());
161 connectionLineList.emplace_back(copyLine);
162 cLineMap[cLine.get()] = copyLine;
163 }
164
165 // Copy elements (exept connection line).
166 std::map<Node*, Node*> nodeMap;
167 for (auto& cElement : m_ctrlElementsList) {
168 ControlElement* copyElement = static_cast<ControlElement*>(cElement->GetCopy());
169 cElementMap[cElement.get()] = copyElement;
170 controlElementList.emplace_back(copyElement);
171 // Copy nodes.
172 std::vector<Node*> nodeListCopy;
173 for (Node* node : copyElement->GetNodeList()) {
174 Node* copyNode = node->GetCopy();
175 nodeMap[node] = copyNode;
176 nodeListCopy.push_back(copyNode);
177 }
178 copyElement->SetNodeList(nodeListCopy);
179 }
180
181 // Correct the parent and child pointers
182 for (auto& copyElement : controlElementList) {
183 // Child
184 for (Element* child : copyElement->GetChildList()) {
185 auto it = cLineMap.find(child);
186 if (it != cLineMap.end())
187 copyElement->ReplaceChild(child, it->second);
188 }
189 }
190 for (auto& copyLine : connectionLineList) {
191 // Nodes
192 for (Node* node : copyLine->GetNodeList()) {
193 auto it = nodeMap.find(node);
194 if (it != nodeMap.end())
195 copyLine->ReplaceNode(node, it->second);
196 }
197
198 // Parent element
199 for (Element* parent : copyLine->GetParentList()) {
200 auto it = cElementMap.find(parent);
201 if (it != cElementMap.end())
202 copyLine->ReplaceParent(parent, it->second);
203 }
204 // Parent cLine
205 Element* parentLine = static_cast<Element*>(copyLine->GetParentLine());
206 auto it = cLineMap.find(parentLine);
207 if (it != cLineMap.end())
208 copyLine->SetParentLine(static_cast<ConnectionLine*>(it->second));
209 else
210 copyLine->SetParentLine(nullptr);
211
212 // Childs
213 for (Element* child : copyLine->GetChildList()) {
214 auto it = cLineMap.find(child);
215
216 if (it != cLineMap.end())
217 copyLine->ReplaceChild(child, it->second);
218 }
219 }
220
221 //int nodeID = 0;
222 //for (auto it = m_ctrlElementsList.begin(), itEnd = m_ctrlElementsList.end(); it != itEnd; ++it) {
223 // ControlElement* oldElement = *it;
224 // ControlElement* copy = static_cast<ControlElement*>(oldElement->GetCopy());
225 // controlElementList.push_back(copy);
226 // // Copy nodes.
227 // std::vector<Node*> nodeList = copy->GetNodeList();
228 // std::vector<Node*> nodeListCopy;
229 // for (auto itN = nodeList.begin(), itEndN = nodeList.end(); itN != itEndN; ++itN) {
230 // Node* node = *itN;
231 // node->SetID(nodeID);
232 // Node* copyNode = new Node();
233 // *copyNode = *node;
234 // nodeListCopy.push_back(copyNode);
235 // nodeID++;
236 // }
237 // copy->SetNodeList(nodeListCopy);
238 //
239 // // Replace children to copies.
240 // auto childList = copy->GetChildList();
241 // for (auto itC = childList.begin(), itEndC = childList.end(); itC != itEndC; ++itC) {
242 // ConnectionLine* child = static_cast<ConnectionLine*>(*itC);
243 // // Replace child's parent to copy.
244 // for (auto itCL = connectionLineList.begin(), itEndCL = connectionLineList.end(); itCL != itEndCL; ++itCL) {
245 // ConnectionLine* copyLine = *itCL;
246 // if (copyLine->GetID() == child->GetID()) {
247 // // Replace node.
248 // nodeList = child->GetNodeList();
249 // for (auto itN = nodeList.begin(), itEndN = nodeList.end(); itN != itEndN; ++itN) {
250 // Node* node = *itN;
251 // for (auto itCN = nodeListCopy.begin(), itEndCN = nodeListCopy.end(); itCN != itEndCN; ++itCN) {
252 // Node* nodeCopy = *itCN;
253 // if (node->GetID() == nodeCopy->GetID()) {
254 // copyLine->ReplaceNode(node, nodeCopy);
255 // break;
256 // }
257 // }
258 // }
259 // copyLine->ReplaceParent(oldElement, copy);
260 // copy->ReplaceChild(child, copyLine);
261 // }
262 // }
263 // }
264 //}
265}
Connection between two control elements or other connection line and an element.
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:112
virtual void ReplaceParent(Element *oldParent, Element *newParent)
Replace a parent.
Definition Element.cpp:559
virtual void ReplaceChild(Element *oldChild, Element *newChild)
Replace a child from the list.
Definition Element.cpp:575
Node of a control element. This class manages the user interaction with the connection and control el...

◆ GetControlElementsList()

std::vector< std::shared_ptr< ControlElement > > ControlElementContainer::GetControlElementsList ( ) const
inline

Definition at line 60 of file ControlElementContainer.h.

60{ return m_ctrlElementsList; }

◆ GetDividerList()

std::vector< Divider * > ControlElementContainer::GetDividerList ( ) const
inline

Definition at line 71 of file ControlElementContainer.h.

71{ return m_dividerList; }

◆ GetExponentialList()

std::vector< Exponential * > ControlElementContainer::GetExponentialList ( ) const
inline

Definition at line 63 of file ControlElementContainer.h.

63{ return m_exponentialList; }

◆ GetGainList()

std::vector< Gain * > ControlElementContainer::GetGainList ( ) const
inline

Definition at line 64 of file ControlElementContainer.h.

64{ return m_gainList; }

◆ GetIOControlList()

std::vector< IOControl * > ControlElementContainer::GetIOControlList ( ) const
inline

Definition at line 65 of file ControlElementContainer.h.

65{ return m_ioControlList; }

◆ GetLimiterList()

std::vector< Limiter * > ControlElementContainer::GetLimiterList ( ) const
inline

Definition at line 66 of file ControlElementContainer.h.

66{ return m_limiterList; }

◆ GetMathExprList()

std::vector< MathExpression * > ControlElementContainer::GetMathExprList ( ) const
inline

Definition at line 72 of file ControlElementContainer.h.

72{ return m_mathExprList; }

◆ GetMultiplierList()

std::vector< Multiplier * > ControlElementContainer::GetMultiplierList ( ) const
inline

Definition at line 67 of file ControlElementContainer.h.

67{ return m_multiplierList; }

◆ GetRateLimiterList()

std::vector< RateLimiter * > ControlElementContainer::GetRateLimiterList ( ) const
inline

Definition at line 68 of file ControlElementContainer.h.

68{ return m_rateLimiterList; }

◆ GetSumList()

std::vector< Sum * > ControlElementContainer::GetSumList ( ) const
inline

Definition at line 69 of file ControlElementContainer.h.

69{ return m_sumList; }

◆ GetTFList()

std::vector< TransferFunction * > ControlElementContainer::GetTFList ( ) const
inline

Definition at line 70 of file ControlElementContainer.h.

70{ return m_tfList; }

Member Data Documentation

◆ m_cLineList

std::vector< std::shared_ptr<ConnectionLine> > ControlElementContainer::m_cLineList
protected

Definition at line 75 of file ControlElementContainer.h.

◆ m_constantList

std::vector<Constant*> ControlElementContainer::m_constantList
protected

Definition at line 77 of file ControlElementContainer.h.

◆ m_ctrlElementsList

std::vector< std::shared_ptr<ControlElement> > ControlElementContainer::m_ctrlElementsList
protected

Definition at line 74 of file ControlElementContainer.h.

◆ m_dividerList

std::vector<Divider*> ControlElementContainer::m_dividerList
protected

Definition at line 86 of file ControlElementContainer.h.

◆ m_exponentialList

std::vector<Exponential*> ControlElementContainer::m_exponentialList
protected

Definition at line 78 of file ControlElementContainer.h.

◆ m_gainList

std::vector<Gain*> ControlElementContainer::m_gainList
protected

Definition at line 79 of file ControlElementContainer.h.

◆ m_ioControlList

std::vector<IOControl*> ControlElementContainer::m_ioControlList
protected

Definition at line 80 of file ControlElementContainer.h.

◆ m_limiterList

std::vector<Limiter*> ControlElementContainer::m_limiterList
protected

Definition at line 81 of file ControlElementContainer.h.

◆ m_mathExprList

std::vector<MathExpression*> ControlElementContainer::m_mathExprList
protected

Definition at line 87 of file ControlElementContainer.h.

◆ m_multiplierList

std::vector<Multiplier*> ControlElementContainer::m_multiplierList
protected

Definition at line 82 of file ControlElementContainer.h.

◆ m_rateLimiterList

std::vector<RateLimiter*> ControlElementContainer::m_rateLimiterList
protected

Definition at line 83 of file ControlElementContainer.h.

◆ m_sumList

std::vector<Sum*> ControlElementContainer::m_sumList
protected

Definition at line 84 of file ControlElementContainer.h.

◆ m_tfList

std::vector<TransferFunction*> ControlElementContainer::m_tfList
protected

Definition at line 85 of file ControlElementContainer.h.


The documentation for this class was generated from the following files: