Power System Platform  2026w10a-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)
 
BusDataGetBusDataFromID (int id)
 
BranchDataGetBranchDataFromID (int id, int fromBus, int toBus, ElementTypeAnarede type)
 
IndElementDataGetIndElementDataFromID (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 849 of file ImportForm.cpp.

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

◆ ~ParseAnarede()

ParseAnarede::~ParseAnarede ( )
inline

Definition at line 168 of file ImportForm.h.

168{ ClearData(); }

Member Function Documentation

◆ ClearData()

void ParseAnarede::ClearData ( )

Definition at line 1353 of file ImportForm.cpp.

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

◆ 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 1335 of file ImportForm.cpp.

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

◆ 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 1327 of file ImportForm.cpp.

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

◆ 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 1345 of file ImportForm.cpp.

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

◆ GetLenghtAndRotationFromBusCode()

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

Definition at line 1036 of file ImportForm.cpp.

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

◆ 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 1021 of file ImportForm.cpp.

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

◆ 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 1065 of file ImportForm.cpp.

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

◆ 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 1310 of file ImportForm.cpp.

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

◆ GetPWFStructuredData() [2/2]

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

Definition at line 1292 of file ImportForm.cpp.

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

◆ Parse()

bool ParseAnarede::Parse ( )

Definition at line 855 of file ImportForm.cpp.

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

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

1078{
1079 // Check if type exists, othewise return false
1080 int typeInt = wxAtoi(strType);
1081 switch(typeInt) {
1082 case ANA_BUS:
1083 case ANA_GENERATOR:
1084 case ANA_LOAD:
1085 case ANA_SHUNT:
1086 case ANA_MIT:
1087 case ANA_TRANSFORMER:
1088 case ANA_LINE:
1089 case ANA_IND_LOAD:
1090 case ANA_IND_SHUNT:
1091 case ANA_IND_GENERATOR: {
1092 type = static_cast<ElementTypeAnarede>(typeInt);
1093 return true;
1094 } break;
1095 default:
1096 break;
1097 }
1098 return false;
1099}
@ 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: