Power System Platform  2026w23a-beta
Loading...
Searching...
No Matches
Load Class Reference

Loas shunt power element. More...

#include <Load.h>

Inheritance diagram for Load:
Collaboration diagram for Load:

Public Member Functions

 Load (wxString name)
 
virtual ElementGetCopy ()
 Get a the element copy.
 
virtual bool AddParent (Element *parent, wxPoint2DDouble position)
 Add a parent to the element. This method must be used on power elements that connect to a bus, so the parent must be a bus. The element basic points are calculated in this method, so apply this when the element is being inserted.
 
virtual void DrawDC (GUIColour *guiColour, wxPoint2DDouble translation, double scale, wxGraphicsContext *gc) const
 Draw the element using GDI+.
 
virtual void DrawDC (GUIColour *guiColour, wxPoint2DDouble translation, double scale, wxDC &dc) const
 Draw the element using wxDC.
 
virtual void Rotate (bool clockwise=true)
 Rotate the element.
 
virtual bool GetContextMenu (wxMenu &menu)
 Get the element contex menu.
 
virtual wxString GetTipText () const
 Get the tip text.
 
virtual bool ShowForm (wxWindow *parent, Element *element, wxWindow *workspace=nullptr)
 Show element data form.
 
LoadElectricalData GetElectricalData ()
 
LoadElectricalDataGetElectricalDataRef ()
 
LoadElectricalData GetPUElectricalData (double systemPowerBase)
 
void SetElectricalData (const LoadElectricalData &electricalData)
 
virtual bool GetPlotData (ElementPlotData &plotData, PlotStudy study=PlotStudy::STABILITY)
 Fill the plot data.
 
virtual rapidxml::xml_node * SaveElement (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementListNode)
 
virtual bool OpenElement (rapidxml::xml_node<> *elementNode, std::vector< Element * > parentList)
 
- Public Member Functions inherited from Shunt
virtual bool Contains (wxPoint2DDouble position) const
 Checks if the element contains a position.
 
virtual bool Intersects (wxRect2DDouble rect) const
 Check if the element's rect intersects other rect.
 
virtual void Move (wxPoint2DDouble position)
 Move the element other position.
 
virtual void MoveNode (Element *element, wxPoint2DDouble position)
 Move a node. StartMove(wxPoint2DDouble position) before start moving.
 
virtual void StartMove (wxPoint2DDouble position)
 Update the element attributes related to the movement.
 
virtual void RotateNode (Element *parent, bool clockwise=true)
 Rotate a node.
 
virtual void RemoveParent (Element *parent)
 Remove a parent.
 
virtual bool NodeContains (wxPoint2DDouble position)
 Check if a node contains a point. If contains, set the attributes related to node movement.
 
virtual bool SetNodeParent (Element *parent)
 Set a perent to the node. If all conditions are met, a new parent are added to the element and the points related to the nodes will be calculated.
 
virtual void UpdateNodes ()
 Update the nodes according to the parents. If a parent is removed, use this method.
 
- Public Member Functions inherited from PowerElement
 PowerElement ()
 Constructor.
 
virtual ~PowerElement ()
 Destructor.
 
virtual wxPoint2DDouble GetSwitchPoint (Element *parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const
 Get the correct switch position.
 
virtual bool SwitchesContains (wxPoint2DDouble position) const
 Check if switch contains position.
 
virtual void UpdateSwitches ()
 Update the switch position.
 
virtual void DrawDCSwitches (GUIColour *guiColour, wxGraphicsContext *gc) const
 Draw switch.
 
virtual void DrawDCSwitches (GUIColour *guiColour, wxDC &dc) const
 
virtual void CalculatePowerFlowPts (std::vector< wxPoint2DDouble > edges)
 Calculate the points of the power flow arrows.
 
virtual void DrawDCPowerFlowPts (GUIColour *guiColour, wxGraphicsContext *gc) const
 Draw power flow arrows.
 
virtual void DrawDCPowerFlowPts (GUIColour *guiColour, wxDC &dc) const
 
virtual void SetNominalVoltage (std::vector< double > nominalVoltage, std::vector< ElectricalUnit > nominalVoltageUnit)
 Set nominal voltage of the element.
 
virtual void SetSwitchingData (SwitchingData data)
 Set the switching data of the element.
 
virtual SwitchingData GetSwitchingData ()
 Returns the switching data of the element.
 
virtual void SetPowerFlowDirection (PowerFlowDirection pfDirection)
 Set the direction of the power flow.
 
virtual PowerFlowDirection GetPowerFlowDirection () const
 Return the direction of the power flow.
 
virtual bool HaveDynamicEvent () const
 Check if the power element have dynamic event.
 
virtual void SetDynamicEvent (bool dynEvent=true)
 Set if the power element have dynamic event.
 
virtual double GetValueFromUnit (double value, ElectricalUnit valueUnit) const
 
virtual void SaveCADProperties (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode)
 
virtual void SaveSwitchingData (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *electricalNode)
 
virtual bool OpenCADProperties (rapidxml::xml_node<> *elementNode, std::vector< Element * > parentList)
 
virtual bool OpenSwitchingData (rapidxml::xml_node<> *electricalNode)
 
- Public Member Functions inherited from Element
 Element ()
 Constructor.
 
virtual ~Element ()
 Destructor.
 
void SetDragging (bool dragging=true)
 Set if the element are being dragged.
 
void SetHeight (double height)
 Set element height.
 
void SetPosition (const wxPoint2DDouble position)
 Set the element position and update the rectangle.
 
void SetSelected (bool selected=true)
 Set element selection.
 
void SetWidth (double width)
 Set element width.
 
void SetAngle (double angle)
 Set element angle.
 
void ShowPickbox (bool showPickbox=true)
 Set if the pickbox is shown.
 
void SetBorderSize (double borderSize)
 Set the size of the border (shown in selected elements).
 
bool SetOnline (bool online=true)
 Set if the element is online or offline.
 
virtual void SetPointList (std::vector< wxPoint2DDouble > pointList)
 Set the list of points that connect the element to the bus.
 
ElementType GetElementType ()
 
wxRect2DDouble GetRect () const
 Get the element rectangle.
 
wxPoint2DDouble GetPosition () const
 Get the element position.
 
bool IsDragging () const
 Checks if the element is being dragged.
 
double GetHeight () const
 Get the element height.
 
bool IsSelected () const
 Checks if the element is selected.
 
double GetWidth () const
 Get the element width.
 
double GetAngle () const
 Get the element angle.
 
double GetRotationAngle () const
 Get the angle of rotation.
 
bool IsPickboxShown () const
 Checks if the pickbox is shown.
 
bool IsOnline () const
 Checks if the element is online or offline.
 
virtual std::vector< wxPoint2DDouble > GetPointList () const
 Get the list of points that connect the element to bus.
 
virtual void AddParent (Element *parent)
 Add a parent to the element.
 
virtual void SetID (int id)
 Set the element ID.
 
virtual int GetID () const
 Get the element ID.
 
virtual void AddChild (Element *child)
 Add a child to the child list.
 
virtual void RemoveChild (Element *child)
 Remove a child from the list.
 
virtual void ReplaceChild (Element *oldChild, Element *newChild)
 Replace a child from the list.
 
virtual void AddPoint (wxPoint2DDouble point)
 Add point to the list of points that connect the element to the bus.
 
void SetParent (Element *parent, int num)
 
void SetChild (Element *child, int num)
 
virtual void ReplaceParent (Element *oldParent, Element *newParent)
 Replace a parent.
 
virtual bool PickboxContains (wxPoint2DDouble position)
 Check if a pickbox contains a point. If contains the attributes related to pickbox movement will be calculated.
 
virtual void MovePickbox (wxPoint2DDouble position)
 Move the pickbox.
 
virtual wxCursor GetBestPickboxCursor () const
 Get the best cursor to shown to the user when the mouse is above a pickbox.
 
virtual void ResetPickboxes ()
 Remove the pickboxes.
 
virtual void ResetNodes ()
 Remove the active nodes.
 
virtual wxPoint2DDouble WorldToScreen (wxPoint2DDouble translation, double scale, double offsetX=0.0, double offsetY=0.0) const
 Convert the element position to screen position.
 
virtual wxPoint2DDouble WorldToScreen (wxPoint2DDouble position, wxPoint2DDouble translation, double scale, double offsetX=0.0, double offsetY=0.0) const
 Convert a generic position to screen position.
 
virtual bool RotatedRectanglesIntersects (wxRect2DDouble rect1, wxRect2DDouble rect2, double angle1, double angle2) const
 Check if two roteted rectangles intersect.
 
virtual void DrawDCRectangle (wxPoint2DDouble position, double width, double height, double angle, wxDC &dc) const
 Draw a circle.
 
virtual void DrawDCRoundedRectRotated (wxDC &dc, const wxPoint2DDouble &center, double width, double height, double radius, double angleDeg, int arcSegments=8) const
 
virtual void DrawDCCircle (wxPoint2DDouble position, double radius, int numSegments, wxGraphicsContext *gc) const
 Draw a circle using device context.
 
virtual void DrawDCCircle (wxPoint2DDouble position, double radius, wxDC &dc) const
 
virtual void DrawDCArc (wxPoint2DDouble position, double radius, double initAngle, double finalAngle, int numSegments, wxGraphicsContext *gc) const
 
virtual void DrawDCArc (wxPoint2DDouble position, double radius, double initAngle, double finalAngle, wxDC &dc) const
 
virtual void DrawDCTriangle (std::vector< wxPoint2DDouble > points, wxGraphicsContext *gc) const
 Draw rectangle.
 
virtual void DrawDCTriangle (std::vector< wxPoint > points, wxDC &dc) const
 
virtual void DrawDCPickbox (wxPoint2DDouble position, wxGraphicsContext *gc) const
 Draw a point.
 
virtual wxPoint2DDouble RotateAtPosition (wxPoint2DDouble pointToRotate, double angle, bool degrees=true) const
 Rotate a point as element position being the origin.
 
virtual wxPoint2DDouble RotateLocal (wxPoint2DDouble local, double angleDeg) const
 
virtual wxPoint RotateAround (const wxPoint2DDouble &p, const wxPoint2DDouble &center, double angleDeg) const
 
virtual std::vector< Element * > GetParentList () const
 Get the parent list.
 
virtual std::vector< Element * > GetChildList () const
 Get the Child list.
 
virtual void CalculateBoundaries (wxPoint2DDouble &leftUp, wxPoint2DDouble &rightBottom) const
 Calculate the element boundaries.
 
virtual void GeneralMenuItens (wxMenu &menu)
 Insert general itens to context menu.
 
virtual double PointToLineDistance (wxPoint2DDouble point, int *segmentNumber=nullptr) const
 Calculate the distance between a line (formed by point list) and a point.
 
bool IsInserted () const
 Check if the element is properly inserted in the workspace.
 
void SetInserted (bool inserted=true)
 Set if the element is properly inserted in the workspace.
 
virtual bool OpenElement (rapidxml::xml_node<> *elementNode)
 
void SaveCADProperties (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode)
 
bool OpenCADProperties (rapidxml::xml_node<> *elementNode)
 

Protected Attributes

std::vector< wxPoint2DDouble > m_triangPts
 
LoadElectricalData m_electricalData
 
- Protected Attributes inherited from PowerElement
SwitchingData m_swData
 
std::vector< std::vector< wxPoint2DDouble > > m_powerFlowArrow
 
PowerFlowDirection m_pfDirection = PowerFlowDirection::PF_NONE
 
wxColour m_busColour
 
wxColour m_onlineElementColour
 
wxColour m_offlineElementColour
 
wxColour m_closedSwitchColour
 
wxColour m_openedSwitchColour
 
wxColour m_powerFlowArrowColour
 
wxColour m_dynamicEventColour
 
bool m_dynEvent = false
 
- Protected Attributes inherited from Element
ElementType m_elementType = ElementType::TYPE_NONE
 
int m_elementID = 0
 
std::vector< Element * > m_parentList
 
std::vector< Element * > m_childList
 
wxRect2DDouble m_rect
 
wxPoint2DDouble m_position
 
double m_width = 0.0
 
double m_height = 0.0
 
double m_angle = 0.0
 
double m_borderSize = 2.0
 
double m_rotationAngle = 45.0
 
double m_switchSize = 10.0
 
std::vector< wxRect2DDouble > m_switchRect
 
bool m_selected = false
 
bool m_dragging = false
 
bool m_showPickbox = false
 
bool m_inserted = false
 
int m_activePickboxID = ID_PB_NONE
 
int m_activeNodeID = 0
 
std::vector< wxPoint2DDouble > m_pointList
 
std::vector< wxPoint2DDouble > m_movePts
 
wxPoint2DDouble m_moveStartPt
 
wxPoint2DDouble m_movePos
 
bool m_online = true
 

Additional Inherited Members

- Static Public Member Functions inherited from Element
static bool DoubleFromString (wxWindow *parent, wxString strValue, double &value, wxString errorMsg)
 Get a double value from a string. Show a error message if the conversion fail.
 
static bool IntFromString (wxWindow *parent, wxString strValue, int &value, wxString errorMsg)
 Convert a string to int. Show a error message if the conversion fail.
 
static wxString StringFromDouble (double value, int minDecimal=1, int maxDecimals=13)
 Convert a double value to string.
 
- Protected Member Functions inherited from Shunt
void UpdateSwitchesPosition ()
 
void UpdatePowerFlowArrowsPosition ()
 
void DrawDCGround (wxPoint2DDouble position, wxGraphicsContext *gc) const
 
void DrawDCGround (wxPoint2DDouble position, wxDC &dc) const
 

Detailed Description

Loas shunt power element.

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

Definition at line 73 of file Load.h.

Constructor & Destructor Documentation

◆ Load() [1/2]

Load::Load ( )

Definition at line 21 of file Load.cpp.

21 : Shunt()
22{
23 m_elementType = TYPE_LOAD;
24}
Abstract class for shunt power elements.
Definition Shunt.h:32

◆ Load() [2/2]

Load::Load ( wxString  name)

Definition at line 26 of file Load.cpp.

26 : Shunt()
27{
28 m_elementType = TYPE_LOAD;
29 m_electricalData.name = name;
30}

◆ ~Load()

Load::~Load ( )

Definition at line 32 of file Load.cpp.

32{}

Member Function Documentation

◆ AddParent()

bool Load::AddParent ( Element parent,
wxPoint2DDouble  position 
)
virtual

Add a parent to the element. This method must be used on power elements that connect to a bus, so the parent must be a bus. The element basic points are calculated in this method, so apply this when the element is being inserted.

Parameters
parentElement parent.
positionNode position in the parent.

Reimplemented from Element.

Definition at line 34 of file Load.cpp.

35{
36 if (parent) {
37 m_parentList.push_back(parent);
38 parent->AddChild(this);
39 wxPoint2DDouble parentPt =
40 parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position.
41 parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus.
42 parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back.
43
44 m_position = parentPt + wxPoint2DDouble(0.0, 100.0); // Shifts the position to the down of the bus.
45 m_width = m_height = 20.0;
46 m_rect = wxRect2DDouble(m_position.m_x - 10.0, m_position.m_y - 10.0, m_width, m_height);
47
48 m_pointList.push_back(parentPt);
49 m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_position));
50 m_pointList.push_back(m_position + wxPoint2DDouble(0.0, -20.0));
51 m_pointList.push_back(m_position + wxPoint2DDouble(0.0, -10.0));
52
53 m_triangPts.push_back(wxPoint2DDouble(-m_width / 2.0, -m_height / 2.0));
54 m_triangPts.push_back(wxPoint2DDouble(m_width / 2.0, -m_height / 2.0));
55 m_triangPts.push_back(wxPoint2DDouble(0.0, m_height / 2.0));
56
57 m_inserted = true;
58
59 wxRect2DDouble genRect(0, 0, 0, 0);
60 m_switchRect.push_back(genRect); // Push a general rectangle.
63 UpdatePowerFlowArrowsPosition();
64
65 return true;
66 }
67 return false;
68}
wxPoint2DDouble GetPosition() const
Get the element position.
Definition Element.h:188
double GetAngle() const
Get the element angle.
Definition Element.h:213
virtual wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees=true) const
Rotate a point as element position being the origin.
Definition Element.cpp:228
virtual void AddChild(Element *child)
Add a child to the child list.
Definition Element.cpp:499
virtual void UpdateSwitches()
Update the switch position.
virtual wxPoint2DDouble GetSwitchPoint(Element *parent, wxPoint2DDouble parentPoint, wxPoint2DDouble secondPoint) const
Get the correct switch position.
Here is the call graph for this function:

◆ DrawDC() [1/2]

void Load::DrawDC ( GUIColour guiColour,
wxPoint2DDouble  translation,
double  scale,
wxDC &  dc 
) const
virtual

Draw the element using wxDC.

Parameters
guiColourColours of the system defined in properties.
translationTranslation of the system.
scaleScale of the system.
dcDevice context.

Reimplemented from Element.

Definition at line 139 of file Load.cpp.

140{
141 wxColour elementColour;
142 if (m_online) {
143 if (m_dynEvent)
144 elementColour = guiColour->eventElement;
145 else
146 elementColour = guiColour->enabled;
147 }
148 else
149 elementColour = guiColour->disable;
150
151 std::vector<wxPoint> pointListInt;
152 for (auto& pt : m_pointList) {
153 pointListInt.emplace_back(static_cast<int>(pt.m_x), static_cast<int>(pt.m_y));
154 }
155 wxPoint pos = wxPoint(static_cast<int>(m_position.m_x), static_cast<int>(m_position.m_y));
156
157 if (m_inserted) {
158 // Draw Selection (layer 1).
159 if (m_selected) {
160 dc.SetPen(wxPen(guiColour->selection, 2 + m_borderSize * 2.0));
161 dc.SetBrush(*wxTRANSPARENT_BRUSH);
162
163 dc.DrawLines(pointListInt.size(), &pointListInt[0]);
164
165 dc.SetPen(*wxTRANSPARENT_PEN);
166 dc.SetBrush(wxBrush(guiColour->selection));
167
168 wxPoint2DDouble p;
169 wxPoint selTriangPts[3];
170 p = m_triangPts[0] + m_position + wxPoint2DDouble(-m_borderSize / scale, -m_borderSize / scale);
171 selTriangPts[0] = RotateAround(p, m_position, m_angle);
172 p = m_triangPts[1] + m_position + wxPoint2DDouble(m_borderSize / scale, -m_borderSize / scale);
173 selTriangPts[1] = RotateAround(p, m_position, m_angle);
174 p = m_triangPts[2] + m_position + wxPoint2DDouble(0.0, m_borderSize / scale);
175 selTriangPts[2] = RotateAround(p, m_position, m_angle);
176
177 dc.DrawPolygon(3, selTriangPts);
178
179 // Draw node selection.
180 DrawDCCircle(m_pointList[0], 5.0 + m_borderSize / scale, dc);
181 }
182
183 // Draw Load (layer 2).
184 dc.SetPen(wxPen(elementColour, 2));
185 dc.SetBrush(*wxTRANSPARENT_BRUSH);
186 dc.DrawLines(pointListInt.size(), &pointListInt[0]);
187
188 // Draw node.
189 dc.SetPen(*wxTRANSPARENT_PEN);
190 dc.SetBrush(wxBrush(elementColour));
191 DrawDCCircle(m_pointList[0], 5.0, dc);
192
193 DrawDCSwitches(guiColour, dc);
194 DrawDCPowerFlowPts(guiColour, dc);
195
196 wxPoint2DDouble p;
197 wxPoint triangPts[3];
198
199 //std::vector<wxPoint2DDouble> triangPts;
200 for (int i = 0; i < 3; i++) {
201 p = m_triangPts[i] + m_position;
202 triangPts[i] = RotateAround(p, m_position, m_angle);
203 }
204 dc.SetPen(*wxTRANSPARENT_PEN);
205 dc.SetBrush(wxBrush(elementColour));
206 dc.DrawPolygon(3, triangPts);
207 }
208}
virtual void DrawDCCircle(wxPoint2DDouble position, double radius, int numSegments, wxGraphicsContext *gc) const
Draw a circle using device context.
Definition Element.cpp:173
virtual void DrawDCPowerFlowPts(GUIColour *guiColour, wxGraphicsContext *gc) const
Draw power flow arrows.
virtual void DrawDCSwitches(GUIColour *guiColour, wxGraphicsContext *gc) const
Draw switch.
Here is the call graph for this function:

◆ DrawDC() [2/2]

void Load::DrawDC ( GUIColour guiColour,
wxPoint2DDouble  translation,
double  scale,
wxGraphicsContext *  gc 
) const
virtual

Draw the element using GDI+.

Parameters
guiColourColours of the system defined in properties.
translationTranslation of the system.
scaleScale of the system.
gcGraphics context

Reimplemented from Element.

Definition at line 70 of file Load.cpp.

71{
72 wxColour elementColour;
73 if (m_online) {
74 if (m_dynEvent)
75 elementColour = guiColour->eventElement;
76 else
77 elementColour = guiColour->enabled;
78 }
79 else
80 elementColour = guiColour->disable;
81
82 if (m_inserted) {
83 // Draw Selection (layer 1).
84 if (m_selected) {
85 gc->SetPen(wxPen(guiColour->selection, 2 + m_borderSize * 2.0));
86 gc->SetBrush(*wxTRANSPARENT_BRUSH);
87
88 gc->StrokeLines(m_pointList.size(), &m_pointList[0]);
89
90 gc->SetPen(*wxTRANSPARENT_PEN);
91 gc->SetBrush(wxBrush(guiColour->selection));
92
93 std::vector<wxPoint2DDouble> selTriangPts;
94 selTriangPts.push_back(m_triangPts[0] + m_position +
95 wxPoint2DDouble(-m_borderSize / scale, -m_borderSize / scale));
96 selTriangPts.push_back(m_triangPts[1] + m_position +
97 wxPoint2DDouble(m_borderSize / scale, -m_borderSize / scale));
98 selTriangPts.push_back(m_triangPts[2] + m_position + wxPoint2DDouble(0.0, m_borderSize / scale));
99
100 // Push the current matrix on stack.
101 gc->PushState();
102 // Rotate the matrix around the object position.
103 gc->Translate(m_position.m_x, m_position.m_y);
104 gc->Rotate(wxDegToRad(m_angle));
105 gc->Translate(-m_position.m_x, -m_position.m_y);
106 DrawDCTriangle(selTriangPts, gc);
107 gc->PopState();
108
109 // Draw node selection.
110 DrawDCCircle(m_pointList[0], 5.0 + m_borderSize / scale, 10, gc);
111 }
112
113 // Draw Load (layer 2).
114 gc->SetPen(wxPen(elementColour, 2));
115 gc->SetBrush(*wxTRANSPARENT_BRUSH);
116 gc->StrokeLines(m_pointList.size(), &m_pointList[0]);
117
118 // Draw node.
119 gc->SetPen(*wxTRANSPARENT_PEN);
120 gc->SetBrush(wxBrush(elementColour));
121 DrawDCCircle(m_pointList[0], 5.0, 10, gc);
122
123 DrawDCSwitches(guiColour, gc);
124 DrawDCPowerFlowPts(guiColour, gc);
125
126 std::vector<wxPoint2DDouble> triangPts;
127 for (int i = 0; i < 3; i++) { triangPts.push_back(m_triangPts[i] + m_position); }
128 gc->PushState();
129 gc->Translate(m_position.m_x, m_position.m_y);
130 gc->Rotate(wxDegToRad(m_angle));
131 gc->Translate(-m_position.m_x, -m_position.m_y);
132 gc->SetPen(*wxTRANSPARENT_PEN);
133 gc->SetBrush(wxBrush(elementColour));
134 DrawDCTriangle(triangPts, gc);
135 gc->PopState();
136 }
137}
virtual void DrawDCTriangle(std::vector< wxPoint2DDouble > points, wxGraphicsContext *gc) const
Draw rectangle.
Definition Element.cpp:209
Here is the call graph for this function:

