diff --git a/testHasttable/cimexporter.cpp b/testHasttable/cimexporter.cpp index 4ad2552..fff9089 100644 --- a/testHasttable/cimexporter.cpp +++ b/testHasttable/cimexporter.cpp @@ -10,6 +10,7 @@ void CIMExporter::add(const QPair& fromTo,Line* line) lineStru.line=line; lineStru.fromID=fromTo.first; lineStru.toID=fromTo.second; + lineStru.id=line->ac->getID(); this->line.push_back(lineStru); } @@ -19,6 +20,7 @@ void CIMExporter::add(const QPair& fromTo,Switch* sw) switchStru.sw=sw; switchStru.fromID=fromTo.first; switchStru.toID=fromTo.second; + switchStru.id=sw->id; this->sw.push_back(switchStru); } void CIMExporter::add(const QPair& fromTo,Transformer* tf) diff --git a/testHasttable/element/branch.cpp b/testHasttable/element/branch.cpp index b296529..9d1a733 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, QObject *parent):from(from),to(to) +Branch::Branch(const QString& from, const QString& to, QObject *parent):from(from),to(to),QObject(parent) { } diff --git a/testHasttable/element/commontype.h b/testHasttable/element/commontype.h index 53382dc..6d80c82 100644 --- a/testHasttable/element/commontype.h +++ b/testHasttable/element/commontype.h @@ -1,12 +1,17 @@ #ifndef COMMONTYPE #define COMMONTYPE +#include +#include "line.h" +#include "switch.h" +#include "transformer.h" struct BranchStruc { QString fromID; QString toID; int fromNum; int toNum; + QString id;//后面有用的 }; struct LineStru:public BranchStruc { diff --git a/testHasttable/element/line.cpp b/testHasttable/element/line.cpp index cd4b51a..5e38537 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, QObject *parent):Branch(fromTo.first,fromTo.second) +Line::Line(const QPair& fromTo, ACLineSegment* ac, QObject *parent):Branch(fromTo.first,fromTo.second,parent) { this->ratio=1; this->ac=ac; diff --git a/testHasttable/element/line.h b/testHasttable/element/line.h index 327758f..b335dcd 100644 --- a/testHasttable/element/line.h +++ b/testHasttable/element/line.h @@ -9,10 +9,11 @@ class Line:public Branch public: Line(const QPair &fromTo, ACLineSegment* ac,QObject* parent=0); double length; + ACLineSegment *ac; protected: virtual void extract(); private: - ACLineSegment *ac; + }; #endif // LINE_H diff --git a/testHasttable/element/switch.cpp b/testHasttable/element/switch.cpp index 947db4a..82634cc 100644 --- a/testHasttable/element/switch.cpp +++ b/testHasttable/element/switch.cpp @@ -1,6 +1,6 @@ #include "switch.h" -Switch::Switch(const QPair& fromTo, QObject *parent):Branch(fromTo.first,fromTo.second) +Switch::Switch(const QPair& fromTo, const QString &id, QObject *parent):Branch(fromTo.first,fromTo.second,parent),id(id) { this->extract(); } diff --git a/testHasttable/element/switch.h b/testHasttable/element/switch.h index 2e93e91..cbb17c1 100644 --- a/testHasttable/element/switch.h +++ b/testHasttable/element/switch.h @@ -6,10 +6,12 @@ class Switch:public Branch { public: - Switch(const QPair &fromTo,QObject *parent=0); + Switch(const QPair &fromTo,const QString& id,QObject *parent=0); + QString id; protected: virtual void extract(); + }; #endif // SWITCH_H diff --git a/testHasttable/element/transformer.cpp b/testHasttable/element/transformer.cpp index c7b348d..671a211 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, QObject *parent):Branch(fromTo.first,fromTo.second) +Transformer::Transformer(const QPair& fromTo, PowerTransformer* tf, QObject *parent):Branch(fromTo.first,fromTo.second,parent) { this->ratio=1; this->tf=tf; diff --git a/testHasttable/elementreduction.cpp b/testHasttable/elementreduction.cpp index 28ec3ee..af45e1e 100644 --- a/testHasttable/elementreduction.cpp +++ b/testHasttable/elementreduction.cpp @@ -1,6 +1,6 @@ #include "elementreduction.h" -ElementReduction::ElementReduction() +ElementReduction::ElementReduction(const QList &branchList):branchList(branchList) { } @@ -10,3 +10,13 @@ ElementReduction::~ElementReduction() } +void ElementReduction::doIt() +{ + //先重新编号 + int add=0; + foreach(Branch *v,this->branchList) + { + v->id=add++; + } +} + diff --git a/testHasttable/elementreduction.h b/testHasttable/elementreduction.h index 3c38c72..37bb098 100644 --- a/testHasttable/elementreduction.h +++ b/testHasttable/elementreduction.h @@ -1,12 +1,17 @@ #ifndef ELEMENTREDUCTION_H #define ELEMENTREDUCTION_H +#include +#include "element/commontype.h" //把电阻等于0的元件都去掉 class ElementReduction { public: - ElementReduction(); + explicit ElementReduction(const QList& branchList); + void doIt(); ~ElementReduction(); +private: + const QList& branchList; }; #endif // ELEMENTREDUCTION_H diff --git a/testHasttable/topologyrecorder.cpp b/testHasttable/topologyrecorder.cpp index 529a6ac..6318cc6 100644 --- a/testHasttable/topologyrecorder.cpp +++ b/testHasttable/topologyrecorder.cpp @@ -284,11 +284,11 @@ bool TopologyRecorder::startWithNode(const QString& node) this->cimExporter.add(fromTo,static_cast(branch)); break; case TopologyRecorder::Type::BREAKER: - branch=new Switch(fromTo,this); + branch=new Switch(fromTo,foundEle->getID(),this); this->cimExporter.add(fromTo,static_cast(branch)); break; case TopologyRecorder::Type::DISCONNECTOR: - branch=new Switch(fromTo,this); + branch=new Switch(fromTo,foundEle->getID(),this); this->cimExporter.add(fromTo,static_cast(branch)); break; case TopologyRecorder::Type::TF: