1#include "StabilityEventList.h"
9StabilityEventList::StabilityEventList(wxWindow* parent, std::vector<Element*> elementList)
10 : StabilityEventListBase(parent)
12 m_elementList = elementList;
14 if (wxSystemSettings::GetAppearance().IsDark())
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);
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);
33 m_eventDescription.clear();
34 m_eventColour.clear();
39 SetRowsColours(m_gridStabEventList);
41 SetSize(GetBestSize());
44StabilityEventList::~StabilityEventList() {}
46void StabilityEventList::GetTimeEventsList()
48 ElectricCalculation eCalc;
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 = ") +
60 AddEvent(data.stabFaultTime + data.stabFaultLength, _(
"Fault"),
61 _(
"Fault removal at \"") + data.name + _(
"\" (Zf = ") +
68 for(
unsigned int i = 0; i < capacitorList.size(); ++i) {
69 Capacitor* capacitor = capacitorList[i];
70 SetPowerElementSwitchingEvent(capacitor, capacitor->GetElectricalData().name);
73 for(
unsigned int i = 0; i < indMotorList.size(); ++i) {
74 IndMotor* indMotor = indMotorList[i];
75 SetPowerElementSwitchingEvent(indMotor, indMotor->GetElectricalData().name);
78 for(
unsigned int i = 0; i < inductorList.size(); ++i) {
79 Inductor* inductor = inductorList[i];
80 SetPowerElementSwitchingEvent(inductor, inductor->GetElectricalData().name);
83 for(
unsigned int i = 0; i < lineList.size(); ++i) {
84 Line* line = lineList[i];
85 SetPowerElementSwitchingEvent(line, line->GetElectricalData().name);
88 for(
unsigned int i = 0; i < loadList.size(); ++i) {
89 Load* load = loadList[i];
90 SetPowerElementSwitchingEvent(load, load->GetElectricalData().name);
93 for(
unsigned int i = 0; i < syncGeneratorList.size(); ++i) {
94 SyncGenerator* syncGenerator = syncGeneratorList[i];
95 SetPowerElementSwitchingEvent(syncGenerator, syncGenerator->GetElectricalData().name);
98 for(
unsigned int i = 0; i < syncMotorList.size(); ++i) {
99 SyncMotor* syncMotor = syncMotorList[i];
100 SetPowerElementSwitchingEvent(syncMotor, syncMotor->GetElectricalData().name);
103 for(
unsigned int i = 0; i < transformerList.size(); ++i) {
104 Transformer* transformer = transformerList[i];
105 SetPowerElementSwitchingEvent(transformer, transformer->GetElectricalData().name);
109void StabilityEventList::AddEvent(
double eventTime, wxString eventType, wxString eventDescription, wxColour eventColour)
111 m_time.emplace_back(eventTime);
112 m_eventType.emplace_back(eventType);
113 m_eventDescription.emplace_back(eventDescription);
114 m_eventColour.emplace_back(eventColour);
117void StabilityEventList::FillGrid()
119 wxFont headerFont = m_gridStabEventList->GetLabelFont();
120 headerFont.SetWeight(wxFONTWEIGHT_BOLD);
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);
132 m_gridStabEventList->SetDefaultCellAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
134 m_gridStabEventList->AppendRows(m_time.size());
137 m_gridStabEventList->SetCellValue(0, 0, _(
"Event time"));
138 m_gridStabEventList->SetCellValue(0, 1, _(
"Type"));
139 m_gridStabEventList->SetCellValue(0, 2, _(
"Description"));
142 for(
unsigned int i = 0; i < m_time.size(); ++i) {
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]); }
150 m_gridStabEventList->AutoSize();
153void StabilityEventList::SetRowsColours(wxGrid* grid,
int rowStart)
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);
160 attr->SetBackgroundColour(m_oddRowColour);
161 grid->SetRowAttr(i, attr);
165void StabilityEventList::SetPowerElementSwitchingEvent(
PowerElement* element, wxString elementName)
168 for(
unsigned int i = 0; i < swData.
swTime.size(); ++i) {
170 AddEvent(swData.
swTime[i], _(
"Switching"), _(
"Insertion of \"") + elementName + _(
"\""), m_blueColour);
172 AddEvent(swData.
swTime[i], _(
"Switching"), _(
"Removal of \"") + elementName + _(
"\""), m_redColour);
177void StabilityEventList::SortEvents()
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];
191 m_eventType[j] = type;
192 m_eventDescription[j] = description;
193 m_eventColour[j] = colour;
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.
static wxString StringFromDouble(double value, int minDecimal=1, int maxDecimals=13)
Convert a double value to string.
Abstract class of power elements.
virtual SwitchingData GetSwitchingData()
Returns the switching data of the element.
std::vector< double > swTime
std::vector< SwitchingType > swType