◆ GetContextMenu()

bool Load::GetContextMenu ( wxMenu &  menu)
virtual

Get the element contex menu.

Parameters
menumenu that will be inserted the element itens.
Returns
True if was possible to build the menu, false otherwise.

Reimplemented from Element.

Definition at line 223 of file Load.cpp.

224{
225 menu.Append(ID_EDIT_ELEMENT, _("Edit Load"));
226
227 wxMenu* textMenu = new wxMenu();
228
229 textMenu->Append(ID_TXT_NAME, _("Name"));
230 textMenu->Append(ID_TXT_ACTIVE_POWER, _("Active power"));
231 textMenu->Append(ID_TXT_REACTIVE_POWER, _("Reactive power"));
232 textMenu->SetClientData(menu.GetClientData());
233
234
235 menu.AppendSubMenu(textMenu, _("Add text"));
236
237 GeneralMenuItens(menu);
238 return true;
239}
@ ID_EDIT_ELEMENT
Definition Element.h:77
virtual void GeneralMenuItens(wxMenu &menu)
Insert general itens to context menu.
Definition Element.cpp:393
Here is the call graph for this function:

◆ GetCopy()

Element * Load::GetCopy ( )
virtual

Get a the element copy.

Returns
Copy of the element.

Reimplemented from Element.

