把LineStru等类型声明放到单独的文件中。

Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
dmy@lab 2015-01-20 20:59:47 +08:00
parent 41502b5afa
commit da0a7f192e
7 changed files with 72 additions and 36 deletions

View File

@ -6,7 +6,7 @@ CIMExporter::CIMExporter(const QHash<QString, BasicElementInfo *> &eleHT, const
void CIMExporter::add(const QPair<QString,QString>& fromTo,Line* line) void CIMExporter::add(const QPair<QString,QString>& fromTo,Line* line)
{ {
CIMExporter::LineStru lineStru; LineStru lineStru;
lineStru.line=line; lineStru.line=line;
lineStru.fromID=fromTo.first; lineStru.fromID=fromTo.first;
lineStru.toID=fromTo.second; lineStru.toID=fromTo.second;
@ -15,7 +15,7 @@ void CIMExporter::add(const QPair<QString,QString>& fromTo,Line* line)
} }
void CIMExporter::add(const QPair<QString,QString>& fromTo,Switch* sw) void CIMExporter::add(const QPair<QString,QString>& fromTo,Switch* sw)
{ {
CIMExporter::SwitchStru switchStru; SwitchStru switchStru;
switchStru.sw=sw; switchStru.sw=sw;
switchStru.fromID=fromTo.first; switchStru.fromID=fromTo.first;
switchStru.toID=fromTo.second; switchStru.toID=fromTo.second;
@ -23,7 +23,7 @@ void CIMExporter::add(const QPair<QString,QString>& fromTo,Switch* sw)
} }
void CIMExporter::add(const QPair<QString,QString>& fromTo,Transformer* tf) void CIMExporter::add(const QPair<QString,QString>& fromTo,Transformer* tf)
{ {
CIMExporter::TransformerStru tfStru; TransformerStru tfStru;
tfStru.tf=tf; tfStru.tf=tf;
tfStru.fromID=fromTo.first; tfStru.fromID=fromTo.first;
tfStru.toID=fromTo.second; tfStru.toID=fromTo.second;
@ -48,7 +48,7 @@ void CIMExporter::exportTo(const QString& path)
QTextStream writer(&fd); QTextStream writer(&fd);
writer<<QStringLiteral("线路")<<QStringLiteral("\r\n"); writer<<QStringLiteral("线路")<<QStringLiteral("\r\n");
writer<<QStringLiteral("节点号")<<QStringLiteral("\t")<<QStringLiteral("节点号")<<QStringLiteral("\t")<<QStringLiteral("型号")<<QStringLiteral("\t")<<QStringLiteral("长度(m)")<<QStringLiteral("\r\n"); writer<<QStringLiteral("节点号")<<QStringLiteral("\t")<<QStringLiteral("节点号")<<QStringLiteral("\t")<<QStringLiteral("型号")<<QStringLiteral("\t")<<QStringLiteral("长度(m)")<<QStringLiteral("\r\n");
for(QList<CIMExporter::LineStru>::iterator ite=this->line.begin(); for(QList<LineStru>::iterator ite=this->line.begin();
ite!=this->line.end(); ite!=this->line.end();
ite++) ite++)
{ {
@ -59,7 +59,7 @@ void CIMExporter::exportTo(const QString& path)
writer<<l.line->length<<"\r\n"; writer<<l.line->length<<"\r\n";
} }
//输出刀闸 //输出刀闸
for(QList<CIMExporter::SwitchStru>::iterator ite=this->sw.begin(); for(QList<SwitchStru>::iterator ite=this->sw.begin();
ite!=this->sw.end(); ite!=this->sw.end();
ite++) ite++)
{ {
@ -83,7 +83,7 @@ void CIMExporter::exportTo(const QString& path)
writer<<QStringLiteral("变压器")<<"\r\n"; writer<<QStringLiteral("变压器")<<"\r\n";
writer<<QStringLiteral("节点号")<<"\t"<<QStringLiteral("节点号")<<"\t"<<QStringLiteral("型号")<<"\t"<<QStringLiteral("容量(MVA)")<<"\r\n"; writer<<QStringLiteral("节点号")<<"\t"<<QStringLiteral("节点号")<<"\t"<<QStringLiteral("型号")<<"\t"<<QStringLiteral("容量(MVA)")<<"\r\n";
QStringList usedLoad; QStringList usedLoad;
for(QList<CIMExporter::TransformerStru>::iterator ite=this->tf.begin(); for(QList<TransformerStru>::iterator ite=this->tf.begin();
ite!=this->tf.end(); ite!=this->tf.end();
ite++) ite++)
{ {
@ -168,19 +168,19 @@ bool CIMExporter::topologyTest()
{ {
//检查一下拓扑关系 //检查一下拓扑关系
QList<QPair<int,int> > linkage; QList<QPair<int,int> > linkage;
for(QList<CIMExporter::LineStru>::iterator ite=this->line.begin(); for(QList<LineStru>::iterator ite=this->line.begin();
ite!=this->line.end(); ite!=this->line.end();
ite++) ite++)
{ {
linkage.push_back(QPair<int,int>(ite->fromNum,ite->toNum)); linkage.push_back(QPair<int,int>(ite->fromNum,ite->toNum));
} }
for(QList<CIMExporter::SwitchStru>::iterator ite=this->sw.begin(); for(QList<SwitchStru>::iterator ite=this->sw.begin();
ite!=this->sw.end(); ite!=this->sw.end();
ite++) ite++)
{ {
linkage.push_back(QPair<int,int>(ite->fromNum,ite->toNum)); linkage.push_back(QPair<int,int>(ite->fromNum,ite->toNum));
} }
for(QList<CIMExporter::TransformerStru>::iterator ite=this->tf.begin(); for(QList<TransformerStru>::iterator ite=this->tf.begin();
ite!=this->tf.end(); ite!=this->tf.end();
ite++) ite++)
{ {

View File

@ -4,6 +4,7 @@
#include "element/line.h" #include "element/line.h"
#include "element/switch.h" #include "element/switch.h"
#include "element/transformer.h" #include "element/transformer.h"
#include "element/commontype.h"
#include <QPair> #include <QPair>
#include <QHash> #include <QHash>
#include <QStringList> #include <QStringList>
@ -19,31 +20,10 @@
#include <QVector> #include <QVector>
#include "topologytest.h" #include "topologytest.h"
//#include "elementhashtable.h" //#include "elementhashtable.h"
class Substation; //class Substation;
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:
explicit CIMExporter(const QHash<QString,BasicElementInfo *>& eleHT,const QString& loadDir); explicit CIMExporter(const QHash<QString,BasicElementInfo *>& eleHT,const QString& loadDir);
void add(const QPair<QString,QString>& fromTo,Line* line); void add(const QPair<QString,QString>& fromTo,Line* line);

View File

@ -0,0 +1,29 @@
#ifndef COMMONTYPE
#define COMMONTYPE
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;
};
#endif // COMMONTYPE

View File

@ -0,0 +1,12 @@
#include "elementreduction.h"
ElementReduction::ElementReduction()
{
}
ElementReduction::~ElementReduction()
{
}

View File

@ -0,0 +1,12 @@
#ifndef ELEMENTREDUCTION_H
#define ELEMENTREDUCTION_H
//把电阻等于0的元件都去掉
class ElementReduction
{
public:
ElementReduction();
~ElementReduction();
};
#endif // ELEMENTREDUCTION_H

View File

@ -44,7 +44,8 @@ SOURCES += main.cpp \
loadmatchexception.cpp \ loadmatchexception.cpp \
dgmapping.cpp \ dgmapping.cpp \
dginfo.cpp \ dginfo.cpp \
topologytest.cpp topologytest.cpp \
elementreduction.cpp
HEADERS += \ HEADERS += \
elementhashtable.h \ elementhashtable.h \
@ -75,7 +76,9 @@ HEADERS += \
loadmatchexception.h \ loadmatchexception.h \
dgmapping.h \ dgmapping.h \
dginfo.h \ dginfo.h \
topologytest.h topologytest.h \
elementreduction.h \
element/commontype.h
#release{ #release{
DEFINES += QT_NO_DEBUG_OUTPUT DEFINES += QT_NO_DEBUG_OUTPUT

View File

@ -20,9 +20,9 @@ bool TopologyTest::start(const QList<QPair<int,int> >& linkage)
ite++ ite++
) )
{ {
int f=(*ite).first-1; // int f=(*ite).first-1;
int s=(*ite).second-1; // int s=(*ite).second-1;
std::cout<<f<<" to "<<s<<std::endl; // std::cout<<f<<" to "<<s<<std::endl;
arch[(*ite).first-1].push_back((*ite).second-1); arch[(*ite).first-1].push_back((*ite).second-1);
arch[(*ite).second-1].push_back((*ite).first-1); arch[(*ite).second-1].push_back((*ite).first-1);
} }