diff --git a/testHasttable/cimexporter.cpp b/testHasttable/cimexporter.cpp index 36f16c6..c976101 100644 --- a/testHasttable/cimexporter.cpp +++ b/testHasttable/cimexporter.cpp @@ -1,6 +1,6 @@ #include "cimexporter.h" #include -CIMExporter::CIMExporter() +CIMExporter::CIMExporter(const QHash &eleHT, const QString &loadDir):loadDir(loadDir),eleHT(eleHT) { } @@ -33,25 +33,78 @@ void CIMExporter::add(const QPair& fromTo,Transformer* tf) void CIMExporter::exportTo(const QString& path) { - return; //先给所有节点都编号 this->idToNumber(this->line); this->idToNumber(this->sw); this->idToNumber(this->tf); //开始按要求输出 //先输出线路 - for(QList::iterator ite=this->line.begin(); - ite!=this->line.end(); +// for(QList::iterator ite=this->line.begin(); +// ite!=this->line.end(); +// ite++) +// { +// LineStru l=*ite; +// std::cout<r<<","<x<<","<g1<<","<g2<loadDir); + QStringList files; + files=recurseDir.getFiles(); + //转换斜杠 + for(QStringList::iterator ite=files.begin();ite!=files.end();ite++) + { + *ite=(*ite).replace("\\","/"); + } + +// //只取文件名 +// QStringList baseNames; +// foreach(QString file,files) +// { +// QFileInfo fileInfo(file); +// baseNames<::iterator ite=this->tf.begin(); + ite!=this->tf.end(); ite++) { - LineStru l=*ite; - std::cout<r<<","<x<<","<g1<<","<g2<tf->getTF(); + QString subID=tf->getEquipmentMemberOf_EquipmentContainer();//所属Substation的ID + Substation *sub=static_cast(this->eleHT[subID]); + if(!sub) + { + std::cout<<"CIMExporter:: can not substation of "< > vecLoadInfo=loadMapping.getSubstationLoad(sub->getID()); + foreach(QSharedPointer p,vecLoadInfo) + { + std::cout<<"match "<getLoadPath().toLocal8Bit().data()<getLoadPath()) ) + { + usedLoad<getLoadPath(); + p->getPA(); + break; + } + } + + } + //列出没有用的负荷文件 + foreach(QString file, files) + { + if(!usedLoad.contains(file)) + { + std::cout< #include +#include +#include +#include +#include "recursedir.h" +#include "substation.h" +#include "loadmapping.h" +#include "loadinfo.h" +#include +//#include "elementhashtable.h" +class Substation; class CIMExporter { struct BranchStruc @@ -31,7 +41,7 @@ class CIMExporter }; public: - CIMExporter(); + explicit CIMExporter(const QHash& eleHT,const QString& loadDir); void add(const QPair& fromTo,Line* line); void add(const QPair& fromTo,Switch* sw); void add(const QPair& fromTo,Transformer* tf); @@ -44,6 +54,8 @@ private: int numberIt(const QString &id);//编号 template void idToNumber(QList &s);//把所有元件的标识进行编号 + QString loadDir; + const QHash& eleHT; }; #endif // CIMEXPORTER_H diff --git a/testHasttable/element/transformer.cpp b/testHasttable/element/transformer.cpp index 104e583..3ad2eb7 100644 --- a/testHasttable/element/transformer.cpp +++ b/testHasttable/element/transformer.cpp @@ -24,4 +24,12 @@ void Transformer::extract() this->g2=g0*length; this->b1=b0*length; this->b2=b0*length; + //解析负荷 + +} + + +PowerTransformer *Transformer::getTF() +{ + return this->tf; } diff --git a/testHasttable/element/transformer.h b/testHasttable/element/transformer.h index b790d53..0cf04db 100644 --- a/testHasttable/element/transformer.h +++ b/testHasttable/element/transformer.h @@ -4,10 +4,12 @@ #include #include "branch.h" #include "./../powertransformer.h" +#include "./../loadmapping.h" class Transformer:public Branch { public: Transformer(const QPair &fromTo, PowerTransformer *tf,QObject *parent=0); + PowerTransformer *getTF(); protected: virtual void extract(); private: diff --git a/testHasttable/elementhashtable.cpp b/testHasttable/elementhashtable.cpp index 0bbf2c5..392346c 100644 --- a/testHasttable/elementhashtable.cpp +++ b/testHasttable/elementhashtable.cpp @@ -71,6 +71,8 @@ bool ElementHashtable::child(QXmlStreamReader &reader) return true; } + + bool ElementHashtable::GoPath() { const QHash &zwht=this->eleHT;//从配网开始找 @@ -101,9 +103,9 @@ bool ElementHashtable::GoPath() delete this->tpRecorder; this->tpRecorder=NULL; } - this->tpRecorder=new TopologyRecorder(this->eleHT,this->FDSet); + this->tpRecorder=new TopologyRecorder(this->eleHT,this->FDSet,this->loadFilePath); this->tpRecorder->startWithNode(node); - this->tpRecorder->exportTo(""); +// this->tpRecorder->exportTo(""); break; } } @@ -187,3 +189,8 @@ void ElementHashtable::ShowContainerInfo(const QString& fileName) std::cerr<<"not open"<loadFilePath=path; +} diff --git a/testHasttable/elementhashtable.h b/testHasttable/elementhashtable.h index 17a98ea..cf370da 100644 --- a/testHasttable/elementhashtable.h +++ b/testHasttable/elementhashtable.h @@ -27,7 +27,9 @@ public: explicit ElementHashtable(QObject *parent = 0); bool Parse(const QString& xmlPWPath,const QString& xmlZWPath); bool GoPath(); +// void ExportTo(const QString& path); void SetACLineID(const QString &id);//寻找的线路ID + void SetLoadFilePath(const QString &path); void SetFDSet(const QVector &FDSet);//FeeDer集合 void ShowContainerInfo(const QString& fileName); private: @@ -41,6 +43,7 @@ private: QString lineID; QVector FDSet; TopologyRecorder *tpRecorder; + QString loadFilePath; signals: public slots: diff --git a/testHasttable/loadmapping.cpp b/testHasttable/loadmapping.cpp index 51ccf31..84a2a67 100644 --- a/testHasttable/loadmapping.cpp +++ b/testHasttable/loadmapping.cpp @@ -41,6 +41,16 @@ bool LoadMapping::broadcastUpdateByTime(const QTime& time) return true; } +QSharedPointer LoadMapping::getALoad(const QString& id) +{ + return (*this->loadsToLoadInfo)[id]; +} + +QVector > LoadMapping::getSubstationLoad(const QString& id) +{ + return (*this->loads)[id]; +} + bool LoadMapping::load(const QString &loadDir,const QString &matchdDir,const QString &exceptionFile) { diff --git a/testHasttable/loadmapping.h b/testHasttable/loadmapping.h index 2907c62..28ded18 100644 --- a/testHasttable/loadmapping.h +++ b/testHasttable/loadmapping.h @@ -24,9 +24,12 @@ public: LoadMapping(); ~LoadMapping(); bool broadcastUpdateByTime(const QTime& time); + QSharedPointer getALoad(const QString& id); + QVector > getSubstationLoad(const QString& id); bool load(const QString& loadDir, const QString &matchdDir, const QString &exceptionFile); bool readLoads(const QString& dir); bool readMatch(const QString& dir); + private: class CG // 它的唯一工作就是在析构函数中删除CSingleton的实例 { diff --git a/testHasttable/task.cpp b/testHasttable/task.cpp index d94b4a8..4f3c7e9 100644 --- a/testHasttable/task.cpp +++ b/testHasttable/task.cpp @@ -54,18 +54,21 @@ void Task::doAgainstTaskFile(ElementHashtable &eleHT) } // //开始解析 sep=line.split(','); - if(sep.length()<3) + if(sep.length()<4) { std::cout<<"error: "< +//#include #include -TopologyRecorder::TopologyRecorder(const QHash& elementHT, const QVector &FDSet, QObject *parent):eleHT(elementHT),FDSet(FDSet) +TopologyRecorder::TopologyRecorder(const QHash& elementHT, const QVector &FDSet,const QString& loadFilePath, QObject *parent):QObject(parent),eleHT(elementHT),FDSet(FDSet),cimExporter(elementHT,loadFilePath) { } @@ -141,9 +141,7 @@ bool TopologyRecorder::startWithNode(const QString& node) { // std::cout<<"sw "<getNamingDescription().toStdString()<<"is close"<(ht[SW->getEquipmentMemberOf_EquipmentContainer()]); -// std::cout<<"sw container"<getNamingDescription().toLocal8Bit().data()<getID().toStdString()<getTerminalA(); terminalB=SW->getTerminalB(); // std::cout<<"find"<getID().toStdString()<isEquipmentNeeded(equipmentContainer)) { this->tfs.push_back(tfID); -// fromTo.first=node; -// fromTo.second=tfID; + foundEle=tf; } else @@ -245,23 +242,41 @@ bool TopologyRecorder::startWithNode(const QString& node) } if(foundEle) { - Branch *branch=NULL; - QString nextTerminal; - nextTerminal=(terminalA==anotherTerminal)?terminalB:terminalA; - Terminal *nextTerminalP=static_cast(ht[nextTerminal]); - if(!nextTerminalP) - { - continue; - } + //有可能会访问到重复的元件,所以这里判断一下,如果是已经访问过的就不添加了。 if(this->hasAdded.contains(foundEle->getID())) { continue; } this->hasAdded[foundEle->getID()]=0; - QString nextNode=nextTerminalP->getConnectivityNode(); - fromTo.first=node; - fromTo.second=nextNode; + + Branch *branch=NULL; + QString nextTerminal; + Terminal *nextTerminalP; + QString nextNode; + if(typ!=TopologyRecorder::Type::TF) + { + nextTerminal=(terminalA==anotherTerminal)?terminalB:terminalA; + nextTerminalP=static_cast(ht[nextTerminal]); + if(!nextTerminalP) + { + continue; + } + else + { + nextNode=nextTerminalP->getConnectivityNode(); + fromTo.first=node; + fromTo.second=nextNode; + } + } + else + { + nextNode=""; + fromTo.first=node; + fromTo.second=foundEle->getID();//用变压器编号做虚拟节点 + } + +// std::cout<(foundEle),this); +// std::cout<<"add tf"<cimExporter.add(fromTo,static_cast(branch)); break; default: break; } // std::cout<startWithNode(nextNode); + if(nextNode!="") + this->startWithNode(nextNode); } else { diff --git a/testHasttable/topologyrecorder.h b/testHasttable/topologyrecorder.h index e2291c0..48c17e5 100644 --- a/testHasttable/topologyrecorder.h +++ b/testHasttable/topologyrecorder.h @@ -30,7 +30,7 @@ class TopologyRecorder:public QObject }; public: - TopologyRecorder(const QHash& elementHT,const QVector &FDSet,QObject *parent=0); + TopologyRecorder(const QHash& elementHT, const QVector &FDSet, const QString &loadFilePath, QObject *parent=0); ~TopologyRecorder(); void showContainerInfo(QTextStream &stream); bool startWithNode(const QString& node); @@ -40,8 +40,8 @@ private: const QHash& eleHT; QHash reachedTerminal; QVector tfs; - CIMExporter cimExporter; QVector FDSet; + CIMExporter cimExporter; QHash hasAdded; bool isEquipmentNeeded(const QString& substatinID); };