From 9cb2f5a8f6e01085d657d6aaee517667bd94b30a Mon Sep 17 00:00:00 2001 From: "facat@lab.com" Date: Sun, 28 Dec 2014 16:40:57 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8CIMExporter=E5=88=86=E5=88=AB=E5=A4=84?= =?UTF-8?q?=E7=90=86=E8=AF=BB=E5=88=B0=E7=9A=84=E7=BA=BF=E8=B7=AF=EF=BC=8C?= =?UTF-8?q?=E5=BC=80=E5=85=B3=EF=BC=8C=E5=8F=98=E5=8E=8B=E5=99=A8=E7=AD=89?= =?UTF-8?q?=E5=85=83=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: facat@lab.com --- testHasttable/cimexporter.cpp | 23 ++++++++++++++ testHasttable/cimexporter.h | 35 ++++++++++++++++++++- testHasttable/element/branch.cpp | 2 +- testHasttable/element/branch.h | 6 ++-- testHasttable/element/line.cpp | 2 +- testHasttable/element/line.h | 3 +- testHasttable/element/switch.cpp | 2 +- testHasttable/element/switch.h | 3 +- testHasttable/element/transformer.cpp | 2 +- testHasttable/element/transformer.h | 3 +- testHasttable/topologyrecorder.cpp | 45 ++++++++++++++++++++++----- testHasttable/topologyrecorder.h | 19 +++++++++-- 12 files changed, 124 insertions(+), 21 deletions(-) diff --git a/testHasttable/cimexporter.cpp b/testHasttable/cimexporter.cpp index d5229f3..7803a3b 100644 --- a/testHasttable/cimexporter.cpp +++ b/testHasttable/cimexporter.cpp @@ -3,3 +3,26 @@ CIMExporter::CIMExporter() { } + +void CIMExporter::add(const QPair& fromTo,Line* line) +{ + CIMExporter::LineStru lineStru; + lineStru.line=line; + lineStru.fromID=fromTo.first; + lineStru.toID=fromTo.second; + +} +void CIMExporter::add(const QPair& fromTo,Switch* sw) +{ + CIMExporter::SwitchStru switchStru; + switchStru.sw=sw; + switchStru.fromID=fromTo.first; + switchStru.toID=fromTo.second; +} +void CIMExporter::add(const QPair& fromTo,Transformer* tf) +{ + CIMExporter::TransformerStru tfStru; + tfStru.tf=tf; + tfStru.fromID=fromTo.first; + tfStru.toID=fromTo.second; +} diff --git a/testHasttable/cimexporter.h b/testHasttable/cimexporter.h index 97d93b5..3c41fc2 100644 --- a/testHasttable/cimexporter.h +++ b/testHasttable/cimexporter.h @@ -1,10 +1,43 @@ #ifndef CIMEXPORTER_H #define CIMEXPORTER_H - +#include +#include "element/line.h" +#include "element/switch.h" +#include "element/transformer.h" +#include class CIMExporter { + struct BranchStruc + { + QString fromID; + QString toID; + int fromNum; + int toNum; + }; + struct LineStru:public BranchStruc + { + Line *line; + + }; + struct SwitchStru:public BranchStruc + { + Switch *sw; + + }; + struct TransformerStru:public BranchStruc + { + Transformer *tf; + + }; public: CIMExporter(); + void add(const QPair& fromTo,Line* line); + void add(const QPair& fromTo,Switch* sw); + void add(const QPair& fromTo,Transformer* tf); +private: + QList line; + QList sw; + QList tf; }; #endif // CIMEXPORTER_H diff --git a/testHasttable/element/branch.cpp b/testHasttable/element/branch.cpp index 2b67372..b296529 100644 --- a/testHasttable/element/branch.cpp +++ b/testHasttable/element/branch.cpp @@ -1,5 +1,5 @@ #include "branch.h" -Branch::Branch(const QString& from, const QString& to):from(from),to(to) +Branch::Branch(const QString& from, const QString& to, QObject *parent):from(from),to(to) { } diff --git a/testHasttable/element/branch.h b/testHasttable/element/branch.h index a721e95..33f5fb8 100644 --- a/testHasttable/element/branch.h +++ b/testHasttable/element/branch.h @@ -1,10 +1,12 @@ #ifndef BRANCH_H #define BRANCH_H +#include #include -class Branch +class Branch:public QObject { + Q_OBJECT public: - Branch(const QString& from, const QString& to); + Branch(const QString& from, const QString& to,QObject* parent=0); protected: double r; double x; diff --git a/testHasttable/element/line.cpp b/testHasttable/element/line.cpp index 10ea17c..21439b2 100644 --- a/testHasttable/element/line.cpp +++ b/testHasttable/element/line.cpp @@ -1,6 +1,6 @@ #include "line.h" -Line::Line(const QPair& fromTo, ACLineSegment* ac):Branch(fromTo.first,fromTo.second) +Line::Line(const QPair& fromTo, ACLineSegment* ac, QObject *parent):Branch(fromTo.first,fromTo.second) { this->ratio=1; this->ac=ac; diff --git a/testHasttable/element/line.h b/testHasttable/element/line.h index f5953ce..c4123ca 100644 --- a/testHasttable/element/line.h +++ b/testHasttable/element/line.h @@ -1,12 +1,13 @@ #ifndef LINE_H #define LINE_H +#include #include #include "branch.h" #include "./../aclinesegment.h" class Line:public Branch { public: - Line(const QPair &fromTo, ACLineSegment* ac); + Line(const QPair &fromTo, ACLineSegment* ac,QObject* parent=0); protected: virtual void extract(); private: diff --git a/testHasttable/element/switch.cpp b/testHasttable/element/switch.cpp index 7be1876..947db4a 100644 --- a/testHasttable/element/switch.cpp +++ b/testHasttable/element/switch.cpp @@ -1,6 +1,6 @@ #include "switch.h" -Switch::Switch(const QPair& fromTo):Branch(fromTo.first,fromTo.second) +Switch::Switch(const QPair& fromTo, QObject *parent):Branch(fromTo.first,fromTo.second) { this->extract(); } diff --git a/testHasttable/element/switch.h b/testHasttable/element/switch.h index 60bd265..2e93e91 100644 --- a/testHasttable/element/switch.h +++ b/testHasttable/element/switch.h @@ -1,11 +1,12 @@ #ifndef SWITCH_H #define SWITCH_H +#include #include #include "branch.h" class Switch:public Branch { public: - Switch(const QPair &fromTo); + Switch(const QPair &fromTo,QObject *parent=0); protected: virtual void extract(); diff --git a/testHasttable/element/transformer.cpp b/testHasttable/element/transformer.cpp index 84ed4c6..104e583 100644 --- a/testHasttable/element/transformer.cpp +++ b/testHasttable/element/transformer.cpp @@ -1,7 +1,7 @@ #include "transformer.h" -Transformer::Transformer(const QPair& fromTo, PowerTransformer* tf):Branch(fromTo.first,fromTo.second) +Transformer::Transformer(const QPair& fromTo, PowerTransformer* tf, QObject *parent):Branch(fromTo.first,fromTo.second) { this->ratio=1; this->tf=tf; diff --git a/testHasttable/element/transformer.h b/testHasttable/element/transformer.h index 72eea33..b790d53 100644 --- a/testHasttable/element/transformer.h +++ b/testHasttable/element/transformer.h @@ -1,12 +1,13 @@ #ifndef TRANSFORMER_H #define TRANSFORMER_H +#include #include #include "branch.h" #include "./../powertransformer.h" class Transformer:public Branch { public: - Transformer(const QPair &fromTo, PowerTransformer *tf); + Transformer(const QPair &fromTo, PowerTransformer *tf,QObject *parent=0); protected: virtual void extract(); private: diff --git a/testHasttable/topologyrecorder.cpp b/testHasttable/topologyrecorder.cpp index ffddda9..93fbf41 100644 --- a/testHasttable/topologyrecorder.cpp +++ b/testHasttable/topologyrecorder.cpp @@ -1,6 +1,6 @@ #include "topologyrecorder.h" #include -TopologyRecorder::TopologyRecorder(const QHash& elementHT):eleHT(elementHT) +TopologyRecorder::TopologyRecorder(const QHash& elementHT, QObject *parent):eleHT(elementHT) { } @@ -37,7 +37,9 @@ bool TopologyRecorder::startWithNode(const QString& node) anotherTerminalVector=this->nodeToTerminal.value(node);//一个Node可以找到多个与之相连的Terminal for(int atI=0;atIreachedTerminal.contains(anotherTerminal)) { @@ -65,7 +67,8 @@ bool TopologyRecorder::startWithNode(const QString& node) terminalB=AC->getTerminalB(); std::cout<<"find"<getID().toStdString()<getNamingDescription().toStdString()<(ht[swID]); if(!SW) { - // std::cout<<"can not SW "<getTerminalA(); terminalB=SW->getTerminalB(); std::cout<<"find"<getID().toStdString()<getName()=="Disconnector") { @@ -130,7 +133,8 @@ bool TopologyRecorder::startWithNode(const QString& node) terminalA=Dis->getTerminalA(); terminalB=Dis->getTerminalB(); std::cout<<"find"<getID().toStdString()<isEquipmentNeeded(equipmentContainer)) { this->tfs.push_back(tf->getNamingDescription()); + fromTo.first=node; + fromTo.second=tfID; + foundEle=tf; } else { std::cout<getNamingDescription().toStdString()<<"not belong"<branch.push_back(fromTo); + Branch *branch=NULL; + switch(typ) + { + case TopologyRecorder::Type::AC: + branch=new Line(fromTo,static_cast(foundEle),this); + this->cimExporter.add(fromTo,static_cast(branch)); + break; + case TopologyRecorder::Type::BREAKER: + branch=new Switch(fromTo,this); + this->cimExporter.add(fromTo,static_cast(branch)); + break; + case TopologyRecorder::Type::DISCONNECTOR: + branch=new Switch(fromTo,this); + this->cimExporter.add(fromTo,static_cast(branch)); + break; + case TopologyRecorder::Type::TF: + branch=new Transformer(fromTo,static_cast(foundEle),this); + this->cimExporter.add(fromTo,static_cast(branch)); + break; + default: + break; + } QString nextTerminal; nextTerminal=(terminalA==anotherTerminal)?terminalB:terminalA; Terminal *nextTerminalP=static_cast(ht[nextTerminal]); diff --git a/testHasttable/topologyrecorder.h b/testHasttable/topologyrecorder.h index ee687df..c6fb580 100644 --- a/testHasttable/topologyrecorder.h +++ b/testHasttable/topologyrecorder.h @@ -1,5 +1,6 @@ #ifndef TOPOLOGYRECORDER_H #define TOPOLOGYRECORDER_H +#include #include #include #include @@ -13,18 +14,30 @@ #include "substation.h" #include "busbarsection.h" #include "disconnector.h" -class TopologyRecorder +#include "cimexporter.h" +#include "element/branch.h" +#include "element/line.h" +#include "element/switch.h" +#include "element/transformer.h" +class TopologyRecorder:public QObject { + Q_OBJECT + class Type + { + public: + enum EleType{AC=0,BREAKER,DISCONNECTOR,BS,TF}; + }; + public: - TopologyRecorder(const QHash& elementHT); + TopologyRecorder(const QHash& elementHT,QObject *parent=0); ~TopologyRecorder(); bool startWithNode(const QString& node); private: NodeToTerminal nodeToTerminal; const QHash& eleHT; - QVector > branch; QHash reachedTerminal; QVector tfs; + CIMExporter cimExporter; bool isEquipmentNeeded(const QString& substatinID); };