利用文件中独读到的线路头节点ID

Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
dmy@lab 2015-01-22 11:09:20 +08:00
parent 5017c73f09
commit 1c9f65b6cd
7 changed files with 14 additions and 13 deletions

View File

@ -40,7 +40,7 @@ void CIMExporter::add(const QPair<QString,QString>& fromTo,Transformer* tf)
} }
void CIMExporter::exportTo(const QString& path) void CIMExporter::exportTo(const QString& path,const QString &rootID)
{ {
@ -63,7 +63,7 @@ void CIMExporter::exportTo(const QString& path)
elements.push_back( &(this->tf[i]) ); elements.push_back( &(this->tf[i]) );
} }
ElementReduction elementReduction(elements); ElementReduction elementReduction(elements);
elementReduction.doIt(); elementReduction.doIt(rootID);
//先给所有节点都编号 //先给所有节点都编号
this->idToNumber(this->line); this->idToNumber(this->line);
this->idToNumber(this->sw); this->idToNumber(this->sw);

View File

@ -32,7 +32,7 @@ public:
void add(const QPair<QString,QString>& fromTo,Line* line); void add(const QPair<QString,QString>& fromTo,Line* line);
void add(const QPair<QString,QString>& fromTo,Switch* sw); void add(const QPair<QString,QString>& fromTo,Switch* sw);
void add(const QPair<QString,QString>& fromTo,Transformer* tf); void add(const QPair<QString,QString>& fromTo,Transformer* tf);
void exportTo(const QString& path); void exportTo(const QString& path, const QString &rootID);
private: private:
bool topologyTest(); bool topologyTest();
QList<LineStru> line; QList<LineStru> line;

View File

@ -103,7 +103,7 @@ bool ElementHashtable::GoPath()
delete this->tpRecorder; delete this->tpRecorder;
this->tpRecorder=NULL; this->tpRecorder=NULL;
} }
this->tpRecorder=new TopologyRecorder(this->eleHT,this->FDSet,this->loadFilePath); this->tpRecorder=new TopologyRecorder(this->eleHT,this->FDSet,this->loadFilePath,this->lineID);
this->tpRecorder->startWithNode(node); this->tpRecorder->startWithNode(node);
// this->tpRecorder->exportTo(""); // this->tpRecorder->exportTo("");
break; break;

View File

@ -21,7 +21,7 @@ void ElementReduction::calibration(const QString &id,QHash<QString,BranchStruc *
} }
} }
void ElementReduction::doIt() void ElementReduction::doIt(const QString& rootID)
{ {
QHash<QString,QVector<BranchStruc *> > linkage; QHash<QString,QVector<BranchStruc *> > linkage;
//先记录元件之间的连接关系 //先记录元件之间的连接关系
@ -36,9 +36,9 @@ void ElementReduction::doIt()
QDomDocument root; QDomDocument root;
// QDomElement element=root.createElement(this->branchList.at(2)->id); // QDomElement element=root.createElement(this->branchList.at(2)->id);
QDomElement element=root.createElement("AC-671677"); QDomElement element=root.createElement(rootID);
this->calibration("AC-671677",idToBranch,linkage); this->calibration(rootID,idToBranch,linkage);
std::cout<<"start "<<"AC-671677"<<std::endl; std::cout<<"start "<<rootID.toStdString()<<std::endl;
root.appendChild(element); root.appendChild(element);
this->buildTreeTo(element,root,linkage,idToBranch); this->buildTreeTo(element,root,linkage,idToBranch);
// this->visited.remove(this->branchList.at(2)->id); // this->visited.remove(this->branchList.at(2)->id);
@ -135,7 +135,7 @@ void ElementReduction::buildTreeTo(QDomElement &element,QDomDocument &root,QHash
nextTo=branch->toID; nextTo=branch->toID;
QVector<BranchStruc *> nextVec; QVector<BranchStruc *> nextVec;
nextVec=linkage[nextTo]; nextVec=linkage[nextTo];
std::cout<<nextVec.length()<<" of "<<element.tagName().toStdString()<<std::endl; // std::cout<<nextVec.length()<<" of "<<element.tagName().toStdString()<<std::endl;
foreach(BranchStruc *n,nextVec) foreach(BranchStruc *n,nextVec)
{ {

View File

@ -16,7 +16,7 @@ class ElementReduction
{ {
public: public:
explicit ElementReduction(const QList<BranchStruc*>& branchList); explicit ElementReduction(const QList<BranchStruc*>& branchList);
void doIt(); void doIt(const QString &rootID);
~ElementReduction(); ~ElementReduction();
private: private:
void calibration(const QString &id, QHash<QString, BranchStruc *> &idToBranch, QHash<QString, QVector<BranchStruc *> > &linkage); void calibration(const QString &id, QHash<QString, BranchStruc *> &idToBranch, QHash<QString, QVector<BranchStruc *> > &linkage);

View File

@ -1,7 +1,7 @@
#include "topologyrecorder.h" #include "topologyrecorder.h"
#include <iostream> #include <iostream>
#include <QList> #include <QList>
TopologyRecorder::TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT, const QVector<QString> &FDSet,const QString& loadFilePath, QObject *parent):QObject(parent),eleHT(elementHT),FDSet(FDSet),cimExporter(elementHT,loadFilePath) TopologyRecorder::TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT, const QVector<QString> &FDSet, const QString& loadFilePath, const QString &rootID, QObject *parent):QObject(parent),eleHT(elementHT),FDSet(FDSet),cimExporter(elementHT,loadFilePath),rootID(rootID)
{ {
} }
@ -28,7 +28,7 @@ bool TopologyRecorder::isEquipmentNeeded(const QString& substatinID)
void TopologyRecorder::exportTo(const QString& path) void TopologyRecorder::exportTo(const QString& path)
{ {
this->cimExporter.exportTo(path); this->cimExporter.exportTo(path,this->rootID);
} }
void TopologyRecorder::showContainerInfo(QTextStream &stream) void TopologyRecorder::showContainerInfo(QTextStream &stream)

View File

@ -30,7 +30,7 @@ class TopologyRecorder:public QObject
}; };
public: public:
TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT, const QVector<QString> &FDSet, const QString &loadFilePath, QObject *parent=0); TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT, const QVector<QString> &FDSet, const QString &loadFilePath,const QString &rootID, QObject *parent=0);
~TopologyRecorder(); ~TopologyRecorder();
void showContainerInfo(QTextStream &stream); void showContainerInfo(QTextStream &stream);
bool startWithNode(const QString& node); bool startWithNode(const QString& node);
@ -43,6 +43,7 @@ private:
QVector<QString> FDSet; QVector<QString> FDSet;
CIMExporter cimExporter; CIMExporter cimExporter;
QHash<QString,char> hasAdded; QHash<QString,char> hasAdded;
QString rootID;
bool isEquipmentNeeded(const QString& substatinID); bool isEquipmentNeeded(const QString& substatinID);
}; };