diff options
-rw-r--r-- | .codelite/.tern-port | 2 | ||||
-rw-r--r-- | .codelite/PSP.session | 13 | ||||
-rw-r--r-- | .codelite/PSP.tags | bin | 72169472 -> 72197120 bytes | |||
-rw-r--r-- | .codelite/compilation.db | bin | 63488 -> 63488 bytes | |||
-rw-r--r-- | .codelite/refactoring.db | bin | 2356224 -> 2584576 bytes | |||
-rw-r--r-- | Project/Bus.cpp | 2 | ||||
-rw-r--r-- | Project/Capacitor.cpp | 1 | ||||
-rw-r--r-- | Project/Element.h | 2 | ||||
-rw-r--r-- | Project/FileHanding.cpp | 495 | ||||
-rw-r--r-- | Project/FileHanding.h | 3 | ||||
-rw-r--r-- | Project/Inductor.cpp | 1 | ||||
-rw-r--r-- | Project/Load.cpp | 1 | ||||
-rw-r--r-- | Project/Machines.cpp | 237 | ||||
-rw-r--r-- | Project/Project.mk | 2 | ||||
-rw-r--r-- | Project/Release/Branch.cpp.o | bin | 33186 -> 33983 bytes | |||
-rw-r--r-- | Project/Release/Bus.cpp.o | bin | 41729 -> 42552 bytes | |||
-rw-r--r-- | Project/Release/BusForm.cpp.o | bin | 119004 -> 119004 bytes | |||
-rw-r--r-- | Project/Release/Capacitor.cpp.o | bin | 43196 -> 44061 bytes | |||
-rw-r--r-- | Project/Release/ElectricCalculation.cpp.o | bin | 74373 -> 74373 bytes | |||
-rw-r--r-- | Project/Release/Element.cpp.o | bin | 155853 -> 156634 bytes | |||
-rw-r--r-- | Project/Release/FileHanding.cpp.o | bin | 62931 -> 106036 bytes | |||
-rw-r--r-- | Project/Release/GeneratorStabForm.cpp.o | bin | 104202 -> 104202 bytes | |||
-rw-r--r-- | Project/Release/IndMotor.cpp.o | bin | 36128 -> 36909 bytes | |||
-rw-r--r-- | Project/Release/IndMotorForm.cpp.o | bin | 87116 -> 87116 bytes | |||
-rw-r--r-- | Project/Release/Inductor.cpp.o | bin | 43101 -> 43966 bytes | |||
-rw-r--r-- | Project/Release/Line.cpp.o | bin | 163124 -> 163921 bytes | |||
-rw-r--r-- | Project/Release/LineForm.cpp.o | bin | 101112 -> 101112 bytes | |||
-rw-r--r-- | Project/Release/Load.cpp.o | bin | 41732 -> 42597 bytes | |||
-rw-r--r-- | Project/Release/Machines.cpp.o | bin | 38827 -> 39724 bytes | |||
-rw-r--r-- | Project/Release/MainFrame.cpp.o | bin | 154563 -> 154563 bytes | |||
-rw-r--r-- | Project/Release/PSP-UFU.exe | bin | 4330576 -> 4359746 bytes | |||
-rw-r--r-- | Project/Release/PowerFlow.cpp.o | bin | 43132 -> 43132 bytes | |||
-rw-r--r-- | Project/Release/ReactiveShuntElementForm.cpp.o | bin | 93115 -> 93115 bytes | |||
-rw-r--r-- | Project/Release/Shunt.cpp.o | bin | 34826 -> 35607 bytes | |||
-rw-r--r-- | Project/Release/SwitchingForm.cpp.o | bin | 107046 -> 107046 bytes | |||
-rw-r--r-- | Project/Release/SyncGenerator.cpp.o | bin | 41232 -> 42029 bytes | |||
-rw-r--r-- | Project/Release/SyncMachineForm.cpp.o | bin | 123729 -> 123729 bytes | |||
-rw-r--r-- | Project/Release/SyncMotor.cpp.o | bin | 37518 -> 38299 bytes | |||
-rw-r--r-- | Project/Release/Text.cpp.o | bin | 100370 -> 101167 bytes | |||
-rw-r--r-- | Project/Release/TextForm.cpp.o | bin | 165817 -> 165817 bytes | |||
-rw-r--r-- | Project/Release/Transformer.cpp.o | bin | 49898 -> 50721 bytes | |||
-rw-r--r-- | Project/Release/TransformerForm.cpp.o | bin | 108670 -> 108670 bytes | |||
-rw-r--r-- | Project/Release/Workspace.cpp.o | bin | 210774 -> 210774 bytes | |||
-rw-r--r-- | Project/Transformer.cpp | 2 |
44 files changed, 620 insertions, 141 deletions
diff --git a/.codelite/.tern-port b/.codelite/.tern-port index 947a654..5fcca59 100644 --- a/.codelite/.tern-port +++ b/.codelite/.tern-port @@ -1 +1 @@ -55536
\ No newline at end of file +50926
\ No newline at end of file diff --git a/.codelite/PSP.session b/.codelite/PSP.session index 8ee3401..5df01e6 100644 --- a/.codelite/PSP.session +++ b/.codelite/PSP.session @@ -34,14 +34,21 @@ <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\FileHanding.h" Name="FileName"/> <int Value="15" Name="FirstVisibleLine"/> - <int Value="26" Name="CurrentLine"/> + <int Value="38" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> <TabInfo> <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\FileHanding.cpp" Name="FileName"/> - <int Value="15" Name="FirstVisibleLine"/> - <int Value="34" Name="CurrentLine"/> + <int Value="400" Name="FirstVisibleLine"/> + <int Value="419" Name="CurrentLine"/> + <wxArrayString Name="Bookmarks"/> + <IntVector Name="CollapsedFolds"/> + </TabInfo> + <TabInfo> + <wxString Value="C:\Users\Thales\Documents\GitHub\PSP\Project\SyncGenerator.h" Name="FileName"/> + <int Value="3" Name="FirstVisibleLine"/> + <int Value="20" Name="CurrentLine"/> <wxArrayString Name="Bookmarks"/> <IntVector Name="CollapsedFolds"/> </TabInfo> diff --git a/.codelite/PSP.tags b/.codelite/PSP.tags Binary files differindex 365ab92..1255234 100644 --- a/.codelite/PSP.tags +++ b/.codelite/PSP.tags diff --git a/.codelite/compilation.db b/.codelite/compilation.db Binary files differindex 5615286..2102799 100644 --- a/.codelite/compilation.db +++ b/.codelite/compilation.db diff --git a/.codelite/refactoring.db b/.codelite/refactoring.db Binary files differindex 88197a0..d190c43 100644 --- a/.codelite/refactoring.db +++ b/.codelite/refactoring.db diff --git a/Project/Bus.cpp b/Project/Bus.cpp index a684ed4..f41b0d1 100644 --- a/Project/Bus.cpp +++ b/Project/Bus.cpp @@ -165,7 +165,7 @@ void Bus::Rotate(bool clockwise) if(!clockwise) rotAngle = -m_rotationAngle; m_angle += rotAngle; - if(m_angle >= 360.0) m_angle = 0.0; + if(m_angle >= 360 || m_angle <= -360) m_angle = 0.0; } bool Bus::GetContextMenu(wxMenu& menu) diff --git a/Project/Capacitor.cpp b/Project/Capacitor.cpp index 0110df3..332582d 100644 --- a/Project/Capacitor.cpp +++ b/Project/Capacitor.cpp @@ -91,6 +91,7 @@ void Capacitor::Rotate(bool clockwise) if(!clockwise) rotAngle = -m_rotationAngle; m_angle += rotAngle; + if(m_angle >= 360 || m_angle <= -360) m_angle = 0.0; m_pointList[2] = RotateAtPosition(m_pointList[2], rotAngle); m_pointList[3] = RotateAtPosition(m_pointList[3], rotAngle); UpdateSwitchesPosition(); diff --git a/Project/Element.h b/Project/Element.h index f5a2edb..27933a9 100644 --- a/Project/Element.h +++ b/Project/Element.h @@ -108,6 +108,8 @@ public: double GetAngle() const { return m_angle; } bool IsPickboxShown() const { return m_showPickbox; } bool IsOnline() const { return m_online; } + virtual std::vector<wxPoint2DDouble> GetPointList() const { return m_pointList; } + // Pure-virtuals methods virtual bool AddParent(Element* parent, wxPoint2DDouble position) = 0; virtual bool Contains(wxPoint2DDouble position) const = 0; diff --git a/Project/FileHanding.cpp b/Project/FileHanding.cpp index 5611ca6..c7a8759 100644 --- a/Project/FileHanding.cpp +++ b/Project/FileHanding.cpp @@ -2,16 +2,13 @@ FileHanding::~FileHanding() {} -FileHanding::FileHanding(Workspace* workspace) -{ - m_workspace = workspace; -} +FileHanding::FileHanding(Workspace* workspace) { m_workspace = workspace; } FileHanding::FileHanding() {} void FileHanding::SaveProject(wxFileName path) { - //Erase the file (if exists or not) and write the initial data + // Erase the file (if exists or not) and write the initial data std::ofstream writeProjectsFile(path.GetFullPath()); writeProjectsFile.close(); @@ -28,18 +25,458 @@ void FileHanding::SaveProject(wxFileName path) rapidxml::xml_node<>* rootNode = doc.allocate_node(rapidxml::node_element, "Project"); doc.append_node(rootNode); - + rapidxml::xml_node<>* projectNameNode = AppendNode(doc, rootNode, "Name"); SetNodeValue(doc, projectNameNode, path.GetName()); + + auto elementsNode = AppendNode(doc, rootNode, "Elements"); + + // Save all the data + ElectricCalculation allElements; + allElements.GetElementsFromList(m_workspace->GetElementList()); + + //{ Buses + auto busesNode = AppendNode(doc, elementsNode, "BusList"); + auto busList = allElements.GetBusList(); + for(int i = 0; i < (int)busList.size(); i++) { + Bus* bus = busList[i]; + auto busNode = AppendNode(doc, busesNode, "Bus"); + SetNodeAttribute(doc, busNode, "ID", i); + auto cadProp = AppendNode(doc, busNode, "CADProperties"); + auto position = AppendNode(doc, cadProp, "Position"); + auto posX = AppendNode(doc, position, "X"); + SetNodeValue(doc, posX, bus->GetPosition().m_x); + auto posY = AppendNode(doc, position, "Y"); + SetNodeValue(doc, posY, bus->GetPosition().m_y); + auto size = AppendNode(doc, cadProp, "Size"); + auto width = AppendNode(doc, size, "Width"); + SetNodeValue(doc, width, bus->GetWidth()); + auto height = AppendNode(doc, size, "Height"); + SetNodeValue(doc, height, bus->GetHeight()); + auto angle = AppendNode(doc, cadProp, "Angle"); + SetNodeValue(doc, angle, bus->GetAngle()); + + BusElectricalData data = bus->GetEletricalData(); + auto electricalProp = AppendNode(doc, busNode, "ElectricalProperties"); + auto name = AppendNode(doc, electricalProp, "Name"); + SetNodeValue(doc, name, data.name); + auto nominalVoltage = AppendNode(doc, electricalProp, "NominalVoltage"); + SetNodeValue(doc, nominalVoltage, data.nominalVoltage); + auto nominalVoltageUnit = AppendNode(doc, electricalProp, "NominalVoltageUnit"); + SetNodeValue(doc, nominalVoltageUnit, data.nominalVoltageUnit); + auto isVoltageControlled = AppendNode(doc, electricalProp, "IsVoltageControlled"); + SetNodeValue(doc, isVoltageControlled, data.isVoltageControlled); + auto controlledVoltage = AppendNode(doc, electricalProp, "ControlledVoltage"); + SetNodeValue(doc, controlledVoltage, data.controlledVoltage); + auto controlledVoltageUnitChoice = AppendNode(doc, electricalProp, "ControlledVoltageUnitChoice"); + SetNodeValue(doc, controlledVoltageUnitChoice, data.controlledVoltageUnitChoice); + auto slackBus = AppendNode(doc, electricalProp, "SlackBus"); + SetNodeValue(doc, slackBus, data.slackBus); + + auto fault = AppendNode(doc, electricalProp, "Fault"); + auto hasFault = AppendNode(doc, fault, "HasFault"); + SetNodeValue(doc, hasFault, data.hasFault); + auto faultType = AppendNode(doc, fault, "Type"); + SetNodeValue(doc, faultType, data.faultType); + auto faultLocation = AppendNode(doc, fault, "Location"); + SetNodeValue(doc, faultLocation, data.faultLocation); + auto faultResistance = AppendNode(doc, fault, "Resistance"); + SetNodeValue(doc, faultResistance, data.faultResistance); + auto faultReactance = AppendNode(doc, fault, "Reactance"); + SetNodeValue(doc, faultReactance, data.faultReactance); + + auto stability = AppendNode(doc, electricalProp, "Stability"); + auto plotBus = AppendNode(doc, stability, "Plot"); + SetNodeValue(doc, plotBus, data.plotBus); + auto stabHasFault = AppendNode(doc, stability, "HasFault"); + SetNodeValue(doc, stabHasFault, data.stabHasFault); + auto stabFaultTime = AppendNode(doc, stability, "FaultTime"); + SetNodeValue(doc, stabFaultTime, data.stabFaultTime); + auto stabFaultLength = AppendNode(doc, stability, "FaultLength"); + SetNodeValue(doc, stabFaultLength, data.stabFaultLength); + auto stabFaultResistance = AppendNode(doc, stability, "FaultResistance"); + SetNodeValue(doc, stabFaultResistance, data.stabFaultResistance); + auto stabFaultReactance = AppendNode(doc, stability, "FaultReactance"); + SetNodeValue(doc, stabFaultReactance, data.stabFaultReactance); + + data.number = i; + bus->SetElectricalData(data); + } //} + + //{ Capacitor + auto capacitorsNode = AppendNode(doc, elementsNode, "CapacitorList"); + auto capacitorList = allElements.GetCapacitorList(); + for(int i = 0; i < (int)capacitorList.size(); i++) { + Capacitor* capacitor = capacitorList[i]; + auto capacitorNode = AppendNode(doc, capacitorsNode, "Capacitor"); + auto cadProp = AppendNode(doc, capacitorNode, "CADProperties"); + auto position = AppendNode(doc, cadProp, "Position"); + auto posX = AppendNode(doc, position, "X"); + SetNodeValue(doc, posX, capacitor->GetPosition().m_x); + auto posY = AppendNode(doc, position, "Y"); + SetNodeValue(doc, posY, capacitor->GetPosition().m_y); + auto size = AppendNode(doc, cadProp, "Size"); + auto width = AppendNode(doc, size, "Width"); + SetNodeValue(doc, width, capacitor->GetWidth()); + auto height = AppendNode(doc, size, "Height"); + SetNodeValue(doc, height, capacitor->GetHeight()); + auto angle = AppendNode(doc, cadProp, "Angle"); + SetNodeValue(doc, angle, capacitor->GetAngle()); + auto parentID = AppendNode(doc, cadProp, "ParentID"); + Bus* parent = (Bus*)capacitor->GetParentList()[0]; + if(parent) SetNodeValue(doc, parentID, parent->GetEletricalData().number); + + CapacitorElectricalData data = capacitor->GetElectricalData(); + auto electricalProp = AppendNode(doc, capacitorNode, "ElectricalProperties"); + auto isOnline = AppendNode(doc, electricalProp, "IsOnline"); + SetNodeValue(doc, isOnline, capacitor->IsOnline()); + auto name = AppendNode(doc, capacitorNode, "Name"); + SetNodeValue(doc, name, data.name); + auto reactivePower = AppendNode(doc, electricalProp, "ReactivePower"); + SetNodeValue(doc, reactivePower, data.reactivePower); + auto reactivePowerUnit = AppendNode(doc, electricalProp, "ReactivePowerUnit"); + SetNodeValue(doc, reactivePowerUnit, data.reactivePowerUnit); + + auto switchingList = AppendNode(doc, electricalProp, "SwitchingList"); + SwitchingData swData = capacitor->GetSwitchingData(); + for(int j = 0; j < (int)swData.swType.size(); j++) { + auto switching = AppendNode(doc, switchingList, "Switching"); + SetNodeAttribute(doc, switching, "ID", j); + auto swType = AppendNode(doc, switching, "Type"); + SetNodeValue(doc, swType, swData.swType[j]); + auto swTime = AppendNode(doc, switching, "Time"); + SetNodeValue(doc, swTime, swData.swTime[j]); + } + } //} + + //{ IndMotor + auto indMotorsNode = AppendNode(doc, elementsNode, "IndMotorList"); + auto indMotorList = allElements.GetIndMotorList(); + for(int i = 0; i < (int)indMotorList.size(); i++) { + IndMotor* indMotor = indMotorList[i]; + auto indMotorNode = AppendNode(doc, indMotorsNode, "IndMotor"); + auto cadProp = AppendNode(doc, indMotorNode, "CADProperties"); + auto position = AppendNode(doc, cadProp, "Position"); + auto posX = AppendNode(doc, position, "X"); + SetNodeValue(doc, posX, indMotor->GetPosition().m_x); + auto posY = AppendNode(doc, position, "Y"); + SetNodeValue(doc, posY, indMotor->GetPosition().m_y); + auto size = AppendNode(doc, cadProp, "Size"); + auto width = AppendNode(doc, size, "Width"); + SetNodeValue(doc, width, indMotor->GetWidth()); + auto height = AppendNode(doc, size, "Height"); + SetNodeValue(doc, height, indMotor->GetHeight()); + auto angle = AppendNode(doc, cadProp, "Angle"); + SetNodeValue(doc, angle, indMotor->GetAngle()); + auto parentID = AppendNode(doc, cadProp, "ParentID"); + SetNodeValue(doc, parentID, ((Bus*)indMotor->GetParentList()[0])->GetEletricalData().number); + + IndMotorElectricalData data = indMotor->GetElectricalData(); + auto electricalProp = AppendNode(doc, indMotorNode, "ElectricalProperties"); + auto isOnline = AppendNode(doc, electricalProp, "IsOnline"); + SetNodeValue(doc, isOnline, indMotor->IsOnline()); + auto name = AppendNode(doc, electricalProp, "Name"); + SetNodeValue(doc, name, data.name); + auto activePower = AppendNode(doc, electricalProp, "ActivePower"); + SetNodeValue(doc, activePower, data.activePower); + auto activePowerUnit = AppendNode(doc, electricalProp, "ActivePowerUnit"); + SetNodeValue(doc, activePowerUnit, data.activePowerUnit); + auto reactivePower = AppendNode(doc, electricalProp, "ReactivePower"); + SetNodeValue(doc, reactivePower, data.reactivePower); + auto reactivePowerUnit = AppendNode(doc, electricalProp, "ReactivePowerUnit"); + SetNodeValue(doc, reactivePowerUnit, data.reactivePowerUnit); + } //} + + //{ Inductor + auto inductorsNode = AppendNode(doc, elementsNode, "InductorList"); + auto inductorList = allElements.GetInductorList(); + for(int i = 0; i < (int)inductorList.size(); i++) { + Inductor* inductor = inductorList[i]; + auto inductorNode = AppendNode(doc, inductorsNode, "Inductor"); + auto cadProp = AppendNode(doc, inductorNode, "CADProperties"); + auto position = AppendNode(doc, cadProp, "Position"); + auto posX = AppendNode(doc, position, "X"); + SetNodeValue(doc, posX, inductor->GetPosition().m_x); + auto posY = AppendNode(doc, position, "Y"); + SetNodeValue(doc, posY, inductor->GetPosition().m_y); + auto size = AppendNode(doc, cadProp, "Size"); + auto width = AppendNode(doc, size, "Width"); + SetNodeValue(doc, width, inductor->GetWidth()); + auto height = AppendNode(doc, size, "Height"); + SetNodeValue(doc, height, inductor->GetHeight()); + auto angle = AppendNode(doc, cadProp, "Angle"); + SetNodeValue(doc, angle, inductor->GetAngle()); + auto nodePos = AppendNode(doc, cadProp, "NodePosition"); + auto nodePosX = AppendNode(doc, nodePos, "X"); + SetNodeValue(doc, nodePosX, inductor->GetPointList()[0].m_x); + auto nodePosY = AppendNode(doc, nodePos, "Y"); + SetNodeValue(doc, nodePosY, inductor->GetPointList()[0].m_y); + auto parentID = AppendNode(doc, cadProp, "ParentID"); + Bus* parent = (Bus*)inductor->GetParentList()[0]; + if(parent) SetNodeValue(doc, parentID, parent->GetEletricalData().number); + + InductorElectricalData data = inductor->GetElectricalData(); + auto electricalProp = AppendNode(doc, inductorNode, "ElectricalProperties"); + auto isOnline = AppendNode(doc, electricalProp, "IsOnline"); + SetNodeValue(doc, isOnline, inductor->IsOnline()); + auto name = AppendNode(doc, electricalProp, "Name"); + SetNodeValue(doc, name, data.name); + auto reactivePower = AppendNode(doc, electricalProp, "ReactivePower"); + SetNodeValue(doc, reactivePower, data.reactivePower); + auto reactivePowerUnit = AppendNode(doc, electricalProp, "ReactivePowerUnit"); + SetNodeValue(doc, reactivePowerUnit, data.reactivePowerUnit); + + auto switchingList = AppendNode(doc, electricalProp, "SwitchingList"); + SwitchingData swData = inductor->GetSwitchingData(); + for(int j = 0; j < (int)swData.swType.size(); j++) { + auto switching = AppendNode(doc, switchingList, "Switching"); + SetNodeAttribute(doc, switching, "ID", j); + auto swType = AppendNode(doc, switching, "Type"); + SetNodeValue(doc, swType, swData.swType[j]); + auto swTime = AppendNode(doc, switching, "Time"); + SetNodeValue(doc, swTime, swData.swTime[j]); + } + } //} + + //{ Line + auto linesNode = AppendNode(doc, elementsNode, "LineList"); + auto lineList = allElements.GetLineList(); + for(int i = 0; i < (int)lineList.size(); i++) { + Line* line = lineList[i]; + auto lineNode = AppendNode(doc, linesNode, "Line"); + auto cadProp = AppendNode(doc, lineNode, "CADProperties"); + auto nodeList = AppendNode(doc, cadProp, "NodeList"); + auto ptList = line->GetPointList(); + int nodeID = 0; + for(int j = 0; j < (int)ptList.size(); j++) { + if((j != 1) && (j != (int)ptList.size() - 2)) { + auto nodePos = AppendNode(doc, nodeList, "Node"); + SetNodeAttribute(doc, nodePos, "ID", nodeID); + auto nodePosX = AppendNode(doc, nodePos, "X"); + SetNodeValue(doc, nodePosX, ptList[j].m_x); + auto nodePosY = AppendNode(doc, nodePos, "Y"); + SetNodeValue(doc, nodePosY, ptList[j].m_y); + nodeID++; + } + } + + auto parentIDList = AppendNode(doc, cadProp, "ParentIDList"); + for(int j = 0; j < (int)line->GetParentList().size(); j++) { + Bus* parent = (Bus*)line->GetParentList()[j]; + if(parent) { + auto parentID = AppendNode(doc, parentIDList, "ParentID"); + SetNodeAttribute(doc, parentID, "ID", j); + SetNodeValue(doc, parentID, parent->GetEletricalData().number); + } + } + + LineElectricalData data = line->GetElectricalData(); + auto electricalProp = AppendNode(doc, lineNode, "ElectricalProperties"); + auto isOnline = AppendNode(doc, electricalProp, "IsOnline"); + SetNodeValue(doc, isOnline, line->IsOnline()); + auto name = AppendNode(doc, electricalProp, "Name"); + SetNodeValue(doc, name, data.name); + auto nominalVoltage = AppendNode(doc, electricalProp, "NominalVoltage"); + SetNodeValue(doc, nominalVoltage, data.nominalVoltage); + auto nominalVoltageUnit = AppendNode(doc, electricalProp, "NominalVoltageUnit"); + SetNodeValue(doc, nominalVoltageUnit, data.nominalVoltageUnit); + auto nominalPower = AppendNode(doc, electricalProp, "NominalPower"); + SetNodeValue(doc, nominalPower, data.nominalPower); + auto nominalPowerUnit = AppendNode(doc, electricalProp, "NominalPowerUnit"); + SetNodeValue(doc, nominalPowerUnit, data.nominalPowerUnit); + auto resistance = AppendNode(doc, electricalProp, "Resistance"); + SetNodeValue(doc, resistance, data.resistance); + auto resistanceUnit = AppendNode(doc, electricalProp, "ResistanceUnit"); + SetNodeValue(doc, resistanceUnit, data.resistanceUnit); + auto indReactance = AppendNode(doc, electricalProp, "IndReactance"); + SetNodeValue(doc, indReactance, data.indReactance); + auto indReactanceUnit = AppendNode(doc, electricalProp, "IndReactanceUnit"); + SetNodeValue(doc, indReactanceUnit, data.indReactanceUnit); + auto capSusceptance = AppendNode(doc, electricalProp, "CapSusceptance"); + SetNodeValue(doc, capSusceptance, data.capSusceptance); + auto capSusceptanceUnit = AppendNode(doc, electricalProp, "CapSusceptanceUnit"); + SetNodeValue(doc, capSusceptanceUnit, data.capSusceptanceUnit); + auto lineSize = AppendNode(doc, electricalProp, "LineSize"); + SetNodeValue(doc, lineSize, data.lineSize); + auto useLinePower = AppendNode(doc, electricalProp, "UseLinePower"); + SetNodeValue(doc, useLinePower, data.useLinePower); + + auto fault = AppendNode(doc, electricalProp, "Fault"); + auto zeroResistance = AppendNode(doc, fault, "ZeroResistance"); + SetNodeValue(doc, zeroResistance, data.zeroResistance); + auto zeroIndReactance = AppendNode(doc, fault, "ZeroIndReactance"); + SetNodeValue(doc, zeroIndReactance, data.zeroIndReactance); + auto zeroCapSusceptance = AppendNode(doc, fault, "ZeroCapSusceptance"); + SetNodeValue(doc, zeroCapSusceptance, data.zeroCapSusceptance); + + auto switchingList = AppendNode(doc, electricalProp, "SwitchingList"); + SwitchingData swData = line->GetSwitchingData(); + for(int j = 0; j < (int)swData.swType.size(); j++) { + auto switching = AppendNode(doc, switchingList, "Switching"); + SetNodeAttribute(doc, switching, "ID", j); + auto swType = AppendNode(doc, switching, "Type"); + SetNodeValue(doc, swType, swData.swType[j]); + auto swTime = AppendNode(doc, switching, "Time"); + SetNodeValue(doc, swTime, swData.swTime[j]); + } + } //} + + //{ Load + auto loadsNode = AppendNode(doc, elementsNode, "LoadList"); + auto loadList = allElements.GetLoadList(); + for(int i = 0; i < (int)loadList.size(); i++) { + Load* load = loadList[i]; + auto loadNode = AppendNode(doc, loadsNode, "Load"); + auto cadProp = AppendNode(doc, loadNode, "CADProperties"); + auto position = AppendNode(doc, cadProp, "Position"); + auto posX = AppendNode(doc, position, "X"); + SetNodeValue(doc, posX, load->GetPosition().m_x); + auto posY = AppendNode(doc, position, "Y"); + SetNodeValue(doc, posY, load->GetPosition().m_y); + auto size = AppendNode(doc, cadProp, "Size"); + auto width = AppendNode(doc, size, "Width"); + SetNodeValue(doc, width, load->GetWidth()); + auto height = AppendNode(doc, size, "Height"); + SetNodeValue(doc, height, load->GetHeight()); + auto angle = AppendNode(doc, cadProp, "Angle"); + SetNodeValue(doc, angle, load->GetAngle()); + auto nodePos = AppendNode(doc, cadProp, "NodePosition"); + auto nodePosX = AppendNode(doc, nodePos, "X"); + SetNodeValue(doc, nodePosX, load->GetPointList()[0].m_x); + auto nodePosY = AppendNode(doc, nodePos, "Y"); + SetNodeValue(doc, nodePosY, load->GetPointList()[0].m_y); + auto parentID = AppendNode(doc, cadProp, "ParentID"); + Bus* parent = (Bus*)load->GetParentList()[0]; + if(parent) SetNodeValue(doc, parentID, parent->GetEletricalData().number); + + LoadElectricalData data = load->GetElectricalData(); + auto electricalProp = AppendNode(doc, loadNode, "ElectricalProperties"); + auto isOnline = AppendNode(doc, electricalProp, "IsOnline"); + SetNodeValue(doc, isOnline, load->IsOnline()); + auto name = AppendNode(doc, electricalProp, "Name"); + SetNodeValue(doc, name, data.name); + auto activePower = AppendNode(doc, electricalProp, "ActivePower"); + SetNodeValue(doc, activePower, data.activePower); + auto activePowerUnit = AppendNode(doc, electricalProp, "ActivePowerUnit"); + SetNodeValue(doc, activePowerUnit, data.activePowerUnit); + auto reactivePower = AppendNode(doc, electricalProp, "ReactivePower"); + SetNodeValue(doc, reactivePower, data.reactivePower); + auto reactivePowerUnit = AppendNode(doc, electricalProp, "ReactivePowerUnit"); + SetNodeValue(doc, reactivePowerUnit, data.reactivePowerUnit); + auto loadType = AppendNode(doc, electricalProp, "LoadType"); + SetNodeValue(doc, loadType, data.loadType); + + auto switchingList = AppendNode(doc, electricalProp, "SwitchingList"); + SwitchingData swData = load->GetSwitchingData(); + for(int j = 0; j < (int)swData.swType.size(); j++) { + auto switching = AppendNode(doc, switchingList, "Switching"); + SetNodeAttribute(doc, switching, "ID", j); + auto swType = AppendNode(doc, switching, "Type"); + SetNodeValue(doc, swType, swData.swType[j]); + auto swTime = AppendNode(doc, switching, "Time"); + SetNodeValue(doc, swTime, swData.swTime[j]); + } + } //} - //Save all the data - rapidxml::xml_node<>* testValues = AppendNode(doc, rootNode, "TestValues"); - rapidxml::xml_node<>* testDouble = AppendNode(doc, testValues, "TestDouble"); - SetNodeValue(doc, testDouble, 1.23456789123456789123456789); - rapidxml::xml_node<>* testInt = AppendNode(doc, testValues, "TestInt"); - SetNodeValue(doc, testInt, 123456789); - rapidxml::xml_node<>* testString = AppendNode(doc, testValues, "TestString"); - SetNodeValue(doc, testString, (wxString)"TESTE"); + //{ SyncGenerator + auto syncGeneratorsNode = AppendNode(doc, elementsNode, "SyncGeneratorList"); + auto syncGeneratorList = allElements.GetLoadList(); + for(int i = 0; i < (int)syncGeneratorList.size(); i++) { + SyncGenerator* syncGenerator = syncGeneratorList[i]; + auto syncGeneratorNode = AppendNode(doc, syncGeneratorsNode, "SyncGenerator"); + auto cadProp = AppendNode(doc, syncGeneratorNode, "CADProperties"); + auto position = AppendNode(doc, cadProp, "Position"); + auto posX = AppendNode(doc, position, "X"); + SetNodeValue(doc, posX, syncGenerator->GetPosition().m_x); + auto posY = AppendNode(doc, position, "Y"); + SetNodeValue(doc, posY, syncGenerator->GetPosition().m_y); + auto size = AppendNode(doc, cadProp, "Size"); + auto width = AppendNode(doc, size, "Width"); + SetNodeValue(doc, width, syncGenerator->GetWidth()); + auto height = AppendNode(doc, size, "Height"); + SetNodeValue(doc, height, syncGenerator->GetHeight()); + auto angle = AppendNode(doc, cadProp, "Angle"); + SetNodeValue(doc, angle, syncGenerator->GetAngle()); + auto nodePos = AppendNode(doc, cadProp, "NodePosition"); + auto nodePosX = AppendNode(doc, nodePos, "X"); + SetNodeValue(doc, nodePosX, syncGenerator->GetPointList()[0].m_x); + auto nodePosY = AppendNode(doc, nodePos, "Y"); + SetNodeValue(doc, nodePosY, syncGenerator->GetPointList()[0].m_y); + auto parentID = AppendNode(doc, cadProp, "ParentID"); + Bus* parent = (Bus*)syncGenerator->GetParentList()[0]; + if(parent) SetNodeValue(doc, parentID, parent->GetEletricalData().number); + + SyncGeneratorElectricalData data = syncGenerator->GetElectricalData(); + auto electricalProp = AppendNode(doc, syncGeneratorNode, "ElectricalProperties"); + auto isOnline = AppendNode(doc, electricalProp, "IsOnline"); + SetNodeValue(doc, isOnline, syncGenerator->IsOnline()); + auto name = AppendNode(doc, electricalProp, "Name"); + SetNodeValue(doc, name, data.name); + + /*wxString name = ""; + double nominalPower = 100.0; + ElectricalUnit nominalPowerUnit = UNIT_MVA; + double nominalVoltage = 13.8; + ElectricalUnit nominalVoltageUnit = UNIT_kV; + double activePower = 100.0; + ElectricalUnit activePowerUnit = UNIT_MW; + double reactivePower = 0.0; + ElectricalUnit reactivePowerUnit = UNIT_MVAr; + bool haveMaxReactive = false; + double maxReactive = 9999.0; + ElectricalUnit maxReactiveUnit = UNIT_MVAr; + bool haveMinReactive = false; + double minReactive = -9999.0; + ElectricalUnit minReactiveUnit = UNIT_MVAr; + bool useMachineBase = false; + + // Fault + double positiveResistance = 0.0; + double positiveReactance = 1.0; + double negativeResistance = 0.0; + double negativeReactance = 1.0; + double zeroResistance = 0.0; + double zeroReactance = 1.0; + double groundResistance = 0.0; + double groundReactance = 0.0; + bool groundNeutral = true; + // p.u. fault data + std::complex<double> faultCurrent[3] = { std::complex<double>(0.0, 0.0), std::complex<double>(0.0, 0.0), + std::complex<double>(0.0, 0.0) }; + + // Stability + bool plotSyncMachine = false; + double inertia = 0.0; + double damping = 0.0; + bool useAVR = false; + bool useSpeedGovernor = false; + + double armResistance = 0.0; + double potierReactance = 0.0; + double satFactor = 0.0; + + double syncXd = 0.0; + double syncXq = 0.0; + double transXd = 1.0; + double transXq = 0.0; + double transTd0 = 0.0; + double transTq0 = 0.0; + double subXd = 0.0; + double subXq = 0.0; + double subTd0 = 0.0; + double subTq0 = 0.0;*/ + + auto switchingList = AppendNode(doc, electricalProp, "SwitchingList"); + SwitchingData swData = syncGenerator->GetSwitchingData(); + for(int j = 0; j < (int)swData.swType.size(); j++) { + auto switching = AppendNode(doc, switchingList, "Switching"); + SetNodeAttribute(doc, switching, "ID", j); + auto swType = AppendNode(doc, switching, "Type"); + SetNodeValue(doc, swType, swData.swType[j]); + auto swTime = AppendNode(doc, switching, "Time"); + SetNodeValue(doc, swTime, swData.swTime[j]); + } + } //} std::ofstream writeXML(path.GetFullPath()); writeXML << doc; @@ -48,7 +485,10 @@ void FileHanding::SaveProject(wxFileName path) void FileHanding::OpenProject(wxFileName path) {} -rapidxml::xml_node<>* FileHanding::AppendNode(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* parentNode, const char* name, rapidxml::node_type nodeType) +rapidxml::xml_node<>* FileHanding::AppendNode(rapidxml::xml_document<>& doc, + rapidxml::xml_node<>* parentNode, + const char* name, + rapidxml::node_type nodeType) { rapidxml::xml_node<>* node = doc.allocate_node(nodeType, name); parentNode->append_node(node); @@ -69,3 +509,28 @@ void FileHanding::SetNodeValue(rapidxml::xml_document<>& doc, rapidxml::xml_node { node->value(doc.allocate_string(wxString::FromCDouble(value, 13).mb_str())); } + +void FileHanding::SetNodeAttribute(rapidxml::xml_document<>& doc, + rapidxml::xml_node<>* node, + const char* atrName, + wxString value) +{ + node->append_attribute(doc.allocate_attribute(atrName, doc.allocate_string(value.mb_str()))); +} + +void FileHanding::SetNodeAttribute(rapidxml::xml_document<>& doc, + rapidxml::xml_node<>* node, + const char* atrName, + int value) +{ + node->append_attribute(doc.allocate_attribute(atrName, doc.allocate_string(wxString::Format("%d", value)))); +} + +void FileHanding::SetNodeAttribute(rapidxml::xml_document<>& doc, + rapidxml::xml_node<>* node, + const char* atrName, + double value) +{ + node->append_attribute( + doc.allocate_attribute(atrName, doc.allocate_string(wxString::FromCDouble(value, 13).mb_str()))); +} diff --git a/Project/FileHanding.h b/Project/FileHanding.h index 4aa7f37..5e06c3e 100644 --- a/Project/FileHanding.h +++ b/Project/FileHanding.h @@ -36,6 +36,9 @@ protected: void SetNodeValue(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* node, wxString value); void SetNodeValue(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* node, int value); void SetNodeValue(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* node, double value); + void SetNodeAttribute(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* node, const char* atrName, wxString value); + void SetNodeAttribute(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* node, const char* atrName, int value); + void SetNodeAttribute(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* node, const char* atrName, double value); }; #endif // FILEHANDING_H diff --git a/Project/Inductor.cpp b/Project/Inductor.cpp index 9c85d9a..9c13f15 100644 --- a/Project/Inductor.cpp +++ b/Project/Inductor.cpp @@ -89,6 +89,7 @@ void Inductor::Rotate(bool clockwise) if(!clockwise) rotAngle = -m_rotationAngle; m_angle += rotAngle; + if(m_angle >= 360 || m_angle <= -360) m_angle = 0.0; m_pointList[2] = RotateAtPosition(m_pointList[2], rotAngle); m_pointList[3] = RotateAtPosition(m_pointList[3], rotAngle); UpdateSwitchesPosition(); diff --git a/Project/Load.cpp b/Project/Load.cpp index e46b48b..9889215 100644 --- a/Project/Load.cpp +++ b/Project/Load.cpp @@ -97,6 +97,7 @@ void Load::Rotate(bool clockwise) if(!clockwise) rotAngle = -m_rotationAngle; m_angle += rotAngle; + if(m_angle >= 360 || m_angle <= -360) m_angle = 0.0; m_pointList[2] = RotateAtPosition(m_pointList[2], rotAngle); m_pointList[3] = RotateAtPosition(m_pointList[3], rotAngle); UpdateSwitchesPosition(); diff --git a/Project/Machines.cpp b/Project/Machines.cpp index f859831..c24deaf 100644 --- a/Project/Machines.cpp +++ b/Project/Machines.cpp @@ -1,95 +1,96 @@ #include "Machines.h" -Machines::Machines() : Element() {} +Machines::Machines() + : Element() +{ +} Machines::~Machines() {} bool Machines::AddParent(Element* parent, wxPoint2DDouble position) { if(parent) { - m_parentList.push_back(parent); - wxPoint2DDouble parentPt = - parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position. - parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. - parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back. - - m_position = parentPt + wxPoint2DDouble(-100.0, 0.0); // Shifts the position to the left of the bus. - m_width = m_height = 50.0; - m_rect = wxRect2DDouble(m_position.m_x - 25.0, m_position.m_y - 25.0, m_width, m_height); - - m_pointList.push_back(parentPt); - m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_position)); - m_pointList.push_back(m_position + wxPoint2DDouble(35.0, 0.0)); - m_pointList.push_back(m_position + wxPoint2DDouble(25.0, 0.0)); - m_inserted = true; - - wxRect2DDouble genRect(0,0,0,0); - m_switchRect.push_back(genRect); // Push a general rectangle. - UpdateSwitches(); + m_parentList.push_back(parent); + wxPoint2DDouble parentPt = + parent->RotateAtPosition(position, -parent->GetAngle()); // Rotate click to horizontal position. + parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. + parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); // Rotate back. + + m_position = parentPt + wxPoint2DDouble(-100.0, 0.0); // Shifts the position to the left of the bus. + m_width = m_height = 50.0; + m_rect = wxRect2DDouble(m_position.m_x - 25.0, m_position.m_y - 25.0, m_width, m_height); + + m_pointList.push_back(parentPt); + m_pointList.push_back(GetSwitchPoint(parent, parentPt, m_position)); + m_pointList.push_back(m_position + wxPoint2DDouble(35.0, 0.0)); + m_pointList.push_back(m_position + wxPoint2DDouble(25.0, 0.0)); + m_inserted = true; + + wxRect2DDouble genRect(0, 0, 0, 0); + m_switchRect.push_back(genRect); // Push a general rectangle. + UpdateSwitches(); UpdatePowerFlowArrowsPosition(); - return true; - } + return true; + } return false; } void Machines::Draw(wxPoint2DDouble translation, double scale) const { if(m_inserted) { - - // Draw Selection (layer 1). - if(m_selected) { - glLineWidth(1.5 + m_borderSize * 2.0); - glColor4d(0.0, 0.5, 1.0, 0.5); - DrawCircle(m_position, 25.0 + (m_borderSize + 1.5) / scale, 20, GL_POLYGON); - DrawLine(m_pointList); - - // Draw node selection. - DrawCircle(m_pointList[0], 5.0 + m_borderSize / scale, 10, GL_POLYGON); - } - - // Draw Machines (layer 2). - glLineWidth(1.5); - - // Draw node. - glColor4d(0.2, 0.2, 0.2, 1.0); - DrawCircle(m_pointList[0], 5.0, 10, GL_POLYGON); - - DrawLine(m_pointList); - - DrawSwitches(); + + // Draw Selection (layer 1). + if(m_selected) { + glLineWidth(1.5 + m_borderSize * 2.0); + glColor4d(0.0, 0.5, 1.0, 0.5); + DrawCircle(m_position, 25.0 + (m_borderSize + 1.5) / scale, 20, GL_POLYGON); + DrawLine(m_pointList); + + // Draw node selection. + DrawCircle(m_pointList[0], 5.0 + m_borderSize / scale, 10, GL_POLYGON); + } + + // Draw Machines (layer 2). + glLineWidth(1.5); + + // Draw node. + glColor4d(0.2, 0.2, 0.2, 1.0); + DrawCircle(m_pointList[0], 5.0, 10, GL_POLYGON); + + DrawLine(m_pointList); + + DrawSwitches(); DrawPowerFlowPts(); - glColor4d(1.0, 1.0, 1.0, 1.0); - DrawCircle(m_position, 25.0, 20, GL_POLYGON); + glColor4d(1.0, 1.0, 1.0, 1.0); + DrawCircle(m_position, 25.0, 20, GL_POLYGON); - glColor4d(0.2, 0.2, 0.2, 1.0); - DrawCircle(m_position, 25.0, 20); + glColor4d(0.2, 0.2, 0.2, 1.0); + DrawCircle(m_position, 25.0, 20); - // Draw machine symbol. - glLineWidth(2.0); - DrawSymbol(); - } + // Draw machine symbol. + glLineWidth(2.0); + DrawSymbol(); + } } void Machines::UpdateSwitchesPosition() { if(m_parentList[0]) { - m_pointList[1] = GetSwitchPoint(m_parentList[0], m_pointList[0], m_pointList[2]); - } - else - { - m_pointList[1] = m_pointList[0]; - } - UpdateSwitches(); + m_pointList[1] = GetSwitchPoint(m_parentList[0], m_pointList[0], m_pointList[2]); + } else { + m_pointList[1] = m_pointList[0]; + } + UpdateSwitches(); } void Machines::Move(wxPoint2DDouble position) { SetPosition(m_movePos + position - m_moveStartPt); for(int i = 2; i < (int)m_pointList.size(); i++) { - m_pointList[i] = m_movePts[i] + position - m_moveStartPt; - } + m_pointList[i] = m_movePts[i] + position - m_moveStartPt; + } if(!m_parentList[0]) { - m_pointList[0] = m_movePts[0] + position - m_moveStartPt; - } + m_pointList[0] = m_movePts[0] + position - m_moveStartPt; + } UpdateSwitchesPosition(); UpdatePowerFlowArrowsPosition(); } @@ -97,18 +98,16 @@ void Machines::Move(wxPoint2DDouble position) void Machines::MoveNode(Element* element, wxPoint2DDouble position) { if(element) { - if(element == m_parentList[0]) { - m_pointList[0] = m_movePts[0] + position - m_moveStartPt; - } - } - else - { - if(m_activeNodeID == 1) { - m_pointList[0] = m_movePts[0] + position - m_moveStartPt; - m_parentList[0] = NULL; - m_online = false; - } - } + if(element == m_parentList[0]) { + m_pointList[0] = m_movePts[0] + position - m_moveStartPt; + } + } else { + if(m_activeNodeID == 1) { + m_pointList[0] = m_movePts[0] + position - m_moveStartPt; + m_parentList[0] = NULL; + m_online = false; + } + } // Recalculate switches positions UpdateSwitchesPosition(); @@ -124,33 +123,33 @@ void Machines::StartMove(wxPoint2DDouble position) void Machines::RotateNode(Element* parent, bool clockwise) { - double rotAngle = m_rotationAngle; - if(!clockwise) rotAngle = -m_rotationAngle; - + double rotAngle = m_rotationAngle; + if(!clockwise) rotAngle = -m_rotationAngle; + if(parent == m_parentList[0]) { - m_pointList[0] = parent->RotateAtPosition(m_pointList[0], rotAngle); - UpdateSwitchesPosition(); - } + m_pointList[0] = parent->RotateAtPosition(m_pointList[0], rotAngle); + UpdateSwitchesPosition(); + } } void Machines::RemoveParent(Element* parent) { if(parent == m_parentList[0]) { - m_parentList[0] = NULL; - UpdateSwitchesPosition(); + m_parentList[0] = NULL; + UpdateSwitchesPosition(); UpdatePowerFlowArrowsPosition(); - } + } } bool Machines::NodeContains(wxPoint2DDouble position) { wxRect2DDouble nodeRect(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize, - 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); + 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); if(nodeRect.Contains(position)) { - m_activeNodeID = 1; - return true; - } + m_activeNodeID = 1; + return true; + } m_activeNodeID = 0; return false; @@ -159,52 +158,52 @@ bool Machines::NodeContains(wxPoint2DDouble position) bool Machines::SetNodeParent(Element* parent) { if(parent && m_activeNodeID != 0) { - wxRect2DDouble nodeRect(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize, - 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); + wxRect2DDouble nodeRect(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize, + 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); - if(parent->Intersects(nodeRect)) { - m_parentList[0] = parent; + if(parent->Intersects(nodeRect)) { + m_parentList[0] = parent; - // Centralize the node on bus. - wxPoint2DDouble parentPt = parent->RotateAtPosition( - m_pointList[0], -parent->GetAngle()); // Rotate click to horizontal position. - parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. - parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); - m_pointList[0] = parentPt; + // Centralize the node on bus. + wxPoint2DDouble parentPt = + parent->RotateAtPosition(m_pointList[0], -parent->GetAngle()); // Rotate click to horizontal position. + parentPt.m_y = parent->GetPosition().m_y; // Centralize on bus. + parentPt = parent->RotateAtPosition(parentPt, parent->GetAngle()); + m_pointList[0] = parentPt; - UpdateSwitchesPosition(); + UpdateSwitchesPosition(); UpdatePowerFlowArrowsPosition(); - return true; - } - else - { - m_parentList[0] = NULL; - m_online = false; - } - } + return true; + } else { + m_parentList[0] = NULL; + m_online = false; + } + } return false; } void Machines::UpdateNodes() { if(m_parentList[0]) { - wxRect2DDouble nodeRect(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize, - 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); + wxRect2DDouble nodeRect(m_pointList[0].m_x - 5.0 - m_borderSize, m_pointList[0].m_y - 5.0 - m_borderSize, + 10 + 2.0 * m_borderSize, 10 + 2.0 * m_borderSize); - if(!m_parentList[0]->Intersects(nodeRect)) { - m_parentList[0] = NULL; - m_online = false; - UpdateSwitchesPosition(); + if(!m_parentList[0]->Intersects(nodeRect)) { + m_parentList[0] = NULL; + m_online = false; + UpdateSwitchesPosition(); UpdatePowerFlowArrowsPosition(); - } - } + } + } } void Machines::Rotate(bool clockwise) { - double rotAngle = m_rotationAngle; - if(!clockwise) rotAngle = -m_rotationAngle; - + double rotAngle = m_rotationAngle; + if(!clockwise) rotAngle = -m_rotationAngle; + + m_angle += rotAngle; + if(m_angle >= 360 || m_angle <= -360) m_angle = 0.0; m_pointList[2] = RotateAtPosition(m_pointList[2], rotAngle); m_pointList[3] = RotateAtPosition(m_pointList[3], rotAngle); UpdateSwitchesPosition(); @@ -229,7 +228,7 @@ void Machines::UpdatePowerFlowArrowsPosition() default: break; } - + CalculatePowerFlowPts(edges); } diff --git a/Project/Project.mk b/Project/Project.mk index 7ada2ea..0451eab 100644 --- a/Project/Project.mk +++ b/Project/Project.mk @@ -13,7 +13,7 @@ CurrentFileName := CurrentFilePath := CurrentFileFullPath := User :=Thales -Date :=10/12/2016 +Date :=12/12/2016 CodeLitePath :="C:/Program Files/CodeLite" LinkerName :=C:/TDM-GCC-64/bin/g++.exe SharedObjectLinkerName :=C:/TDM-GCC-64/bin/g++.exe -shared -fPIC diff --git a/Project/Release/Branch.cpp.o b/Project/Release/Branch.cpp.o Binary files differindex 374429b..47cacb2 100644 --- a/Project/Release/Branch.cpp.o +++ b/Project/Release/Branch.cpp.o diff --git a/Project/Release/Bus.cpp.o b/Project/Release/Bus.cpp.o Binary files differindex 54c9c29..b19ebb8 100644 --- a/Project/Release/Bus.cpp.o +++ b/Project/Release/Bus.cpp.o diff --git a/Project/Release/BusForm.cpp.o b/Project/Release/BusForm.cpp.o Binary files differindex 3aff5ba..62c4670 100644 --- a/Project/Release/BusForm.cpp.o +++ b/Project/Release/BusForm.cpp.o diff --git a/Project/Release/Capacitor.cpp.o b/Project/Release/Capacitor.cpp.o Binary files differindex bbf9649..7a5cb4a 100644 --- a/Project/Release/Capacitor.cpp.o +++ b/Project/Release/Capacitor.cpp.o diff --git a/Project/Release/ElectricCalculation.cpp.o b/Project/Release/ElectricCalculation.cpp.o Binary files differindex 8fe31cc..9d93e51 100644 --- a/Project/Release/ElectricCalculation.cpp.o +++ b/Project/Release/ElectricCalculation.cpp.o diff --git a/Project/Release/Element.cpp.o b/Project/Release/Element.cpp.o Binary files differindex 76baaaf..3cceece 100644 --- a/Project/Release/Element.cpp.o +++ b/Project/Release/Element.cpp.o diff --git a/Project/Release/FileHanding.cpp.o b/Project/Release/FileHanding.cpp.o Binary files differindex 025c50d..c6d8cc5 100644 --- a/Project/Release/FileHanding.cpp.o +++ b/Project/Release/FileHanding.cpp.o diff --git a/Project/Release/GeneratorStabForm.cpp.o b/Project/Release/GeneratorStabForm.cpp.o Binary files differindex 6e3ecd6..4526373 100644 --- a/Project/Release/GeneratorStabForm.cpp.o +++ b/Project/Release/GeneratorStabForm.cpp.o diff --git a/Project/Release/IndMotor.cpp.o b/Project/Release/IndMotor.cpp.o Binary files differindex c4ca27f..e94e83a 100644 --- a/Project/Release/IndMotor.cpp.o +++ b/Project/Release/IndMotor.cpp.o diff --git a/Project/Release/IndMotorForm.cpp.o b/Project/Release/IndMotorForm.cpp.o Binary files differindex 876b22e..75d326a 100644 --- a/Project/Release/IndMotorForm.cpp.o +++ b/Project/Release/IndMotorForm.cpp.o diff --git a/Project/Release/Inductor.cpp.o b/Project/Release/Inductor.cpp.o Binary files differindex f65788c..3c71fb6 100644 --- a/Project/Release/Inductor.cpp.o +++ b/Project/Release/Inductor.cpp.o diff --git a/Project/Release/Line.cpp.o b/Project/Release/Line.cpp.o Binary files differindex 0fd9f2a..9b667e3 100644 --- a/Project/Release/Line.cpp.o +++ b/Project/Release/Line.cpp.o diff --git a/Project/Release/LineForm.cpp.o b/Project/Release/LineForm.cpp.o Binary files differindex 4e36059..90e0e77 100644 --- a/Project/Release/LineForm.cpp.o +++ b/Project/Release/LineForm.cpp.o diff --git a/Project/Release/Load.cpp.o b/Project/Release/Load.cpp.o Binary files differindex c5641c2..8dca824 100644 --- a/Project/Release/Load.cpp.o +++ b/Project/Release/Load.cpp.o diff --git a/Project/Release/Machines.cpp.o b/Project/Release/Machines.cpp.o Binary files differindex 78e4dd9..7229880 100644 --- a/Project/Release/Machines.cpp.o +++ b/Project/Release/Machines.cpp.o diff --git a/Project/Release/MainFrame.cpp.o b/Project/Release/MainFrame.cpp.o Binary files differindex 9b93a20..0ab62ae 100644 --- a/Project/Release/MainFrame.cpp.o +++ b/Project/Release/MainFrame.cpp.o diff --git a/Project/Release/PSP-UFU.exe b/Project/Release/PSP-UFU.exe Binary files differindex d529223..6f1788c 100644 --- a/Project/Release/PSP-UFU.exe +++ b/Project/Release/PSP-UFU.exe diff --git a/Project/Release/PowerFlow.cpp.o b/Project/Release/PowerFlow.cpp.o Binary files differindex 3f8ce8e..995810b 100644 --- a/Project/Release/PowerFlow.cpp.o +++ b/Project/Release/PowerFlow.cpp.o diff --git a/Project/Release/ReactiveShuntElementForm.cpp.o b/Project/Release/ReactiveShuntElementForm.cpp.o Binary files differindex 1ce9ee8..a84e93f 100644 --- a/Project/Release/ReactiveShuntElementForm.cpp.o +++ b/Project/Release/ReactiveShuntElementForm.cpp.o diff --git a/Project/Release/Shunt.cpp.o b/Project/Release/Shunt.cpp.o Binary files differindex e898859..6cc9830 100644 --- a/Project/Release/Shunt.cpp.o +++ b/Project/Release/Shunt.cpp.o diff --git a/Project/Release/SwitchingForm.cpp.o b/Project/Release/SwitchingForm.cpp.o Binary files differindex 88c8520..822dd20 100644 --- a/Project/Release/SwitchingForm.cpp.o +++ b/Project/Release/SwitchingForm.cpp.o diff --git a/Project/Release/SyncGenerator.cpp.o b/Project/Release/SyncGenerator.cpp.o Binary files differindex df5cc88..18ef964 100644 --- a/Project/Release/SyncGenerator.cpp.o +++ b/Project/Release/SyncGenerator.cpp.o diff --git a/Project/Release/SyncMachineForm.cpp.o b/Project/Release/SyncMachineForm.cpp.o Binary files differindex a2afa10..2603398 100644 --- a/Project/Release/SyncMachineForm.cpp.o +++ b/Project/Release/SyncMachineForm.cpp.o diff --git a/Project/Release/SyncMotor.cpp.o b/Project/Release/SyncMotor.cpp.o Binary files differindex dfeab4c..24d25c0 100644 --- a/Project/Release/SyncMotor.cpp.o +++ b/Project/Release/SyncMotor.cpp.o diff --git a/Project/Release/Text.cpp.o b/Project/Release/Text.cpp.o Binary files differindex 830aa66..0d95dd4 100644 --- a/Project/Release/Text.cpp.o +++ b/Project/Release/Text.cpp.o diff --git a/Project/Release/TextForm.cpp.o b/Project/Release/TextForm.cpp.o Binary files differindex 26381da..153e347 100644 --- a/Project/Release/TextForm.cpp.o +++ b/Project/Release/TextForm.cpp.o diff --git a/Project/Release/Transformer.cpp.o b/Project/Release/Transformer.cpp.o Binary files differindex 3c97848..cfbc088 100644 --- a/Project/Release/Transformer.cpp.o +++ b/Project/Release/Transformer.cpp.o diff --git a/Project/Release/TransformerForm.cpp.o b/Project/Release/TransformerForm.cpp.o Binary files differindex 50fbf8c..1deaecd 100644 --- a/Project/Release/TransformerForm.cpp.o +++ b/Project/Release/TransformerForm.cpp.o diff --git a/Project/Release/Workspace.cpp.o b/Project/Release/Workspace.cpp.o Binary files differindex 850a2a5..cb14f6f 100644 --- a/Project/Release/Workspace.cpp.o +++ b/Project/Release/Workspace.cpp.o diff --git a/Project/Transformer.cpp b/Project/Transformer.cpp index 04770e4..42fffaf 100644 --- a/Project/Transformer.cpp +++ b/Project/Transformer.cpp @@ -172,7 +172,7 @@ void Transformer::Rotate(bool clockwise) if(!clockwise) rotAngle = -m_rotationAngle; m_angle += rotAngle; - if(m_angle >= 360.0) m_angle = 0.0; + if(m_angle >= 360 || m_angle <= -360) m_angle = 0.0; // Rotate all the points, except the switches and buses points. for(int i = 2; i < (int)m_pointList.size() - 2; i++) { |