From 3345e00fbd82514bf6402f9c8015e2b940247f6b Mon Sep 17 00:00:00 2001 From: "dmy@lab" Date: Sun, 1 Feb 2015 13:52:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8ADG=E5=8A=A0=E8=BF=9B=E5=8E=BB=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dmy@lab --- testHasttable/cimexporter.cpp | 23 ++++++++++++++++++++++- testHasttable/elementreduction.cpp | 12 +++++++++++- testHasttable/topologyrecorder.cpp | 3 ++- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/testHasttable/cimexporter.cpp b/testHasttable/cimexporter.cpp index efd573d..1820927 100644 --- a/testHasttable/cimexporter.cpp +++ b/testHasttable/cimexporter.cpp @@ -66,22 +66,31 @@ void CIMExporter::exportTo(const QString& path,const QString &rootID) QList elements; for(int i=0;iline.length();i++) { +// std::cout<line[i].fromID.toStdString()<<" "<line[i].id.toStdString()<<" "<line[i].toID.toStdString()<line[i]) ); } for(int i=0;isw.length();i++) { +// std::cout<sw[i].fromID.toStdString()<<" "<sw[i].id.toStdString()<<" "<sw[i].toID.toStdString()<sw[i]) ); } for(int i=0;itf.length();i++) { +// std::cout<tf[i].fromID.toStdString()<<" "<tf[i].id.toStdString()<<" "<tf[i].toID.toStdString()<tf[i]) ); } + for(int i=0;idg.length();i++) + { +// std::cout<dg[i].fromID.toStdString()<<" "<dg[i].id.toStdString()<<" "<dg[i].toID.toStdString()<dg[i]) ); + } ElementReduction elementReduction(elements); -// elementReduction.doIt(rootID);//消除0阻抗支路,把几段线路连成一段 + elementReduction.doIt(rootID);//消除0阻抗支路,把几段线路连成一段 //先给所有节点都编号 this->idToNumber(this->line); this->idToNumber(this->sw); this->idToNumber(this->tf); + this->idToNumber(this->dg); //开始按要求输出 //先输出线路 QTextStream writer(&fd); @@ -285,6 +294,18 @@ bool CIMExporter::topologyTest() linkage.push_back(QPair(ite->fromNum,ite->toNum)); } + for(QList::iterator ite=this->dg.begin(); + ite!=this->dg.end(); + ite++) + { + if(ite->dispose) + { + continue; + } + linkage.push_back(QPair(ite->fromNum,ite->toNum)); + } + + TopologyTest tpTest(this->number.keys().length()); if(tpTest.start(linkage)) { diff --git a/testHasttable/elementreduction.cpp b/testHasttable/elementreduction.cpp index 52adbc0..2ff843c 100644 --- a/testHasttable/elementreduction.cpp +++ b/testHasttable/elementreduction.cpp @@ -44,8 +44,10 @@ void ElementReduction::doIt(const QString& rootID) this->buildTreeTo(element,root,linkage,idToBranch); // this->visited.remove(this->branchList.at(2)->id); // this->buildTreeFrom(element,root,linkage,idToBranch); + this->merge(element,idToBranch); this->reduceSection(); + // QFile file("1.xml"); // if(file.open(QFile::WriteOnly)) // { @@ -76,7 +78,15 @@ void ElementReduction::merge(QDomElement &element,QHash& // return; QString parentID=idToBranch[element.tagName()]->id; QStringList sep=parentID.split('-'); - QString toID=sep.at(1)+sep.at(0); + QString toID; + if(sep.length()>1) + { + toID=sep.at(1)+sep.at(0); + } + else + { + toID=sep.at(0)+"_"+sep.at(0); + } idToBranch[element.tagName()]->toID=toID; element.setAttribute("toID",toID); //顺便编号 diff --git a/testHasttable/topologyrecorder.cpp b/testHasttable/topologyrecorder.cpp index 6326387..4df1504 100644 --- a/testHasttable/topologyrecorder.cpp +++ b/testHasttable/topologyrecorder.cpp @@ -25,9 +25,10 @@ bool TopologyRecorder::addDG(const QString& substationID, const QString &fromNod { break;//这个Substation下面已经添加过DG,不用再添加了。 } +// std::cout<<"from node"<getName(),this); this->cimExporter.add(fromTo,DGP); - std::cout<<"add "<<_DG->getName().toLocal8Bit().data()<getName().toLocal8Bit().data()<usedDG[_DG->getName()]=0;//用过了,做个记号 } return true;