Power System Platform  2026w34a-beta
Loading...
Searching...
No Matches
Bus Class Reference

Node for power elements. All others power elements are connected through this. More...

#include <Bus.h>

Inheritance diagram for Bus:
Collaboration diagram for Bus:

Public Member Functions

 Bus ()
 Default constructor.
 
 Bus (wxPoint2DDouble position)
 Contructor of a new Busbar.
 
 Bus (wxPoint2DDouble position, wxString name)
 Contructor of a new Busbar.
 
virtual Element * GetCopy ()
 Get a the element copy.
 
virtual bool AddParent (Element *parent, wxPoint2DDouble position, bool isOpening=false)
 Add a parent element to the Bus.
 
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 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 void AlignToGrid (double gridSize=20.0) override
 
virtual wxCursor GetBestPickboxCursor () const
 Get the best cursor to shown to the user when the mouse is above a pickbox.
 
virtual void MovePickbox (wxPoint2DDouble position)
 Move the pickbox.
 
virtual bool PickboxContains (wxPoint2DDouble position)
 Check if a pickbox contains a point. If contains the attributes related to pickbox movement will be calculated.
 
virtual bool GetContextMenu (wxMenu &menu)
 Get the element contex menu.
 
virtual wxString GetTipText () const
 Get the tip text.
 
virtual wxColour GetVoltageColour (GUIColour *guiColour=nullptr) const
 
virtual BusElectricalData GetElectricalData () const
 
virtual BusElectricalData & GetElectricalDataRef ()
 
virtual void SetElectricalData (const BusElectricalData &electricalData)
 
virtual bool ShowForm (wxWindow *parent, Element *element, wxWindow *workspace=nullptr)
 Show element data form.
 
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)
 
- 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 UpdateSwitchesPosition ()
 
virtual void UpdatePowerFlowArrowsPosition ()
 
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 OpenElement (rapidxml::xml_node<> *elementNode, std::vector< Element * > parentList)
 
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 std::vector< wxPoint2DDouble > & GetPointListRef ()
 
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.
 
virtual void StartMove (wxPoint2DDouble position)
 Update the element attributes related to the movement.
 
virtual void Move (wxPoint2DDouble position)
 Move the element other position.
 
virtual void MoveNode (Element *parent, wxPoint2DDouble position)
 Move a node. StartMove(wxPoint2DDouble position) before start moving.
 
virtual bool NodeContains (wxPoint2DDouble position)
 Check if a node contains a point. If contains, set the attributes related to node movement.
 
virtual void UpdateNodes ()
 Update the nodes according to the parents. If a parent is removed, use this method.
 
void SetParent (Element *parent, int num)
 
void SetChild (Element *child, int num)
 
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 RemoveParent (Element *parent)
 Remove a parent.
 
virtual void ReplaceParent (Element *oldParent, Element *newParent)
 Replace a parent.
 
virtual void RotateNode (Element *parent, bool clockwise=true)
 Rotate a node.
 
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 DrawStabilityEventGC (wxGraphicsContext *gc, wxPoint2DDouble translation, double scale, GUIColour *guiColour, bool rotateAnchor=false, wxPoint2DDouble iconPosition=wxPoint2DDouble(-1, -1)) 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 wxPoint2DDouble GetMoveStartPosition () const
 
virtual wxPoint2DDouble GetMovePosition () const
 
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.
 
void SaveCADProperties (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementNode)
 
bool OpenCADProperties (rapidxml::xml_node<> *elementNode)
 

Protected Attributes

BusElectricalData 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.
 

Detailed Description

Node for power elements. All others power elements are connected through this.

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

Definition at line 86 of file Bus.h.

Constructor & Destructor Documentation

◆ Bus() [1/3]

Bus::Bus ( )

Default constructor.

Definition at line 23 of file Bus.cpp.

23: PowerElement() { m_elementType = TYPE_BUS; }
PowerElement()
Constructor.
Here is the caller graph for this function:

◆ Bus() [2/3]

Bus::Bus ( wxPoint2DDouble  position)

Contructor of a new Busbar.

Parameters
positionPosition to be placed in Workspace.

Definition at line 24 of file Bus.cpp.

24 : PowerElement()
25{
26 m_elementType = TYPE_BUS;
27 m_width = 100.0;
28 m_height = 5.0;
29 SetPosition(position);
30}
void SetPosition(const wxPoint2DDouble position)
Set the element position and update the rectangle.
Definition Element.cpp:33
Here is the call graph for this function:

◆ Bus() [3/3]

Bus::Bus ( wxPoint2DDouble  position,
wxString  name 
)

Contructor of a new Busbar.

Parameters
positionPosition to be placed in Workspace.
nameBus name

Definition at line 32 of file Bus.cpp.

33{
34 m_elementType = TYPE_BUS;
35 m_width = 100.0;
36 m_height = 5.0;
37 SetPosition(position);
38
39 m_electricalData.name = name;
40}
Here is the call graph for this function:

◆ ~Bus()

Bus::~Bus ( )

Definition at line 42 of file Bus.cpp.

42{}

