Power System Platform  2026w23a-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 if (wxSystemSettings::GetAppearance().IsDark())
15 {
16 m_headerColour = wxColour(50, 50, 50);
17 m_oddRowColour = wxColour(70, 70, 70);
18 m_evenRowColour = wxColour(40, 40, 40);
19 m_redColour = wxColour(255, 110, 110);
20 m_blueColour = wxColour(120, 170, 255);
21 }
22 else
23 {
24 m_headerColour = wxColour(191, 223, 255);
25 m_oddRowColour = wxColour(220, 220, 220);
26 m_evenRowColour = wxColour(255, 255, 255);
27 m_redColour = wxColour(210, 35, 35);
28 m_blueColour = wxColour(25, 90, 220);
29 }
30
31 m_time.clear();
32 m_eventType.clear();
33 m_eventDescription.clear();
34 m_eventColour.clear();
35
36 GetTimeEventsList();
37 SortEvents();
38 FillGrid();
39 SetRowsColours(m_gridStabEventList);
40
41 SetSize(GetBestSize());
42}

◆ ~StabilityEventList()

StabilityEventList::~StabilityEventList ( )
virtual

Definition at line 44 of file StabilityEventList.cpp.

44{}

Member Function Documentation

◆ AddEvent()

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

Definition at line 109 of file StabilityEventList.cpp.

110{
111 m_time.emplace_back(eventTime);
112 m_eventType.emplace_back(eventType);
113 m_eventDescription.emplace_back(eventDescription);
114 m_eventColour.emplace_back(eventColour);
115}

◆ FillGrid()

void StabilityEventList::FillGrid ( )
protectedvirtual

Definition at line 117 of file StabilityEventList.cpp.

118{
119 wxFont headerFont = m_gridStabEventList->GetLabelFont();
120 headerFont.SetWeight(wxFONTWEIGHT_BOLD);
121
122 // Create Grid
123 // Header
124 m_gridStabEventList->AppendCols(3);
125 m_gridStabEventList->AppendRows();
126 m_gridStabEventList->HideColLabels();
127 m_gridStabEventList->HideRowLabels();
128 for(int i = 0; i < 7; ++i) {
129 m_gridStabEventList->SetCellBackgroundColour(0, i, m_headerColour);
130 m_gridStabEventList->SetCellFont(0, i, headerFont);
131 }
132 m_gridStabEventList->SetDefaultCellAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
133 // Values
134 m_gridStabEventList->AppendRows(m_time.size());
135
136 // Set headers
137 m_gridStabEventList->SetCellValue(0, 0, _("Event time"));
138 m_gridStabEventList->SetCellValue(0, 1, _("Type"));
139 m_gridStabEventList->SetCellValue(0, 2, _("Description"));
140
141 // Fill Values
142 for(unsigned int i = 0; i < m_time.size(); ++i) {
143 m_gridStabEventList->SetCellValue(i + 1, 0, Element::StringFromDouble(m_time[i]) + wxT(" s"));
144 m_gridStabEventList->SetCellValue(i + 1, 1, m_eventType[i]);
145 m_gridStabEventList->SetCellValue(i + 1, 2, m_eventDescription[i]);
146 m_gridStabEventList->SetCellAlignment(i + 1, 2, wxALIGN_LEFT, wxALIGN_CENTRE);
147 for(int j = 0; j < 3; ++j) { m_gridStabEventList->SetCellTextColour(i + 1, j, m_eventColour[i]); }
148 }
149
150 m_gridStabEventList->AutoSize();
151}
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.
Definition Element.cpp:466

◆ GetTimeEventsList()

void StabilityEventList::GetTimeEventsList ( )
protectedvirtual

Definition at line 46 of file StabilityEventList.cpp.

47{
49 eCalc.GetElementsFromList(m_elementList);
50 auto busList = eCalc.GetBusList();
51 for(unsigned int i = 0; i < busList.size(); ++i) {
52 Bus* bus = busList[i];
53 auto data = bus->GetElectricalData();
54 if(data.stabHasFault) {
55 AddEvent(data.stabFaultTime, _("Fault"),
56 _("Fault insertion at \"") + data.name + _("\" (Zf = ") +
57 bus->StringFromDouble(data.stabFaultResistance) + wxT(" +j") +
58 bus->StringFromDouble(data.stabFaultReactance) + wxT(" p.u.)"),
59 m_redColour);
60 AddEvent(data.stabFaultTime + data.stabFaultLength, _("Fault"),
61 _("Fault removal at \"") + data.name + _("\" (Zf = ") +
62 bus->StringFromDouble(data.stabFaultResistance) + wxT(" +j") +
63 bus->StringFromDouble(data.stabFaultReactance) + wxT(" p.u.)"),
64 m_blueColour);
65 }
66 }
67 auto capacitorList = eCalc.GetCapacitorList();
68 for(unsigned int i = 0; i < capacitorList.size(); ++i) {
69 Capacitor* capacitor = capacitorList[i];
70 SetPowerElementSwitchingEvent(capacitor, capacitor->GetElectricalData().name);
71 }
72 auto indMotorList = eCalc.GetIndMotorList();
73 for(unsigned int i = 0; i < indMotorList.size(); ++i) {
74 IndMotor* indMotor = indMotorList[i];
75 SetPowerElementSwitchingEvent(indMotor, indMotor->GetElectricalData().name);
76 }
77 auto inductorList = eCalc.GetInductorList();
78 for(unsigned int i = 0; i < inductorList.size(); ++i) {
79 Inductor* inductor = inductorList[i];
80 SetPowerElementSwitchingEvent(inductor, inductor->GetElectricalData().name);
81 }
82 auto lineList = eCalc.GetLineList();
83 for(unsigned int i = 0; i < lineList.size(); ++i) {
84 Line* line = lineList[i];
85 SetPowerElementSwitchingEvent(line, line->GetElectricalData().name);
86 }
87 auto loadList = eCalc.GetLoadList();
88 for(unsigned int i = 0; i < loadList.size(); ++i) {
89 Load* load = loadList[i];
90 SetPowerElementSwitchingEvent(load, load->GetElectricalData().name);
91 }
92 auto syncGeneratorList = eCalc.GetSyncGeneratorList();
93 for(unsigned int i = 0; i < syncGeneratorList.size(); ++i) {
94 SyncGenerator* syncGenerator = syncGeneratorList[i];
95 SetPowerElementSwitchingEvent(syncGenerator, syncGenerator->GetElectricalData().name);
96 }
97 auto syncMotorList = eCalc.GetSyncMotorList();
98 for(unsigned int i = 0; i < syncMotorList.size(); ++i) {
99 SyncMotor* syncMotor = syncMotorList[i];
100 SetPowerElementSwitchingEvent(syncMotor, syncMotor->GetElectricalData().name);
101 }
102 auto transformerList = eCalc.GetTransformerList();
103 for(unsigned int i = 0; i < transformerList.size(); ++i) {
104 Transformer* transformer = transformerList[i];
105 SetPowerElementSwitchingEvent(transformer, transformer->GetElectricalData().name);
106 }
107}
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 165 of file StabilityEventList.cpp.

166{
167 SwitchingData swData = element->GetSwitchingData();
168 for(unsigned int i = 0; i < swData.swTime.size(); ++i) {
169 if(swData.swType[i] == SwitchingType::SW_INSERT) {
170 AddEvent(swData.swTime[i], _("Switching"), _("Insertion of \"") + elementName + _("\""), m_blueColour);
171 } else {
172 AddEvent(swData.swTime[i], _("Switching"), _("Removal of \"") + elementName + _("\""), m_redColour);
173 }
174 }
175}
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 153 of file StabilityEventList.cpp.

154{
155 for(int i = rowStart; i < grid->GetNumberRows(); ++i) {
156 wxGridCellAttr* attr = grid->GetOrCreateCellAttr(i, 0);
157 if((i - rowStart) % 2 == 0)
158 attr->SetBackgroundColour(m_evenRowColour);
159 else
160 attr->SetBackgroundColour(m_oddRowColour);
161 grid->SetRowAttr(i, attr);
162 }
163}

◆ SortEvents()

void StabilityEventList::SortEvents ( )
protectedvirtual

Definition at line 177 of file StabilityEventList.cpp.

178{
179 for(unsigned int i = 0; i < m_time.size(); ++i) {
180 for(unsigned int j = 0; j < m_time.size(); ++j) {
181 if(m_time[i] < m_time[j]) {
182 double time = m_time[i];
183 wxString type = m_eventType[i];
184 wxString description = m_eventDescription[i];
185 wxColour colour = m_eventColour[i];
186 m_time[i] = m_time[j];
187 m_eventType[i] = m_eventType[j];
188 m_eventDescription[i] = m_eventDescription[j];
189 m_eventColour[i] = m_eventColour[j];
190 m_time[j] = time;
191 m_eventType[j] = type;
192 m_eventDescription[j] = description;
193 m_eventColour[j] = colour;
194 }
195 }
196 }
197}

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: