把网架信息输出到文件

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

@ -33,70 +33,102 @@ void CIMExporter::add(const QPair<QString,QString>& fromTo,Transformer* tf)
void CIMExporter::exportTo(const QString& path) void CIMExporter::exportTo(const QString& path)
{ {
//先给所有节点都编号 //输出到文件
this->idToNumber(this->line); QFile fd(path);
this->idToNumber(this->sw); if(fd.open(QFile::WriteOnly))
this->idToNumber(this->tf);
//开始按要求输出
//先输出线路
// for(QList<CIMExporter::LineStru>::iterator ite=this->line.begin();
// ite!=this->line.end();
// ite++)
// {
// LineStru l=*ite;
// std::cout<<l.fromID.toStdString()<<" "<<l.fromNum<<" ";
// 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;
// }
//输出负荷
RecurseDir recurseDir;
recurseDir.setDir(this->loadDir);
QStringList files;
files=recurseDir.getFiles();
//只取文件名
QStringList baseNames;
foreach(QString file,files)
{ {
QFileInfo fileInfo(file); //先给所有节点都编号
baseNames<<fileInfo.baseName(); this->idToNumber(this->line);
} this->idToNumber(this->sw);
QStringList usedLoad; this->idToNumber(this->tf);
for(QList<CIMExporter::TransformerStru>::iterator ite=this->tf.begin(); //开始按要求输出
ite!=this->tf.end(); //先输出线路
ite++) QTextStream writer(&fd);
{ writer<<QStringLiteral("线路")<<QStringLiteral("\r\n");
PowerTransformer *tf=ite->tf->getTF(); writer<<QStringLiteral("节点号")<<QStringLiteral("\t")<<QStringLiteral("节点号")<<QStringLiteral("\t")<<QStringLiteral("型号")<<QStringLiteral("\t")<<QStringLiteral("长度(m)")<<QStringLiteral("\r\n");
QString subID=tf->getEquipmentMemberOf_EquipmentContainer();//所属Substation的ID for(QList<CIMExporter::LineStru>::iterator ite=this->line.begin();
Substation *sub=static_cast<Substation *>(this->eleHT[subID]); ite!=this->line.end();
if(!sub) ite++)
{ {
std::cout<<"CIMExporter:: can not substation of "<<subID.toStdString()<<std::endl; LineStru l=*ite;
continue; writer<<l.fromNum<<"\t";
writer<<l.toNum<<"\t";
writer<<"type"<<"\t";
writer<<l.line->length<<"\r\n";
} }
LoadMapping loadMapping; //输出刀闸
QVector<QSharedPointer<LoadInfo> > vecLoadInfo=loadMapping.getSubstationLoad(sub->getID()); for(QList<CIMExporter::SwitchStru>::iterator ite=this->sw.begin();
foreach(QSharedPointer<LoadInfo> p,vecLoadInfo) ite!=this->sw.end();
ite++)
{ {
QFileInfo targetBasename(p->getLoadPath()); writer<<ite->fromNum<<"\t";
std::cout<<targetBasename.baseName().toLocal8Bit().data()<<std::endl; writer<<ite->toNum<<"\t";
if( baseNames.contains( targetBasename.baseName()) and !usedLoad.contains(targetBasename.baseName())) writer<<"type"<<"\t";
writer<<0<<"\r\n";
}
//输出负荷
RecurseDir recurseDir;
recurseDir.setDir(this->loadDir);
QStringList files;
files=recurseDir.getFiles();
//只取文件名
QStringList baseNames;
foreach(QString file,files)
{
QFileInfo fileInfo(file);
baseNames<<fileInfo.baseName();
}
writer<<QStringLiteral("变压器")<<"\r\n";
writer<<QStringLiteral("节点号")<<"\t"<<QStringLiteral("节点号")<<"\t"<<QStringLiteral("型号")<<"\t"<<QStringLiteral("容量(MVA)")<<"\r\n";
QStringList usedLoad;
for(QList<CIMExporter::TransformerStru>::iterator ite=this->tf.begin();
ite!=this->tf.end();
ite++)
{
PowerTransformer *tf=ite->tf->getTF();
QString subID=tf->getEquipmentMemberOf_EquipmentContainer();//所属Substation的ID
Substation *sub=static_cast<Substation *>(this->eleHT[subID]);
if(!sub)
{ {
// std::cout<<"match "<<targetBasename.baseName().toLocal8Bit().data()<<std::endl; std::cout<<"CIMExporter:: can not substation of "<<subID.toStdString()<<std::endl;
usedLoad<<targetBasename.baseName(); continue;
p->getPA(); }
break; LoadMapping loadMapping;
QVector<QSharedPointer<LoadInfo> > vecLoadInfo=loadMapping.getSubstationLoad(sub->getID());
foreach(QSharedPointer<LoadInfo> p,vecLoadInfo)
{
QFileInfo targetBasename(p->getLoadPath());
// std::cout<<targetBasename.baseName().toLocal8Bit().data()<<std::endl;
if( baseNames.contains( targetBasename.baseName()) and !usedLoad.contains(targetBasename.baseName()))
{
// std::cout<<"match "<<targetBasename.baseName().toLocal8Bit().data()<<std::endl;
usedLoad<<targetBasename.baseName();
// 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;
}
}
}
//列出没有用的负荷文件
foreach(QString name, baseNames)
{
if(!usedLoad.contains(name))
{
std::cout<<name.toLocal8Bit().data()<<"not used"<<std::endl;
} }
} }
fd.close();
} }
//列出没有用的负荷文件
foreach(QString name, baseNames)
{
if(!usedLoad.contains(name))
{
std::cout<<name.toLocal8Bit().data()<<"not used"<<std::endl;
}
}
} }
@ -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;