Member Function Documentation

◆ AddParent()

virtual bool Bus::AddParent ( Element *  parent,
wxPoint2DDouble  position,
bool  isOpening = false 
)
inlinevirtual

Add a parent element to the Bus.

Warning
Since the Bus is always a parent element, it doesn't make sense to add a parent to the bus. Therefore, this method will return true.
Parameters
parentParent element.
positionPosition of the parent element.
Returns
True.

Reimplemented from Element.

Definition at line 117 of file Bus.h.

117{ return true; }

◆ AlignToGrid()

void Bus::AlignToGrid ( double  gridSize = 20.0)
overridevirtual

Reimplemented from Element.

Definition at line 324 of file Bus.cpp.

325{
326 if (gridSize <= 0.0) gridSize = 20.0;
327 wxPoint2DDouble newPos(std::round(m_position.m_x / gridSize) * gridSize,
328 std::round(m_position.m_y / gridSize) * gridSize);
329 m_width = std::round(m_width / gridSize) * gridSize;
330 if (m_width < gridSize) m_width = gridSize;
331 SetPosition(newPos);
332}

◆ Contains()

bool Bus::Contains ( wxPoint2DDouble  position) const
virtual

Checks if the element contains a position.

Parameters
positionPosition to be checked.

Implements Element.

Definition at line 234 of file Bus.cpp.

235{
236 wxPoint2DDouble ptR = RotateAtPosition(position, -m_angle);
237 return m_rect.Contains(ptR);
238}
virtual wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees=true) const
Rotate a point as element position being the origin.
Definition Element.cpp:298
Here is the call graph for this function:

◆ DrawDC() [1/2]

void Bus::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 159 of file Bus.cpp.

160{
161 //wxPoint2DDouble gcPosition = m_position - wxPoint2DDouble(m_width / 2.0, m_height / 2.0);
162 wxPoint2DDouble gcPosition = m_position;
163
164 dc.SetPen(*wxTRANSPARENT_PEN);
165
166 // Draw selection (layer 1)
167 if (m_selected) {
168 dc.SetBrush(wxBrush(guiColour->selection));
169
170 wxPoint2DDouble pts[4] = { WorldToScreen(translation, scale, -(m_width / 2.0), -(m_height / 2.0)) -
171 wxPoint2DDouble(m_borderSize, m_borderSize),
172 WorldToScreen(translation, scale, -(m_width / 2.0), (m_height / 2.0)) -
173 wxPoint2DDouble(m_borderSize, -m_borderSize),
174 WorldToScreen(translation, scale, (m_width / 2.0), (m_height / 2.0)) -
175 wxPoint2DDouble(-m_borderSize, -m_borderSize),
176 WorldToScreen(translation, scale, (m_width / 2.0), -(m_height / 2.0)) -
177 wxPoint2DDouble(-m_borderSize, m_borderSize) };
178
179 DrawDCRectangle(gcPosition, m_width + 2 * m_borderSize, m_height + 2 * m_borderSize, m_angle, dc);
180 }
181
182
183 if (!m_electricalData.isConnected)
184 dc.SetBrush(wxBrush(guiColour->disable));
185 else if (m_dynEvent || m_electricalData.hasFault)
186 dc.SetBrush(wxBrush(guiColour->eventElement));
187 else
188 dc.SetBrush(wxBrush(GetVoltageColour(guiColour)));
189
190 DrawDCRectangle(gcPosition, m_width, m_height, m_angle, dc);
191
192
193 // Draw faulted bus symbol (layer 4)
194 if (m_electricalData.hasFault) {
195
196 wxPoint2DDouble center = m_position;
197 wxPoint2DDouble fsPosition = center + wxPoint2DDouble(m_width / 2.0, 0.0);
198
199 wxColour faultSymbolColour(255, 0, 0, 255);
200
201 double localScale = 1.5;
202
203 dc.SetBrush(*wxRED_BRUSH);
204 dc.SetPen(*wxTRANSPARENT_PEN);
205 //gc->SetPen(*wxRED_PEN);
206
207 wxPoint points[4];
208
209 wxPoint2DDouble p;
210
211 // Primeiro polígono
212 p = wxPoint2DDouble(fsPosition.m_x + 1 * localScale, fsPosition.m_y + 3 * localScale);
213 points[0] = RotateAround(p, center, m_angle);
214 p = wxPoint2DDouble(fsPosition.m_x + 1 * localScale, fsPosition.m_y - 3 * localScale);
215 points[1] = RotateAround(p, center, m_angle);
216 p = wxPoint2DDouble(fsPosition.m_x + 11 * localScale, fsPosition.m_y - 1 * localScale);
217 points[2] = RotateAround(p, center, m_angle);
218 p = wxPoint2DDouble(fsPosition.m_x + 11 * localScale, fsPosition.m_y + 5 * localScale);
219 points[3] = RotateAround(p, center, m_angle);
220
221 dc.DrawPolygon(4, points);
222
223 p = wxPoint2DDouble(fsPosition.m_x + 7 * localScale, fsPosition.m_y - 5 * localScale);
224 points[0] = RotateAround(p, center, m_angle);
225 p = wxPoint2DDouble(fsPosition.m_x + 21 * localScale, fsPosition.m_y + 3 * localScale);
226 points[1] = RotateAround(p, center, m_angle);
227 p = wxPoint2DDouble(fsPosition.m_x + 7 * localScale, fsPosition.m_y + 1 * localScale);
228 points[2] = RotateAround(p, center, m_angle);
229
230 dc.DrawPolygon(3, points);
231 }
232}
virtual void DrawDCRectangle(wxPoint2DDouble position, double width, double height, double angle, wxDC &dc) const
Draw a circle.
Definition Element.cpp:41
virtual wxPoint2DDouble WorldToScreen(wxPoint2DDouble translation, double scale, double offsetX=0.0, double offsetY=0.0) const
Convert the element position to screen position.
Definition Element.cpp:354
Here is the call graph for this function:

◆ DrawDC() [2/2]

void Bus::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 44 of file Bus.cpp.

45{
46 wxPoint2DDouble gcPosition = m_position - wxPoint2DDouble(m_width / 2.0, m_height / 2.0);
47 wxGraphicsMatrix identityMatrix = gc->GetTransform();
48 identityMatrix.Set(); // Set to identity
49
50 gc->SetPen(*wxTRANSPARENT_PEN);
51
52 // Draw selection (layer 1)
53 if (m_selected) {
54 // If the object is selected, the matrix is reset to remove scale effects applied to it, thus keeping the
55 // edges with fixed sizes for all zoom levels.
56 gc->PushState();
57 gc->SetTransform(identityMatrix);
58 // The matrix was reset, so we must use screen coordinates (WorldToScreen).
59 wxPoint2DDouble screenPt = WorldToScreen(translation, scale);
60 gc->Translate(screenPt.m_x, screenPt.m_y);
61 gc->Rotate(wxDegToRad(m_angle));
62 gc->Translate(-screenPt.m_x, -screenPt.m_y);
63
64 gc->SetBrush(wxBrush(guiColour->selection));
65
66 wxPoint2DDouble pts[4] = { WorldToScreen(translation, scale, -(m_width / 2.0), -(m_height / 2.0)) -
67 wxPoint2DDouble(m_borderSize, m_borderSize),
68 WorldToScreen(translation, scale, -(m_width / 2.0), (m_height / 2.0)) -
69 wxPoint2DDouble(m_borderSize, -m_borderSize),
70 WorldToScreen(translation, scale, (m_width / 2.0), (m_height / 2.0)) -
71 wxPoint2DDouble(-m_borderSize, -m_borderSize),
72 WorldToScreen(translation, scale, (m_width / 2.0), -(m_height / 2.0)) -
73 wxPoint2DDouble(-m_borderSize, m_borderSize) };
74 gc->DrawLines(4, pts);
75 gc->PopState();
76 }
77
78 gc->PushState();
79 gc->Translate(m_position.m_x, m_position.m_y);
80 gc->Rotate(wxDegToRad(m_angle));
81 gc->Translate(-m_position.m_x, -m_position.m_y);
82
83
84 if (!m_electricalData.isConnected)
85 gc->SetBrush(wxBrush(guiColour->disable));
86 //else if (m_dynEvent)
87 // gc->SetBrush(wxBrush(guiColour->eventElement));
88 else if (guiColour->useVoltageLevels)
89 gc->SetBrush(wxBrush(GetVoltageColour(guiColour)));
90 else
91 gc->SetBrush(wxBrush(guiColour->bus));
92
93 gc->DrawRectangle(gcPosition.m_x, gcPosition.m_y, m_width, m_height);
94
95 gc->PopState();
96
97 // Draw pickbox (layer 3)
98 if (m_showPickbox) {
99 gc->PushState();
100 gc->SetTransform(identityMatrix);
101
102 wxPoint2DDouble screenPt = WorldToScreen(translation, scale);
103 gc->Translate(screenPt.m_x, screenPt.m_y);
104 gc->Rotate(wxDegToRad(m_angle));
105 gc->Translate(-screenPt.m_x, -screenPt.m_y);
106
107 wxPoint2DDouble pbPosition[2] = { WorldToScreen(translation, scale, m_width / 2.0) - wxPoint2DDouble(4, 4),
108 WorldToScreen(translation, scale, -m_width / 2.0) - wxPoint2DDouble(4, 4) };
109 DrawDCPickbox(pbPosition[0], gc);
110 DrawDCPickbox(pbPosition[1], gc);
111
112 gc->PopState();
113 }
114
115 // Draw faulted bus symbol (layer 4)
116 if (m_electricalData.hasFault) {
117 gc->PushState();
118 gc->SetTransform(identityMatrix);
119
120 wxPoint2DDouble screenPt = WorldToScreen(translation, scale);
121 gc->Translate(screenPt.m_x, screenPt.m_y);
122 gc->Rotate(wxDegToRad(m_angle));
123 gc->Translate(-screenPt.m_x, -screenPt.m_y);
124
125 wxPoint2DDouble fsPosition = WorldToScreen(translation, scale, m_width / 2.0);
126
127 wxColour faultSymbolColour(255, 0, 0, 255);
128
129 double scale = 1.5;
130
131 gc->SetBrush(*wxRED_BRUSH);
132 gc->SetPen(*wxTRANSPARENT_PEN);
133 //gc->SetPen(*wxRED_PEN);
134
135 wxPoint2DDouble* points = new wxPoint2DDouble[4];
136 points[0] = wxPoint2DDouble(fsPosition.m_x + 1 * scale, fsPosition.m_y + 3 * scale);
137 points[1] = wxPoint2DDouble(fsPosition.m_x + 1 * scale, fsPosition.m_y - 3 * scale);
138 points[2] = wxPoint2DDouble(fsPosition.m_x + 11 * scale, fsPosition.m_y - 1 * scale);
139 points[3] = wxPoint2DDouble(fsPosition.m_x + 11 * scale, fsPosition.m_y + 5 * scale);
140
141 gc->DrawLines(4, points);
142
143 points[0] = wxPoint2DDouble(fsPosition.m_x + 7 * scale, fsPosition.m_y - 5 * scale);
144 points[1] = wxPoint2DDouble(fsPosition.m_x + 21 * scale, fsPosition.m_y + 3 * scale);
145 points[2] = wxPoint2DDouble(fsPosition.m_x + 7 * scale, fsPosition.m_y + 1 * scale);
146
147 gc->DrawLines(3, points);
148
149 delete[] points;
150
151 gc->PopState();
152 }
153
154 if (m_dynEvent) {
155 DrawStabilityEventGC(gc, translation, scale, guiColour, true);
156 }
157}
virtual void DrawDCPickbox(wxPoint2DDouble position, wxGraphicsContext *gc) const
Draw a point.
Definition Element.cpp:291
Here is the call graph for this function:

◆ GetBestPickboxCursor()

wxCursor Bus::GetBestPickboxCursor ( ) const
virtual

Get the best cursor to shown to the user when the mouse is above a pickbox.

Returns
Cursor.

Reimplemented from Element.

Definition at line 271 of file Bus.cpp.

272{
273 double angle = m_angle;
274 while (angle >= 157.5) angle -= 180.0;
275
276 if (angle >= -22.5 && angle < 22.5)
277 return wxCursor(wxCURSOR_SIZEWE);
278 else if (angle >= 22.5 && angle < 67.5)
279 return wxCursor(wxCURSOR_SIZENWSE);
280 else if (angle >= 67.5 && angle < 112.5)
281 return wxCursor(wxCURSOR_SIZENS);
282 else if (angle >= 112.5 && angle < 157.5)
283 return wxCursor(wxCURSOR_SIZENESW);
284
285 return wxCursor(wxCURSOR_ARROW);
286}

◆ GetContextMenu()

bool Bus::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 334 of file Bus.cpp.

335{
336 menu.Append(ContextMenuID::ID_EDIT_ELEMENT, _("Edit bus"));
337
338 wxMenu* textMenu = new wxMenu();
339
340 textMenu->Append(ID_TXT_NAME, _("Name"));
341 textMenu->Append(ID_TXT_VOLTAGE, _("Voltage"));
342 textMenu->Append(ID_TXT_ANGLE, _("Angle"));
343 textMenu->Append(ID_TXT_FAULTCURRENT, _("Fault current"));
344 textMenu->Append(ID_TXT_FAULTVOLTAGE, _("Fault voltage"));
345 textMenu->Append(ID_TXT_SCC, _("Short-circuit power"));
346 textMenu->Append(ID_TXT_THD, _("Voltage THD"));
347 textMenu->SetClientData(menu.GetClientData());
348
349
350 menu.AppendSubMenu(textMenu, _("Add text"));
351 GeneralMenuItens(menu);
352 return true;
353}
@ ID_EDIT_ELEMENT
Definition Element.h:77
virtual void GeneralMenuItens(wxMenu &menu)
Insert general itens to context menu.
Definition Element.cpp:475
Here is the call graph for this function:

◆ GetCopy()

Element * Bus::GetCopy ( )
virtual

Get a the element copy.

Returns
Copy of the element.

Reimplemented from Element.

Definition at line 365 of file Bus.cpp.

366{
367 Bus* copy = new Bus();
368 *copy = *this;
369 return copy;
370}
Node for power elements. All others power elements are connected through this.
Definition Bus.h:87
Bus()
Default constructor.
Definition Bus.cpp:23
Here is the call graph for this function:

◆ GetElectricalData()

virtual BusElectricalData Bus::GetElectricalData ( ) const
inlinevirtual

Definition at line 131 of file Bus.h.

131{ return m_electricalData; }

◆ GetElectricalDataRef()

virtual BusElectricalData & Bus::GetElectricalDataRef ( )
inlinevirtual

Definition at line 132 of file Bus.h.

132{ return m_electricalData; }

◆ GetPlotData()

bool Bus::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 475 of file Bus.cpp.

476{
477 if (study == PlotStudy::STABILITY) {
478 if (!m_electricalData.plotBus) return false;
479 plotData.SetName(m_electricalData.name);
480 plotData.SetCurveType(ElementPlotData::CurveType::CT_BUS);
481
482 std::vector<double> absVoltage, argVoltage;
483 for (unsigned int i = 0; i < m_electricalData.stabVoltageVector.size(); ++i) {
484 absVoltage.push_back(std::abs(m_electricalData.stabVoltageVector[i]));
485 argVoltage.push_back(wxRadToDeg(std::arg(m_electricalData.stabVoltageVector[i])));
486 }
487 plotData.AddData(absVoltage, _("Voltage"));
488 plotData.AddData(argVoltage, _("Angle"));
489 plotData.AddData(m_electricalData.stabFreqVector, _("Frequency"));
490 return true;
491 }
492 else if (study == PlotStudy::FREQRESPONSE) {
493 if (!m_electricalData.plotPQData) return false;
494 plotData.SetName(m_electricalData.name);
495 plotData.SetCurveType(ElementPlotData::CurveType::CT_BUS);
496 plotData.AddData(m_electricalData.absImpedanceVector, _("Impedance"));
497 const auto& z = m_electricalData.complexImpedanceVector;
498 std::vector<double> r(z.size());
499 std::vector<double> x(z.size());
500 for (std::size_t i = 0; i < z.size(); ++i) {
501 r[i] = z[i].real();
502 x[i] = z[i].imag();
503 }
504 plotData.AddData(r, _("Resistance"));
505 plotData.AddData(x, _("Reactance"));
506 return true;
507 }
508 return false;
509}

◆ GetTipText()

wxString Bus::GetTipText ( ) const
virtual

Get the tip text.

Returns
Tip text.

Reimplemented from Element.

Definition at line 432 of file Bus.cpp.

433{
434 wxString tipText = m_electricalData.name;
435 tipText += wxString::Format(" (%d)", m_electricalData.number + 1);
436 tipText += "\n";
437 tipText += StringFromDouble(m_electricalData.nominalVoltage, 1) +
438 (m_electricalData.nominalVoltageUnit == ElectricalUnit::UNIT_V
439 ? _(" V")
440 : _(" kV"));
441 tipText += "\n";
442 tipText += _("\nV = ") + wxString::FromDouble(std::abs(m_electricalData.voltage), 5) + _(" p.u.");
443 tipText += "\n";
444 tipText += wxString(L'\u03B8') + " = " + wxString::FromDouble(wxRadToDeg(std::arg(m_electricalData.voltage)), 5)
445 + wxString(L'\u00B0');
446
447 tipText += _("\n\nFault info:");
448 tipText += _("\nVa = ") + wxString::FromDouble(std::abs(m_electricalData.faultVoltage[0]), 5) + _(" p.u.");
449 tipText += _("\nVb = ") + wxString::FromDouble(std::abs(m_electricalData.faultVoltage[1]), 5) + _(" p.u.");
450 tipText += _("\nVc = ") + wxString::FromDouble(std::abs(m_electricalData.faultVoltage[2]), 5) + _(" p.u.");
451 if (m_electricalData.hasFault) {
452 tipText += _("\nIa = ") + wxString::FromDouble(std::abs(m_electricalData.faultCurrent[0]), 5) + _(" p.u.");
453 tipText += _("\nIb = ") + wxString::FromDouble(std::abs(m_electricalData.faultCurrent[1]), 5) + _(" p.u.");
454 tipText += _("\nIc = ") + wxString::FromDouble(std::abs(m_electricalData.faultCurrent[2]), 5) + _(" p.u.");
455 }
456
457 tipText += _("\n\nSsc = ") + wxString::FromDouble(std::abs(m_electricalData.scPower), 5) + _(" p.u.");
458
459 wxString harmonicsInfo = _("\n\nHarmonics info:");
460 bool hasHarmonics = false;
461 harmonicsInfo += _("\nTHD = ") + wxString::FromDouble(std::abs(m_electricalData.thd), 5) + wxT("%");
462 int i = 0;
463 for (auto& hVoltage : m_electricalData.harmonicVoltage) {
464 hasHarmonics = true;
465 wxString hVoltageStr;
466 hVoltageStr.Printf(_("\nVh(%d) = %.5e%s%.2f%s p.u."), m_electricalData.harmonicOrder[i], std::abs(hVoltage), wxString(L'\u2220'), wxRadToDeg(std::arg(hVoltage)), wxString(L'\u00B0'));
467 harmonicsInfo += hVoltageStr;
468 i++;
469 }
470 if (hasHarmonics) tipText += harmonicsInfo;
471
472 return tipText;
473}
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.
Definition Element.cpp:548
Here is the call graph for this function:

◆ GetVoltageColour()

wxColour Bus::GetVoltageColour ( GUIColour *  guiColour = nullptr) const
virtual

Definition at line 372 of file Bus.cpp.

373{
374 double v_kV = m_electricalData.nominalVoltage;
375 if (m_electricalData.nominalVoltageUnit == ElectricalUnit::UNIT_V) {
376 v_kV /= 1000.0;
377 }
378
379 const std::vector<VoltageLevelColour>* levels = nullptr;
380 if (guiColour && !guiColour->voltageLevels.empty()) {
381 levels = &guiColour->voltageLevels;
382 }
383
384 if (levels && !levels->empty()) {
385 // 1. Find closest configured level within 15% tolerance
386 double minDiff = 1e9;
387 int bestIdx = -1;
388 for (size_t i = 0; i < levels->size(); ++i) {
389 double diff = std::abs(v_kV - (*levels)[i].voltage);
390 if (diff < minDiff) {
391 minDiff = diff;
392 bestIdx = static_cast<int>(i);
393 }
394 }
395
396 if (bestIdx >= 0) {
397 double tol = std::max((*levels)[bestIdx].voltage * 0.15, 0.5);
398 if (minDiff <= tol) {
399 return (*levels)[bestIdx].colour;
400 }
401 // 2. Range match (assuming ordered descending)
402 for (size_t i = 0; i < levels->size(); ++i) {
403 if (v_kV >= (*levels)[i].voltage * 0.9) {
404 return (*levels)[i].colour;
405 }
406 }
407 return levels->back().colour;
408 }
409 }
410
411 if (v_kV >= 500.0) {
412 return wxColour(0, 90, 220); // >= 500 kV (ex: 500 kV, 765 kV) - Royal Blue
413 } else if (v_kV >= 300.0) {
414 return wxColour(160, 82, 45); // 300 kV - 500 kV (ex: 345 kV, 440 kV) - Brown
415 } else if (v_kV >= 200.0) {
416 return wxColour(220, 35, 35); // 200 kV - 300 kV (ex: 230 kV) - Red
417 } else if (v_kV >= 100.0) {
418 return wxColour(0, 155, 65); // 100 kV - 200 kV (ex: 138 kV, 161 kV) - Green
419 } else if (v_kV >= 50.0) {
420 return wxColour(145, 40, 205); // 50 kV - 100 kV (ex: 69 kV, 88 kV) - Violet / Purple
421 } else if (v_kV >= 20.0) {
422 return wxColour(215, 35, 135); // 20 kV - 50 kV (ex: 34.5 kV) - Magenta / Pink
423 } else if (v_kV >= 10.0) {
424 return wxColour(0, 165, 195); // 10 kV - 20 kV (ex: 13.8 kV, 18 kV) - Cyan / Teal
425 } else if (v_kV >= 1.0) {
426 return wxColour(205, 150, 15); // 1 kV - 10 kV (ex: 2.4 kV, 4.16 kV, 6.9 kV) - Gold / Amber
427 } else {
428 return wxColour(120, 125, 135); // < 1 kV (220 V, 380 V, 440 V) - Slate Gray
429 }
430}

◆ Intersects()

bool Bus::Intersects ( wxRect2DDouble  rect) const
virtual

Check if the element's rect intersects other rect.

Parameters
rectRect to check intersection.

Implements Element.

Definition at line 240 of file Bus.cpp.

241{
242 if (m_angle == 0.0 || m_angle == 180.0) return m_rect.Intersects(rect);
243
244 return RotatedRectanglesIntersects(m_rect, rect, m_angle, 0.0);
245}
virtual bool RotatedRectanglesIntersects(wxRect2DDouble rect1, wxRect2DDouble rect2, double angle1, double angle2) const
Check if two roteted rectangles intersect.
Definition Element.cpp:377
Here is the call graph for this function:

◆ MovePickbox()

void Bus::MovePickbox ( wxPoint2DDouble  position)
virtual

Move the pickbox.

Parameters
positionposition that the pickbox will be moved.

Reimplemented from Element.

Definition at line 288 of file Bus.cpp.

289{
290 if (m_activePickboxID == ID_PB_NONE) return;
291
292 wxPoint2DDouble ptR = RotateAtPosition(position, -m_angle);
293
294 double dx = 0.0;
295 if (m_activePickboxID == ID_PB_RIGHT)
296 dx = ptR.m_x - m_position.m_x - m_width / 2.0;
297 else if (m_activePickboxID == ID_PB_LEFT)
298 dx = m_position.m_x - m_width / 2.0 - ptR.m_x;
299
300 if (m_width + dx < 20.0) return;
301
302 if (m_activePickboxID == ID_PB_RIGHT) {
303 m_position.m_x += (dx / 2.0) * std::cos(wxDegToRad(m_angle));
304 m_position.m_y += (dx / 2.0) * std::sin(wxDegToRad(m_angle));
305 }
306 else if (m_activePickboxID == ID_PB_LEFT) {
307 m_position.m_x -= (dx / 2.0) * std::cos(wxDegToRad(m_angle));
308 m_position.m_y -= (dx / 2.0) * std::sin(wxDegToRad(m_angle));
309 }
310 m_width += dx;
311
312 SetPosition(m_position);
313}
@ ID_PB_NONE
Definition Element.h:63
@ ID_PB_LEFT
Definition Element.h:65
@ ID_PB_RIGHT
Definition Element.h:64
Here is the call graph for this function:

◆ OpenElement()

bool Bus::OpenElement ( rapidxml::xml_node<> *  elementNode)
virtual

Reimplemented from Element.

Definition at line 567 of file Bus.cpp.

568{
569 if (!Element::OpenCADProperties(elementNode)) return false;
570
571 auto electricalProp = elementNode->first_node("ElectricalProperties");
572 if (!electricalProp) return false;
573
574 m_electricalData.name = electricalProp->first_node("Name")->value();
575 m_electricalData.nominalVoltage = XMLParser::GetNodeValueDouble(electricalProp, "NominalVoltage");
576 m_electricalData.nominalVoltageUnit =
577 (ElectricalUnit)XMLParser::GetAttributeValueInt(electricalProp, "NominalVoltage", "UnitID");
578 m_electricalData.isVoltageControlled = XMLParser::GetNodeValueInt(electricalProp, "IsVoltageControlled");
579 m_electricalData.controlledVoltage = XMLParser::GetNodeValueDouble(electricalProp, "ControlledVoltage");
580 m_electricalData.controlledVoltageUnitChoice =
581 XMLParser::GetAttributeValueInt(electricalProp, "ControlledVoltage", "Choice");
582 m_electricalData.slackBus = XMLParser::GetNodeValueInt(electricalProp, "SlackBus");
583 auto fault = electricalProp->first_node("Fault");
584 m_electricalData.hasFault = XMLParser::GetNodeValueInt(fault, "HasFault");
585 m_electricalData.faultType = (FaultData)XMLParser::GetNodeValueInt(fault, "Type");
586 m_electricalData.faultLocation = (FaultData)XMLParser::GetNodeValueInt(fault, "Location");
587 m_electricalData.faultResistance = XMLParser::GetNodeValueDouble(fault, "Resistance");
588 m_electricalData.faultReactance = XMLParser::GetNodeValueDouble(fault, "Reactance");
589 auto stability = electricalProp->first_node("Stability");
590 m_electricalData.plotBus = XMLParser::GetNodeValueInt(stability, "Plot");
591 m_electricalData.stabHasFault = XMLParser::GetNodeValueInt(stability, "HasFault");
592 m_electricalData.stabFaultTime = XMLParser::GetNodeValueDouble(stability, "FaultTime");
593 m_electricalData.stabFaultLength = XMLParser::GetNodeValueDouble(stability, "FaultLength");
594 m_electricalData.stabFaultResistance = XMLParser::GetNodeValueDouble(stability, "FaultResistance");
595 m_electricalData.stabFaultReactance = XMLParser::GetNodeValueDouble(stability, "FaultReactance");
596
597 auto powerQuality = electricalProp->first_node("PowerQuality");
598 if (powerQuality) m_electricalData.plotPQData = XMLParser::GetNodeValueInt(powerQuality, "Plot");
599
600 if (m_electricalData.stabHasFault) SetDynamicEvent(true);
601 SetInserted();
602 return true;
603}
FaultData
Information about fault (type and location).
void SetInserted(bool inserted=true)
Set if the element is properly inserted in the workspace.
Definition Element.h:639
virtual void SetDynamicEvent(bool dynEvent=true)
Set if the power element have dynamic event.

◆ PickboxContains()

bool Bus::PickboxContains ( wxPoint2DDouble  position)
virtual

Check if a pickbox contains a point. If contains the attributes related to pickbox movement will be calculated.

Parameters
positionPosition to be checked.
Returns
True if the element constains the pickbox, false otherwise.

Reimplemented from Element.

Definition at line 247 of file Bus.cpp.

248{
249 m_activePickboxID = ID_PB_NONE;
250
251 wxPoint2DDouble ptR = RotateAtPosition(position, -m_angle);
252
253 wxPoint2DDouble center(m_position.m_x + m_width / 2.0, m_position.m_y);
254 wxRect2DDouble rectRight(center.m_x - 5.0, center.m_y - 5.0, 10.0, 10.0);
255
256 center = wxPoint2DDouble(m_position.m_x - m_width / 2.0, m_position.m_y);
257 wxRect2DDouble rectLeft(center.m_x - 5.0, center.m_y - 5.0, 10.0, 10.0);
258
259 if (rectRight.Contains(ptR)) {
260 m_activePickboxID = ID_PB_RIGHT;
261 return true;
262 }
263 if (rectLeft.Contains(ptR)) {
264 m_activePickboxID = ID_PB_LEFT;
265 return true;
266 }
267
268 return false;
269}
Here is the call graph for this function:

◆ Rotate()

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

Rotate the element.

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

Reimplemented from Element.

Definition at line 315 of file Bus.cpp.

316{
317 double rotAngle = m_rotationAngle;
318 if (!clockwise) rotAngle = -m_rotationAngle;
319
320 m_angle += rotAngle;
321 if (m_angle >= 360 || m_angle <= -360) m_angle = 0.0;
322}

◆ SaveElement()

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

Reimplemented from Element.

Definition at line 511 of file Bus.cpp.

512{
513 m_electricalData.number = m_elementID;
514
515 auto elementNode = XMLParser::AppendNode(doc, elementListNode, "Bus");
516 XMLParser::SetNodeAttribute(doc, elementNode, "ID", m_elementID);
517
518 Element::SaveCADProperties(doc, elementNode);
519
520 auto electricalProp = XMLParser::AppendNode(doc, elementNode, "ElectricalProperties");
521 auto name = XMLParser::AppendNode(doc, electricalProp, "Name");
522 XMLParser::SetNodeValue(doc, name, m_electricalData.name);
523 auto nominalVoltage = XMLParser::AppendNode(doc, electricalProp, "NominalVoltage");
524 XMLParser::SetNodeValue(doc, nominalVoltage, m_electricalData.nominalVoltage);
525 XMLParser::SetNodeAttribute(doc, nominalVoltage, "UnitID", static_cast<int>(m_electricalData.nominalVoltageUnit));
526 auto isVoltageControlled = XMLParser::AppendNode(doc, electricalProp, "IsVoltageControlled");
527 XMLParser::SetNodeValue(doc, isVoltageControlled, m_electricalData.isVoltageControlled);
528 auto controlledVoltage = XMLParser::AppendNode(doc, electricalProp, "ControlledVoltage");
529 XMLParser::SetNodeValue(doc, controlledVoltage, m_electricalData.controlledVoltage);
530 XMLParser::SetNodeAttribute(doc, controlledVoltage, "Choice", m_electricalData.controlledVoltageUnitChoice);
531 auto slackBus = XMLParser::AppendNode(doc, electricalProp, "SlackBus");
532 XMLParser::SetNodeValue(doc, slackBus, m_electricalData.slackBus);
533
534 auto fault = XMLParser::AppendNode(doc, electricalProp, "Fault");
535 auto hasFault = XMLParser::AppendNode(doc, fault, "HasFault");
536 XMLParser::SetNodeValue(doc, hasFault, m_electricalData.hasFault);
537 auto faultType = XMLParser::AppendNode(doc, fault, "Type");
538 XMLParser::SetNodeValue(doc, faultType, static_cast<int>(m_electricalData.faultType));
539 auto faultLocation = XMLParser::AppendNode(doc, fault, "Location");
540 XMLParser::SetNodeValue(doc, faultLocation, static_cast<int>(m_electricalData.faultLocation));
541 auto faultResistance = XMLParser::AppendNode(doc, fault, "Resistance");
542 XMLParser::SetNodeValue(doc, faultResistance, m_electricalData.faultResistance);
543 auto faultReactance = XMLParser::AppendNode(doc, fault, "Reactance");
544 XMLParser::SetNodeValue(doc, faultReactance, m_electricalData.faultReactance);
545
546 auto stability = XMLParser::AppendNode(doc, electricalProp, "Stability");
547 auto plotBus = XMLParser::AppendNode(doc, stability, "Plot");
548 XMLParser::SetNodeValue(doc, plotBus, m_electricalData.plotBus);
549 auto stabHasFault = XMLParser::AppendNode(doc, stability, "HasFault");
550 XMLParser::SetNodeValue(doc, stabHasFault, m_electricalData.stabHasFault);
551 auto stabFaultTime = XMLParser::AppendNode(doc, stability, "FaultTime");
552 XMLParser::SetNodeValue(doc, stabFaultTime, m_electricalData.stabFaultTime);
553 auto stabFaultLength = XMLParser::AppendNode(doc, stability, "FaultLength");
554 XMLParser::SetNodeValue(doc, stabFaultLength, m_electricalData.stabFaultLength);
555 auto stabFaultResistance = XMLParser::AppendNode(doc, stability, "FaultResistance");
556 XMLParser::SetNodeValue(doc, stabFaultResistance, m_electricalData.stabFaultResistance);
557 auto stabFaultReactance = XMLParser::AppendNode(doc, stability, "FaultReactance");
558 XMLParser::SetNodeValue(doc, stabFaultReactance, m_electricalData.stabFaultReactance);
559
560 auto powerQuality = XMLParser::AppendNode(doc, electricalProp, "PowerQuality");
561 auto plotPQData = XMLParser::AppendNode(doc, powerQuality, "Plot");
562 XMLParser::SetNodeValue(doc, plotPQData, m_electricalData.plotPQData);
563
564 return elementNode;
565}

◆ SetElectricalData()

virtual void Bus::SetElectricalData ( const BusElectricalData &  electricalData)
inlinevirtual

Definition at line 133 of file Bus.h.

133{ m_electricalData = electricalData; }

◆ ShowForm()

bool Bus::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 355 of file Bus.cpp.

356{
357 BusForm busForm(parent, this);
358 busForm.CentreOnParent();
359 if (busForm.ShowModal() == wxID_OK) {
360 return true;
361 }
362 return false;
363}
Form to edit the bus power data.
Definition BusForm.h:32

Member Data Documentation

◆ m_electricalData

BusElectricalData Bus::m_electricalData
protected

Definition at line 141 of file Bus.h.


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