用CIMExporter分别处理读到的线路,开关,变压器等元件。

Signed-off-by: facat@lab.com <facat@lab.com>
This commit is contained in:
facat@lab.com 2014-12-28 16:40:57 +08:00
parent 28e1df38fa
commit 9cb2f5a8f6
12 changed files with 124 additions and 21 deletions

View File

@ -3,3 +3,26 @@
CIMExporter::CIMExporter() CIMExporter::CIMExporter()
{ {
} }
void CIMExporter::add(const QPair<QString,QString>& fromTo,Line* line)
{
CIMExporter::LineStru lineStru;
lineStru.line=line;
lineStru.fromID=fromTo.first;
lineStru.toID=fromTo.second;
}
void CIMExporter::add(const QPair<QString,QString>& fromTo,Switch* sw)
{
CIMExporter::SwitchStru switchStru;
switchStru.sw=sw;
switchStru.fromID=fromTo.first;
switchStru.toID=fromTo.second;
}
void CIMExporter::add(const QPair<QString,QString>& fromTo,Transformer* tf)
{
CIMExporter::TransformerStru tfStru;
tfStru.tf=tf;
tfStru.fromID=fromTo.first;
tfStru.toID=fromTo.second;
}

View File

@ -1,10 +1,43 @@
#ifndef CIMEXPORTER_H #ifndef CIMEXPORTER_H
#define CIMEXPORTER_H #define CIMEXPORTER_H
#include <QList>
#include "element/line.h"
#include "element/switch.h"
#include "element/transformer.h"
#include <QPair>
class CIMExporter class CIMExporter
{ {
struct BranchStruc
{
QString fromID;
QString toID;
int fromNum;
int toNum;
};
struct LineStru:public BranchStruc
{
Line *line;
};
struct SwitchStru:public BranchStruc
{
Switch *sw;
};
struct TransformerStru:public BranchStruc
{
Transformer *tf;
};
public: public:
CIMExporter(); CIMExporter();
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,Transformer* tf);
private:
QList<LineStru> line;
QList<Switch> sw;
QList<TransformerStru> tf;
}; };
#endif // CIMEXPORTER_H #endif // CIMEXPORTER_H

View File

@ -1,5 +1,5 @@
#include "branch.h" #include "branch.h"
Branch::Branch(const QString& from, const QString& to):from(from),to(to) Branch::Branch(const QString& from, const QString& to, QObject *parent):from(from),to(to)
{ {
} }

View File

@ -1,10 +1,12 @@
#ifndef BRANCH_H #ifndef BRANCH_H
#define BRANCH_H #define BRANCH_H
#include <QObject>
#include <QString> #include <QString>
class Branch class Branch:public QObject
{ {
Q_OBJECT
public: public:
Branch(const QString& from, const QString& to); Branch(const QString& from, const QString& to,QObject* parent=0);
protected: protected:
double r; double r;
double x; double x;

View File

@ -1,6 +1,6 @@
#include "line.h" #include "line.h"
Line::Line(const QPair<QString,QString>& fromTo, ACLineSegment* ac):Branch(fromTo.first,fromTo.second) Line::Line(const QPair<QString,QString>& fromTo, ACLineSegment* ac, QObject *parent):Branch(fromTo.first,fromTo.second)
{ {
this->ratio=1; this->ratio=1;
this->ac=ac; this->ac=ac;

View File

@ -1,12 +1,13 @@
#ifndef LINE_H #ifndef LINE_H
#define LINE_H #define LINE_H
#include <QObject>
#include <QPair> #include <QPair>
#include "branch.h" #include "branch.h"
#include "./../aclinesegment.h" #include "./../aclinesegment.h"
class Line:public Branch class Line:public Branch
{ {
public: public:
Line(const QPair<QString, QString> &fromTo, ACLineSegment* ac); Line(const QPair<QString, QString> &fromTo, ACLineSegment* ac,QObject* parent=0);
protected: protected:
virtual void extract(); virtual void extract();
private: private:

View File

@ -1,6 +1,6 @@
#include "switch.h" #include "switch.h"
Switch::Switch(const QPair<QString,QString>& fromTo):Branch(fromTo.first,fromTo.second) Switch::Switch(const QPair<QString,QString>& fromTo, QObject *parent):Branch(fromTo.first,fromTo.second)
{ {
this->extract(); this->extract();
} }

View File

@ -1,11 +1,12 @@
#ifndef SWITCH_H #ifndef SWITCH_H
#define SWITCH_H #define SWITCH_H
#include <QObject>
#include <QPair> #include <QPair>
#include "branch.h" #include "branch.h"
class Switch:public Branch class Switch:public Branch
{ {
public: public:
Switch(const QPair<QString, QString> &fromTo); Switch(const QPair<QString, QString> &fromTo,QObject *parent=0);
protected: protected:
virtual void extract(); virtual void extract();

View File

@ -1,7 +1,7 @@
#include "transformer.h" #include "transformer.h"
Transformer::Transformer(const QPair<QString,QString>& fromTo, PowerTransformer* tf):Branch(fromTo.first,fromTo.second) Transformer::Transformer(const QPair<QString,QString>& fromTo, PowerTransformer* tf, QObject *parent):Branch(fromTo.first,fromTo.second)
{ {
this->ratio=1; this->ratio=1;
this->tf=tf; this->tf=tf;

View File

@ -1,12 +1,13 @@
#ifndef TRANSFORMER_H #ifndef TRANSFORMER_H
#define TRANSFORMER_H #define TRANSFORMER_H
#include <QObject>
#include <QPair> #include <QPair>
#include "branch.h" #include "branch.h"
#include "./../powertransformer.h" #include "./../powertransformer.h"
class Transformer:public Branch class Transformer:public Branch
{ {
public: public:
Transformer(const QPair<QString, QString> &fromTo, PowerTransformer *tf); Transformer(const QPair<QString, QString> &fromTo, PowerTransformer *tf,QObject *parent=0);
protected: protected:
virtual void extract(); virtual void extract();
private: private:

View File

@ -1,6 +1,6 @@
#include "topologyrecorder.h" #include "topologyrecorder.h"
#include <iostream> #include <iostream>
TopologyRecorder::TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT):eleHT(elementHT) TopologyRecorder::TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT, QObject *parent):eleHT(elementHT)
{ {
} }
@ -37,7 +37,9 @@ bool TopologyRecorder::startWithNode(const QString& node)
anotherTerminalVector=this->nodeToTerminal.value(node);//一个Node可以找到多个与之相连的Terminal anotherTerminalVector=this->nodeToTerminal.value(node);//一个Node可以找到多个与之相连的Terminal
for(int atI=0;atI<anotherTerminalVector.length();atI++) for(int atI=0;atI<anotherTerminalVector.length();atI++)
{ {
bool foundCate=false; TopologyRecorder::Type::EleType typ;
BasicElementInfo *foundEle=NULL;
// bool foundCate=false;
anotherTerminal=anotherTerminalVector.at(atI); anotherTerminal=anotherTerminalVector.at(atI);
if(this->reachedTerminal.contains(anotherTerminal)) if(this->reachedTerminal.contains(anotherTerminal))
{ {
@ -65,7 +67,8 @@ bool TopologyRecorder::startWithNode(const QString& node)
terminalB=AC->getTerminalB(); terminalB=AC->getTerminalB();
std::cout<<"find"<<AC->getID().toStdString()<<std::endl; std::cout<<"find"<<AC->getID().toStdString()<<std::endl;
std::cout<<AC->getNamingDescription().toStdString()<<std::endl; std::cout<<AC->getNamingDescription().toStdString()<<std::endl;
foundCate=true; foundEle=AC;
typ=TopologyRecorder::Type::AC;
} }
if(ce.startsWith("SW")) if(ce.startsWith("SW"))
{ {
@ -82,7 +85,6 @@ bool TopologyRecorder::startWithNode(const QString& node)
Breaker *SW=static_cast<Breaker *>(ht[swID]); Breaker *SW=static_cast<Breaker *>(ht[swID]);
if(!SW) if(!SW)
{ {
// std::cout<<"can not SW "<<swID.toStdString()<<std::endl;//@1
continue; continue;
} }
//显示开关状态 //显示开关状态
@ -97,7 +99,8 @@ bool TopologyRecorder::startWithNode(const QString& node)
terminalA=SW->getTerminalA(); terminalA=SW->getTerminalA();
terminalB=SW->getTerminalB(); terminalB=SW->getTerminalB();
std::cout<<"find"<<SW->getID().toStdString()<<std::endl; std::cout<<"find"<<SW->getID().toStdString()<<std::endl;
foundCate=true; foundEle=SW;
typ=TopologyRecorder::Type::BREAKER;
} }
if(bi->getName()=="Disconnector") if(bi->getName()=="Disconnector")
{ {
@ -130,7 +133,8 @@ bool TopologyRecorder::startWithNode(const QString& node)
terminalA=Dis->getTerminalA(); terminalA=Dis->getTerminalA();
terminalB=Dis->getTerminalB(); terminalB=Dis->getTerminalB();
std::cout<<"find"<<Dis->getID().toStdString()<<std::endl; std::cout<<"find"<<Dis->getID().toStdString()<<std::endl;
foundCate=true; foundEle=Dis;
typ=TopologyRecorder::Type::DISCONNECTOR;
} }
} }
else else
@ -174,16 +178,41 @@ bool TopologyRecorder::startWithNode(const QString& node)
if(this->isEquipmentNeeded(equipmentContainer)) if(this->isEquipmentNeeded(equipmentContainer))
{ {
this->tfs.push_back(tf->getNamingDescription()); this->tfs.push_back(tf->getNamingDescription());
fromTo.first=node;
fromTo.second=tfID;
foundEle=tf;
} }
else else
{ {
std::cout<<tf->getNamingDescription().toStdString()<<"not belong"<<std::endl; std::cout<<tf->getNamingDescription().toStdString()<<"not belong"<<std::endl;
} }
typ=TopologyRecorder::Type::TF;
} }
if(foundCate) if(foundEle)
{ {
this->branch.push_back(fromTo); Branch *branch=NULL;
switch(typ)
{
case TopologyRecorder::Type::AC:
branch=new Line(fromTo,static_cast<ACLineSegment *>(foundEle),this);
this->cimExporter.add(fromTo,static_cast<Line *>(branch));
break;
case TopologyRecorder::Type::BREAKER:
branch=new Switch(fromTo,this);
this->cimExporter.add(fromTo,static_cast<Switch *>(branch));
break;
case TopologyRecorder::Type::DISCONNECTOR:
branch=new Switch(fromTo,this);
this->cimExporter.add(fromTo,static_cast<Switch *>(branch));
break;
case TopologyRecorder::Type::TF:
branch=new Transformer(fromTo,static_cast<PowerTransformer *>(foundEle),this);
this->cimExporter.add(fromTo,static_cast<Transformer *>(branch));
break;
default:
break;
}
QString nextTerminal; QString nextTerminal;
nextTerminal=(terminalA==anotherTerminal)?terminalB:terminalA; nextTerminal=(terminalA==anotherTerminal)?terminalB:terminalA;
Terminal *nextTerminalP=static_cast<Terminal *>(ht[nextTerminal]); Terminal *nextTerminalP=static_cast<Terminal *>(ht[nextTerminal]);

View File

@ -1,5 +1,6 @@
#ifndef TOPOLOGYRECORDER_H #ifndef TOPOLOGYRECORDER_H
#define TOPOLOGYRECORDER_H #define TOPOLOGYRECORDER_H
#include <QObject>
#include <QVector> #include <QVector>
#include <QHash> #include <QHash>
#include <QString> #include <QString>
@ -13,18 +14,30 @@
#include "substation.h" #include "substation.h"
#include "busbarsection.h" #include "busbarsection.h"
#include "disconnector.h" #include "disconnector.h"
class TopologyRecorder #include "cimexporter.h"
#include "element/branch.h"
#include "element/line.h"
#include "element/switch.h"
#include "element/transformer.h"
class TopologyRecorder:public QObject
{
Q_OBJECT
class Type
{ {
public: public:
TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT); enum EleType{AC=0,BREAKER,DISCONNECTOR,BS,TF};
};
public:
TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT,QObject *parent=0);
~TopologyRecorder(); ~TopologyRecorder();
bool startWithNode(const QString& node); bool startWithNode(const QString& node);
private: private:
NodeToTerminal nodeToTerminal; NodeToTerminal nodeToTerminal;
const QHash<QString,BasicElementInfo *>& eleHT; const QHash<QString,BasicElementInfo *>& eleHT;
QVector<QPair<QString,QString> > branch;
QHash<QString,char> reachedTerminal; QHash<QString,char> reachedTerminal;
QVector<QString> tfs; QVector<QString> tfs;
CIMExporter cimExporter;
bool isEquipmentNeeded(const QString& substatinID); bool isEquipmentNeeded(const QString& substatinID);
}; };