#include "elementhashtable.h" #include ElementHashtable::ElementHashtable(QObject *parent) : QObject(parent),currentHT(NULL),tpRecorder(NULL) { } bool ElementHashtable::child(QXmlStreamReader &reader) { QStringRef elementName; elementName=reader.name(); QString id; if(reader.attributes().hasAttribute("rdf:ID")) { id=reader.attributes().value("rdf:ID").toString(); } BasicElementInfo *pointer=NULL; if(elementName=="BusbarSection") { pointer=new BusbarSection(this); pointer->parse(reader); } if(elementName=="Terminal") { pointer=new Terminal(this); pointer->parse(reader); } if(elementName=="ACLineSegment") { pointer=new ACLineSegment(this); pointer->parse(reader); } if(elementName=="Breaker") { pointer=new Breaker(this); pointer->parse(reader); } if(elementName=="Substation") { pointer=new Substation(this); pointer->parse(reader); } // if(elementName=="Compensator") // { // pointer=new Compensator(this); // pointer->parse(reader); // } if(elementName=="Disconnector") { pointer=new Disconnector(this); pointer->parse(reader); } if(elementName=="PowerTransformer") { pointer=new PowerTransformer(this); pointer->parse(reader); } if(elementName=="SynchronousMachine") { pointer=new SynchronousMachine(this); pointer->parse(reader); } if(pointer && id!="") { QHash *hash=this->currentHT; (*hash)[id]=pointer; } return true; } bool ElementHashtable::GoPath() { const QHash &zwht=this->eleHT;//从配网开始找 QList keys; keys=zwht.keys(); // std::cout<::Iterator ite=keys.begin(); ite!=keys.end(); ite++) { BasicElementInfo *p=zwht[*ite]; if(p->getName()=="ACLineSegment" && p->getID()==this->lineID) { ACLineSegment *ac=static_cast(p);//BusbarSection也就是线路头节点 QString acTerminal=ac->getTerminalB(); //找Terminal的东西 Terminal *acTerminalP=static_cast(zwht[acTerminal]); // std::cout<getID().toStdString()<getConnectivityNode(); if(node=="") { continue;//有些Terminal是没有Node的 } // std::cout<tpRecorder!=NULL) { delete this->tpRecorder; this->tpRecorder=NULL; } this->tpRecorder=new TopologyRecorder(this->eleHT,this->FDSet,this->loadFilePath); this->tpRecorder->startWithNode(node); this->tpRecorder->exportTo(""); break; } } return true; } bool ElementHashtable::parse(const QString& xmlPath) { QFile xmlFile(xmlPath); int loop=0; if(xmlFile.open(QFile::ReadOnly)) { QXmlStreamReader reader(&xmlFile); while(!reader.atEnd() && !reader.hasError()) { reader.readNext(); if(reader.isStartElement()) { if(reader.name()=="RDF")//不要读 *t) { this->currentHT=t; return true; } bool ElementHashtable::Parse(const QString& xmlPWPath,const QString& xmlZWPath){ this->setCurrentHashTable(&this->eleHT); this->parse(xmlPWPath); // this->setCurrentHashTable(&this->mainStationHT); // this->parse(xmlZWPath); return true; } void ElementHashtable::SetACLineID(const QString &id)//寻找的线路ID { this->lineID=id; } void ElementHashtable::SetFDSet(const QVector &FDSet)//FeeDer集合 { this->FDSet=FDSet; } void ElementHashtable::ShowContainerInfo(const QString& fileName) { QString relPath="D:/MyPro/cimforreduceloss/testHasttable/output/"; relPath+=fileName+".txt"; QFile file(relPath); if(file.open(QFile::WriteOnly|QFile::Text)) { QTextStream stream(&file); this->tpRecorder->showContainerInfo(stream); file.close(); } else { std::cerr<<"not open"<loadFilePath=path; }