Power System Platform  2026w34a-beta
Loading...
Searching...
No Matches
ParseAnarede Class Reference

Class responsible to parse ANAREDE files to import data to PSP. More...

#include <ImportForm.h>

Classes

struct  BranchData
 
struct  BusData
 
struct  Component
 
struct  IndElementData
 
struct  IndGenData
 
struct  PowerLine
 

Public Member Functions

 ParseAnarede (wxFileName lstFile, wxFileName pwfFile)
 
bool Parse ()
 
std::vector< Component * > GetComponents () const
 
std::vector< PowerLine * > GetLines () const
 
std::vector< BranchData * > GetBranchData () const
 
std::vector< BusData * > GetBusData () const
 
std::vector< IndElementData * > GetIndElementData () const
 
wxString GetProjectName () const
 
double GetMVAPowerBase () const
 
wxPoint2DDouble GetNodePositionFromID (Bus *bus, double scale, int nodeID)
 
BusData * GetBusDataFromID (int id)
 
BranchData * GetBranchDataFromID (int id, int fromBus, int toBus, ElementTypeAnarede type)
 
IndElementData * GetIndElementDataFromID (int id, int busID, ElementTypeAnarede type)
 
void ClearData ()
 

Protected Member Functions

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, 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)
 

Protected Attributes

wxFileName m_lstFile
 
wxFileName m_pwfFile
 
std::vector< Component * > m_components
 
std::vector< PowerLine * > m_lines
 
std::vector< BusData * > m_busData
 
std::vector< BranchData * > m_branchData
 
std::vector< IndElementData * > m_indElementData
 
wxString m_projectName = _("Imported project")
 
double m_mvaBase = 100.0
 

Detailed Description

Class responsible to parse ANAREDE files to import data to PSP.

Author
Thales Lima Oliveira thale.nosp@m.s@uf.nosp@m.u.br
Date
27/03/2018

Definition at line 96 of file ImportForm.h.

Constructor & Destructor Documentation

◆ ParseAnarede()

ParseAnarede::ParseAnarede ( wxFileName  lstFile,
wxFileName  pwfFile 
)

Definition at line 850 of file ImportForm.cpp.

851{
852 m_lstFile = lstFile;
853 m_pwfFile = pwfFile;
854}

◆ ~ParseAnarede()

ParseAnarede::~ParseAnarede ( )
inline

Definition at line 168 of file ImportForm.h.

168{ ClearData(); }

Member Function Documentation

◆ ClearData()

void ParseAnarede::ClearData ( )

Definition at line 1354 of file ImportForm.cpp.

1355{
1356 for(auto it = m_components.begin(), itEnd = m_components.end(); it != itEnd; ++it) {
1357 if(*it) delete *it;
1358 }
1359 m_components.clear();
1360 for(auto it = m_lines.begin(), itEnd = m_lines.end(); it != itEnd; ++it) {
1361 if(*it) delete *it;
1362 }
1363 m_lines.clear();
1364 for(auto it = m_busData.begin(), itEnd = m_busData.end(); it != itEnd; ++it) {
1365 if(*it) delete *it;
1366 }
1367 m_busData.clear();
1368 for(auto it = m_branchData.begin(), itEnd = m_branchData.end(); it != itEnd; ++it) {
1369 if(*it) delete *it;
1370 }
1371 m_branchData.clear();
1372 for(auto it = m_indElementData.begin(), itEnd = m_indElementData.end(); it != itEnd; ++it) {
1373 if(*it) delete *it;
1374 }
1375 m_indElementData.clear();
1376}

◆ GetBranchData()

std::vector< BranchData * > ParseAnarede::GetBranchData ( ) const
inline

Definition at line 174 of file ImportForm.h.

174{ return m_branchData; }

◆ GetBranchDataFromID()

ParseAnarede::BranchData * ParseAnarede::GetBranchDataFromID ( int  id,
int  fromBus,
int  toBus,
ElementTypeAnarede  type 
)

Definition at line 1336 of file ImportForm.cpp.

1337{
1338 for(auto it = m_branchData.begin(), itEnd = m_branchData.end(); it != itEnd; ++it) {
1339 if((*it)->id == id && (*it)->busConnections.first == fromBus && (*it)->busConnections.second == toBus &&
1340 (*it)->type == type)
1341 return *it;
1342 }
1343 return nullptr;
1344}

◆ GetBusData()

std::vector< BusData * > ParseAnarede::GetBusData ( ) const
inline

Definition at line 175 of file ImportForm.h.

175{ return m_busData; }

◆ GetBusDataFromID()

ParseAnarede::BusData * ParseAnarede::GetBusDataFromID ( int  id)

Definition at line 1328 of file ImportForm.cpp.

1329{
1330 for(auto it = m_busData.begin(), itEnd = m_busData.end(); it != itEnd; ++it) {
1331 if((*it)->id == id) return *it;
1332 }
1333 return nullptr;
1334}

◆ GetComponents()

std::vector< Component * > ParseAnarede::GetComponents ( ) const
inline

Definition at line 172 of file ImportForm.h.

172{ return m_components; }

◆ GetIndElementData()

std::vector< IndElementData * > ParseAnarede::GetIndElementData ( ) const
inline

Definition at line 176 of file ImportForm.h.

176{ return m_indElementData; }

◆ GetIndElementDataFromID()

ParseAnarede::IndElementData * ParseAnarede::GetIndElementDataFromID ( int  id,
int  busID,
ElementTypeAnarede  type 
)

Definition at line 1346 of file ImportForm.cpp.

1347{
1348 for(auto it = m_indElementData.begin(), itEnd = m_indElementData.end(); it != itEnd; ++it) {
1349 if((*it)->id == id && (*it)->busConnection == busID && (*it)->type == type) return *it;
1350 }
1351 return nullptr;
1352}

◆ GetLenghtAndRotationFromBusCode()

bool ParseAnarede::GetLenghtAndRotationFromBusCode ( wxString  code,
double &  lenght,
int &  rotationID 
)
protected

Definition at line 1037 of file ImportForm.cpp.

1038{
1039 // Get code in decimal.
1040 long longCode;
1041 if(!code.ToLong(&longCode)) return false;
1042 // Convert code to hex
1043 std::stringstream hexCode;
1044 hexCode << std::hex << longCode;
1045 // Convert code to string
1046 wxString hexCodeStr = hexCode.str();
1047 // Get length on the substring
1048 wxString lenghtStr = hexCodeStr.Left(hexCodeStr.length() - 1);
1049 // Convert lenght string (hex) to decimal
1050 hexCode.str("");
1051 hexCode << lenghtStr.ToStdString();
1052 int intLenght;
1053 hexCode >> std::hex >> intLenght;
1054 lenght = static_cast<double>(intLenght);
1055 // Get rotation ID from substring
1056 wxString rotationIDStr = hexCodeStr.Right(1);
1057 // Convert rotation ID string to int
1058 long rotationIDLong;
1059 if(!rotationIDStr.ToLong(&rotationIDLong)) return false;
1060 rotationID = static_cast<int>(rotationIDLong);
1061 // Calculate the true value of lenght
1062 lenght = 3.0 * lenght - 16.0;
1063 return true;
1064}

◆ GetLines()

std::vector< PowerLine * > ParseAnarede::GetLines ( ) const
inline

Definition at line 173 of file ImportForm.h.

173{ return m_lines; }

◆ GetLSTLineNextValue()

wxString ParseAnarede::GetLSTLineNextValue ( wxString  line,
int &  currentPos 
)
protected

Definition at line 1022 of file ImportForm.cpp.

1023{
1024 // Parse each line column
1025 wxString strValue = "=";
1026 for(; currentPos < static_cast<int>(line.length()); ++currentPos) {
1027 if(line[currentPos] != ' ') { // Skip the firsts whitespaces
1028 wxString parsedLine = line.Mid(currentPos);
1029 strValue = parsedLine.BeforeFirst(' '); // Get the character before the first whitespace
1030 currentPos += strValue.length(); // Set the current parse position
1031 break;
1032 }
1033 }
1034 return strValue;
1035}

◆ GetMVAPowerBase()

double ParseAnarede::GetMVAPowerBase ( ) const
inline

Definition at line 178 of file ImportForm.h.

178{ return m_mvaBase; }

◆ GetNodePositionFromID()

wxPoint2DDouble ParseAnarede::GetNodePositionFromID ( Bus *  bus,
double  scale,
int  nodeID 
)

Definition at line 1066 of file ImportForm.cpp.

1067{
1068 wxPoint2DDouble nodePt;
1069
1070 double offset = (static_cast<double>(nodeID) - 1.0) * 16.0;
1071 nodePt = bus->GetPosition() + wxPoint2DDouble(offset * scale, 0) -
1072 wxPoint2DDouble(bus->GetWidth() / 2, bus->GetHeight() / 2);
1073 nodePt = bus->RotateAtPosition(nodePt, bus->GetAngle(), true);
1074
1075 return nodePt;
1076}
double GetWidth() const
Get the element width.
Definition Element.h:209
wxPoint2DDouble GetPosition() const
Get the element position.
Definition Element.h:189
double GetAngle() const
Get the element angle.
Definition Element.h:214
double GetHeight() const
Get the element height.
Definition Element.h:199
virtual wxPoint2DDouble RotateAtPosition(wxPoint2DDouble pointToRotate, double angle, bool degrees=true) const
Rotate a point as element position being the origin.
Definition Element.cpp:298

◆ GetProjectName()

wxString ParseAnarede::GetProjectName ( ) const
inline

Definition at line 177 of file ImportForm.h.

177{ return m_projectName; }

◆ GetPWFStructuredData() [1/2]

bool ParseAnarede::GetPWFStructuredData ( wxString  data,
unsigned int  startPos,
unsigned int  dataLenght,
double &  value,
int  decimalPos = -1 
)
protected

Definition at line 1311 of file ImportForm.cpp.

1316{
1317 if(data.length() < startPos || data.length() < (startPos + dataLenght)) {
1318 value = 0.0;
1319 return true;
1320 }
1321 wxString strValue = data.Mid(startPos, dataLenght);
1322 if(strValue.Find('-') == wxNOT_FOUND) strValue.Replace(' ', '0');
1323 if(decimalPos != -1 && strValue.Find('.') == wxNOT_FOUND) strValue.insert(decimalPos, '.');
1324 if(!strValue.ToCDouble(&value)) return false;
1325 return true;
1326}

◆ GetPWFStructuredData() [2/2]

bool ParseAnarede::GetPWFStructuredData ( wxString  data,
unsigned int  startPos,
unsigned int  dataLenght,
int &  value,
int  decimalPos = -1 
)
protected

Definition at line 1293 of file ImportForm.cpp.

1298{
1299 if(data.length() < startPos || data.length() < (startPos + dataLenght)) {
1300 value = 0;
1301 return true;
1302 }
1303 wxString strValue = data.Mid(startPos, dataLenght);
1304 strValue.Replace(' ', '0');
1305 long lValue = 0;
1306 if(!strValue.ToLong(&lValue)) return false;
1307 value = static_cast<int>(lValue);
1308 return true;
1309}

◆ Parse()

bool ParseAnarede::Parse ( )

Definition at line 856 of file ImportForm.cpp.

857{
858 wxTextFile lst(m_lstFile.GetFullPath());
859 wxTextFile pwf(m_pwfFile.GetFullPath());
860 if(!lst.Open()) return false;
861 if(!pwf.Open()) return false;
862
863 // Parse LST file
864 for(wxString line = lst.GetFirstLine(); !lst.Eof(); line = lst.GetNextLine()) {
865 // Current line
866 switch(static_cast<char>(line[0])) {
867 case 'C': { // Component
868 int parsePosition = 1;
869
870 Component* component = new Component();
871
872 component->id = wxAtoi(GetLSTLineNextValue(line, parsePosition));
873 // Check if is component type is valid
874 if(StrToElementType(GetLSTLineNextValue(line, parsePosition), component->type)) {
875 if(component->type == ANA_BUS) {
876 if(!GetLenghtAndRotationFromBusCode(GetLSTLineNextValue(line, parsePosition), component->length,
877 component->rotationID))
878 return false;
879 } else {
880 component->rotationID = wxAtoi(GetLSTLineNextValue(line, parsePosition));
881 }
882 parsePosition += 2; // Jump to position
883 if(!GetLSTLineNextValue(line, parsePosition).ToCDouble(&component->position.m_x)) return false;
884 if(!GetLSTLineNextValue(line, parsePosition).ToCDouble(&component->position.m_y)) return false;
885 parsePosition += 8; // Jump to electrical ID
886 component->electricalID = wxAtoi(GetLSTLineNextValue(line, parsePosition));
887
888 // Bus connection IDs
889 if(component->type != ANA_BUS) {
890 int fromBus = wxAtoi(GetLSTLineNextValue(line, parsePosition)); // Origin bus
891 int toBus = 0;
892 // If the component is a transformer, parse the next value (toBus)
893 if(component->type == ANA_TRANSFORMER) {
894 toBus = wxAtoi(GetLSTLineNextValue(line, parsePosition)); // Destiny bus
895 }
896 // Iterate through the already parsed components (the buses is saved first)
897 for(auto it = m_components.begin(), itEnd = m_components.end(); it != itEnd; ++it) {
898 if((*it)->type == ANA_BUS) {
899 if(fromBus == (*it)->electricalID) {
900 component->busConnectionID[0] = std::make_pair((*it)->id, fromBus);
901 } else if(toBus == (*it)->electricalID) {
902 component->busConnectionID[1] = std::make_pair((*it)->id, toBus);
903 }
904 }
905 }
906 }
907 m_components.push_back(component);
908 }
909 } break;
910 case 'L': { // Line
911 int parsePosition = 1;
912
913 PowerLine* pLine = new PowerLine();
914
915 pLine->id = wxAtoi(GetLSTLineNextValue(line, parsePosition));
916 pLine->type = static_cast<ElementTypeAnarede>(wxAtoi(GetLSTLineNextValue(line, parsePosition)));
917 parsePosition += 4; // Jump to from bus
918
919 int fromBus = wxAtoi(GetLSTLineNextValue(line, parsePosition)); // Origin bus
920 int toBus = wxAtoi(GetLSTLineNextValue(line, parsePosition)); // Destiny bus
921
922 // Iterate through the already parsed components
923 for(auto it = m_components.begin(), itEnd = m_components.end(); it != itEnd; ++it) {
924 if((*it)->type == ANA_BUS) {
925 if(fromBus == (*it)->id) {
926 pLine->busConnectionID[0] = std::make_pair((*it)->id, (*it)->electricalID);
927 } else if(toBus == (*it)->id) {
928 pLine->busConnectionID[1] = std::make_pair((*it)->id, (*it)->electricalID);
929 }
930 }
931 }
932 pLine->electricalID = wxAtoi(GetLSTLineNextValue(line, parsePosition));
933
934 m_lines.push_back(pLine);
935 } break;
936 case 'U': { // Connection
937 // The connection data depends on the component type, so this data definition must be more generic.
938 int parsePosition = 1;
939
940 int id = wxAtoi(GetLSTLineNextValue(line, parsePosition));
941 (void)id; // Unused id.
942 parsePosition += 5; // Jump to next relevant data
943 int data1 = wxAtoi(GetLSTLineNextValue(line, parsePosition));
944 int data2 = wxAtoi(GetLSTLineNextValue(line, parsePosition));
945 int data3 = wxAtoi(GetLSTLineNextValue(line, parsePosition));
946 int data4 = wxAtoi(GetLSTLineNextValue(line, parsePosition));
947 int data5 = wxAtoi(GetLSTLineNextValue(line, parsePosition));
948 int data6 = wxAtoi(GetLSTLineNextValue(line, parsePosition));
949
950 // If data5 differs from -1, the connection is power line data with data5's value as its ID, otherwise
951 // data1 is the ID of a component.
952 if(data5 != -1) {
953 // Iterate through parsed lines
954 for(auto it = m_lines.begin(), itEnd = m_lines.end(); it != itEnd; ++it) {
955 if(data5 == (*it)->id) {
956 (*it)->busConnectionNode[0] = std::make_pair(data1, data2);
957 (*it)->busConnectionNode[1] = std::make_pair(data3, data4);
958 for(int i = 0; i < data6; ++i) {
959 wxPoint2DDouble nodePt;
960 if(!GetLSTLineNextValue(line, parsePosition).ToCDouble(&nodePt.m_x)) return false;
961 if(!GetLSTLineNextValue(line, parsePosition).ToCDouble(&nodePt.m_y)) return false;
962 (*it)->nodesPosition.push_back(nodePt);
963 }
964 }
965 }
966 } else {
967 // Iterate through parsed components
968 for(auto it = m_components.begin(), itEnd = m_components.end(); it != itEnd; ++it) {
969 if(data1 == (*it)->id) {
970 if((*it)->type == ANA_BUS) {
971 // If the data1 is a bus ID, the element is a element with different data order.
972 // Find the correct element ID with data3
973 for(auto itDiff = m_components.begin(), itDiffEnd = m_components.end();
974 itDiff != itDiffEnd; ++itDiff) {
975 if(data3 == (*itDiff)->id) {
976 (*itDiff)->busConnectionNode[data4 - 1] = std::make_pair(data1, data2);
977 break;
978 }
979 }
980 } else {
981 (*it)->busConnectionNode[data2 - 1] = std::make_pair(data3, data4);
982 break;
983 }
984 }
985 }
986 }
987 } break;
988 default:
989 break;
990 }
991 }
992 // Last line
993
994 // Parse PWF file
995 for(wxString line = pwf.GetFirstLine(); !pwf.Eof(); line = pwf.GetNextLine()) {
996 // Current line
997 if(line == "TITU") { // Title
998 m_projectName = pwf.GetNextLine().Trim();
999 } else if(line != "") {
1000 if(line == "FIM") break;
1001 if(line[0] != '(') { // Ignore commented line
1002 wxString exeCode = line;
1003 wxString data = "";
1004 for(wxString lineData = pwf.GetNextLine(); lineData != "99999" && !pwf.Eof();
1005 lineData = pwf.GetNextLine()) {
1006 if(lineData == "FIM") break;
1007 if(lineData[0] != '(') { // Ignore commented line
1008 data += lineData + "\n";
1009 }
1010 }
1011 if(data != "" || data != "FIM") { // Don't parse empty data
1012 if(!ParsePWFExeCode(data, exeCode)) return false;
1013 }
1014 }
1015 }
1016 }
1017 // Last line
1018
1019 return true;
1020}
ElementTypeAnarede
Definition ImportForm.h:76
@ ANA_BUS
Definition ImportForm.h:77
@ ANA_TRANSFORMER
Definition ImportForm.h:82

