summaryrefslogtreecommitdiffstats
path: root/Project/IndMotor.cpp
diff options
context:
space:
mode:
authorThales Lima Oliveira <thaleslima.ufu@gmail.com>2018-01-05 20:04:28 -0200
committerThales Lima Oliveira <thaleslima.ufu@gmail.com>2018-01-05 20:04:28 -0200
commit95f61a7cad71c45c9e27af5c6f4bc5d64d5ecc45 (patch)
treed11fb974997f49942977a5ce3318074ea503f9bc /Project/IndMotor.cpp
parent76df1de5e2307229da9870306e4a1031170aaadf (diff)
downloadPSP.git-95f61a7cad71c45c9e27af5c6f4bc5d64d5ecc45.tar.gz
PSP.git-95f61a7cad71c45c9e27af5c6f4bc5d64d5ecc45.tar.xz
PSP.git-95f61a7cad71c45c9e27af5c6f4bc5d64d5ecc45.zip
Some power element file hand. organized
Diffstat (limited to 'Project/IndMotor.cpp')
-rw-r--r--Project/IndMotor.cpp45
1 files changed, 44 insertions, 1 deletions
diff --git a/Project/IndMotor.cpp b/Project/IndMotor.cpp
index 64d40c4..73c9c4f 100644
--- a/Project/IndMotor.cpp
+++ b/Project/IndMotor.cpp
@@ -15,8 +15,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-#include "IndMotorForm.h"
#include "IndMotor.h"
+#include "IndMotorForm.h"
IndMotor::IndMotor() : Machines() {}
IndMotor::IndMotor(wxString name) : Machines() { m_electricalData.name = name; }
@@ -142,3 +142,46 @@ wxString IndMotor::GetTipText() const
return tipText;
}
+
+void IndMotor::SaveElement(rapidxml::xml_document<>& doc, rapidxml::xml_node<>* elementListNode)
+{
+ auto elementNode = XMLParser::AppendNode(doc, elementListNode, "IndMotor");
+ XMLParser::SetNodeAttribute(doc, elementNode, "ID", m_elementID);
+
+ SaveCADProperties(doc, elementNode);
+
+ // Element properties
+ auto electricalProp = XMLParser::AppendNode(doc, elementNode, "ElectricalProperties");
+ auto isOnline = XMLParser::AppendNode(doc, electricalProp, "IsOnline");
+ XMLParser::SetNodeValue(doc, isOnline, m_online);
+ auto name = XMLParser::AppendNode(doc, electricalProp, "Name");
+ XMLParser::SetNodeValue(doc, name, m_electricalData.name);
+ auto activePower = XMLParser::AppendNode(doc, electricalProp, "ActivePower");
+ XMLParser::SetNodeValue(doc, activePower, m_electricalData.activePower);
+ XMLParser::SetNodeAttribute(doc, activePower, "UnitID", m_electricalData.activePowerUnit);
+ auto reactivePower = XMLParser::AppendNode(doc, electricalProp, "ReactivePower");
+ XMLParser::SetNodeValue(doc, reactivePower, m_electricalData.reactivePower);
+ XMLParser::SetNodeAttribute(doc, reactivePower, "UnitID", m_electricalData.reactivePowerUnit);
+}
+
+bool IndMotor::OpenElement(rapidxml::xml_node<>* elementNode, std::vector<Element*> parentList)
+{
+ if(!OpenCADProperties(elementNode, parentList)) return false;
+
+ auto electricalProp = elementNode->first_node("ElectricalProperties");
+ if(!electricalProp) return false;
+
+ // Element properties
+ SetOnline(XMLParser::GetNodeValueInt(electricalProp, "IsOnline"));
+ m_electricalData.name = electricalProp->first_node("Name")->value();
+ m_electricalData.activePower = XMLParser::GetNodeValueDouble(electricalProp, "ActivePower");
+ m_electricalData.activePowerUnit =
+ static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "ActivePower", "UnitID"));
+ m_electricalData.reactivePower = XMLParser::GetNodeValueDouble(electricalProp, "ReactivePower");
+ m_electricalData.reactivePowerUnit =
+ static_cast<ElectricalUnit>(XMLParser::GetAttributeValueInt(electricalProp, "ReactivePower", "UnitID"));
+
+ m_inserted = true;
+
+ return true;
+}