把网架信息输出到文件

Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
dmy@lab 2015-01-20 15:56:30 +08:00
parent a208823264
commit 5b9625f708
9 changed files with 104 additions and 61 deletions

View File

@ -32,6 +32,10 @@ void CIMExporter::add(const QPair<QString,QString>& fromTo,Transformer* tf)
void CIMExporter::exportTo(const QString& path) void CIMExporter::exportTo(const QString& path)
{
//输出到文件
QFile fd(path);
if(fd.open(QFile::WriteOnly))
{ {
//先给所有节点都编号 //先给所有节点都编号
this->idToNumber(this->line); this->idToNumber(this->line);
@ -39,15 +43,29 @@ void CIMExporter::exportTo(const QString& path)
this->idToNumber(this->tf); this->idToNumber(this->tf);
//开始按要求输出 //开始按要求输出
//先输出线路 //先输出线路
// for(QList<CIMExporter::LineStru>::iterator ite=this->line.begin(); QTextStream writer(&fd);
// ite!=this->line.end(); writer<<QStringLiteral("线路")<<QStringLiteral("\r\n");
// ite++) writer<<QStringLiteral("节点号")<<QStringLiteral("\t")<<QStringLiteral("节点号")<<QStringLiteral("\t")<<QStringLiteral("型号")<<QStringLiteral("\t")<<QStringLiteral("长度(m)")<<QStringLiteral("\r\n");
// { for(QList<CIMExporter::LineStru>::iterator ite=this->line.begin();
// LineStru l=*ite; ite!=this->line.end();
// std::cout<<l.fromID.toStdString()<<" "<<l.fromNum<<" "; ite++)
// std::cout<<l.toID.toStdString()<<" "<<l.toNum<<std::endl; {
// std::cout<<l.line->r<<","<<l.line->x<<","<<l.line->g1<<","<<l.line->g2<<std::endl; LineStru l=*ite;
// } writer<<l.fromNum<<"\t";
writer<<l.toNum<<"\t";
writer<<"type"<<"\t";
writer<<l.line->length<<"\r\n";
}
//输出刀闸
for(QList<CIMExporter::SwitchStru>::iterator ite=this->sw.begin();
ite!=this->sw.end();
ite++)
{
writer<<ite->fromNum<<"\t";
writer<<ite->toNum<<"\t";
writer<<"type"<<"\t";
writer<<0<<"\r\n";
}
//输出负荷 //输出负荷
RecurseDir recurseDir; RecurseDir recurseDir;
recurseDir.setDir(this->loadDir); recurseDir.setDir(this->loadDir);
@ -60,6 +78,8 @@ void CIMExporter::exportTo(const QString& path)
QFileInfo fileInfo(file); QFileInfo fileInfo(file);
baseNames<<fileInfo.baseName(); baseNames<<fileInfo.baseName();
} }
writer<<QStringLiteral("变压器")<<"\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<CIMExporter::TransformerStru>::iterator ite=this->tf.begin();
ite!=this->tf.end(); ite!=this->tf.end();
@ -78,12 +98,17 @@ void CIMExporter::exportTo(const QString& path)
foreach(QSharedPointer<LoadInfo> p,vecLoadInfo) foreach(QSharedPointer<LoadInfo> p,vecLoadInfo)
{ {
QFileInfo targetBasename(p->getLoadPath()); QFileInfo targetBasename(p->getLoadPath());
std::cout<<targetBasename.baseName().toLocal8Bit().data()<<std::endl; // std::cout<<targetBasename.baseName().toLocal8Bit().data()<<std::endl;
if( baseNames.contains( targetBasename.baseName()) and !usedLoad.contains(targetBasename.baseName())) if( baseNames.contains( targetBasename.baseName()) and !usedLoad.contains(targetBasename.baseName()))
{ {
// std::cout<<"match "<<targetBasename.baseName().toLocal8Bit().data()<<std::endl; // std::cout<<"match "<<targetBasename.baseName().toLocal8Bit().data()<<std::endl;
usedLoad<<targetBasename.baseName(); usedLoad<<targetBasename.baseName();
p->getPA(); // p->updateByTime(QTime(3,45,0));
// std::cout<<this->numberIt(ite->toID)<<" "<< p->getPA()<<std::endl;
writer<<ite->fromNum<<"\t";
writer<<ite->toNum<<"\t";
writer<<"type"<<"\t";
writer<<tf->getMVA()<<"\r\n";
break; break;
} }
} }
@ -99,6 +124,13 @@ void CIMExporter::exportTo(const QString& path)
} }
fd.close();
}
} }
template<typename T> template<typename T>
@ -124,7 +156,7 @@ int CIMExporter::numberIt(const QString& id)
} }
else else
{ {
int n=this->number.values().length()+1; int n=this->number.keys().length()+1;
this->number[id]=n; this->number[id]=n;
return n; return n;

View File

@ -9,6 +9,9 @@
#include <QStringList> #include <QStringList>
#include <QFileInfo> #include <QFileInfo>
#include <QSharedPointer> #include <QSharedPointer>
#include <QTime>
#include <QFile>
#include <QTextStream>
#include "recursedir.h" #include "recursedir.h"
#include "substation.h" #include "substation.h"
#include "loadmapping.h" #include "loadmapping.h"

View File

@ -23,4 +23,5 @@ void Line::extract()
this->g2=g0*length; this->g2=g0*length;
this->b1=b0*length; this->b1=b0*length;
this->b2=b0*length; this->b2=b0*length;
this->length=length;
} }