◆ ParsePWFExeCode()

bool ParseAnarede::ParsePWFExeCode ( wxString  data,
wxString  exeCode 
)
protected

Definition at line 1102 of file ImportForm.cpp.

1103{
1104 if(exeCode == "DCTE") {
1105 // Parse data
1106 wxString code = "";
1107 wxString value = "";
1108 for(unsigned int i = 0; i < data.length(); ++i) {
1109 code = data.Mid(i, 4);
1110 value = data.Mid(i + 5, 6).Trim(false);
1111 i += 11;
1112 if(code == "BASE") {
1113 if(!value.ToCDouble(&m_mvaBase)) return false;
1114 break;
1115 }
1116 }
1117 } else if(exeCode == "DBAR") {
1118 wxString lineData = "";
1119 while(data != "") {
1120 wxString rest = "";
1121 lineData = data.BeforeFirst('\n', &rest);
1122 data = rest;
1123 BusData* busData = new BusData();
1124
1125 if(!GetPWFStructuredData(lineData, 0, 5, busData->id)) return false;
1126 wxString isOnlineCode = lineData.Mid(6, 1);
1127 if(isOnlineCode == "L" || isOnlineCode == " ")
1128 busData->isOnline = true;
1129 else if(isOnlineCode == "D")
1130 busData->isOnline = false;
1131 else
1132 return false;
1133 if(!GetPWFStructuredData(lineData, 7, 1, busData->type)) return false;
1134 busData->voltageBase = lineData.Mid(8, 2);
1135 busData->busName = lineData.Mid(10, 12).Trim();
1136 if(!GetPWFStructuredData(lineData, 24, 4, busData->voltage, 1)) return false;
1137 if(!GetPWFStructuredData(lineData, 28, 4, busData->angle)) return false;
1138 double pg, qg;
1139 if(!GetPWFStructuredData(lineData, 32, 5, pg)) return false;
1140 if(!GetPWFStructuredData(lineData, 37, 5, qg)) return false;
1141 busData->genPower = std::complex<double>(pg, qg);
1142 if(!GetPWFStructuredData(lineData, 42, 5, busData->minReactivePower)) return false;
1143 if(!GetPWFStructuredData(lineData, 47, 5, busData->maxReactivePower)) return false;
1144 if(!GetPWFStructuredData(lineData, 52, 6, busData->ctrlBusID)) return false;
1145 double pl, ql;
1146 if(!GetPWFStructuredData(lineData, 58, 5, pl)) return false;
1147 if(!GetPWFStructuredData(lineData, 63, 5, ql)) return false;
1148 busData->loadPower = std::complex<double>(pl, ql);
1149 if(!GetPWFStructuredData(lineData, 68, 5, busData->shuntReactive)) return false;
1150
1151 m_busData.push_back(busData);
1152 }
1153 } else if(exeCode == "DLIN") {
1154 wxString lineData = "";
1155 while(data != "") {
1156 wxString rest = "";
1157 lineData = data.BeforeFirst('\n', &rest);
1158 data = rest;
1159 BranchData* branchData = new BranchData();
1160
1161 if(!GetPWFStructuredData(lineData, 15, 2, branchData->id)) return false;
1162 int from, to;
1163 if(!GetPWFStructuredData(lineData, 0, 5, from)) return false;
1164 if(!GetPWFStructuredData(lineData, 10, 5, to)) return false;
1165 branchData->busConnections = std::make_pair(from, to);
1166
1167 wxString isOnlineCode = lineData.Mid(6, 1) + lineData.Mid(9, 1) + lineData.Mid(17, 1);
1168 if(isOnlineCode.Find('D') == wxNOT_FOUND)
1169 branchData->isOnline = true;
1170 else
1171 branchData->isOnline = false;
1172 if(!GetPWFStructuredData(lineData, 20, 6, branchData->resistance, 4)) return false;
1173 if(!GetPWFStructuredData(lineData, 26, 6, branchData->indReactance, 4)) return false;
1174 if(!GetPWFStructuredData(lineData, 32, 6, branchData->capSusceptance, 4)) return false;
1175 if(!GetPWFStructuredData(lineData, 38, 5, branchData->tap, 2)) return false;
1176 if(!GetPWFStructuredData(lineData, 53, 5, branchData->phaseShift, 3)) return false;
1177
1178 if(branchData->tap < 1e-3)
1179 branchData->type = ANA_LINE;
1180 else
1181 branchData->type = ANA_TRANSFORMER;
1182
1183 m_branchData.push_back(branchData);
1184 }
1185 } else if(exeCode == "DCAI") {
1186 wxString lineData = "";
1187 while(data != "") {
1188 wxString rest = "";
1189 lineData = data.BeforeFirst('\n', &rest);
1190 data = rest;
1191 IndElementData* indData = new IndElementData();
1192 indData->type = ANA_IND_LOAD;
1193
1194 if(!GetPWFStructuredData(lineData, 9, 2, indData->id)) return false;
1195 if(!GetPWFStructuredData(lineData, 0, 5, indData->busConnection)) return false;
1196
1197 wxString isOnlineCode = lineData.Mid(13, 1);
1198 if(isOnlineCode == "L" || isOnlineCode == " ")
1199 indData->isOnline = true;
1200 else if(isOnlineCode == "D")
1201 indData->isOnline = false;
1202 else
1203 return false;
1204
1205 double pl, ql;
1206 if(!GetPWFStructuredData(lineData, 22, 5, pl)) return false;
1207 if(!GetPWFStructuredData(lineData, 28, 5, ql)) return false;
1208 indData->power = std::complex<double>(pl, ql);
1209 // Unities in operation
1210 if(!GetPWFStructuredData(lineData, 18, 3, indData->numUnits)) return false;
1211
1212 m_indElementData.push_back(indData);
1213 }
1214 } else if(exeCode == "DGEI") {
1215 wxString lineData = "";
1216 while(data != "") {
1217 wxString rest = "";
1218 lineData = data.BeforeFirst('\n', &rest);
1219 data = rest;
1220 IndGenData* genData = new IndGenData();
1221 genData->type = ANA_IND_GENERATOR;
1222
1223 if(!GetPWFStructuredData(lineData, 9, 2, genData->id)) return false;
1224 if(!GetPWFStructuredData(lineData, 0, 5, genData->busConnection)) return false;
1225
1226 wxString isOnlineCode = lineData.Mid(12, 1);
1227 if(isOnlineCode == "L" || isOnlineCode == " ")
1228 genData->isOnline = true;
1229 else if(isOnlineCode == "D")
1230 genData->isOnline = false;
1231 else
1232 return false;
1233
1234 double pg, qg;
1235 if(!GetPWFStructuredData(lineData, 22, 5, pg)) return false;
1236 if(!GetPWFStructuredData(lineData, 27, 5, qg)) return false;
1237 genData->power = std::complex<double>(pg, qg);
1238 // Unities in operation
1239 if(!GetPWFStructuredData(lineData, 16, 3, genData->numUnits)) return false;
1240 if(!GetPWFStructuredData(lineData, 32, 5, genData->minReactivePower)) return false;
1241 if(!GetPWFStructuredData(lineData, 37, 5, genData->maxReactivePower)) return false;
1242 if(!GetPWFStructuredData(lineData, 42, 6, genData->xt, 2)) return false;
1243 if(!GetPWFStructuredData(lineData, 49, 5, genData->xd, 4)) return false;
1244 if(!GetPWFStructuredData(lineData, 54, 5, genData->xq, 4)) return false;
1245 if(!GetPWFStructuredData(lineData, 59, 5, genData->xl, 4)) return false;
1246 if(!GetPWFStructuredData(lineData, 69, 5, genData->ratedPower, 3)) return false;
1247
1248 m_indElementData.push_back(genData);
1249 }
1250 } else if(exeCode == "DBSH") {
1251 int lineNumber = 1;
1252 wxString lineData = "";
1253 int busNumber = -1;
1254
1255 while(data != "") {
1256 wxString rest = "";
1257 lineData = data.BeforeFirst('\n', &rest);
1258 data = rest;
1259
1260 if(lineNumber == 1) {
1261 if(!GetPWFStructuredData(lineData, 0, 5, busNumber)) return false;
1262 } else if(lineData == "FBAN") {
1263 lineNumber = 0;
1264 busNumber = -1;
1265 } else if(lineNumber >= 2 && busNumber != -1) {
1266 IndElementData* indShunt = new IndElementData();
1267 indShunt->type = ANA_IND_SHUNT;
1268 indShunt->busConnection = busNumber;
1269
1270 if(!GetPWFStructuredData(lineData, 0, 2, indShunt->id)) return false;
1271
1272 wxString isOnlineCode = lineData.Mid(6, 1);
1273 if(isOnlineCode == "L" || isOnlineCode == " ")
1274 indShunt->isOnline = true;
1275 else if(isOnlineCode == "D")
1276 indShunt->isOnline = false;
1277 else
1278 return false;
1279
1280 if(!GetPWFStructuredData(lineData, 12, 3, indShunt->numUnits)) return false;
1281 double ql;
1282 if(!GetPWFStructuredData(lineData, 16, 6, ql)) return false;
1283 indShunt->power = std::complex<double>(0.0, ql);
1284 m_indElementData.push_back(indShunt);
1285 }
1286 ++lineNumber;
1287 }
1288 }
1289
1290 return true;
1291}
@ ANA_IND_GENERATOR
Definition ImportForm.h:86
@ ANA_LINE
Definition ImportForm.h:83
@ ANA_IND_LOAD
Definition ImportForm.h:84
@ ANA_IND_SHUNT
Definition ImportForm.h:85

◆ StrToElementType()

bool ParseAnarede::StrToElementType ( wxString  strType,
ElementTypeAnarede &  type 
)
protected

Definition at line 1078 of file ImportForm.cpp.

1079{
1080 // Check if type exists, othewise return false
1081 int typeInt = wxAtoi(strType);
1082 switch(typeInt) {
1083 case ANA_BUS:
1084 case ANA_GENERATOR:
1085 case ANA_LOAD:
1086 case ANA_SHUNT:
1087 case ANA_MIT:
1088 case ANA_TRANSFORMER:
1089 case ANA_LINE:
1090 case ANA_IND_LOAD:
1091 case ANA_IND_SHUNT:
1092 case ANA_IND_GENERATOR: {
1093 type = static_cast<ElementTypeAnarede>(typeInt);
1094 return true;
1095 } break;
1096 default:
1097 break;
1098 }
1099 return false;
1100}
@ ANA_MIT
Definition ImportForm.h:81
@ ANA_GENERATOR
Definition ImportForm.h:78
@ ANA_SHUNT
Definition ImportForm.h:80
@ ANA_LOAD
Definition ImportForm.h:79

Member Data Documentation

◆ m_branchData

std::vector<BranchData*> ParseAnarede::m_branchData
protected

Definition at line 209 of file ImportForm.h.

◆ m_busData

std::vector<BusData*> ParseAnarede::m_busData
protected

Definition at line 208 of file ImportForm.h.

◆ m_components

std::vector<Component*> ParseAnarede::m_components
protected

Definition at line 206 of file ImportForm.h.

◆ m_indElementData

std::vector<IndElementData*> ParseAnarede::m_indElementData
protected

Definition at line 210 of file ImportForm.h.

◆ m_lines

std::vector<PowerLine*> ParseAnarede::m_lines
protected

Definition at line 207 of file ImportForm.h.

◆ m_lstFile

wxFileName ParseAnarede::m_lstFile
protected

Definition at line 203 of file ImportForm.h.

◆ m_mvaBase

double ParseAnarede::m_mvaBase = 100.0
protected

Definition at line 213 of file ImportForm.h.

◆ m_projectName

wxString ParseAnarede::m_projectName = _("Imported project")
protected

Definition at line 212 of file ImportForm.h.

◆ m_pwfFile

wxFileName ParseAnarede::m_pwfFile
protected

Definition at line 204 of file ImportForm.h.


The documentation for this class was generated from the following files: