summaryrefslogtreecommitdiffstats
path: root/Project/ImportForm.h
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2019-04-25 01:25:41 -0300
committerThales Lima Oliveira <thaleslima.ufu@gmail.com>2019-04-25 01:25:41 -0300
commit2771fff79ac9c3c09b70f4668e7142b2e944d1f2 (patch)
treec55b0780b0da2ac270df16c5b92d7fc243ea0756 /Project/ImportForm.h
parentfdb50c49b323edf16ce72c7ee2c678aa1ac99777 (diff)
downloadPSP.git-2771fff79ac9c3c09b70f4668e7142b2e944d1f2.tar.gz
PSP.git-2771fff79ac9c3c09b70f4668e7142b2e944d1f2.tar.xz
PSP.git-2771fff79ac9c3c09b70f4668e7142b2e944d1f2.zip
Matpower Importer and power quality calculation
Power quality in implementation
Diffstat (limited to 'Project/ImportForm.h')
-rw-r--r--Project/ImportForm.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/Project/ImportForm.h b/Project/ImportForm.h
index 280396b..b4643a5 100644
--- a/Project/ImportForm.h
+++ b/Project/ImportForm.h
@@ -23,7 +23,9 @@
#include <wx/geometry.h>
#include <wx/msgdlg.h>
#include <wx/textfile.h>
+#include <wx/tokenzr.h>
#include <bitset>
+#include <complex>
class Workspace;
class Bus;
@@ -38,6 +40,8 @@ class Transformer;
class Line;
class PropertiesData;
+class GraphAutoLayout;
+
/**
* @class ImportForm
* @author Thales Lima Oliveira <thales@ufu.br>
@@ -57,6 +61,8 @@ class ImportForm : public ImportFormBase
virtual void OnButtonCancelClick(wxCommandEvent& event);
virtual void OnButtonOKClick(wxCommandEvent& event);
bool ImportSelectedFiles();
+ bool ImportCEPELFiles();
+ bool ImportMatpowerFiles();
Bus* GetBusFromID(std::vector<Bus*> busList, int id);
Workspace* m_workspace = NULL;
@@ -207,4 +213,67 @@ class ParseAnarede
double m_mvaBase = 100.0;
};
+class ParseMatpower
+{
+ public:
+ struct BusData {
+ int id = 0; /**< Bus electrical ID */
+ int type = 0; /**< Bus Type: 1 = PQ; 2 = PV; 3 = Ref.; 4 = isolated */
+ double pd = 0.0; /**< Real power demand (MW) */
+ double qd = 0.0; /**< Reactive power demand (MVAr) */
+ double gs = 0.0; /**< Shunt condutance (MW, V = 1.0 p.u.) */
+ double bs = 0.0; /**< Shunt susceptance (MVAr, V = 1.0 p.u.). Positive for capacitor, negative for inductor? */
+ int area = 0; /**< Bus area */
+ double voltage = 1.0; /**< Bus abs voltage (controlled value for PV and Ref. types) */
+ double angle = 0.0; /**< Angle of voltage */
+ double baseVoltage = 138; /**< Base voltage (kV)*/
+ wxString busName = "Bus"; /**< Bus name */
+ wxPoint2DDouble busPosition = wxPoint2DDouble(0,0); /**< Bus position */
+ };
+ struct GenData {
+ int busID = 0; /**< Bus electrical ID */
+ double pg = 0.0; /**< Real power output (MW) */
+ double qg = 0.0; /**< Reactive power output (MVAr) */
+ double maxReactivePower = 99999.0; /**< Maximum reactive power (MVAr) */
+ double minReactivePower = -9999.0; /**< Minimal reactive power (MVAr) */
+ double baseMVA = 100; /**< Generator power base (MVA)*/
+ bool isOnline = true; /**< Machine status (> 0 = machine in-service; <= 0 = machine out-of-service) */
+ };
+ struct BranchData {
+ std::pair<int, int> busConnections = std::make_pair(0, 0); /**< Branch connection IDs */
+ double resistance = 0.0; /**< Branch resistance */
+ double indReactance = 0.0; /**< Branch inductive reactance */
+ double capSusceptance = 0.0; /**< Branch capacitive susceptance */
+ double tap = 0.0; /**< Transformer tap. If equal zero the branch is a line element */
+ double phaseShift = 0.0; /**< Transformer phase shift. Positive represents delay */
+ bool isOnline = true; /**< Element is online */
+ };
+
+ ParseMatpower(wxFileName mFile);
+ ~ParseMatpower() { ClearData(); }
+
+ void ClearData();
+
+ bool Parse();
+
+ std::vector<BranchData*> GetBranchData() const { return m_branchData; }
+ std::vector<BusData*> GetBusData() const { return m_busData; }
+ std::vector<GenData*> GetGenData() const { return m_genData; }
+ double GetMVAPowerBase() const { return m_mvaBase; }
+
+ BusData* GetBusDataFromID(int id);
+ Bus* GetBusFromID(int id, std::vector<Bus*> busList);
+
+ protected:
+ wxStringTokenizer GetMFileTokenData(wxTextFile& mFile, wxString currentLine);
+ wxFileName m_mFile;
+
+ std::vector<BusData*> m_busData;
+ std::vector<BranchData*> m_branchData;
+ std::vector<GenData*> m_genData;
+
+ wxString m_projectName = _("Imported project");
+ double m_mvaBase = 100.0;
+};
+
#endif // IMPORTFORM_H