View File

@ -8,6 +8,7 @@ class Line:public Branch
{ {
public: public:
Line(const QPair<QString, QString> &fromTo, ACLineSegment* ac,QObject* parent=0); Line(const QPair<QString, QString> &fromTo, ACLineSegment* ac,QObject* parent=0);
double length;
protected: protected:
virtual void extract(); virtual void extract();
private: private:

View File

@ -11,7 +11,8 @@ Transformer::Transformer(const QPair<QString,QString>& fromTo, PowerTransformer*
void Transformer::extract() void Transformer::extract()
{ {
// PowerTransformer *tf=this->tf; PowerTransformer *tf=this->tf;
this->capacityMVA=tf->getMVA();
double length=10; double length=10;
//单位阻抗 //单位阻抗
double r0=0.01; double r0=0.01;
@ -24,7 +25,7 @@ void Transformer::extract()
this->g2=g0*length; this->g2=g0*length;
this->b1=b0*length; this->b1=b0*length;
this->b2=b0*length; this->b2=b0*length;
//解析负荷
} }

View File

@ -10,6 +10,7 @@ class Transformer:public Branch
public: public:
Transformer(const QPair<QString, QString> &fromTo, PowerTransformer *tf,QObject *parent=0); Transformer(const QPair<QString, QString> &fromTo, PowerTransformer *tf,QObject *parent=0);
PowerTransformer *getTF(); PowerTransformer *getTF();
double capacityMVA;
protected: protected:
virtual void extract(); virtual void extract();
private: private:

View File

@ -105,7 +105,7 @@ bool ElementHashtable::GoPath()
} }
this->tpRecorder=new TopologyRecorder(this->eleHT,this->FDSet,this->loadFilePath); this->tpRecorder=new TopologyRecorder(this->eleHT,this->FDSet,this->loadFilePath);
this->tpRecorder->startWithNode(node); this->tpRecorder->startWithNode(node);
this->tpRecorder->exportTo(""); // this->tpRecorder->exportTo("");
break; break;
} }
} }
@ -162,7 +162,10 @@ bool ElementHashtable::Parse(const QString& xmlPWPath,const QString& xmlZWPath){
return true; return true;
} }
void ElementHashtable::ExportTo(const QString& path)
{
this->tpRecorder->exportTo(path);
}
void ElementHashtable::SetACLineID(const QString &id)//寻找的线路ID void ElementHashtable::SetACLineID(const QString &id)//寻找的线路ID
{ {

View File

@ -27,7 +27,7 @@ public:
explicit ElementHashtable(QObject *parent = 0); explicit ElementHashtable(QObject *parent = 0);
bool Parse(const QString& xmlPWPath,const QString& xmlZWPath); bool Parse(const QString& xmlPWPath,const QString& xmlZWPath);
bool GoPath(); bool GoPath();
// void ExportTo(const QString& path); void ExportTo(const QString& path);
void SetACLineID(const QString &id);//寻找的线路ID void SetACLineID(const QString &id);//寻找的线路ID
void SetLoadFilePath(const QString &path); void SetLoadFilePath(const QString &path);
void SetFDSet(const QVector<QString> &FDSet);//FeeDer集合 void SetFDSet(const QVector<QString> &FDSet);//FeeDer集合

View File

@ -69,6 +69,7 @@ void Task::doAgainstTaskFile(ElementHashtable &eleHT)
eleHT.SetACLineID(lineID); eleHT.SetACLineID(lineID);
eleHT.SetFDSet(setSep.toVector()); eleHT.SetFDSet(setSep.toVector());
eleHT.GoPath(); eleHT.GoPath();
eleHT.ExportTo(QString("D:/MyPro/cimforreduceloss/testHasttable/output/pan/")+sep.at(0)+".txt");
eleHT.ShowContainerInfo(lineName); eleHT.ShowContainerInfo(lineName);
break; break;