把网架信息输出到文件

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)
{
//先给所有节点都编号
this->idToNumber(this->line);
this->idToNumber(this->sw);
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)
//输出到文件
QFile fd(path);
if(fd.open(QFile::WriteOnly))
{
QFileInfo fileInfo(file);
baseNames<<fileInfo.baseName();
}
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)
//先给所有节点都编号
this->idToNumber(this->line);
this->idToNumber(this->sw);
this->idToNumber(this->tf);
//开始按要求输出
//先输出线路
QTextStream writer(&fd);
writer<<QStringLiteral("线路")<<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();
ite!=this->line.end();
ite++)
{
std::cout<<"CIMExporter:: can not substation of "<<subID.toStdString()<<std::endl;
continue;
LineStru l=*ite;
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());
foreach(QSharedPointer<LoadInfo> p,vecLoadInfo)
//输出刀闸
for(QList<CIMExporter::SwitchStru>::iterator ite=this->sw.begin();
ite!=this->sw.end();
ite++)
{
QFileInfo targetBasename(p->getLoadPath());
std::cout<<targetBasename.baseName().toLocal8Bit().data()<<std::endl;
if( baseNames.contains( targetBasename.baseName()) and !usedLoad.contains(targetBasename.baseName()))
writer<<ite->fromNum<<"\t";
writer<<ite->toNum<<"\t";
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;
usedLoad<<targetBasename.baseName();
p->getPA();
break;
std::cout<<"CIMExporter:: can not substation of "<<subID.toStdString()<<std::endl;
continue;
}
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
{
int n=this->number.values().length()+1;
int n=this->number.keys().length()+1;
this->number[id]=n;
return n;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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