Definition at line 302 of file Load.cpp.

303{
304 Load* copy = new Load();
305 *copy = *this;
306 return copy;
307}
Loas shunt power element.
Definition Load.h:74

◆ GetElectricalData()

LoadElectricalData Load::GetElectricalData ( )
inline

Definition at line 89 of file Load.h.

89{ return m_electricalData; }

◆ GetElectricalDataRef()

LoadElectricalData & Load::GetElectricalDataRef ( )
inline

Definition at line 90 of file Load.h.

90{ return m_electricalData; }

◆ GetPlotData()

bool Load::GetPlotData ( ElementPlotData plotData,
PlotStudy  study = PlotStudy::STABILITY 
)
virtual

Fill the plot data.

Parameters
plotDataPlot data to be filled.
Returns
true if the plot data was successfully filled, false otherwise.

Reimplemented from PowerElement.

Definition at line 364 of file Load.cpp.

365{
366 if (!m_electricalData.plotLoad) return false;
367 plotData.SetName(m_electricalData.name);
368 plotData.SetCurveType(ElementPlotData::CurveType::CT_LOAD);
369
370 std::vector<double> absVoltage, activePower, reactivePower, current;
371 for (unsigned int i = 0; i < m_electricalData.voltageVector.size(); ++i) {
372 absVoltage.push_back(std::abs(m_electricalData.voltageVector[i]));
373 activePower.push_back(std::real(m_electricalData.electricalPowerVector[i]));
374 reactivePower.push_back(std::imag(m_electricalData.electricalPowerVector[i]));
375 current.push_back(std::abs(std::complex<double>(activePower[i], -reactivePower[i]) /
376 std::conj(m_electricalData.voltageVector[i])));
377 }
378
379 plotData.AddData(absVoltage, _("Voltage"));
380 plotData.AddData(activePower, _("Active power"));
381 plotData.AddData(reactivePower, _("Reactive power"));
382 plotData.AddData(current, _("Current"));
383
384 return true;
385}

◆ GetPUElectricalData()

LoadElectricalData Load::GetPUElectricalData ( double  systemPowerBase)

Definition at line 254 of file Load.cpp.

255{
257
258 data.name = m_electricalData.name;
259
260 data.activePower = m_electricalData.activePower;
261 data.activePowerUnit = m_electricalData.activePowerUnit;
262
263 data.reactivePower = m_electricalData.reactivePower;
264 data.reactivePowerUnit = m_electricalData.reactivePowerUnit;
265
266 switch (data.activePowerUnit) {
267 case ElectricalUnit::UNIT_W: {
268 data.activePower = data.activePower / systemPowerBase;
269 data.activePowerUnit = ElectricalUnit::UNIT_PU;
270 } break;
271 case ElectricalUnit::UNIT_kW: {
272 data.activePower = (data.activePower * 1e3) / systemPowerBase;
273 data.activePowerUnit = ElectricalUnit::UNIT_PU;
274 } break;
275 case ElectricalUnit::UNIT_MW: {
276 data.activePower = (data.activePower * 1e6) / systemPowerBase;
277 data.activePowerUnit = ElectricalUnit::UNIT_PU;
278 } break;
279 default:
280 break;
281 }
282 switch (data.reactivePowerUnit) {
283 case ElectricalUnit::UNIT_var: {
284 data.reactivePower = data.reactivePower / systemPowerBase;
285 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
286 } break;
287 case ElectricalUnit::UNIT_kvar: {
288 data.reactivePower = (data.reactivePower * 1e3) / systemPowerBase;
289 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
290 } break;
291 case ElectricalUnit::UNIT_Mvar: {
292 data.reactivePower = (data.reactivePower * 1e6) / systemPowerBase;
293 data.reactivePowerUnit = ElectricalUnit::UNIT_PU;
294 } break;
295 default:
296 break;
297 }
298
299 return data;
300}

◆ GetTipText()

wxString Load::GetTipText ( ) const
virtual

Get the tip text.

Returns
Tip text.

Reimplemented from Element.

Definition at line 309 of file Load.cpp.

310{
311 wxString tipText = m_electricalData.name;
312
313 // TODO: Avoid power calculation.
314 double activePower = m_electricalData.activePower;
315 double reactivePower = m_electricalData.reactivePower;
316 if (!m_online) {
317 activePower = 0.0;
318 reactivePower = 0.0;
319 }
320 if (m_online && m_electricalData.loadType == CONST_IMPEDANCE) {
321 std::complex<double> v = static_cast<Bus*>(m_parentList[0])->GetElectricalData().voltage;
322 reactivePower *= std::pow(std::abs(v), 2);
323 activePower *= std::pow(std::abs(v), 2);
324 }
325 tipText += "\n";
326 tipText += _("\nP = ") + wxString::FromDouble(activePower, 5);
327 switch (m_electricalData.activePowerUnit) {
328 case ElectricalUnit::UNIT_PU: {
329 tipText += _(" p.u.");
330 } break;
331 case ElectricalUnit::UNIT_W: {
332 tipText += _(" W");
333 } break;
334 case ElectricalUnit::UNIT_kW: {
335 tipText += _(" kW");
336 } break;
337 case ElectricalUnit::UNIT_MW: {
338 tipText += _(" MW");
339 } break;
340 default:
341 break;
342 }
343 tipText += _("\nQ = ") + wxString::FromDouble(reactivePower, 5);
344 switch (m_electricalData.reactivePowerUnit) {
345 case ElectricalUnit::UNIT_PU: {
346 tipText += _(" p.u.");
347 } break;
348 case ElectricalUnit::UNIT_var: {
349 tipText += _(" var");
350 } break;
351 case ElectricalUnit::UNIT_kvar: {
352 tipText += _(" kvar");
353 } break;
354 case ElectricalUnit::UNIT_Mvar: {
355 tipText += _(" Mvar");
356 } break;
357 default:
358 break;
359 }
360
361 return tipText;
362}
Node for power elements. All others power elements are connected through this.
Definition Bus.h:86

◆ OpenElement()

bool Load::OpenElement ( rapidxml::xml_node<> *  elementNode,
std::vector< Element * >  parentList 
)
virtual

Reimplemented from PowerElement.

Definition at line 433 of file Load.cpp.

434{
435 if (!OpenCADProperties(elementNode, parentList)) return false;
436 // The load have to insert the points that define his triangle
437 m_triangPts.push_back(wxPoint2DDouble(-m_width / 2.0, -m_height / 2.0));
438 m_triangPts.push_back(wxPoint2DDouble(m_width / 2.0, -m_height / 2.0));
439 m_triangPts.push_back(wxPoint2DDouble(0.0, m_height / 2.0));
440
441 auto electricalProp = elementNode->first_node("ElectricalProperties");
442 if (!electricalProp) return false;
443
444 SetOnline(XMLParser::GetNodeValueInt(electricalProp, "IsOnline"));
445 m_electricalData.name = electricalProp->first_node("Name")->value();
446 m_electricalData.activePower = XMLParser::GetNodeValueDouble(electricalProp, "ActivePower");
447 m_electricalData.activePowerUnit =
448 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "ActivePower", "UnitID"));
449 m_electricalData.reactivePower = XMLParser::GetNodeValueDouble(electricalProp, "ReactivePower");
450 m_electricalData.reactivePowerUnit =
451 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "ReactivePower", "UnitID"));
452 m_electricalData.loadType = static_cast<LoadType>(XMLParser::GetNodeValueInt(electricalProp, "LoadType"));
453 // Stability
454 auto stability = electricalProp->first_node("Stability");
455 if (stability) {
456 m_electricalData.plotLoad = XMLParser::GetNodeValueInt(stability, "PlotLoad");
457 m_electricalData.useCompLoad = XMLParser::GetNodeValueInt(stability, "UseCompositeLoad");
458 auto activePowerComp = stability->first_node("ActivePowerComposition");
459 m_electricalData.constImpedanceActive = XMLParser::GetNodeValueDouble(activePowerComp, "ConstantImpedance");
460 m_electricalData.constCurrentActive = XMLParser::GetNodeValueDouble(activePowerComp, "ConstantCurrent");
461 m_electricalData.constPowerActive = XMLParser::GetNodeValueDouble(activePowerComp, "ConstantPower");
462 auto reactivePowerComp = stability->first_node("ReactivePowerComposition");
463 m_electricalData.constImpedanceReactive = XMLParser::GetNodeValueDouble(reactivePowerComp, "ConstantImpedance");
464 m_electricalData.constCurrentReactive = XMLParser::GetNodeValueDouble(reactivePowerComp, "ConstantCurrent");
465 m_electricalData.constPowerReactive = XMLParser::GetNodeValueDouble(reactivePowerComp, "ConstantPower");
466 }
467
468 if (!OpenSwitchingData(electricalProp)) return false;
469 if (m_swData.swTime.size() != 0) SetDynamicEvent(true);
470
471 m_inserted = true;
472
473 return true;
474}
bool SetOnline(bool online=true)
Set if the element is online or offline.
Definition Element.cpp:383
virtual void SetDynamicEvent(bool dynEvent=true)
Set if the power element have dynamic event.
std::vector< double > swTime

◆ Rotate()

void Load::Rotate ( bool  clockwise = true)
virtual

Rotate the element.

Parameters
clockwiseTrue to rotate clockwise, false to rotate counter-clockwise.

Reimplemented from Element.

Definition at line 210 of file Load.cpp.

211{
212 double rotAngle = m_rotationAngle;
213 if (!clockwise) rotAngle = -m_rotationAngle;
214
215 m_angle += rotAngle;
216 if (m_angle >= 360 || m_angle <= -360) m_angle = 0.0;
217 m_pointList[2] = RotateAtPosition(m_pointList[2], rotAngle);
218 m_pointList[3] = RotateAtPosition(m_pointList[3], rotAngle);
219 UpdateSwitchesPosition();
220 UpdatePowerFlowArrowsPosition();
221}
Here is the call graph for this function:

◆ SaveElement()

rapidxml::xml_node * Load::SaveElement ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  elementListNode 
)
virtual

Reimplemented from Element.

Definition at line 387 of file Load.cpp.

388{
389 auto elementNode = XMLParser::AppendNode(doc, elementListNode, "Load");
390 XMLParser::SetNodeAttribute(doc, elementNode, "ID", m_elementID);
391
392 SaveCADProperties(doc, elementNode);
393
394 auto electricalProp = XMLParser::AppendNode(doc, elementNode, "ElectricalProperties");
395 auto isOnline = XMLParser::AppendNode(doc, electricalProp, "IsOnline");
396 XMLParser::SetNodeValue(doc, isOnline, m_online);
397 auto name = XMLParser::AppendNode(doc, electricalProp, "Name");
398 XMLParser::SetNodeValue(doc, name, m_electricalData.name);
399 auto activePower = XMLParser::AppendNode(doc, electricalProp, "ActivePower");
400 XMLParser::SetNodeValue(doc, activePower, m_electricalData.activePower);
401 XMLParser::SetNodeAttribute(doc, activePower, "UnitID", static_cast<int>(m_electricalData.activePowerUnit));
402 auto reactivePower = XMLParser::AppendNode(doc, electricalProp, "ReactivePower");
403 XMLParser::SetNodeValue(doc, reactivePower, m_electricalData.reactivePower);
404 XMLParser::SetNodeAttribute(doc, reactivePower, "UnitID", static_cast<int>(m_electricalData.reactivePowerUnit));
405 auto loadType = XMLParser::AppendNode(doc, electricalProp, "LoadType");
406 XMLParser::SetNodeValue(doc, loadType, m_electricalData.loadType);
407
408 auto stability = XMLParser::AppendNode(doc, electricalProp, "Stability");
409 auto plotLoad = XMLParser::AppendNode(doc, stability, "PlotLoad");
410 XMLParser::SetNodeValue(doc, plotLoad, m_electricalData.plotLoad);
411 auto useCompLoad = XMLParser::AppendNode(doc, stability, "UseCompositeLoad");
412 XMLParser::SetNodeValue(doc, useCompLoad, m_electricalData.useCompLoad);
413 auto activePowerCompl = XMLParser::AppendNode(doc, stability, "ActivePowerComposition");
414 auto pzl = XMLParser::AppendNode(doc, activePowerCompl, "ConstantImpedance");
415 XMLParser::SetNodeValue(doc, pzl, m_electricalData.constImpedanceActive);
416 auto pil = XMLParser::AppendNode(doc, activePowerCompl, "ConstantCurrent");
417 XMLParser::SetNodeValue(doc, pil, m_electricalData.constCurrentActive);
418 auto ppl = XMLParser::AppendNode(doc, activePowerCompl, "ConstantPower");
419 XMLParser::SetNodeValue(doc, ppl, m_electricalData.constPowerActive);
420 auto reactivePowerCompl = XMLParser::AppendNode(doc, stability, "ReactivePowerComposition");
421 auto qzl = XMLParser::AppendNode(doc, reactivePowerCompl, "ConstantImpedance");
422 XMLParser::SetNodeValue(doc, qzl, m_electricalData.constImpedanceReactive);
423 auto qil = XMLParser::AppendNode(doc, reactivePowerCompl, "ConstantCurrent");
424 XMLParser::SetNodeValue(doc, qil, m_electricalData.constCurrentReactive);
425 auto qpl = XMLParser::AppendNode(doc, reactivePowerCompl, "ConstantPower");
426 XMLParser::SetNodeValue(doc, qpl, m_electricalData.constPowerReactive);
427
428 SaveSwitchingData(doc, electricalProp);
429
430 return elementNode;
431}

◆ SetElectricalData()

void Load::SetElectricalData ( const LoadElectricalData electricalData)
inline

Definition at line 92 of file Load.h.

92{ m_electricalData = electricalData; }

◆ ShowForm()

bool Load::ShowForm ( wxWindow *  parent,
Element element,
wxWindow *  workspace = nullptr 
)
virtual

Show element data form.

Parameters
parentForm parent
elementElement that will be edited.
Returns
True if the form is shown, false otherwise.

Reimplemented from Element.

Definition at line 241 of file Load.cpp.

242{
243 wxLogDebug("Before form constructor");
244 LoadForm loadForm(parent, this);
245 loadForm.CenterOnParent();
246 wxLogDebug("Before ShowModal");
247 if (loadForm.ShowModal() == wxID_OK) {
248 wxLogDebug("After ShowModal");
249 return true;
250 }
251 return false;
252}
Form to edit the load power data.
Definition LoadForm.h:33

Member Data Documentation

◆ m_electricalData

LoadElectricalData Load::m_electricalData
protected

Definition at line 100 of file Load.h.

◆ m_triangPts

std::vector<wxPoint2DDouble> Load::m_triangPts
protected

Definition at line 99 of file Load.h.


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