1.修复了一些类的isTerminal没有被初始化的bug
2.修复了一些地方判断下一个Terminal的bug Signed-off-by: facat@lab.com <facat@lab.com>
This commit is contained in:
parent
38025aa1fc
commit
69cd117f35
|
|
@ -10,7 +10,7 @@ bool ACLineSegment::derivedParse(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
QString terminal;
|
QString terminal;
|
||||||
terminal=reader.attributes().value("rdf:resource").toString();
|
terminal=reader.attributes().value("rdf:resource").toString();
|
||||||
this->terminalA=terminal.replace("#","").leftRef(-1);//返回整个字符串的Ref
|
this->terminalA=terminal.replace("#","").leftRef(-1).toString();//返回整个字符串的Ref
|
||||||
qDebug()<<"got "<<"ConductingEquipment.Terminals "<<this->terminalA<<"\n";
|
qDebug()<<"got "<<"ConductingEquipment.Terminals "<<this->terminalA<<"\n";
|
||||||
this->isTerminalA=false;
|
this->isTerminalA=false;
|
||||||
}
|
}
|
||||||
|
|
@ -18,19 +18,28 @@ bool ACLineSegment::derivedParse(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
QString terminal;
|
QString terminal;
|
||||||
terminal=reader.attributes().value("rdf:resource").toString();
|
terminal=reader.attributes().value("rdf:resource").toString();
|
||||||
this->terminalB=terminal.replace("#","").leftRef(-1);//返回整个字符串的Ref
|
this->terminalB=terminal.replace("#","").leftRef(-1).toString();//返回整个字符串的Ref
|
||||||
qDebug()<<"got "<<"ConductingEquipment.Terminals "<<this->terminalB<<"\n";
|
qDebug()<<"got "<<"ConductingEquipment.Terminals "<<this->terminalB<<"\n";
|
||||||
}
|
}
|
||||||
if("ConductingEquipment.Substation"==reader.name() && reader.attributes().hasAttribute("rdf:resource"))
|
if("ConductingEquipment.Substation"==reader.name() && reader.attributes().hasAttribute("rdf:resource"))
|
||||||
{
|
{
|
||||||
QString ss;
|
QString ss;
|
||||||
ss=reader.attributes().value("rdf:resource").toString();
|
ss=reader.attributes().value("rdf:resource").toString();
|
||||||
this->containsOfSubstation=ss.replace("#","").leftRef(-1);//返回整个字符串的Ref
|
this->containsOfSubstation=ss.replace("#","").leftRef(-1).toString();//返回整个字符串的Ref
|
||||||
qDebug()<<"got "<<"ConductingEquipment.Substation "<<this->containsOfSubstation<<"\n";
|
qDebug()<<"got "<<"ConductingEquipment.Substation "<<this->containsOfSubstation<<"\n";
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString ACLineSegment::getTerminalA()
|
||||||
|
{
|
||||||
|
return this->terminalA;
|
||||||
|
}
|
||||||
|
QString ACLineSegment::getTerminalB()
|
||||||
|
{
|
||||||
|
return this->terminalB;
|
||||||
|
}
|
||||||
|
|
||||||
bool ACLineSegment::parse(QXmlStreamReader &reader)
|
bool ACLineSegment::parse(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
return this->parseBasicInfo(reader);
|
return this->parseBasicInfo(reader);
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,12 @@ class ACLineSegment:public BasicElementInfo
|
||||||
public:
|
public:
|
||||||
explicit ACLineSegment(QObject *parent = 0);
|
explicit ACLineSegment(QObject *parent = 0);
|
||||||
virtual bool parse(QXmlStreamReader &reader);
|
virtual bool parse(QXmlStreamReader &reader);
|
||||||
|
QString getTerminalA();
|
||||||
|
QString getTerminalB();
|
||||||
protected:
|
protected:
|
||||||
QStringRef terminalA;
|
QString terminalA;
|
||||||
QStringRef terminalB;
|
QString terminalB;
|
||||||
QStringRef containsOfSubstation;
|
QString containsOfSubstation;
|
||||||
virtual bool derivedParse(QXmlStreamReader &reader);
|
virtual bool derivedParse(QXmlStreamReader &reader);
|
||||||
private:
|
private:
|
||||||
bool isTerminalA;
|
bool isTerminalA;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include "breaker.h"
|
#include "breaker.h"
|
||||||
|
#include <iostream>
|
||||||
Breaker::Breaker(QObject *parent):BasicElementInfo(parent)
|
Breaker::Breaker(QObject *parent):BasicElementInfo(parent),isTerminalA(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -31,6 +31,15 @@ bool Breaker::derivedParse(QXmlStreamReader &reader)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString Breaker::getTerminalA()
|
||||||
|
{
|
||||||
|
return this->terminalA;
|
||||||
|
}
|
||||||
|
QString Breaker::getTerminalB()
|
||||||
|
{
|
||||||
|
return this->terminalB;
|
||||||
|
}
|
||||||
|
|
||||||
bool Breaker::parse(QXmlStreamReader &reader)
|
bool Breaker::parse(QXmlStreamReader &reader)
|
||||||
{
|
{
|
||||||
return this->parseBasicInfo(reader);
|
return this->parseBasicInfo(reader);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,15 @@
|
||||||
#ifndef BREAKER_H
|
#ifndef BREAKER_H
|
||||||
#define BREAKER_H
|
#define BREAKER_H
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
|
#include <QString>
|
||||||
#include "BasicElementInfo.h"
|
#include "BasicElementInfo.h"
|
||||||
class Breaker:public BasicElementInfo
|
class Breaker:public BasicElementInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit Breaker(QObject *parent = 0);
|
explicit Breaker(QObject *parent = 0);
|
||||||
virtual bool parse(QXmlStreamReader& reader);
|
virtual bool parse(QXmlStreamReader& reader);
|
||||||
|
QString getTerminalA();
|
||||||
|
QString getTerminalB();
|
||||||
protected:
|
protected:
|
||||||
QString terminalA;
|
QString terminalA;
|
||||||
QString terminalB;
|
QString terminalB;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include "disconnector.h"
|
#include "disconnector.h"
|
||||||
|
|
||||||
Disconnector::Disconnector(QObject *parent):BasicElementInfo(parent)
|
Disconnector::Disconnector(QObject *parent):BasicElementInfo(parent),isTerminalA(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include "elementhashtable.h"
|
#include "elementhashtable.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
ElementHashtable::ElementHashtable(QObject *parent) :
|
ElementHashtable::ElementHashtable(QObject *parent) :
|
||||||
QObject(parent)
|
QObject(parent),currentHT(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,40 +60,45 @@ bool ElementHashtable::child(QXmlStreamReader &reader)
|
||||||
|
|
||||||
if(pointer && id!="")
|
if(pointer && id!="")
|
||||||
{
|
{
|
||||||
this->eleHT[id]=pointer;
|
QHash<QString,BasicElementInfo *> *hash=this->currentHT;
|
||||||
|
(*hash)[id]=pointer;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ElementHashtable::goPath()
|
bool ElementHashtable::GoPath()
|
||||||
{
|
{
|
||||||
const QHash<QString,BasicElementInfo*> &ht=this->eleHT;
|
const QHash<QString,BasicElementInfo*> &zwht=this->eleHT;//从配网开始找
|
||||||
QList<QString> keys;
|
QList<QString> keys;
|
||||||
keys=ht.keys();
|
keys=zwht.keys();
|
||||||
std::cout<<keys.length()<<std::endl;
|
std::cout<<keys.length()<<std::endl;
|
||||||
for(QList<QString>::Iterator ite=keys.begin();
|
for(QList<QString>::Iterator ite=keys.begin();
|
||||||
ite!=keys.end();
|
ite!=keys.end();
|
||||||
ite++)
|
ite++)
|
||||||
{
|
{
|
||||||
BasicElementInfo *p=ht[*ite];
|
BasicElementInfo *p=zwht[*ite];
|
||||||
if(p->getName()=="BusbarSection")
|
// if(p->getName()=="ACLineSegment"){
|
||||||
|
// std::cout<<p->getID().toStdString()<<std::endl;
|
||||||
|
// }
|
||||||
|
if(p->getName()=="ACLineSegment" && p->getID()=="AC-456432")
|
||||||
{
|
{
|
||||||
// std::cout<<"BusbarSection"<<"\n";
|
ACLineSegment *ac=static_cast<ACLineSegment *>(p);//BusbarSection也就是线路头节点
|
||||||
BusbarSection *foo=static_cast<BusbarSection *>(p);
|
QString acTerminal=ac->getTerminalB();
|
||||||
QString terminal=foo->getTerminal();
|
|
||||||
//找Terminal的东西
|
//找Terminal的东西
|
||||||
Terminal *terminalP=static_cast<Terminal *>(ht[terminal]);
|
Terminal *acTerminalP=static_cast<Terminal *>(zwht[acTerminal]);
|
||||||
std::cout<<terminalP->getID().toStdString()<<std::endl;
|
std::cout<<acTerminalP->getID().toStdString()<<std::endl;
|
||||||
QString node;
|
QString node;
|
||||||
node=terminalP->getConnectivityNode();
|
node=acTerminalP->getConnectivityNode();
|
||||||
|
if(node=="")
|
||||||
|
{
|
||||||
|
continue;//有些Terminal是没有Node的
|
||||||
|
}
|
||||||
std::cout<<node.toStdString()<<std::endl;
|
std::cout<<node.toStdString()<<std::endl;
|
||||||
QString anotherTerminal;
|
TopologyRecorder tpRecorder(this->eleHT);
|
||||||
anotherTerminal=this->nodeToTerminal.value(node);
|
tpRecorder.startWithNode(node);
|
||||||
// std::cout<<"anotherTerminal"<<anotherTerminal.toStdString()<<std::endl;
|
|
||||||
Terminal *anotherTerminalP=static_cast<Terminal *>(ht[anotherTerminal]);
|
|
||||||
std::cout<<anotherTerminalP->getConductingEquipment().toStdString()<<std::endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,3 +136,17 @@ bool ElementHashtable::parse(const QString& xmlPath)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ElementHashtable::setCurrentHashTable(QHash<QString,BasicElementInfo *> *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;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
|
#include <QVector>
|
||||||
#include "BasicElementInfo.h"
|
#include "BasicElementInfo.h"
|
||||||
#include "subcontrolarea.h"
|
#include "subcontrolarea.h"
|
||||||
#include "busbarsection.h"
|
#include "busbarsection.h"
|
||||||
|
|
@ -17,18 +18,22 @@
|
||||||
#include "disconnector.h"
|
#include "disconnector.h"
|
||||||
#include "powertransformer.h"
|
#include "powertransformer.h"
|
||||||
#include "synchronousmachine.h"
|
#include "synchronousmachine.h"
|
||||||
#include "nodetoterminal.h"
|
#include "topologyrecorder.h"
|
||||||
class ElementHashtable : public QObject
|
class ElementHashtable : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit ElementHashtable(QObject *parent = 0);
|
explicit ElementHashtable(QObject *parent = 0);
|
||||||
bool parse(const QString& xmlPath);
|
bool Parse(const QString& xmlPWPath,const QString& xmlZWPath);
|
||||||
bool goPath();
|
bool GoPath();
|
||||||
private:
|
private:
|
||||||
bool child(QXmlStreamReader &reader);
|
bool child(QXmlStreamReader &reader);
|
||||||
|
bool setCurrentHashTable(QHash<QString,BasicElementInfo *> *t);
|
||||||
|
bool parse(const QString& xmlPath);
|
||||||
QHash<QString,BasicElementInfo *> eleHT;
|
QHash<QString,BasicElementInfo *> eleHT;
|
||||||
|
QHash<QString,BasicElementInfo *> mainStationHT;//记录主站的元素
|
||||||
NodeToTerminal nodeToTerminal;
|
NodeToTerminal nodeToTerminal;
|
||||||
|
QHash<QString,BasicElementInfo *> *currentHT;
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication a(argc, argv);
|
QCoreApplication a(argc, argv);
|
||||||
ElementHashtable eleReader;
|
ElementHashtable eleReader;
|
||||||
eleReader.parse("D:/Project/佛山项目/佛山收资/exportmodel_pw/df8003/df8600/exportfiles/exportmodel_pw.xml");
|
eleReader.Parse("D:/Project/佛山项目/佛山收资/exportmodel_pw/df8003/df8600/exportfiles/exportmodel_pw.xml","D:/Project/佛山项目/佛山收资/exportmodel_zwyth20141204/exportmodel_zwyth.xml");
|
||||||
// eleReader.parse("D:/Project/佛山项目/佛山收资/按元素分/BusbarSectionb.xml");
|
// eleReader.parse("D:/Project/佛山项目/佛山收资/按元素分/BusbarSectionb.xml");
|
||||||
eleReader.goPath();
|
eleReader.GoPath();
|
||||||
// RegexExtract regexExt;
|
// RegexExtract regexExt;
|
||||||
// regexExt.extract("D:/Project/佛山项目/佛山收资/exportmodel_pw/df8003/df8600/exportfiles/exportmodel_pw.xml");
|
// regexExt.extract("D:/Project/佛山项目/佛山收资/exportmodel_pw/df8003/df8600/exportfiles/exportmodel_pw.xml");
|
||||||
// regexExt.exportBlocks("ThermalGeneratingUnit.xml");
|
// regexExt.exportBlocks("ThermalGeneratingUnit.xml");
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,23 @@
|
||||||
#include "nodetoterminal.h"
|
#include "nodetoterminal.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
QHash<QString,QString> *NodeToTerminal::ht=NULL;
|
QHash<QString,QVector<QString> > *NodeToTerminal::ht=NULL;
|
||||||
NodeToTerminal::NodeToTerminal()
|
NodeToTerminal::NodeToTerminal()
|
||||||
{
|
{
|
||||||
if(!NodeToTerminal::ht)
|
if(!NodeToTerminal::ht)
|
||||||
{
|
{
|
||||||
// std::cout<<"create"<<std::endl;
|
// std::cout<<"create"<<std::endl;
|
||||||
NodeToTerminal::ht=new QHash<QString,QString>;
|
NodeToTerminal::ht=new QHash<QString,QVector<QString> >;
|
||||||
// std::cout<<this->value("").toStdString()<<std::endl;
|
// std::cout<<this->value("").toStdString()<<std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeToTerminal::add(const QString& key,const QString& value)
|
void NodeToTerminal::add(const QString& key,const QString& value)
|
||||||
{
|
{
|
||||||
(*NodeToTerminal::ht)[key]=value;
|
// if(this->contains(key))
|
||||||
|
// {
|
||||||
|
// std::cout<<"duplicat"<<std::endl;
|
||||||
|
// }
|
||||||
|
(*NodeToTerminal::ht)[key].push_back(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NodeToTerminal::contains(const QString& key)
|
bool NodeToTerminal::contains(const QString& key)
|
||||||
|
|
@ -21,7 +25,7 @@ bool NodeToTerminal::contains(const QString& key)
|
||||||
return NodeToTerminal::ht->contains(key);
|
return NodeToTerminal::ht->contains(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NodeToTerminal::value(const QString& key)
|
QVector<QString> NodeToTerminal::value(const QString& key)
|
||||||
{
|
{
|
||||||
// if(NodeToTerminal::ht)
|
// if(NodeToTerminal::ht)
|
||||||
// {
|
// {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
//一个通过Node检索Terminal的表,做成单例形式
|
//一个通过Node检索Terminal的表,做成单例形式
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QVector>
|
||||||
class NodeToTerminal
|
class NodeToTerminal
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -10,7 +11,7 @@ public:
|
||||||
~NodeToTerminal();
|
~NodeToTerminal();
|
||||||
void add(const QString& key,const QString& value);
|
void add(const QString& key,const QString& value);
|
||||||
bool contains(const QString& key);
|
bool contains(const QString& key);
|
||||||
QString value(const QString& key);
|
QVector<QString> value(const QString& key);
|
||||||
private:
|
private:
|
||||||
class CG // 它的唯一工作就是在析构函数中删除CSingleton的实例
|
class CG // 它的唯一工作就是在析构函数中删除CSingleton的实例
|
||||||
{
|
{
|
||||||
|
|
@ -22,7 +23,7 @@ private:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static CG Garbo; // 定义一个静态成员,在程序结束时,系统会调用它的析构函数
|
static CG Garbo; // 定义一个静态成员,在程序结束时,系统会调用它的析构函数
|
||||||
static QHash<QString,QString> *ht;
|
static QHash<QString,QVector<QString> > *ht;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include "powertransformer.h"
|
#include "powertransformer.h"
|
||||||
|
|
||||||
PowerTransformer::PowerTransformer(QObject *parent):BasicElementInfo(parent)
|
PowerTransformer::PowerTransformer(QObject *parent):BasicElementInfo(parent),isTerminalA(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,8 @@ SOURCES += main.cpp \
|
||||||
disconnector.cpp \
|
disconnector.cpp \
|
||||||
powertransformer.cpp \
|
powertransformer.cpp \
|
||||||
synchronousmachine.cpp \
|
synchronousmachine.cpp \
|
||||||
nodetoterminal.cpp
|
nodetoterminal.cpp \
|
||||||
|
topologyrecorder.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
elementhashtable.h \
|
elementhashtable.h \
|
||||||
|
|
@ -44,7 +45,8 @@ HEADERS += \
|
||||||
disconnector.h \
|
disconnector.h \
|
||||||
powertransformer.h \
|
powertransformer.h \
|
||||||
synchronousmachine.h \
|
synchronousmachine.h \
|
||||||
nodetoterminal.h
|
nodetoterminal.h \
|
||||||
|
topologyrecorder.h
|
||||||
|
|
||||||
#release{
|
#release{
|
||||||
DEFINES += QT_NO_DEBUG_OUTPUT
|
DEFINES += QT_NO_DEBUG_OUTPUT
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
#include "topologyrecorder.h"
|
||||||
|
#include <iostream>
|
||||||
|
TopologyRecorder::TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT):eleHT(elementHT)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
bool TopologyRecorder::startWithNode(const QString& node)
|
||||||
|
{
|
||||||
|
if(node=="")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
const QHash<QString,BasicElementInfo*> &ht=this->eleHT;
|
||||||
|
QString anotherTerminal;
|
||||||
|
QVector<QString> anotherTerminalVector;
|
||||||
|
anotherTerminalVector=this->nodeToTerminal.value(node);//一个Node可以找到多个与之相连的Terminal
|
||||||
|
for(int atI=0;atI<anotherTerminalVector.length();atI++)
|
||||||
|
{
|
||||||
|
bool foundCate=false;
|
||||||
|
anotherTerminal=anotherTerminalVector.at(atI);
|
||||||
|
if(this->reachedTerminal.contains(anotherTerminal))
|
||||||
|
{
|
||||||
|
std::cout<<anotherTerminal.toStdString()<<"reached"<<std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this->reachedTerminal[anotherTerminal]=0;
|
||||||
|
std::cout<<"anotherTerminal"<<anotherTerminal.toStdString()<<std::endl;
|
||||||
|
Terminal *anotherTerminalP=static_cast<Terminal *>(ht[anotherTerminal]);
|
||||||
|
QString ce;
|
||||||
|
ce=anotherTerminalP->getConductingEquipment();
|
||||||
|
std::cout<<ce.toStdString()<<"from "<<anotherTerminal.toStdString() <<std::endl;
|
||||||
|
if(ce.startsWith("AC"))
|
||||||
|
{
|
||||||
|
foundCate=true;
|
||||||
|
QString acID=ce;
|
||||||
|
QPair<QString,QString> fromTo;
|
||||||
|
fromTo.first=node;
|
||||||
|
fromTo.second=acID;
|
||||||
|
this->branch.push_back(fromTo);
|
||||||
|
//通过ACSegmentLine的ID来找Terminal。下同。
|
||||||
|
ACLineSegment *AC=static_cast<ACLineSegment *>(ht[acID]);
|
||||||
|
if(!AC)
|
||||||
|
{
|
||||||
|
std::cout<<"can not find "<<acID.toStdString()<<std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QString terminalA;
|
||||||
|
QString terminalB;
|
||||||
|
terminalA=AC->getTerminalA();
|
||||||
|
terminalB=AC->getTerminalB();
|
||||||
|
QString nextTerminal;
|
||||||
|
nextTerminal=(terminalA==anotherTerminal)?terminalB:terminalA;
|
||||||
|
std::cout<<"new Terminal"<<nextTerminal.toStdString()<<std::endl;
|
||||||
|
Terminal *nextTerminalP=static_cast<Terminal *>(ht[nextTerminal]);
|
||||||
|
if(!nextTerminalP)
|
||||||
|
{
|
||||||
|
std::cout<<"can not terminal "<<nextTerminal.toStdString()<<std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QString nextNode=nextTerminalP->getConnectivityNode();
|
||||||
|
std::cout<<"next node"<<nextNode.toStdString()<<"from"<<nextTerminal.toStdString()<<std::endl;
|
||||||
|
this->startWithNode(nextNode);
|
||||||
|
}
|
||||||
|
if(ce.startsWith("SW"))
|
||||||
|
{
|
||||||
|
foundCate=true;
|
||||||
|
QString swID=ce;
|
||||||
|
QPair<QString,QString> fromTo;
|
||||||
|
fromTo.first=node;
|
||||||
|
fromTo.second=swID;
|
||||||
|
this->branch.push_back(fromTo);
|
||||||
|
Breaker *SW=static_cast<Breaker *>(ht[swID]);
|
||||||
|
if(!SW)
|
||||||
|
{
|
||||||
|
std::cout<<"can not SW "<<swID.toStdString()<<std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QString terminalA;
|
||||||
|
QString terminalB;
|
||||||
|
terminalA=SW->getTerminalA();
|
||||||
|
terminalB=SW->getTerminalB();
|
||||||
|
std::cout<<"terminalA"<<terminalA.toStdString()<<std::endl;
|
||||||
|
std::cout<<"terminalB"<<terminalB.toStdString()<<std::endl;
|
||||||
|
QString nextTerminal;
|
||||||
|
nextTerminal=(terminalA==anotherTerminal)?terminalB:terminalA;
|
||||||
|
Terminal *nextTerminalP=static_cast<Terminal *>(ht[nextTerminal]);
|
||||||
|
if(!nextTerminalP)
|
||||||
|
{
|
||||||
|
std::cout<<"can not terminal "<<nextTerminal.toStdString()<<std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
QString nextNode=nextTerminalP->getConnectivityNode();
|
||||||
|
std::cout<<"next node"<<nextNode.toStdString()<<"from"<<nextTerminal.toStdString()<<std::endl;
|
||||||
|
this->startWithNode(nextNode);
|
||||||
|
|
||||||
|
}
|
||||||
|
if(ce.startsWith("BS"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(!foundCate)
|
||||||
|
{
|
||||||
|
std::cout<<"not found cate "<<ce.toStdString()<<std::endl;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
#ifndef TOPOLOGYRECORDER_H
|
||||||
|
#define TOPOLOGYRECORDER_H
|
||||||
|
#include <QVector>
|
||||||
|
#include <QHash>
|
||||||
|
#include <QString>
|
||||||
|
#include <QPair>
|
||||||
|
#include "BasicElementInfo.h"
|
||||||
|
#include "breaker.h"
|
||||||
|
#include "aclinesegment.h"
|
||||||
|
#include "nodetoterminal.h"
|
||||||
|
#include "terminal.h"
|
||||||
|
|
||||||
|
class TopologyRecorder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT);
|
||||||
|
bool startWithNode(const QString& node);
|
||||||
|
private:
|
||||||
|
NodeToTerminal nodeToTerminal;
|
||||||
|
const QHash<QString,BasicElementInfo *>& eleHT;
|
||||||
|
QVector<QPair<QString,QString> > branch;
|
||||||
|
QHash<QString,char> reachedTerminal;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TOPOLOGYRECORDER_H
|
||||||
Loading…
Reference in New Issue