diff options
Diffstat (limited to 'Project')
-rw-r--r-- | Project/Bus.h | 14 | ||||
-rw-r--r-- | Project/Project.mk | 2 | ||||
-rw-r--r-- | Project/Release/Bus.cpp.o | bin | 40981 -> 41853 bytes | |||
-rw-r--r-- | Project/Release/BusForm.cpp.o | bin | 113688 -> 119004 bytes | |||
-rw-r--r-- | Project/Release/ElectricCalculation.cpp.o | bin | 67499 -> 71739 bytes | |||
-rw-r--r-- | Project/Release/Line.cpp.o | bin | 160820 -> 162676 bytes | |||
-rw-r--r-- | Project/Release/MainFrame.cpp.o | bin | 141269 -> 141269 bytes | |||
-rw-r--r-- | Project/Release/PSP-UFU.exe | bin | 4211221 -> 4232274 bytes | |||
-rw-r--r-- | Project/Release/PowerFlow.cpp.o | bin | 42558 -> 43132 bytes | |||
-rw-r--r-- | Project/Release/Text.cpp.o | bin | 47041 -> 53898 bytes | |||
-rw-r--r-- | Project/Release/TextForm.cpp.o | bin | 165811 -> 166463 bytes | |||
-rw-r--r-- | Project/Release/Workspace.cpp.o | bin | 206375 -> 210077 bytes | |||
-rw-r--r-- | Project/Text.cpp | 103 | ||||
-rw-r--r-- | Project/Text.h | 2 |
14 files changed, 97 insertions, 24 deletions
diff --git a/Project/Bus.h b/Project/Bus.h index 836d2f7..470d4cb 100644 --- a/Project/Bus.h +++ b/Project/Bus.h @@ -11,7 +11,7 @@ struct BusElectricalData { ElectricalUnit nominalVoltageUnit = UNIT_kV; bool isVoltageControlled = false; double controlledVoltage = 1.0; - int controlledVoltageUnitChoice = 0; // 0 = p.u., 1 = same as nominalVoltageUnit (UNIT_V or UNIT_kV). + int controlledVoltageUnitChoice = 0; // 0 = p.u., 1 = same as nominalVoltageUnit (UNIT_V or UNIT_kV). bool slackBus = false; // Power flow (p.u.) @@ -21,8 +21,14 @@ struct BusElectricalData { bool hasFault = false; FaultData faultType = FAULT_THREEPHASE; FaultData faultLocation = FAULT_LINE_A; + // p.u. fault data double faultResistance = 0.0; double faultReactance = 0.0; + std::complex<double> faultCurrent[3] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0), + std::complex<double>(0.0, 0.0) }; + std::complex<double> faultVoltage[3] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0), + std::complex<double>(0.0, 0.0) }; + double scPower = 0.0; // Stability bool plotBus = false; @@ -35,7 +41,7 @@ struct BusElectricalData { class Bus : public Element { - public: +public: Bus(); Bus(wxPoint2DDouble position); Bus(wxPoint2DDouble position, wxString name); @@ -53,8 +59,8 @@ class Bus : public Element virtual void SetElectricalData(BusElectricalData electricalData) { m_electricalData = electricalData; } virtual bool ShowForm(wxWindow* parent, Element* element); - protected: +protected: BusElectricalData m_electricalData; }; -#endif // BUS_H +#endif // BUS_H diff --git a/Project/Project.mk b/Project/Project.mk index 8fed411..8ab3b2c 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Thales -Date :=06/12/2016 +Date :=07/12/2016 CodeLitePath :="C:/Program Files/CodeLite" LinkerName :=C:/TDM-GCC-64/bin/g++.exe SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC diff --git a/Project/Release/Bus.cpp.o b/Project/Release/Bus.cpp.o Binary files differindex a0baa28..444c5dc 100644 --- a/Project/Release/Bus.cpp.o +++ b/Project/Release/Bus.cpp.o diff --git a/Project/Release/BusForm.cpp.o b/Project/Release/BusForm.cpp.o Binary files differindex 1644878..3aff5ba 100644 --- a/Project/Release/BusForm.cpp.o +++ b/Project/Release/BusForm.cpp.o diff --git a/Project/Release/ElectricCalculation.cpp.o b/Project/Release/ElectricCalculation.cpp.o Binary files differindex 79d5b45..7dc5f55 100644 --- a/Project/Release/ElectricCalculation.cpp.o +++ b/Project/Release/ElectricCalculation.cpp.o diff --git a/Project/Release/Line.cpp.o b/Project/Release/Line.cpp.o Binary files differindex 8467f11..1bc1c62 100644 --- a/Project/Release/Line.cpp.o +++ b/Project/Release/Line.cpp.o diff --git a/Project/Release/MainFrame.cpp.o b/Project/Release/MainFrame.cpp.o Binary files differindex 0ce9351..07fd41c 100644 --- a/Project/Release/MainFrame.cpp.o +++ b/Project/Release/MainFrame.cpp.o diff --git a/Project/Release/PSP-UFU.exe b/Project/Release/PSP-UFU.exe Binary files differindex c863055..d591cb9 100644 --- a/Project/Release/PSP-UFU.exe +++ b/Project/Release/PSP-UFU.exe diff --git a/Project/Release/PowerFlow.cpp.o b/Project/Release/PowerFlow.cpp.o Binary files differindex e284cdc..1abafea 100644 --- a/Project/Release/PowerFlow.cpp.o +++ b/Project/Release/PowerFlow.cpp.o diff --git a/Project/Release/Text.cpp.o b/Project/Release/Text.cpp.o Binary files differindex 3734ca0..9911071 100644 --- a/Project/Release/Text.cpp.o +++ b/Project/Release/Text.cpp.o diff --git a/Project/Release/TextForm.cpp.o b/Project/Release/TextForm.cpp.o Binary files differindex 09a81f7..cc9a9ca 100644 --- a/Project/Release/TextForm.cpp.o +++ b/Project/Release/TextForm.cpp.o diff --git a/Project/Release/Workspace.cpp.o b/Project/Release/Workspace.cpp.o Binary files differindex ccb9bf6..1200399 100644 --- a/Project/Release/Workspace.cpp.o +++ b/Project/Release/Workspace.cpp.o diff --git a/Project/Text.cpp b/Project/Text.cpp index 7082e17..eb94de0 100644 --- a/Project/Text.cpp +++ b/Project/Text.cpp @@ -51,13 +51,26 @@ void Text::Draw(wxPoint2DDouble translation, double scale) } // Draw text (layer 2) - glColor4d(0.0, 0.0, 0.0, 1.0); - wxGLString glString(m_text); - glString.setFont(wxFont(m_fontSize, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); - glString.consolidate(&dc); - glString.bind(); - glString.render(m_position.m_x, m_position.m_y); + if(!m_isMultlineText) { // Only one line + wxGLString glString(m_text); + glString.setFont(wxFont(m_fontSize, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); + glString.consolidate(&dc); + glString.bind(); + glString.render(m_position.m_x, m_position.m_y); + } else { // Multiples lines + wxGLStringArray glStringArray; + // Fill the string array. + for(int i = 0; i < (int)m_multlineText.size(); i++) glStringArray.addString(m_multlineText[i]); + glStringArray.setFont(wxFont(m_fontSize, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); + glStringArray.consolidate(&dc); + glStringArray.bind(); + // The text will be printed centralized. + for(int i = 0; i < (int)m_multlineText.size(); i++) { + glStringArray.get(i).render(m_position.m_x, m_position.m_y - m_height / 2.0 + + glStringArray.get(i).getheight() * double(i) + glStringArray.get(i).getheight() / 2.0); + } + } glPopMatrix(); } @@ -73,14 +86,40 @@ void Text::SetText(wxString text) m_text = text; // Creating a glString to get the text size. - wxGLString glString(m_text); - glString.setFont(wxFont(m_fontSize, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); - wxScreenDC dc; - glString.consolidate(&dc); - glString.bind(); - - m_width = glString.getWidth(); - m_height = glString.getheight(); + int numberOfLines = m_text.Freq('\n') + 1; + if(numberOfLines == 1) { // Only one line + m_isMultlineText = false; + wxGLString glString(m_text); + glString.setFont(wxFont(m_fontSize, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); + wxScreenDC dc; + glString.consolidate(&dc); + glString.bind(); + + m_width = glString.getWidth(); + m_height = glString.getheight(); + } else { + m_isMultlineText = true; + m_multlineText.clear(); + wxString text = m_text; + double w = 0.0, h = 0.0; + for(int i = 0; i < numberOfLines; ++i) { + wxString nextLine; + wxString currentLine = text.BeforeFirst('\n', &nextLine); + text = nextLine; + m_multlineText.push_back(currentLine); + + wxGLString glString(currentLine); + glString.setFont(wxFont(m_fontSize, wxFONTFAMILY_ROMAN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL)); + wxScreenDC dc; + glString.consolidate(&dc); + glString.bind(); + + if(w < glString.getWidth()) w = glString.getWidth(); // Get the major width. + h = glString.getheight(); + } + m_width = w; + m_height = h * (double)numberOfLines; + } // Update text rectangle. SetPosition(m_position); @@ -115,26 +154,52 @@ void Text::UpdateText(double systemPowerBase) Bus* bus = (Bus*)m_element; if(bus) { BusElectricalData data = bus->GetEletricalData(); + double baseVoltage = data.nominalVoltage; + if(data.nominalVoltageUnit == UNIT_kV) baseVoltage *= 1e3; + double baseCurrent = systemPowerBase / (std::sqrt(3.0) * baseVoltage); + switch(m_dataType) { case DATA_NAME: { SetText(bus->GetEletricalData().name); } break; case DATA_VOLTAGE: { - double baseVoltage = data.nominalVoltage; - if(data.nominalVoltageUnit == UNIT_kV) baseVoltage *= 1e3; double voltage = std::abs(data.voltage); switch(m_unit) { case UNIT_PU: { - SetText(wxString::FromDouble(voltage, m_decimalPlaces) + _(" p.u.")); + SetText(wxString::FromDouble(voltage, m_decimalPlaces) + " p.u."); } break; case UNIT_V: { - SetText(wxString::FromDouble(voltage * baseVoltage, m_decimalPlaces) + _(" V")); + SetText(wxString::FromDouble(voltage * baseVoltage, m_decimalPlaces) + " V"); } break; case UNIT_kV: { - SetText(wxString::FromDouble(voltage * baseVoltage / 1e3, m_decimalPlaces) + _(" kV")); + SetText(wxString::FromDouble(voltage * baseVoltage / 1e3, m_decimalPlaces) + " kV"); } break; } } break; + case DATA_ANGLE: { + double angle = std::arg(data.voltage); + switch(m_unit) { + case UNIT_RADIAN: { + SetText(wxString::FromDouble(angle, m_decimalPlaces) + " rad"); + } break; + case UNIT_DEGREE: { + SetText(wxString::FromDouble(wxRadToDeg(angle), m_decimalPlaces) + "°"); + } break; + } + } break; + case DATA_SC_CURRENT: { + double faultCurrent[3] = { std::abs(data.faultCurrent[0]), std::abs(data.faultCurrent[1]), + std::abs(data.faultCurrent[2]) }; + switch(m_unit) { + case UNIT_PU: { + wxString str = + "Ia = " + wxString::FromDouble(faultCurrent[0], m_decimalPlaces) + " p.u."; + str += "\nIb = " + wxString::FromDouble(faultCurrent[1], m_decimalPlaces) + " p.u."; + str += "\nIc = " + wxString::FromDouble(faultCurrent[2], m_decimalPlaces) + " p.u."; + SetText(str); + } break; + } + } } } } break; diff --git a/Project/Text.h b/Project/Text.h index 98aeb65..80f35fa 100644 --- a/Project/Text.h +++ b/Project/Text.h @@ -80,6 +80,8 @@ class Text : public Element protected: wxString m_text = _("Text"); + std::vector<wxString> m_multlineText; + bool m_isMultlineText = false; int m_fontSize = 10; Element* m_element = NULL; |