Power System Platform  2026w11a-beta
Loading...
Searching...
No Matches
StabilityEventList Class Reference
Inheritance diagram for StabilityEventList:
Collaboration diagram for StabilityEventList:

Public Member Functions

 StabilityEventList (wxWindow *parent, std::vector< Element * > elementList)
 

Protected Member Functions

virtual void OnOKButtonClick (wxCommandEvent &event)
 
virtual void GetTimeEventsList ()
 
virtual void AddEvent (double eventTime, wxString eventType, wxString eventDescription, wxColour eventColour)
 
virtual void FillGrid ()
 
virtual void SortEvents ()
 
virtual void SetRowsColours (wxGrid *grid, int rowStart=1)
 
void SetPowerElementSwitchingEvent (PowerElement *element, wxString elementName)
 

Protected Attributes

std::vector< Element * > m_elementList
 
std::vector< double > m_time
 
std::vector< wxString > m_eventType
 
std::vector< wxString > m_eventDescription
 
std::vector< wxColour > m_eventColour
 
wxColour m_headerColour = wxColour(150, 150, 150)
 
wxColour m_oddRowColour = wxColour(220, 220, 220)
 
wxColour m_evenRowColour = wxColour(255, 255, 255)
 
wxColour m_redColour = wxColour(255, 0, 0)
 
wxColour m_blueColour = wxColour(0, 0, 255)
 

Detailed Description

Definition at line 10 of file StabilityEventList.h.

Constructor & Destructor Documentation

◆ StabilityEventList()

StabilityEventList::StabilityEventList ( wxWindow *  parent,
std::vector< Element * >  elementList 
)

Definition at line 9 of file StabilityEventList.cpp.

10 : StabilityEventListBase(parent)
11{
12 m_elementList = elementList;
13
14 m_time.clear();
15 m_eventType.clear();
16 m_eventDescription.clear();
17 m_eventColour.clear();
18
19 GetTimeEventsList();
20 SortEvents();
21 FillGrid();
22 SetRowsColours(m_gridStabEventList);
23
24 SetSize(GetBestSize());
25}

◆ ~StabilityEventList()

StabilityEventList::~StabilityEventList ( )
virtual

Definition at line 27 of file StabilityEventList.cpp.

27{}

Member Function Documentation

◆ AddEvent()

void StabilityEventList::AddEvent ( double  eventTime,
wxString  eventType,
wxString  eventDescription,
wxColour  eventColour 
)
protectedvirtual

Definition at line 92 of file StabilityEventList.cpp.

93{
94 m_time.emplace_back(eventTime);
95 m_eventType.emplace_back(eventType);
96 m_eventDescription.emplace_back(eventDescription);
97 m_eventColour.emplace_back(eventColour);
98}

◆ FillGrid()

void StabilityEventList::FillGrid ( )
protectedvirtual

Definition at line 100 of file StabilityEventList.cpp.

101{
102 wxFont headerFont = m_gridStabEventList->GetLabelFont();
103 headerFont.SetWeight(wxFONTWEIGHT_BOLD);
104
105 // Create Grid
106 // Header
107 m_gridStabEventList->AppendCols(3);
108 m_gridStabEventList->AppendRows();
109 m_gridStabEventList->HideColLabels();
110 m_gridStabEventList->HideRowLabels();
111 for(int i = 0; i < 7; ++i) {
112 m_gridStabEventList->SetCellBackgroundColour(0, i, m_headerColour);
113 m_gridStabEventList->SetCellFont(0, i, headerFont);
114 }
115 m_gridStabEventList->SetDefaultCellAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
116 // Values
117 m_gridStabEventList->AppendRows(m_time.size());
118
119 // Set headers
120 m_gridStabEventList->SetCellValue(0, 0, _("Event time"));
121 m_gridStabEventList->SetCellValue(0, 1, _("Type"));
122 m_gridStabEventList->SetCellValue(0, 2, _("Description"));
123
124 // Fill Values
125 for(unsigned int i = 0; i < m_time.size(); ++i) {
126 m_gridStabEventList->SetCellValue(i + 1, 0, Element::StringFromDouble(m_time[i]) + wxT(" s"));
127 m_gridStabEventList->SetCellValue(i + 1, 1, m_eventType[i]);
128 m_gridStabEventList->SetCellValue(i + 1, 2, m_eventDescription[i]);
129 m_gridStabEventList->SetCellAlignment(i + 1, 2, wxALIGN_LEFT, wxALIGN_CENTRE);
130 for(int j = 0; j < 3; ++j) { m_gridStabEventList->SetCellTextColour(i + 1, j, m_eventColour[i]); }
131 }
132
133 m_gridStabEventList->AutoSize();
134}
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.
Definition Element.cpp:461

◆ GetTimeEventsList()

void StabilityEventList::GetTimeEventsList ( )
protectedvirtual

Definition at line 29 of file StabilityEventList.cpp.

30{
32 eCalc.GetElementsFromList(m_elementList);
33 auto busList = eCalc.GetBusList();
34 for(unsigned int i = 0; i < busList.size(); ++i) {
35 Bus* bus = busList[i];
36 auto data = bus->GetElectricalData();
37 if(data.stabHasFault) {
38 AddEvent(data.stabFaultTime, _("Fault"),
39 _("Fault insertion at \"") + data.name + _("\" (Zf = ") +
40 bus->StringFromDouble(data.stabFaultResistance) + wxT(" +j") +
41 bus->StringFromDouble(data.stabFaultReactance) + wxT(" p.u.)"),
42 m_redColour);
43 AddEvent(data.stabFaultTime + data.stabFaultLength, _("Fault"),
44 _("Fault removal at \"") + data.name + _("\" (Zf = ") +
45 bus->StringFromDouble(data.stabFaultResistance) + wxT(" +j") +
46 bus->StringFromDouble(data.stabFaultReactance) + wxT(" p.u.)"),
47 m_blueColour);
48 }
49 }
50 auto capacitorList = eCalc.GetCapacitorList();
51 for(unsigned int i = 0; i < capacitorList.size(); ++i) {
52 Capacitor* capacitor = capacitorList[i];
53 SetPowerElementSwitchingEvent(capacitor, capacitor->GetElectricalData().name);
54 }
55 auto indMotorList = eCalc.GetIndMotorList();
56 for(unsigned int i = 0; i < indMotorList.size(); ++i) {
57 IndMotor* indMotor = indMotorList[i];
58 SetPowerElementSwitchingEvent(indMotor, indMotor->GetElectricalData().name);
59 }
60 auto inductorList = eCalc.GetInductorList();
61 for(unsigned int i = 0; i < inductorList.size(); ++i) {
62 Inductor* inductor = inductorList[i];
63 SetPowerElementSwitchingEvent(inductor, inductor->GetElectricalData().name);
64 }
65 auto lineList = eCalc.GetLineList();
66 for(unsigned int i = 0; i < lineList.size(); ++i) {
67 Line* line = lineList[i];
68 SetPowerElementSwitchingEvent(line, line->GetElectricalData().name);
69 }
70 auto loadList = eCalc.GetLoadList();
71 for(unsigned int i = 0; i < loadList.size(); ++i) {
72 Load* load = loadList[i];
73 SetPowerElementSwitchingEvent(load, load->GetElectricalData().name);
74 }
75 auto syncGeneratorList = eCalc.GetSyncGeneratorList();
76 for(unsigned int i = 0; i < syncGeneratorList.size(); ++i) {
77 SyncGenerator* syncGenerator = syncGeneratorList[i];
78 SetPowerElementSwitchingEvent(syncGenerator, syncGenerator->GetElectricalData().name);
79 }
80 auto syncMotorList = eCalc.GetSyncMotorList();
81 for(unsigned int i = 0; i < syncMotorList.size(); ++i) {
82 SyncMotor* syncMotor = syncMotorList[i];
83 SetPowerElementSwitchingEvent(syncMotor, syncMotor->GetElectricalData().name);
84 }
85 auto transformerList = eCalc.GetTransformerList();
86 for(unsigned int i = 0; i < transformerList.size(); ++i) {
87 Transformer* transformer = transformerList[i];
88 SetPowerElementSwitchingEvent(transformer, transformer->GetElectricalData().name);
89 }
90}
Node for power elements. All others power elements are connected through this.
Definition Bus.h:86
Shunt capactior power element.
Definition Capacitor.h:39
Base class for electrical calculations providing general utility methods.
const std::vector< IndMotor * > GetIndMotorList() const
Get the induction motors of the system (use GetElementsFromList first).
const std::vector< Load * > GetLoadList() const
Get the loads of the system (use GetElementsFromList first).
const std::vector< SyncMotor * > GetSyncMotorList() const
Get the synchronous motors of the system (use GetElementsFromList first).
const std::vector< SyncGenerator * > GetSyncGeneratorList() const
Get the synchronous generators of the system (use GetElementsFromList first).
const std::vector< Transformer * > GetTransformerList() const
Get the transformers of the system (use GetElementsFromList first).
const std::vector< Capacitor * > GetCapacitorList() const
Get the capacitors of the system (use GetElementsFromList first).
const std::vector< Inductor * > GetInductorList() const
Get the inductors of the system (use GetElementsFromList first).
const std::vector< Line * > GetLineList() const
Get the lines of the system (use GetElementsFromList first).
const std::vector< Bus * > GetBusList() const
Get the buses of the system (use GetElementsFromList first).
virtual void GetElementsFromList(std::vector< Element * > elementList)
Separate the power elements from a generic list.
Induction motor power element.
Definition IndMotor.h:119
Inductor shunt power element.
Definition Inductor.h:39
Power line element.
Definition Line.h:64
Loas shunt power element.
Definition Load.h:74
Synchronous generator power element.
Synchronous motor (synchronous compensator) power element.
Definition SyncMotor.h:135
Two-winding transformer power element.
Definition Transformer.h:84

◆ OnOKButtonClick()

virtual void StabilityEventList::OnOKButtonClick ( wxCommandEvent &  event)
inlineprotectedvirtual

Definition at line 17 of file StabilityEventList.h.

17{ EndModal(wxID_OK); };

◆ SetPowerElementSwitchingEvent()

void StabilityEventList::SetPowerElementSwitchingEvent ( PowerElement element,
wxString  elementName 
)
protected

Definition at line 148 of file StabilityEventList.cpp.

149{
150 SwitchingData swData = element->GetSwitchingData();
151 for(unsigned int i = 0; i < swData.swTime.size(); ++i) {
152 if(swData.swType[i] == SwitchingType::SW_INSERT) {
153 AddEvent(swData.swTime[i], _("Switching"), _("Insertion of \"") + elementName + _("\""), m_blueColour);
154 } else {
155 AddEvent(swData.swTime[i], _("Switching"), _("Removal of \"") + elementName + _("\""), m_redColour);
156 }
157 }
158}
virtual SwitchingData GetSwitchingData()
Returns the switching data of the element.
Switching data of power elements.
std::vector< double > swTime
std::vector< SwitchingType > swType

◆ SetRowsColours()

void StabilityEventList::SetRowsColours ( wxGrid *  grid,
int  rowStart = 1 
)
protectedvirtual

Definition at line 136 of file StabilityEventList.cpp.

137{
138 for(int i = rowStart; i < grid->GetNumberRows(); ++i) {
139 wxGridCellAttr* attr = grid->GetOrCreateCellAttr(i, 0);
140 if((i - rowStart) % 2 == 0)
141 attr->SetBackgroundColour(m_evenRowColour);
142 else
143 attr->SetBackgroundColour(m_oddRowColour);
144 grid->SetRowAttr(i, attr);
145 }
146}

◆ SortEvents()

void StabilityEventList::SortEvents ( )
protectedvirtual

Definition at line 160 of file StabilityEventList.cpp.

161{
162 for(unsigned int i = 0; i < m_time.size(); ++i) {
163 for(unsigned int j = 0; j < m_time.size(); ++j) {
164 if(m_time[i] < m_time[j]) {
165 double time = m_time[i];
166 wxString type = m_eventType[i];
167 wxString description = m_eventDescription[i];
168 wxColour colour = m_eventColour[i];
169 m_time[i] = m_time[j];
170 m_eventType[i] = m_eventType[j];
171 m_eventDescription[i] = m_eventDescription[j];
172 m_eventColour[i] = m_eventColour[j];
173 m_time[j] = time;
174 m_eventType[j] = type;
175 m_eventDescription[j] = description;
176 m_eventColour[j] = colour;
177 }
178 }
179 }
180}

Member Data Documentation

◆ m_blueColour

wxColour StabilityEventList::m_blueColour = wxColour(0, 0, 255)
protected

Definition at line 36 of file StabilityEventList.h.

◆ m_elementList

std::vector<Element*> StabilityEventList::m_elementList
protected

Definition at line 25 of file StabilityEventList.h.

◆ m_evenRowColour

wxColour StabilityEventList::m_evenRowColour = wxColour(255, 255, 255)
protected

Definition at line 34 of file StabilityEventList.h.

◆ m_eventColour

std::vector<wxColour> StabilityEventList::m_eventColour
protected

Definition at line 29 of file StabilityEventList.h.

◆ m_eventDescription

std::vector<wxString> StabilityEventList::m_eventDescription
protected

Definition at line 28 of file StabilityEventList.h.

◆ m_eventType

std::vector<wxString> StabilityEventList::m_eventType
protected

Definition at line 27 of file StabilityEventList.h.

◆ m_headerColour

wxColour StabilityEventList::m_headerColour = wxColour(150, 150, 150)
protected

Definition at line 32 of file StabilityEventList.h.

◆ m_oddRowColour

wxColour StabilityEventList::m_oddRowColour = wxColour(220, 220, 220)
protected

Definition at line 33 of file StabilityEventList.h.

◆ m_redColour

wxColour StabilityEventList::m_redColour = wxColour(255, 0, 0)
protected

Definition at line 35 of file StabilityEventList.h.

◆ m_time

std::vector<double> StabilityEventList::m_time
protected

Definition at line 26 of file StabilityEventList.h.


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