Power System Platform  2026w10a-beta
Loading...
Searching...
No Matches
FileHanding Class Reference

Save and opens the projects created on disk. More...

#include <FileHanding.h>

Collaboration diagram for FileHanding:

Public Member Functions

 FileHanding (Workspace *workspace)
 
 FileHanding (ControlEditor *controlEditor)
 
void SetWorkspace (Workspace *workspace)
 
void SetControlEditor (ControlEditor *controlEditor)
 
void SaveProject (wxFileName path)
 
bool OpenProject (wxFileName path)
 
void SaveControl (wxFileName path)
 
bool OpenControl (wxFileName path, std::vector< std::shared_ptr< ControlElement > > &ctrlElementList, std::vector< std::shared_ptr< ConnectionLine > > &ctrlConnectionList)
 
void SaveControlElements (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementsNode, ControlElementContainer *ctrlContainer=nullptr)
 
bool OpenControlElements (rapidxml::xml_document<> &doc, rapidxml::xml_node<> *elementsNode, ControlElementContainer *ctrlContainer=nullptr)
 

Protected Attributes

Workspacem_workspace = nullptr
 
ControlEditorm_controlEditor = nullptr
 

Detailed Description

Save and opens the projects created on disk.

Author
Thales Lima Oliveira thale.nosp@m.s@uf.nosp@m.u.br
Date
05/10/2017

Definition at line 42 of file FileHanding.h.

Constructor & Destructor Documentation

◆ FileHanding() [1/3]

FileHanding::FileHanding ( )

Definition at line 23 of file FileHanding.cpp.

23{}

◆ FileHanding() [2/3]

FileHanding::FileHanding ( Workspace workspace)

Definition at line 21 of file FileHanding.cpp.

21{ m_workspace = workspace; }

◆ FileHanding() [3/3]

FileHanding::FileHanding ( ControlEditor controlEditor)

Definition at line 22 of file FileHanding.cpp.

22{ m_controlEditor = controlEditor; }

◆ ~FileHanding()

FileHanding::~FileHanding ( )

Definition at line 20 of file FileHanding.cpp.

20{}

Member Function Documentation

◆ OpenControl()

bool FileHanding::OpenControl ( wxFileName  path,
std::vector< std::shared_ptr< ControlElement > > &  ctrlElementList,
std::vector< std::shared_ptr< ConnectionLine > > &  ctrlConnectionList 
)

Definition at line 661 of file FileHanding.cpp.

664{
665 rapidxml::xml_document<> doc;
666 rapidxml::file<> xmlFile(path.GetFullPath().mb_str());
667
668 doc.parse<0>(xmlFile.data());
669
670 auto projectNode = doc.first_node("Control");
671 if (!projectNode) return false;
672 // auto nameNode = projectNode->first_node("Name");
673 // if(!nameNode) return false;
674 // m_controlEditor->SetName(nameNode->value());
675
676 // Open elements
677 auto elementsNode = projectNode->first_node("ControlElements");
678 if (!elementsNode) return false;
679
680 // auto elementsNode = XMLParser::AppendNode(doc, rootNode, "ControlElements");
681 auto ctrlElementContainer = new ControlElementContainer();
682 if (!OpenControlElements(doc, elementsNode, ctrlElementContainer)) return false;
683
684 ctrlElementList.clear();
685 ctrlConnectionList.clear();
686 auto elementRawList = ctrlElementContainer->GetControlElementsList();
687 for (auto& element : elementRawList) {
688 ctrlElementList.emplace_back(element);
689 }
690 auto connectionRawList = ctrlElementContainer->GetConnectionLineList();
691 for (auto& connection : connectionRawList) {
692 ctrlConnectionList.emplace_back(connection);
693 }
694 //ctrlElementList = ctrlElementContainer->GetControlElementsList();
695 //ctrlConnectionList = ctrlElementContainer->GetConnectionLineList();
696 return true;
697}
Class that can contain all control elements. Can identify (using RTTI) the elements from a generic li...

◆ OpenControlElements()

bool FileHanding::OpenControlElements ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  elementsNode,
ControlElementContainer ctrlContainer = nullptr 
)

Definition at line 815 of file FileHanding.cpp.

818{
819 std::vector< std::shared_ptr<ControlElement> > elementList;
820 std::vector< std::shared_ptr<ConnectionLine> > connectionList;
821
822 //{ Constant
823 auto constListNode = elementsNode->first_node("ConstantList");
824 if (constListNode) {
825 auto constNode = constListNode->first_node("Constant");
826 while (constNode) {
827 int id = XMLParser::GetAttributeValueInt(constNode, "ID");
828 Constant* constant = new Constant(id);
829
830 if (!constant->OpenElement(constNode)) return false;
831 elementList.emplace_back(constant);
832
833 constNode = constNode->next_sibling("Constant");
834 }
835 }
836 //}
837
838 //{ Exponential
839 auto expListNode = elementsNode->first_node("ExponentialList");
840 if (expListNode) {
841 auto expNode = expListNode->first_node("Exponential");
842 while (expNode) {
843 int id = XMLParser::GetAttributeValueInt(expNode, "ID");
844 Exponential* exponential = new Exponential(id);
845
846 if (!exponential->OpenElement(expNode)) return false;
847 elementList.emplace_back(exponential);
848
849 expNode = expNode->next_sibling("Exponential");
850 }
851 }
852 //}
853
854 //{ Gain
855 auto gainListNode = elementsNode->first_node("GainList");
856 if (gainListNode) {
857 auto gainNode = gainListNode->first_node("Gain");
858 while (gainNode) {
859 int id = XMLParser::GetAttributeValueInt(gainNode, "ID");
860 Gain* gain = new Gain(id);
861
862 if (!gain->OpenElement(gainNode)) return false;
863 elementList.emplace_back(gain);
864
865 gainNode = gainNode->next_sibling("Gain");
866 }
867 }
868 //}
869
870 //{ IO
871 auto ioListNode = elementsNode->first_node("IOList");
872 if (ioListNode) {
873 auto ioNode = ioListNode->first_node("IO");
874 while (ioNode) {
875 int id = XMLParser::GetAttributeValueInt(ioNode, "ID");
876 int ioFlags = XMLParser::GetNodeValueInt(ioNode, "IOFlags");
877
878 IOControl* io = new IOControl(ioFlags, id);
879
880 if (!io->OpenElement(ioNode)) return false;
881 elementList.emplace_back(io);
882
883 ioNode = ioNode->next_sibling("IO");
884 }
885 }
886 //}
887
888 //{ Limiter
889 auto limiterListNode = elementsNode->first_node("LimiterList");
890 if (limiterListNode) {
891 auto limiterNode = limiterListNode->first_node("Limiter");
892 while (limiterNode) {
893 int id = XMLParser::GetAttributeValueInt(limiterNode, "ID");
894 Limiter* limiter = new Limiter(id);
895
896 if (!limiter->OpenElement(limiterNode)) return false;
897 elementList.emplace_back(limiter);
898
899 limiterNode = limiterNode->next_sibling("Limiter");
900 }
901 }
902 //}
903
904 //{ Multiplier
905 auto multiplierListNode = elementsNode->first_node("MultiplierList");
906 if (multiplierListNode) {
907 auto multiplierNode = multiplierListNode->first_node("Multiplier");
908 while (multiplierNode) {
909 int id = XMLParser::GetAttributeValueInt(multiplierNode, "ID");
910 Multiplier* multiplier = new Multiplier(id);
911
912 if (!multiplier->OpenElement(multiplierNode)) return false;
913 elementList.emplace_back(multiplier);
914
915 multiplierNode = multiplierNode->next_sibling("Multiplier");
916 }
917 }
918 //}
919
920 //{ Divider
921 auto dividerListNode = elementsNode->first_node("DividerList");
922 if (dividerListNode) {
923 auto dividerNode = dividerListNode->first_node("Divider");
924 while (dividerNode) {
925 int id = XMLParser::GetAttributeValueInt(dividerNode, "ID");
926 Divider* divider = new Divider(id);
927
928 if (!divider->OpenElement(dividerNode)) return false;
929 elementList.emplace_back(divider);
930
931 dividerNode = dividerNode->next_sibling("Divider");
932 }
933 }
934 //}
935
936 //{ Rate limiter
937 auto rateLimiterListNode = elementsNode->first_node("RateLimiterList");
938 if (rateLimiterListNode) {
939 auto rateLimiterNode = rateLimiterListNode->first_node("RateLimiter");
940 while (rateLimiterNode) {
941 int id = XMLParser::GetAttributeValueInt(rateLimiterNode, "ID");
942 RateLimiter* limiter = new RateLimiter(id);
943
944 if (!limiter->OpenElement(rateLimiterNode)) return false;
945 elementList.emplace_back(limiter);
946
947 rateLimiterNode = rateLimiterNode->next_sibling("RateLimiter");
948 }
949 }
950 //}
951
952 //{ Sum
953 auto sumListNode = elementsNode->first_node("SumList");
954 if (sumListNode) {
955 auto sumNode = sumListNode->first_node("Sum");
956 while (sumNode) {
957 int id = XMLParser::GetAttributeValueInt(sumNode, "ID");
958 Sum* sum = new Sum(id);
959
960 if (!sum->OpenElement(sumNode)) return false;
961 elementList.emplace_back(sum);
962
963 sumNode = sumNode->next_sibling("Sum");
964 }
965 }
966 //}
967
968 //{ Math expression
969 auto mathListNode = elementsNode->first_node("MathExprList");
970 if (mathListNode) {
971 auto mathExprNode = mathListNode->first_node("MathExpr");
972 while (mathExprNode) {
973 int id = XMLParser::GetAttributeValueInt(mathExprNode, "ID");
974 MathExpression* mathExpr = new MathExpression(id);
975
976 if (!mathExpr->OpenElement(mathExprNode)) return false;
977 elementList.emplace_back(mathExpr);
978
979 mathExprNode = mathExprNode->next_sibling("MathExpr");
980 }
981 }
982 //}
983
984 //{ Transfer function
985 auto tfListNode = elementsNode->first_node("TransferFunctionList");
986 if (tfListNode) {
987 auto tfNode = tfListNode->first_node("TransferFunction");
988 while (tfNode) {
989 int id = XMLParser::GetAttributeValueInt(tfNode, "ID");
991
992 if (!tf->OpenElement(tfNode)) return false;
993 elementList.emplace_back(tf);
994
995 tfNode = tfNode->next_sibling("TransferFunction");
996 }
997 }
998 //}
999
1000 //{ Connection line
1001 auto connectionListNode = elementsNode->first_node("ConnectionList");
1002 if (connectionListNode) {
1003 auto connNode = connectionListNode->first_node("Connection");
1004 while (connNode) {
1005 ConnectionLine* cLine = nullptr;
1006 int id = XMLParser::GetAttributeValueInt(connNode, "ID");
1007
1008 auto cadPropNode = connNode->first_node("CADProperties");
1009 if (!cadPropNode) return false;
1010 double offset = XMLParser::GetNodeValueDouble(cadPropNode, "Offset");
1011
1012 auto parentList = connNode->first_node("ParentList");
1013 if (!parentList) return false;
1014
1015 auto parentNode = parentList->first_node("Parent");
1016 bool firstNode = true;
1017 while (parentNode) {
1018 int elementID = XMLParser::GetNodeValueInt(parentNode, "ElementID");
1019 int nodeID = XMLParser::GetNodeValueInt(parentNode, "NodeID");
1020
1021 ControlElement* element = ControlElement::GetControlElementFromID(elementList, elementID);
1022 Node* node = element->GetNodeList()[nodeID];
1023
1024 if (firstNode) cLine = new ConnectionLine(node, id);
1025 cLine->AddParent(element);
1026 element->AddChild(cLine);
1027 if (!firstNode) cLine->AppendNode(node, element);
1028
1029 if (firstNode) firstNode = false;
1030 parentNode = parentNode->next_sibling("Parent");
1031 }
1032
1033 auto parentLine = connNode->first_node("ParentLine");
1034 if (!parentLine) return false;
1035 int parentLineID = XMLParser::GetAttributeValueInt(parentLine, "ID");
1036 if (parentLineID != -1) {
1037 for (auto it = connectionList.begin(), itEnd = connectionList.end(); it != itEnd; ++it) {
1038 ConnectionLine* parent = it->get();
1039 if (parent->GetID() == parentLineID) {
1040 cLine->SetParentLine(parent);
1041 parent->AddChild(cLine);
1042 }
1043 }
1044 }
1045
1046 cLine->SetOffset(offset);
1047 cLine->UpdatePoints();
1048 connectionList.emplace_back(cLine);
1049 connNode = connNode->next_sibling("Connection");
1050 }
1051 } //}
1052
1053 ctrlContainer->FillContainer(elementList, connectionList);
1054 return true;
1055}
Connection between two control elements or other connection line and an element.
A control element that provides a constant value.
Definition Constant.h:37
Control element that divides two inputs.
Definition Divider.h:33
virtual int GetID() const
Get the element ID.
Definition Element.h:271
virtual bool AddParent(Element *parent, wxPoint2DDouble position)
Add a parent to the element. This method must be used on power elements that connect to a bus,...
Definition Element.h:239
virtual void AddChild(Element *child)
Add a child to the child list.
Definition Element.cpp:566
Generates an output following an exponential function.
Definition Exponential.h:33
Provide an output multiplying the input by a constant.
Definition Gain.h:37
Provides the communication with the power element.
Definition IOControl.h:43
Limits the input value by superior and inferior values.
Definition Limiter.h:33
A generic math expression block that can perform math and conditional operations with the inputs.
Multiplies two inputs.
Definition Multiplier.h:33
Node of a control element. This class manages the user interaction with the connection and control el...
Limits the rising and/or falling rate.
Definition RateLimiter.h:33
Sum the all inputs (can choose the input signal).
Definition Sum.h:34
Calculates the time response by a frequency domain transfer function.

◆ OpenProject()

bool FileHanding::OpenProject ( wxFileName  path)

Definition at line 300 of file FileHanding.cpp.

301{
302 rapidxml::xml_document<> doc;
303 rapidxml::file<> xmlFile(path.GetFullPath().mb_str());
304
305 doc.parse<0>(xmlFile.data());
306
307 auto projectNode = doc.first_node("Project");
308 if (!projectNode) return false;
309 auto nameNode = projectNode->first_node("Name");
310 if (!nameNode) return false;
311 m_workspace->SetName(nameNode->value());
312
313 PropertiesData* propData = m_workspace->GetProperties();
314 SimulationData simData = propData->GetSimulationPropertiesData();
315
316 //{ Properties data
317 auto propertiesNode = projectNode->first_node("Properties");
318 if (propertiesNode) {
319 auto simPropertiesNode = propertiesNode->first_node("SimulationProperties");
320 if (simPropertiesNode) {
321 // General
322 auto general = simPropertiesNode->first_node("General");
323 simData.basePower = XMLParser::GetNodeValueDouble(general, "BasePower");
324 simData.basePowerUnit =
325 static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(general, "BasePower", "UnitID"));
326 auto contCalc = general->first_node("ContinuousCalculation");
327 simData.faultAfterPowerFlow = XMLParser::GetNodeValueInt(contCalc, "Fault");
328 simData.scPowerAfterPowerFlow = XMLParser::GetNodeValueInt(contCalc, "SCPower");
329 int harmDistortionAfterPowerFlow = XMLParser::GetNodeValueInt(contCalc, "HarmonicDistortion");
330 simData.harmDistortionAfterPowerFlow = harmDistortionAfterPowerFlow != -1 ? harmDistortionAfterPowerFlow : false;
331
332 // Power flow
333 auto powerFlow = simPropertiesNode->first_node("PowerFlow");
334 simData.powerFlowMethod =
335 static_cast<PowerFlowMethod>(XMLParser::GetNodeValueInt(powerFlow, "SolutionMethod"));
336 simData.accFator = XMLParser::GetNodeValueDouble(powerFlow, "AccFactor");
337 simData.powerFlowTolerance = XMLParser::GetNodeValueDouble(powerFlow, "Tolerance");
338 simData.powerFlowMaxIterations = XMLParser::GetNodeValueInt(powerFlow, "MaxIterations");
339 simData.initAngle = XMLParser::GetNodeValueDouble(powerFlow, "SlackAngle");
340
341 // Stability
342 auto stability = simPropertiesNode->first_node("Stability");
343 simData.timeStep = XMLParser::GetNodeValueDouble(stability, "TimeStep");
344 simData.stabilitySimulationTime = XMLParser::GetNodeValueDouble(stability, "SimulationTime");
345 simData.stabilityFrequency = XMLParser::GetNodeValueDouble(stability, "Frequency");
346 simData.stabilityTolerance = XMLParser::GetNodeValueDouble(stability, "Tolerance");
347 simData.stabilityMaxIterations = XMLParser::GetNodeValueDouble(stability, "MaxIterations");
348 simData.controlTimeStepRatio = XMLParser::GetNodeValueInt(stability, "ControlStepRatio");
349 simData.plotTime = XMLParser::GetNodeValueDouble(stability, "PlotStep");
350 simData.useCOI = XMLParser::GetNodeValueInt(stability, "UseCOI");
351
352 // ZIP load
353 auto compLoads = simPropertiesNode->first_node("ZIPLoad");
354 simData.useCompLoads = XMLParser::GetNodeValueInt(compLoads, "UseCompositeLoad");
355 auto activePowerComp = compLoads->first_node("ActivePowerComposition");
356 simData.constImpedanceActive = XMLParser::GetNodeValueDouble(activePowerComp, "ConstantImpedance");
357 simData.constCurrentActive = XMLParser::GetNodeValueDouble(activePowerComp, "ConstantCurrent");
358 simData.constPowerActive = XMLParser::GetNodeValueDouble(activePowerComp, "ConstantPower");
359 auto reactivePowerComp = compLoads->first_node("ReactivePowerComposition");
360 simData.constImpedanceReactive = XMLParser::GetNodeValueDouble(reactivePowerComp, "ConstantImpedance");
361 simData.constCurrentReactive = XMLParser::GetNodeValueDouble(reactivePowerComp, "ConstantCurrent");
362 simData.constPowerReactive = XMLParser::GetNodeValueDouble(reactivePowerComp, "ConstantPower");
363 auto uvLimit = compLoads->first_node("UndervoltageLimit");
364 simData.underVoltageConstCurrent = XMLParser::GetNodeValueDouble(uvLimit, "ConstantCurrent");
365 simData.underVoltageConstPower = XMLParser::GetNodeValueDouble(uvLimit, "ConstantPower");
366 }
367 }
368 //}
369
370 propData->SetSimulationPropertiesData(simData);
371
372 // Open elements
373 auto elementsNode = projectNode->first_node("Elements");
374 if (!elementsNode) return false;
375 std::vector<Element*> elementList;
376 // Save lists individually to get parents
377 std::vector<Bus*> busList;
378 std::vector<Capacitor*> capacitorList;
379 std::vector<IndMotor*> indMotorList;
380 std::vector<Inductor*> inductorList;
381 std::vector<Line*> lineList;
382 std::vector<Load*> loadList;
383 std::vector<SyncGenerator*> syncGeneratorList;
384 std::vector<SyncMotor*> syncMotorList;
385 std::vector<Transformer*> transformerList;
386 std::vector<HarmCurrent*> harmCurrentList;
387 std::vector<EMTElement*> emtElementList;
388 //std::vector<Text*> textList;
389 std::vector< std::shared_ptr<Text> > textList;
390
391 // List of parents
392 std::vector<Element*> parentList;
393
394 //{ Bus
395 auto busListNode = elementsNode->first_node("BusList");
396 if (!busListNode) return false;
397 auto busNode = busListNode->first_node("Bus");
398 while (busNode) {
399 Bus* bus = new Bus();
400
401 if (!bus->OpenElement(busNode)) return false;
402 elementList.push_back(bus);
403 busList.push_back(bus);
404 parentList.push_back(bus);
405
406 busNode = busNode->next_sibling("Bus");
407 } //}
408
409 //{ Capacitor
410 auto capacitorListNode = elementsNode->first_node("CapacitorList");
411 if (!capacitorListNode) return false;
412 auto capacitorNode = capacitorListNode->first_node("Capacitor");
413 while (capacitorNode) {
414 Capacitor* capacitor = new Capacitor();
415
416 if (!capacitor->OpenElement(capacitorNode, parentList)) return false;
417 elementList.push_back(capacitor);
418 capacitorList.push_back(capacitor);
419
420 capacitorNode = capacitorNode->next_sibling("Capacitor");
421 } //}
422
423 //{ IndMotor
424 auto indMotorListNode = elementsNode->first_node("IndMotorList");
425 if (!indMotorListNode) return false;
426 auto indMotorNode = indMotorListNode->first_node("IndMotor");
427 while (indMotorNode) {
428 IndMotor* indMotor = new IndMotor();
429
430 if (!indMotor->OpenElement(indMotorNode, parentList)) return false;
431 elementList.push_back(indMotor);
432 indMotorList.push_back(indMotor);
433
434 indMotorNode = indMotorNode->next_sibling("IndMotor");
435 } //}
436
437 //{ Inductor
438 auto inductorListNode = elementsNode->first_node("InductorList");
439 if (!inductorListNode) return false;
440 auto inductorNode = inductorListNode->first_node("Inductor");
441 while (inductorNode) {
442 Inductor* inductor = new Inductor();
443
444 if (!inductor->OpenElement(inductorNode, parentList)) return false;
445 elementList.push_back(inductor);
446 inductorList.push_back(inductor);
447
448 inductorNode = inductorNode->next_sibling("Inductor");
449 } //}
450
451 //{ Line
452 auto lineListNode = elementsNode->first_node("LineList");
453 if (!lineListNode) return false;
454 auto lineNode = lineListNode->first_node("Line");
455 while (lineNode) {
456 Line* line = new Line();
457
458 if (!line->OpenElement(lineNode, parentList)) return false;
459 elementList.push_back(line);
460 lineList.push_back(line);
461
462 lineNode = lineNode->next_sibling("Line");
463 } //}
464
465 //{ Load
466 auto loadListNode = elementsNode->first_node("LoadList");
467 if (!loadListNode) return false;
468 auto loadNode = loadListNode->first_node("Load");
469 while (loadNode) {
470 Load* load = new Load();
471
472 if (!load->OpenElement(loadNode, parentList)) return false;
473 elementList.push_back(load);
474 loadList.push_back(load);
475
476 loadNode = loadNode->next_sibling("Load");
477 } //}
478
479 //{ SyncGenerator
480 auto syncGeneratorListNode = elementsNode->first_node("SyncGeneratorList");
481 if (!syncGeneratorListNode) return false;
482 auto syncGeneratorNode = syncGeneratorListNode->first_node("SyncGenerator");
483
484 while (syncGeneratorNode) {
485 SyncGenerator* syncGenerator = new SyncGenerator();
486
487 if (!syncGenerator->OpenElement(syncGeneratorNode, parentList)) return false;
488
489 // Open controls.
490 auto data = syncGenerator->GetElectricalData();
491 auto electricalProp = syncGeneratorNode->first_node("ElectricalProperties");
492 auto stability = electricalProp->first_node("Stability");
493
494 auto avr = stability->first_node("AVR");
495 if (!avr) return false;
496 if (!OpenControlElements(doc, avr, data.avr)) return false;
497
498 auto speedGov = stability->first_node("SpeedGovernor");
499 if (!speedGov) return false;
500 if (!OpenControlElements(doc, speedGov, data.speedGov)) return false;
501
502 syncGenerator->SetElectricalData(data);
503
504 elementList.push_back(syncGenerator);
505 syncGeneratorList.push_back(syncGenerator);
506 syncGeneratorNode = syncGeneratorNode->next_sibling("SyncGenerator");
507 } //}
508
509 //{ SyncMotor
510 auto syncMotorListNode = elementsNode->first_node("SyncMotorList");
511 if (!syncMotorListNode) return false;
512 auto syncMotorNode = syncMotorListNode->first_node("SyncMotor");
513 while (syncMotorNode) {
514 SyncMotor* syncMotor = new SyncMotor();
515
516 if (!syncMotor->OpenElement(syncMotorNode, parentList)) return false;
517 elementList.push_back(syncMotor);
518 syncMotorList.push_back(syncMotor);
519
520 syncMotorNode = syncMotorNode->next_sibling("SyncMotor");
521 } //}
522
523 //{ Transformer
524 auto transformerListNode = elementsNode->first_node("TransformerList");
525 if (!transformerListNode) return false;
526 auto transfomerNode = transformerListNode->first_node("Transfomer");
527 while (transfomerNode) {
528 Transformer* transformer = new Transformer();
529
530 if (!transformer->OpenElement(transfomerNode, parentList)) return false;
531 elementList.push_back(transformer);
532 transformerList.push_back(transformer);
533
534 transfomerNode = transfomerNode->next_sibling("Transfomer");
535 } //}
536
537 //{ HarmCurrent
538 auto harmCurrentListNode = elementsNode->first_node("HarmCurrentList");
539 if (harmCurrentListNode) {
540 auto harmCurrentNode = harmCurrentListNode->first_node("HarmCurrent");
541 while (harmCurrentNode) {
542 HarmCurrent* harmCurrent = new HarmCurrent();
543
544 if (!harmCurrent->OpenElement(harmCurrentNode, parentList)) return false;
545 elementList.push_back(harmCurrent);
546 harmCurrentList.push_back(harmCurrent);
547
548 harmCurrentNode = harmCurrentNode->next_sibling("HarmCurrent");
549 }
550 } //}
551 //{ HarmCurrent
552 auto emtElementListNode = elementsNode->first_node("EMTElementList");
553 if (emtElementListNode) {
554 auto emtElementNode = emtElementListNode->first_node("EMTElement");
555 while (emtElementNode) {
556 EMTElement* emtElement = new EMTElement();
557
558 if (!emtElement->OpenElement(emtElementNode, parentList)) return false;
559 elementList.push_back(emtElement);
560 emtElementList.push_back(emtElement);
561
562 emtElementNode = emtElementNode->next_sibling("EMTElement");
563 }
564 } //}
565
566 m_workspace->SetElementList(elementList);
567
568 //{ Text
569 auto textListNode = elementsNode->first_node("TextList");
570 if (!textListNode) return false;
571 auto textNode = textListNode->first_node("Text");
572 while (textNode) {
573 //Text* text = new Text();
574 auto text = std::make_shared<Text>();
575
576 if (!text->OpenElement(textNode)) return true;
577
578 switch (text->GetElementTypeText()) {
579 case TYPE_NONE:
580 break;
581 case TYPE_BUS: {
582 Bus* bus = busList[text->GetElementNumber()];
583 text->SetElement(bus);
584 } break;
585 case TYPE_CAPACITOR: {
586 Capacitor* capacitor = capacitorList[text->GetElementNumber()];
587 text->SetElement(capacitor);
588 } break;
589 case TYPE_IND_MOTOR: {
590 IndMotor* indMotor = indMotorList[text->GetElementNumber()];
591 text->SetElement(indMotor);
592 } break;
593 case TYPE_INDUCTOR: {
594 Inductor* inductor = inductorList[text->GetElementNumber()];
595 text->SetElement(inductor);
596 } break;
597 case TYPE_LINE: {
598 Line* line = lineList[text->GetElementNumber()];
599 text->SetElement(line);
600 } break;
601 case TYPE_LOAD: {
602 Load* load = loadList[text->GetElementNumber()];
603 text->SetElement(load);
604 } break;
605 case TYPE_SYNC_GENERATOR: {
606 SyncGenerator* syncGenerator = syncGeneratorList[text->GetElementNumber()];
607 text->SetElement(syncGenerator);
608 } break;
609 case TYPE_SYNC_MOTOR: {
610 SyncMotor* syncMotor = syncMotorList[text->GetElementNumber()];
611 text->SetElement(syncMotor);
612 } break;
613 case TYPE_TRANSFORMER: {
614 Transformer* transformer = transformerList[text->GetElementNumber()];
615 text->SetElement(transformer);
616 } break;
617 case TYPE_HARMCURRENT: {
618 HarmCurrent* harmCurrent = harmCurrentList[text->GetElementNumber()];
619 text->SetElement(harmCurrent);
620 } break;
621 }
622
623 textList.push_back(text);
624 textNode = textNode->next_sibling("Text");
625 } //}
626
627 m_workspace->SetTextList(textList);
628 return true;
629}
ElectricalUnit
Electrical units.
Node for power elements. All others power elements are connected through this.
Definition Bus.h:86
Shunt capactior power element.
Definition Capacitor.h:39
Element to connect ATP-EMTP.
Definition EMTElement.h:65
Shunt Harmonic Corrent Source.
Definition HarmCurrent.h:24
Induction motor power element.
Definition IndMotor.h:119
Inductor shunt power element.
Definition Inductor.h:39
Power line element.
Definition Line.h:64
Loas shunt power element.
Definition Load.h:74
General and simulation data manager.
Synchronous generator power element.
Synchronous motor (synchronous compensator) power element.
Definition SyncMotor.h:135
Two-winding transformer power element.
Definition Transformer.h:84

◆ SaveControl()

void FileHanding::SaveControl ( wxFileName  path)

Definition at line 631 of file FileHanding.cpp.

632{
633 // Same process present in SaveProject():
634 std::ofstream writeProjectsFile(path.GetFullPath().mb_str());
635 writeProjectsFile.close();
636
637 rapidxml::xml_document<> doc;
638 rapidxml::file<> xmlFile(path.GetFullPath().mb_str());
639 doc.parse<0>(xmlFile.data());
640
641 rapidxml::xml_node<>* decl = doc.allocate_node(rapidxml::node_declaration);
642 rapidxml::xml_attribute<>* ver = doc.allocate_attribute("version", "1.0");
643 rapidxml::xml_attribute<>* encoding = doc.allocate_attribute("encoding", "utf-8");
644 decl->append_attribute(ver);
645 decl->append_attribute(encoding);
646 doc.append_node(decl);
647
648 rapidxml::xml_node<>* rootNode = doc.allocate_node(rapidxml::node_element, "Control");
649 doc.append_node(rootNode);
650
651 rapidxml::xml_node<>* projectNameNode = XMLParser::AppendNode(doc, rootNode, "Name");
652 XMLParser::SetNodeValue(doc, projectNameNode, path.GetName());
653
654 auto elementsNode = XMLParser::AppendNode(doc, rootNode, "ControlElements");
655 SaveControlElements(doc, elementsNode);
656 std::ofstream writeXML(path.GetFullPath().mb_str());
657 writeXML << doc;
658 writeXML.close();
659}

◆ SaveControlElements()

void FileHanding::SaveControlElements ( rapidxml::xml_document<> &  doc,
rapidxml::xml_node<> *  elementsNode,
ControlElementContainer ctrlContainer = nullptr 
)

Definition at line 699 of file FileHanding.cpp.

702{
703 if (!ctrlContainer) {
704 ctrlContainer = new ControlElementContainer();
705 ctrlContainer->FillContainer(m_controlEditor);
706 }
707
708 //{ Constant
709 auto constsNode = XMLParser::AppendNode(doc, elementsNode, "ConstantList");
710 auto constList = ctrlContainer->GetConstantList();
711 for (auto it = constList.begin(), itEnd = constList.end(); it != itEnd; ++it) {
712 (*it)->SaveElement(doc, constsNode);
713 } //}
714
715 //{ Exponential
716 auto expsNode = XMLParser::AppendNode(doc, elementsNode, "ExponentialList");
717 auto expList = ctrlContainer->GetExponentialList();
718 for (auto it = expList.begin(), itEnd = expList.end(); it != itEnd; ++it) { (*it)->SaveElement(doc, expsNode); } //}
719
720 //{ Gain
721 auto gainsNode = XMLParser::AppendNode(doc, elementsNode, "GainList");
722 auto gainList = ctrlContainer->GetGainList();
723 for (auto it = gainList.begin(), itEnd = gainList.end(); it != itEnd; ++it) {
724 (*it)->SaveElement(doc, gainsNode);
725 } //}
726
727 //{ IO
728 auto iosNode = XMLParser::AppendNode(doc, elementsNode, "IOList");
729 auto ioList = ctrlContainer->GetIOControlList();
730 for (auto it = ioList.begin(), itEnd = ioList.end(); it != itEnd; ++it) { (*it)->SaveElement(doc, iosNode); } //}
731
732 //{ Limiter
733 auto limitersNode = XMLParser::AppendNode(doc, elementsNode, "LimiterList");
734 auto limiterList = ctrlContainer->GetLimiterList();
735 for (auto it = limiterList.begin(), itEnd = limiterList.end(); it != itEnd; ++it) {
736 (*it)->SaveElement(doc, limitersNode);
737 } //}
738
739 //{ Multiplier
740 auto multipliersNode = XMLParser::AppendNode(doc, elementsNode, "MultiplierList");
741 auto multiplierList = ctrlContainer->GetMultiplierList();
742 for (auto it = multiplierList.begin(), itEnd = multiplierList.end(); it != itEnd; ++it) {
743 (*it)->SaveElement(doc, multipliersNode);
744 } //}
745
746 //{ Divider
747 auto dividersNode = XMLParser::AppendNode(doc, elementsNode, "DividerList");
748 auto dividersList = ctrlContainer->GetDividerList();
749 for (auto it = dividersList.begin(), itEnd = dividersList.end(); it != itEnd; ++it) {
750 (*it)->SaveElement(doc, dividersNode);
751 } //}
752
753 //{ Rate limiter
754 auto rateLimitersNode = XMLParser::AppendNode(doc, elementsNode, "RateLimiterList");
755 auto rateLimiterList = ctrlContainer->GetRateLimiterList();
756 for (auto it = rateLimiterList.begin(), itEnd = rateLimiterList.end(); it != itEnd; ++it) {
757 (*it)->SaveElement(doc, rateLimitersNode);
758 } //}
759
760 //{ Sum
761 auto sumsNode = XMLParser::AppendNode(doc, elementsNode, "SumList");
762 auto sumList = ctrlContainer->GetSumList();
763 for (auto it = sumList.begin(), itEnd = sumList.end(); it != itEnd; ++it) { (*it)->SaveElement(doc, sumsNode); } //}
764
765 //{ Math expression
766 auto mathExprsNode = XMLParser::AppendNode(doc, elementsNode, "MathExprList");
767 auto mathExprList = ctrlContainer->GetMathExprList();
768 for (auto it = mathExprList.begin(), itEnd = mathExprList.end(); it != itEnd; ++it) {
769 (*it)->SaveElement(doc, mathExprsNode);
770 } //}
771
772 //{ Transfer function
773 auto tfsNode = XMLParser::AppendNode(doc, elementsNode, "TransferFunctionList");
774 auto tfList = ctrlContainer->GetTFList();
775 for (auto it = tfList.begin(), itEnd = tfList.end(); it != itEnd; ++it) { (*it)->SaveElement(doc, tfsNode); } //}
776
777 //{ Connection line
778 auto cLinesNode = XMLParser::AppendNode(doc, elementsNode, "ConnectionList");
779 auto connLineList = ctrlContainer->GetConnectionLineList();
780 for (auto it = connLineList.begin(), itEnd = connLineList.end(); it != itEnd; ++it) {
781 ConnectionLine* cLine = it->get();
782 auto cLineNode = XMLParser::AppendNode(doc, cLinesNode, "Connection");
783 XMLParser::SetNodeAttribute(doc, cLineNode, "ID", cLine->GetID());
784
785 // CAD properties
786 auto cadProp = XMLParser::AppendNode(doc, cLineNode, "CADProperties");
787 auto offset = XMLParser::AppendNode(doc, cadProp, "Offset");
788 XMLParser::SetNodeValue(doc, offset, cLine->GetOffset());
789
790 // Parent list
791 auto parentsNode = XMLParser::AppendNode(doc, cLineNode, "ParentList");
792 auto parentList = cLine->GetParentList();
793 int nodeIndex = 0;
794 for (auto itP = parentList.begin(), itPEnd = parentList.end(); itP != itPEnd; ++itP) {
795 Element* parent = *itP;
796 auto parentNode = XMLParser::AppendNode(doc, parentsNode, "Parent");
797 auto elementID = XMLParser::AppendNode(doc, parentNode, "ElementID");
798 XMLParser::SetNodeValue(doc, elementID, parent->GetID());
799 auto nodeID = XMLParser::AppendNode(doc, parentNode, "NodeID");
800 XMLParser::SetNodeValue(doc, nodeID, cLine->GetNodeList()[nodeIndex]->GetID());
801 nodeIndex++;
802 }
803
804 auto parentLine = XMLParser::AppendNode(doc, cLineNode, "ParentLine");
805 if (cLine->GetParentLine()) {
806 ConnectionLine* parent = cLine->GetParentLine();
807 XMLParser::SetNodeAttribute(doc, parentLine, "ID", parent->GetID());
808 }
809 else {
810 XMLParser::SetNodeAttribute(doc, parentLine, "ID", -1);
811 }
812 } //}
813}
Base class of all elements of the program. This class is responsible for manage graphical and his dat...
Definition Element.h:112
virtual std::vector< Element * > GetParentList() const
Get the parent list.
Definition Element.h:559

◆ SaveProject()

void FileHanding::SaveProject ( wxFileName  path)

Definition at line 24 of file FileHanding.cpp.

25{
26 // Erase the file (if exists or not) and write the initial data
27 std::ofstream writeProjectsFile(path.GetFullPath().mb_str());
28 writeProjectsFile.close();
29
30 rapidxml::xml_document<> doc;
31 rapidxml::file<> xmlFile(path.GetFullPath());
32 doc.parse<0>(xmlFile.data());
33
34 rapidxml::xml_node<>* decl = doc.allocate_node(rapidxml::node_declaration);
35 rapidxml::xml_attribute<>* ver = doc.allocate_attribute("version", "1.0");
36 rapidxml::xml_attribute<>* encoding = doc.allocate_attribute("encoding", "utf-8");
37 decl->append_attribute(ver);
38 decl->append_attribute(encoding);
39 doc.append_node(decl);
40
41 rapidxml::xml_node<>* rootNode = doc.allocate_node(rapidxml::node_element, "Project");
42 doc.append_node(rootNode);
43
44 rapidxml::xml_node<>* projectNameNode = XMLParser::AppendNode(doc, rootNode, "Name");
45 XMLParser::SetNodeValue(doc, projectNameNode, path.GetName());
46
47 //{ Simulation properties
48 PropertiesData* properties = m_workspace->GetProperties();
49 auto propertiesNode = XMLParser::AppendNode(doc, rootNode, "Properties");
50
51 SimulationData simulationData = properties->GetSimulationPropertiesData();
52 auto simulationPropNode = XMLParser::XMLParser::AppendNode(doc, propertiesNode, "SimulationProperties");
53
54 auto generalPropNode = XMLParser::AppendNode(doc, simulationPropNode, "General");
55 auto basePower = XMLParser::AppendNode(doc, generalPropNode, "BasePower");
56 XMLParser::SetNodeValue(doc, basePower, simulationData.basePower);
57 XMLParser::SetNodeAttribute(doc, basePower, "UnitID", static_cast<int>(simulationData.basePowerUnit));
58 auto contCalc = XMLParser::AppendNode(doc, generalPropNode, "ContinuousCalculation");
59 auto contCalcFault = XMLParser::AppendNode(doc, contCalc, "Fault");
60 XMLParser::SetNodeValue(doc, contCalcFault, simulationData.faultAfterPowerFlow);
61 auto contCalcSCPower = XMLParser::AppendNode(doc, contCalc, "SCPower");
62 XMLParser::SetNodeValue(doc, contCalcSCPower, simulationData.scPowerAfterPowerFlow);
63 auto contCalcTHD = XMLParser::AppendNode(doc, contCalc, "HarmonicDistortion");
64 XMLParser::SetNodeValue(doc, contCalcTHD, simulationData.harmDistortionAfterPowerFlow);
65
66 auto powerFlowPropNode = XMLParser::AppendNode(doc, simulationPropNode, "PowerFlow");
67 auto solutionMethod = XMLParser::AppendNode(doc, powerFlowPropNode, "SolutionMethod");
68 XMLParser::SetNodeValue(doc, solutionMethod, simulationData.powerFlowMethod);
69 auto accFactor = XMLParser::AppendNode(doc, powerFlowPropNode, "AccFactor");
70 XMLParser::SetNodeValue(doc, accFactor, simulationData.accFator);
71 auto pfTolerance = XMLParser::AppendNode(doc, powerFlowPropNode, "Tolerance");
72 XMLParser::SetNodeValue(doc, pfTolerance, simulationData.powerFlowTolerance);
73 auto pfMaxIter = XMLParser::AppendNode(doc, powerFlowPropNode, "MaxIterations");
74 XMLParser::SetNodeValue(doc, pfMaxIter, simulationData.powerFlowMaxIterations);
75 auto pfSlackAngle = XMLParser::AppendNode(doc, powerFlowPropNode, "SlackAngle");
76 XMLParser::SetNodeValue(doc, pfSlackAngle, simulationData.initAngle);
77
78 auto stabilityPropNode = XMLParser::AppendNode(doc, simulationPropNode, "Stability");
79 auto timeStep = XMLParser::AppendNode(doc, stabilityPropNode, "TimeStep");
80 XMLParser::SetNodeValue(doc, timeStep, simulationData.timeStep);
81 auto simTime = XMLParser::AppendNode(doc, stabilityPropNode, "SimulationTime");
82 XMLParser::SetNodeValue(doc, simTime, simulationData.stabilitySimulationTime);
83 auto freq = XMLParser::AppendNode(doc, stabilityPropNode, "Frequency");
84 XMLParser::SetNodeValue(doc, freq, simulationData.stabilityFrequency);
85 auto stabTolerance = XMLParser::AppendNode(doc, stabilityPropNode, "Tolerance");
86 XMLParser::SetNodeValue(doc, stabTolerance, simulationData.stabilityTolerance);
87 auto stabTMaxIter = XMLParser::AppendNode(doc, stabilityPropNode, "MaxIterations");
88 XMLParser::SetNodeValue(doc, stabTMaxIter, simulationData.stabilityMaxIterations);
89 auto controlRatio = XMLParser::AppendNode(doc, stabilityPropNode, "ControlStepRatio");
90 XMLParser::SetNodeValue(doc, controlRatio, simulationData.controlTimeStepRatio);
91 auto plotStep = XMLParser::AppendNode(doc, stabilityPropNode, "PlotStep");
92 XMLParser::SetNodeValue(doc, plotStep, simulationData.plotTime);
93 auto useCOI = XMLParser::AppendNode(doc, stabilityPropNode, "UseCOI");
94 XMLParser::SetNodeValue(doc, useCOI, simulationData.useCOI);
95
96 auto zipPropNode = XMLParser::AppendNode(doc, simulationPropNode, "ZIPLoad");
97 auto useCompLoads = XMLParser::AppendNode(doc, zipPropNode, "UseCompositeLoad");
98 XMLParser::SetNodeValue(doc, useCompLoads, simulationData.useCompLoads);
99 auto activePowerComp = XMLParser::AppendNode(doc, zipPropNode, "ActivePowerComposition");
100 auto pz = XMLParser::AppendNode(doc, activePowerComp, "ConstantImpedance");
101 XMLParser::SetNodeValue(doc, pz, simulationData.constImpedanceActive);
102 auto pi = XMLParser::AppendNode(doc, activePowerComp, "ConstantCurrent");
103 XMLParser::SetNodeValue(doc, pi, simulationData.constCurrentActive);
104 auto pp = XMLParser::AppendNode(doc, activePowerComp, "ConstantPower");
105 XMLParser::SetNodeValue(doc, pp, simulationData.constPowerActive);
106 auto reactivePowerComp = XMLParser::AppendNode(doc, zipPropNode, "ReactivePowerComposition");
107 auto qz = XMLParser::AppendNode(doc, reactivePowerComp, "ConstantImpedance");
108 XMLParser::SetNodeValue(doc, qz, simulationData.constImpedanceReactive);
109 auto qi = XMLParser::AppendNode(doc, reactivePowerComp, "ConstantCurrent");
110 XMLParser::SetNodeValue(doc, qi, simulationData.constCurrentReactive);
111 auto qp = XMLParser::AppendNode(doc, reactivePowerComp, "ConstantPower");
112 XMLParser::SetNodeValue(doc, qp, simulationData.constPowerReactive);
113 auto undervoltageLim = XMLParser::AppendNode(doc, zipPropNode, "UndervoltageLimit");
114 auto uvi = XMLParser::AppendNode(doc, undervoltageLim, "ConstantCurrent");
115 XMLParser::SetNodeValue(doc, uvi, simulationData.underVoltageConstCurrent);
116 auto uvp = XMLParser::AppendNode(doc, undervoltageLim, "ConstantPower");
117 XMLParser::SetNodeValue(doc, uvp, simulationData.underVoltageConstPower);
118
119 //}
120
121 auto elementsNode = XMLParser::AppendNode(doc, rootNode, "Elements");
122
123 // Save all the data
124 ElectricCalculation allElements;
125 allElements.GetElementsFromList(m_workspace->GetElementList());
126 int elementID = 0;
127
128 //{ Buses
129 auto busesNode = XMLParser::AppendNode(doc, elementsNode, "BusList");
130 auto busList = allElements.GetBusList();
131 for (auto* bus : busList) {
132 if (bus->IsInserted()) {
133 bus->SetID(elementID);
134 bus->SaveElement(doc, busesNode);
135 elementID++;
136 }
137 }
138 //}
139
140 //{ Capacitor
141 auto capacitorsNode = XMLParser::AppendNode(doc, elementsNode, "CapacitorList");
142 auto capacitorList = allElements.GetCapacitorList();
143 elementID = 0;
144 for (auto* capacitor : capacitorList) {
145 if (capacitor->IsInserted()) {
146 capacitor->SetID(elementID);
147 capacitor->SaveElement(doc, capacitorsNode);
148 elementID++;
149 }
150 }
151 //}
152
153 //{ IndMotor
154 auto indMotorsNode = XMLParser::AppendNode(doc, elementsNode, "IndMotorList");
155 auto indMotorList = allElements.GetIndMotorList();
156 elementID = 0;
157 for (auto* indMotor : indMotorList) {
158 if (indMotor->IsInserted()) {
159 indMotor->SetID(elementID);
160 indMotor->SaveElement(doc, indMotorsNode);
161 elementID++;
162 }
163 }
164 //}
165
166 //{ Inductor
167 auto inductorsNode = XMLParser::AppendNode(doc, elementsNode, "InductorList");
168 auto inductorList = allElements.GetInductorList();
169 elementID = 0;
170 for (auto* inductor : inductorList) {
171 if (inductor->IsInserted()) {
172 inductor->SetID(elementID);
173 inductor->SaveElement(doc, inductorsNode);
174 elementID++;
175 }
176 }
177 //}
178
179 //{ Line
180 auto linesNode = XMLParser::AppendNode(doc, elementsNode, "LineList");
181 auto lineList = allElements.GetLineList();
182 elementID = 0;
183 for (auto* line : lineList) {
184 if (line->IsInserted()) {
185 line->SetID(elementID);
186 line->SaveElement(doc, linesNode);
187 elementID++;
188 }
189 }
190 //}
191
192 //{ Load
193 auto loadsNode = XMLParser::AppendNode(doc, elementsNode, "LoadList");
194 auto loadList = allElements.GetLoadList();
195 elementID = 0;
196 for (auto* load : loadList) {
197 if (load->IsInserted()) {
198 load->SetID(elementID);
199 load->SaveElement(doc, loadsNode);
200 elementID++;
201 }
202 }
203 //}
204
205 //{ SyncGenerator
206 auto syncGeneratorsNode = XMLParser::AppendNode(doc, elementsNode, "SyncGeneratorList");
207 auto syncGeneratorList = allElements.GetSyncGeneratorList();
208 elementID = 0;
209 for (auto syncGen : syncGeneratorList) {
210 if (syncGen->IsInserted()) {
211 syncGen->SetID(elementID);
212 auto elementNode = syncGen->SaveElement(doc, syncGeneratorsNode);
213
214 // Save controls
215 auto data = syncGen->GetElectricalData();
216 auto electricalProp = elementNode->first_node("ElectricalProperties");
217 auto stability = electricalProp->first_node("Stability");
218
219 auto avr = XMLParser::AppendNode(doc, stability, "AVR");
220 if (data.avr) SaveControlElements(doc, avr, data.avr);
221
222 auto speedGov = XMLParser::AppendNode(doc, stability, "SpeedGovernor");
223 if (data.speedGov) SaveControlElements(doc, speedGov, data.speedGov);
224
225 elementID++;
226 }
227 }
228 //}
229
230 //{ SyncMotor
231 auto syncMotorsNode = XMLParser::AppendNode(doc, elementsNode, "SyncMotorList");
232 auto syncMotorList = allElements.GetSyncMotorList();
233 elementID = 0;
234 for (auto* syncMotor : syncMotorList) {
235 if (syncMotor->IsInserted()) {
236 syncMotor->SetID(elementID);
237 syncMotor->SaveElement(doc, syncMotorsNode);
238 elementID++;
239 }
240 }
241 //}
242
243 //{ Transfomer
244 auto transformersNode = XMLParser::AppendNode(doc, elementsNode, "TransformerList");
245 auto transformerList = allElements.GetTransformerList();
246 elementID = 0;
247 for (auto* transformer : transformerList) {
248 if (transformer->IsInserted()) {
249 transformer->SetID(elementID);
250 transformer->SaveElement(doc, transformersNode);
251 elementID++;
252 }
253 }
254 //}
255
256 //{ HarmCurrent
257 auto harmCurrentNode = XMLParser::AppendNode(doc, elementsNode, "HarmCurrentList");
258 auto harmCurrentList = allElements.GetHarmCurrentList();
259 elementID = 0;
260 for (auto* harmCurrent : harmCurrentList) {
261 if (harmCurrent->IsInserted()) {
262 harmCurrent->SetID(elementID);
263 harmCurrent->SaveElement(doc, harmCurrentNode);
264 elementID++;
265 }
266 }
267 //}
268
269 //{ EMTElement
270 auto emtElementNode = XMLParser::AppendNode(doc, elementsNode, "EMTElementList");
271 auto emtElementList = allElements.GetEMTElementList();
272 elementID = 0;
273 for (auto* emtElement : emtElementList) {
274 if (emtElement->IsInserted()) {
275 emtElement->SetID(elementID);
276 emtElement->SaveElement(doc, emtElementNode);
277 elementID++;
278 }
279 }
280 //}
281
282 //{ Text
283 auto textsNode = XMLParser::AppendNode(doc, elementsNode, "TextList");
284 auto textList = m_workspace->GetTextList();
285 elementID = 0;
286 for (auto& text : textList) {
287 if (text->IsInserted()) {
288 text->SetID(elementID);
289 text->SaveElement(doc, textsNode);
290 elementID++;
291 }
292 }
293 //}
294
295 std::ofstream writeXML(path.GetFullPath().mb_str());
296 writeXML << doc;
297 writeXML.close();
298}
Base class for electrical calculations providing general utility methods.
const std::vector< IndMotor * > GetIndMotorList() const
Get the induction motors of the system (use GetElementsFromList first).
const std::vector< Load * > GetLoadList() const
Get the loads of the system (use GetElementsFromList first).
const std::vector< SyncMotor * > GetSyncMotorList() const
Get the synchronous motors of the system (use GetElementsFromList first).
const std::vector< SyncGenerator * > GetSyncGeneratorList() const
Get the synchronous generators of the system (use GetElementsFromList first).
const std::vector< Transformer * > GetTransformerList() const
Get the transformers of the system (use GetElementsFromList first).
const std::vector< Capacitor * > GetCapacitorList() const
Get the capacitors of the system (use GetElementsFromList first).
const std::vector< Inductor * > GetInductorList() const
Get the inductors of the system (use GetElementsFromList first).
const std::vector< Line * > GetLineList() const
Get the lines of the system (use GetElementsFromList first).
const std::vector< EMTElement * > GetEMTElementList() const
Get the electromagnetic element list of the system (use GetElementsFromList first).
const std::vector< Bus * > GetBusList() const
Get the buses of the system (use GetElementsFromList first).
virtual void GetElementsFromList(std::vector< Element * > elementList)
Separate the power elements from a generic list.
const std::vector< HarmCurrent * > GetHarmCurrentList() const
Get the harmonic current source of the system (use GetElementsFromList first).

◆ SetControlEditor()

void FileHanding::SetControlEditor ( ControlEditor controlEditor)
inline

Definition at line 51 of file FileHanding.h.

51{ m_controlEditor = controlEditor; }

◆ SetWorkspace()

void FileHanding::SetWorkspace ( Workspace workspace)
inline

Definition at line 50 of file FileHanding.h.

50{ m_workspace = workspace; }

Member Data Documentation

◆ m_controlEditor

ControlEditor* FileHanding::m_controlEditor = nullptr
protected

Definition at line 66 of file FileHanding.h.

◆ m_workspace

Workspace* FileHanding::m_workspace = nullptr
protected

Definition at line 65 of file FileHanding.h.


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