From 64ed394cdc4b3347768c2e1996518f02982b2ef5 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Mon, 26 Mar 2018 15:54:26 -0300 Subject: Import file GUI implemented --- Project/ImportForm.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Project/ImportForm.h (limited to 'Project/ImportForm.h') diff --git a/Project/ImportForm.h b/Project/ImportForm.h new file mode 100644 index 0000000..7881c64 --- /dev/null +++ b/Project/ImportForm.h @@ -0,0 +1,26 @@ +#ifndef IMPORTFORM_H +#define IMPORTFORM_H + +#include "base/PropertiesFormBase.h" + +#include + +class Workspace; + +class ImportForm : public ImportFormBase +{ + public: + ImportForm(wxWindow* parent, Workspace* workspace); + virtual ~ImportForm(); + + Workspace* GetWorkspace() { return m_workspace; } + + protected: + virtual void OnButtonCancelClick(wxCommandEvent& event); + virtual void OnButtonOKClick(wxCommandEvent& event); + bool ImportSelectedFiles(); + + Workspace* m_workspace = NULL; + wxWindow* m_parent; +}; +#endif // IMPORTFORM_H -- cgit From 25031d1486d307b1cf2ef92db0d37eb70fe8e9f8 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Tue, 27 Mar 2018 21:35:32 -0300 Subject: LST file parse created --- Project/ImportForm.h | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'Project/ImportForm.h') diff --git a/Project/ImportForm.h b/Project/ImportForm.h index 7881c64..a1925de 100644 --- a/Project/ImportForm.h +++ b/Project/ImportForm.h @@ -3,10 +3,20 @@ #include "base/PropertiesFormBase.h" +#include #include +#include +#include class Workspace; +/** + * @class ImportForm + * @author Thales Lima Oliveira + * @date 27/03/2018 + * @brief Form to import other programs files to PSP + * @file ImportForm.h + */ class ImportForm : public ImportFormBase { public: @@ -23,4 +33,71 @@ class ImportForm : public ImportFormBase Workspace* m_workspace = NULL; wxWindow* m_parent; }; + +/** + * @enum ElementType + * @brief ID of ANAREDE's elements. + */ +enum ElementTypeAnarede { + ANA_BUS = 1, /**< Bus */ + ANA_GENERATOR = 4, /**< Generator */ + ANA_LOAD = 5, /**< Load */ + ANA_SHUNT = 6, /**< Shunt element */ + ANA_MIT = 7, /**< Induction motor */ + ANA_TRANSFORMER = 9, /**< Transformer */ + ANA_LINE = 14, /**< Power line */ + ANA_IND_LOAD = 22, /**< Independent load */ + ANA_IND_SHUNT = 23, /**< Independent shunt element */ + ANA_IND_GENERATOR = 24, /**< Independent generator */ +}; + +/** + * @class ParseAnarede + * @author Thales Lima Oliveira + * @date 27/03/2018 + * @brief Class responsible to parse ANAREDE files to import data to PSP. + * @file ImportForm.h + */ +class ParseAnarede +{ + public: + // Graphic files data structs + struct Component { + int id = 0; /**< Graphical ID */ + ElementTypeAnarede type = ANA_BUS; /**< Element type */ + double length = 0.0; /**< Element lenght (only buses) */ + int rotationID = 0; /**< Rotation ID (0, 1, 2 or 4) */ + wxPoint2DDouble position; /**< X and Y coordinates */ + int electricalID = 0; /**< Bus, Branch or Group electrical IDs */ + std::pair busConnectionID[2] = { + std::make_pair(0, 0), std::make_pair(0, 0)}; /**< In the form */ + std::pair busConnectionNode[2] = {std::make_pair(0, 0), + std::make_pair(0, 0)}; /**< In the form */ + }; + struct PowerLine { + int id = 0; /**< Graphical ID */ + ElementTypeAnarede type = ANA_LINE; /**< Element type */ + int electricalID = 0; /**< Bus, Branch or Group electrical IDs */ + std::pair busConnectionID[2] = { + std::make_pair(0, 0), std::make_pair(0, 0)}; /**< In the form */ + std::pair busConnectionNode[2] = {std::make_pair(0, 0), + std::make_pair(0, 0)}; /**< In the form */ + std::vector nodesPosition; /**< Coordinates of the line breaks, if any */ + }; + + ParseAnarede(wxFileName lstFile, wxFileName pwfFile); + ~ParseAnarede() {} + bool Parse(); + + protected: + bool GetLenghtAndRotationFromBusCode(wxString code, double& lenght, int& rotationID); + wxString GetLSTLineNextValue(wxString line, int& currentPos); + + wxFileName m_lstFile; + wxFileName m_pwfFile; + + std::vector m_components; + std::vector m_lines; +}; + #endif // IMPORTFORM_H -- cgit From 3c817f09e1bfcfea4041758ba54d06139d796d3d Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Wed, 28 Mar 2018 01:43:30 -0300 Subject: Bus graphics data imported --- Project/ImportForm.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Project/ImportForm.h') diff --git a/Project/ImportForm.h b/Project/ImportForm.h index a1925de..11357cf 100644 --- a/Project/ImportForm.h +++ b/Project/ImportForm.h @@ -88,6 +88,8 @@ class ParseAnarede ParseAnarede(wxFileName lstFile, wxFileName pwfFile); ~ParseAnarede() {} bool Parse(); + std::vector GetComponents() const { return m_components; } + std::vector GetLines() const { return m_lines; } protected: bool GetLenghtAndRotationFromBusCode(wxString code, double& lenght, int& rotationID); @@ -98,6 +100,7 @@ class ParseAnarede std::vector m_components; std::vector m_lines; + }; #endif // IMPORTFORM_H -- cgit From 856aebefdbaedfbe630c521106f6b06ae758c737 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Wed, 28 Mar 2018 21:40:03 -0300 Subject: All elements graphic data implemented --- Project/ImportForm.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'Project/ImportForm.h') diff --git a/Project/ImportForm.h b/Project/ImportForm.h index 11357cf..8224d3a 100644 --- a/Project/ImportForm.h +++ b/Project/ImportForm.h @@ -9,6 +9,14 @@ #include class Workspace; +class Bus; +class SyncGenerator; +class Load; +class Capacitor; +class Inductor; +class IndMotor; +class Transformer; +class Line; /** * @class ImportForm @@ -29,6 +37,7 @@ class ImportForm : public ImportFormBase virtual void OnButtonCancelClick(wxCommandEvent& event); virtual void OnButtonOKClick(wxCommandEvent& event); bool ImportSelectedFiles(); + Bus* GetBusFromID(std::vector busList, int id); Workspace* m_workspace = NULL; wxWindow* m_parent; @@ -90,17 +99,18 @@ class ParseAnarede bool Parse(); std::vector GetComponents() const { return m_components; } std::vector GetLines() const { return m_lines; } + wxPoint2DDouble GetNodePositionFromID(Bus* bus, double scale, int nodeID); protected: bool GetLenghtAndRotationFromBusCode(wxString code, double& lenght, int& rotationID); wxString GetLSTLineNextValue(wxString line, int& currentPos); + bool StrToElementType(wxString strType, ElementTypeAnarede& type); wxFileName m_lstFile; wxFileName m_pwfFile; std::vector m_components; std::vector m_lines; - }; #endif // IMPORTFORM_H -- cgit From dc08f0dd7682a69b17f3a3d54a726d76455f996b Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Mon, 2 Apr 2018 18:04:23 -0300 Subject: PWF bus data parse implemented --- Project/ImportForm.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'Project/ImportForm.h') diff --git a/Project/ImportForm.h b/Project/ImportForm.h index 8224d3a..e977cbd 100644 --- a/Project/ImportForm.h +++ b/Project/ImportForm.h @@ -93,24 +93,73 @@ class ParseAnarede std::make_pair(0, 0)}; /**< In the form */ std::vector nodesPosition; /**< Coordinates of the line breaks, if any */ }; + struct BusData { + int id = 0; /**< Bus electrical ID */ + bool isOnline = true; /**< Element is online */ + int type = 0; /**< Bus Type: 0 = PQ; 1 = PV; 2 = Ref.; 3 = PQ with voltage between */ + int voltageBase = 0; /**< Voltage base ID */ + wxString busName = "Bus"; /**< Bus name */ + double voltage = 1.0; /**< Bus abs voltage (controlled value for PV and Ref. types) */ + double angle = 0.0; /**< Angle of voltage */ + std::complex genPower = std::complex(0, 0); /**< Generated power */ + double minReactivePower = -9999.0; /**< Minimal reactive power */ + double maxReactivePower = 99999.0; /**< Maximum reactive power */ + int ctrlBusID = 0; /**< Controlled bus ID */ + std::complex loadPower = std::complex(0, 0); /**< Load power */ + double shuntReactive = + 0.0; /**< Reactive power of shunt element. Positive for capacitor, negative for inductor. */ + }; + struct BranchData { + int id = 0; /**< Branch electrical ID */ + std::pair busConnections = std::make_pair(0, 0); /**< Branch connection IDs */ + bool isOnline = true; /**< Element is online */ + double resistance = 0.0; /**< Branch resistance */ + double indReactance = 0.0; /**< Branch inductive reactance */ + double capSusceptance = 0.0; /**< Branch capacitive susceptance */ + double tap = 1.0; /**< Transformer tap */ + double phaseShift = 0.0; /**< Transformer phase shift */ + }; + struct IndElementData { + int id = 0; /**< Group electrical ID */ + ElementTypeAnarede type = ANA_IND_GENERATOR; /**< Element type */ + bool isOnline = true; /**< Element is online */ + std::complex loadPower = std::complex(0, 0); /**< Element power */ + int numUnits = 0; /**< Number of unities */ + }; ParseAnarede(wxFileName lstFile, wxFileName pwfFile); ~ParseAnarede() {} + bool Parse(); + std::vector GetComponents() const { return m_components; } std::vector GetLines() const { return m_lines; } + std::vector GetBranchData() const { return m_branchData; } + std::vector GetBusData() const { return m_busData; } + std::vector GetIndElementData() const { return m_indElementData; } + wxString GetProjectName() const { return m_projectName; } + wxPoint2DDouble GetNodePositionFromID(Bus* bus, double scale, int nodeID); protected: bool GetLenghtAndRotationFromBusCode(wxString code, double& lenght, int& rotationID); wxString GetLSTLineNextValue(wxString line, int& currentPos); bool StrToElementType(wxString strType, ElementTypeAnarede& type); + bool ParsePWFExeCode(wxString data, wxString exeCode); + bool GetPWFStructuredData(wxString data, int startPos, int dataLenght, int& value, int decimalPos = -1); + bool GetPWFStructuredData(wxString data, int startPos, int dataLenght, double& value, int decimalPos = -1); wxFileName m_lstFile; wxFileName m_pwfFile; std::vector m_components; std::vector m_lines; + std::vector m_busData; + std::vector m_branchData; + std::vector m_indElementData; + + wxString m_projectName = _("Imported project"); + double m_mvaBase = 100.0; }; #endif // IMPORTFORM_H -- cgit From aef98fb30666fd86cbbafc8bd748e4815d3c819b Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Tue, 3 Apr 2018 22:06:26 -0300 Subject: .PWF parse implemented, some electrical data set too --- Project/ImportForm.h | 80 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 62 insertions(+), 18 deletions(-) (limited to 'Project/ImportForm.h') diff --git a/Project/ImportForm.h b/Project/ImportForm.h index e977cbd..f561bcd 100644 --- a/Project/ImportForm.h +++ b/Project/ImportForm.h @@ -1,3 +1,20 @@ +/* + * Copyright (C) 2018 Thales Lima Oliveira + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #ifndef IMPORTFORM_H #define IMPORTFORM_H @@ -11,12 +28,15 @@ class Workspace; class Bus; class SyncGenerator; +class SyncMotor; class Load; class Capacitor; class Inductor; +class Capacitor; class IndMotor; class Transformer; class Line; +class PropertiesData; /** * @class ImportForm @@ -120,43 +140,67 @@ class ParseAnarede double phaseShift = 0.0; /**< Transformer phase shift */ }; struct IndElementData { - int id = 0; /**< Group electrical ID */ - ElementTypeAnarede type = ANA_IND_GENERATOR; /**< Element type */ - bool isOnline = true; /**< Element is online */ - std::complex loadPower = std::complex(0, 0); /**< Element power */ - int numUnits = 0; /**< Number of unities */ + int id = 0; /**< Group electrical ID */ + int busConnection = 0; /**< Branch connection ID */ + ElementTypeAnarede type = ANA_IND_GENERATOR; /**< Element type */ + bool isOnline = true; /**< Element is online */ + std::complex power = std::complex(0, 0); /**< Element power */ + int numUnits = 0; /**< Number of unities */ + }; + struct IndGenData : IndElementData { + double minReactivePower = -9999.0; /**< Minimal reactive power */ + double maxReactivePower = 99999.0; /**< Maximum reactive power */ + double xt = 1.0; /**< Transformer reactance of each generator */ + double xd = 1.0; /**< Synchronous direct-axis reactance of each generator */ + double xq = 1.0; /**< Synchronous quadrature-axis reactance of each generator */ + double xl = 1.0; /**< Leakage reactance of each generator */ + double ratedPower = 100.0; /**< Rated power of each generator */ }; ParseAnarede(wxFileName lstFile, wxFileName pwfFile); - ~ParseAnarede() {} + ~ParseAnarede() { ClearData(); } bool Parse(); - std::vector GetComponents() const { return m_components; } - std::vector GetLines() const { return m_lines; } - std::vector GetBranchData() const { return m_branchData; } - std::vector GetBusData() const { return m_busData; } - std::vector GetIndElementData() const { return m_indElementData; } + std::vector GetComponents() const { return m_components; } + std::vector GetLines() const { return m_lines; } + std::vector GetBranchData() const { return m_branchData; } + std::vector GetBusData() const { return m_busData; } + std::vector GetIndElementData() const { return m_indElementData; } wxString GetProjectName() const { return m_projectName; } + double GetMVAPowerBase() const { return m_mvaBase; } wxPoint2DDouble GetNodePositionFromID(Bus* bus, double scale, int nodeID); + BusData* GetBusDataFromID(int id); + BranchData* GetBranchDataFromID(int id, int fromBus, int toBus); + IndElementData* GetIndElementDataFromID(int id, int bus); + + void ClearData(); protected: bool GetLenghtAndRotationFromBusCode(wxString code, double& lenght, int& rotationID); wxString GetLSTLineNextValue(wxString line, int& currentPos); bool StrToElementType(wxString strType, ElementTypeAnarede& type); bool ParsePWFExeCode(wxString data, wxString exeCode); - bool GetPWFStructuredData(wxString data, int startPos, int dataLenght, int& value, int decimalPos = -1); - bool GetPWFStructuredData(wxString data, int startPos, int dataLenght, double& value, int decimalPos = -1); + bool GetPWFStructuredData(wxString data, + unsigned int startPos, + unsigned int dataLenght, + int& value, + int decimalPos = -1); + bool GetPWFStructuredData(wxString data, + unsigned int startPos, + unsigned int dataLenght, + double& value, + int decimalPos = -1); wxFileName m_lstFile; wxFileName m_pwfFile; - std::vector m_components; - std::vector m_lines; - std::vector m_busData; - std::vector m_branchData; - std::vector m_indElementData; + std::vector m_components; + std::vector m_lines; + std::vector m_busData; + std::vector m_branchData; + std::vector m_indElementData; wxString m_projectName = _("Imported project"); double m_mvaBase = 100.0; -- cgit From 54b3719953815bd6a2648bb6dac662f513d80fca Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Wed, 4 Apr 2018 21:31:28 -0300 Subject: Some ANAREDE to PSP electric data implemented Some bugfixes --- Project/ImportForm.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'Project/ImportForm.h') diff --git a/Project/ImportForm.h b/Project/ImportForm.h index f561bcd..021ba66 100644 --- a/Project/ImportForm.h +++ b/Project/ImportForm.h @@ -114,13 +114,13 @@ class ParseAnarede std::vector nodesPosition; /**< Coordinates of the line breaks, if any */ }; struct BusData { - int id = 0; /**< Bus electrical ID */ - bool isOnline = true; /**< Element is online */ - int type = 0; /**< Bus Type: 0 = PQ; 1 = PV; 2 = Ref.; 3 = PQ with voltage between */ - int voltageBase = 0; /**< Voltage base ID */ - wxString busName = "Bus"; /**< Bus name */ - double voltage = 1.0; /**< Bus abs voltage (controlled value for PV and Ref. types) */ - double angle = 0.0; /**< Angle of voltage */ + int id = 0; /**< Bus electrical ID */ + bool isOnline = true; /**< Element is online */ + int type = 0; /**< Bus Type: 0 = PQ; 1 = PV; 2 = Ref.; 3 = PQ with voltage between */ + wxString voltageBase = "0"; /**< Voltage base identifier */ + wxString busName = "Bus"; /**< Bus name */ + double voltage = 1.0; /**< Bus abs voltage (controlled value for PV and Ref. types) */ + double angle = 0.0; /**< Angle of voltage */ std::complex genPower = std::complex(0, 0); /**< Generated power */ double minReactivePower = -9999.0; /**< Minimal reactive power */ double maxReactivePower = 99999.0; /**< Maximum reactive power */ -- cgit From 71379e56edd24c2b4d9ea341710c2a7cda6d3afb Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Thu, 5 Apr 2018 21:42:37 -0300 Subject: Create loads not present in graphical data Create load not present in graphical data, but present in electric data. Data report copy implemented (Ctrl + C). Data report select all implemented (Ctrl + A). Some bugfixes --- Project/ImportForm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Project/ImportForm.h') diff --git a/Project/ImportForm.h b/Project/ImportForm.h index 021ba66..57341e0 100644 --- a/Project/ImportForm.h +++ b/Project/ImportForm.h @@ -173,7 +173,7 @@ class ParseAnarede wxPoint2DDouble GetNodePositionFromID(Bus* bus, double scale, int nodeID); BusData* GetBusDataFromID(int id); BranchData* GetBranchDataFromID(int id, int fromBus, int toBus); - IndElementData* GetIndElementDataFromID(int id, int bus); + IndElementData* GetIndElementDataFromID(int id, int busID); void ClearData(); -- cgit From 4e1e884a21a767f13278e32463b5417569db3534 Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Sat, 7 Apr 2018 16:59:59 -0300 Subject: Bugfixes --- Project/ImportForm.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'Project/ImportForm.h') diff --git a/Project/ImportForm.h b/Project/ImportForm.h index 57341e0..da19734 100644 --- a/Project/ImportForm.h +++ b/Project/ImportForm.h @@ -131,12 +131,13 @@ class ParseAnarede }; struct BranchData { int id = 0; /**< Branch electrical ID */ + ElementTypeAnarede type = ANA_LINE; /**< Element type */ std::pair busConnections = std::make_pair(0, 0); /**< Branch connection IDs */ bool isOnline = true; /**< Element is online */ double resistance = 0.0; /**< Branch resistance */ double indReactance = 0.0; /**< Branch inductive reactance */ double capSusceptance = 0.0; /**< Branch capacitive susceptance */ - double tap = 1.0; /**< Transformer tap */ + double tap = 0.0; /**< Transformer tap */ double phaseShift = 0.0; /**< Transformer phase shift */ }; struct IndElementData { @@ -172,8 +173,8 @@ class ParseAnarede wxPoint2DDouble GetNodePositionFromID(Bus* bus, double scale, int nodeID); BusData* GetBusDataFromID(int id); - BranchData* GetBranchDataFromID(int id, int fromBus, int toBus); - IndElementData* GetIndElementDataFromID(int id, int busID); + BranchData* GetBranchDataFromID(int id, int fromBus, int toBus, ElementTypeAnarede type); + IndElementData* GetIndElementDataFromID(int id, int busID, ElementTypeAnarede type); void ClearData(); -- cgit From 8824eb42aed594822b1a46e0d1492535efacda0e Mon Sep 17 00:00:00 2001 From: Thales Lima Oliveira Date: Tue, 10 Apr 2018 22:09:52 -0300 Subject: Base folder strategy abandoned due compatibility with wxCrafter --- Project/ImportForm.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Project/ImportForm.h') diff --git a/Project/ImportForm.h b/Project/ImportForm.h index da19734..280396b 100644 --- a/Project/ImportForm.h +++ b/Project/ImportForm.h @@ -18,7 +18,7 @@ #ifndef IMPORTFORM_H #define IMPORTFORM_H -#include "base/PropertiesFormBase.h" +#include "PropertiesFormBase.h" #include #include -- cgit