1.把负荷文件路径加入CIMParser中。

2.把变压器也处理成双端支路。

Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
dmy@lab 2015-01-20 13:19:28 +08:00
parent 07cfaef632
commit 8d5fcf9c95
12 changed files with 154 additions and 36 deletions

View File

@ -1,6 +1,6 @@
#include "cimexporter.h"
#include <iostream>
CIMExporter::CIMExporter()
CIMExporter::CIMExporter(const QHash<QString, BasicElementInfo *> &eleHT, const QString &loadDir):loadDir(loadDir),eleHT(eleHT)
{
}
@ -33,25 +33,78 @@ void CIMExporter::add(const QPair<QString,QString>& fromTo,Transformer* tf)
void CIMExporter::exportTo(const QString& path)
{
return;
//先给所有节点都编号
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();
// 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();
//转换斜杠
for(QStringList::iterator ite=files.begin();ite!=files.end();ite++)
{
*ite=(*ite).replace("\\","/");
}
// //只取文件名
// QStringList baseNames;
// foreach(QString file,files)
// {
// QFileInfo fileInfo(file);
// baseNames<<fileInfo.baseName();
// }
QStringList usedLoad;
for(QList<CIMExporter::TransformerStru>::iterator ite=this->tf.begin();
ite!=this->tf.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;
}
//输出负荷
std::cout<<"f"<<std::endl;
PowerTransformer *tf=ite->tf->getTF();
QString subID=tf->getEquipmentMemberOf_EquipmentContainer();//所属Substation的ID
Substation *sub=static_cast<Substation *>(this->eleHT[subID]);
if(!sub)
{
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)
{
std::cout<<"match "<<p->getLoadPath().toLocal8Bit().data()<<std::endl;
if( files.contains( p->getLoadPath()) )
{
usedLoad<<p->getLoadPath();
p->getPA();
break;
}
}
}
//列出没有用的负荷文件
foreach(QString file, files)
{
if(!usedLoad.contains(file))
{
std::cout<<file.toLocal8Bit().data()<<"not used"<<std::endl;
}
}
}

View File

@ -6,6 +6,16 @@
#include "element/transformer.h"
#include <QPair>
#include <QHash>
#include <QStringList>
#include <QFileInfo>
#include <QSharedPointer>
#include "recursedir.h"
#include "substation.h"
#include "loadmapping.h"
#include "loadinfo.h"
#include <QVector>
//#include "elementhashtable.h"
class Substation;
class CIMExporter
{
struct BranchStruc
@ -31,7 +41,7 @@ class CIMExporter
};
public:
CIMExporter();
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,Switch* sw);
void add(const QPair<QString,QString>& fromTo,Transformer* tf);
@ -44,6 +54,8 @@ private:
int numberIt(const QString &id);//编号
template<typename T>
void idToNumber(QList<T> &s);//把所有元件的标识进行编号
QString loadDir;
const QHash<QString,BasicElementInfo *>& eleHT;
};
#endif // CIMEXPORTER_H

View File

@ -24,4 +24,12 @@ void Transformer::extract()
this->g2=g0*length;
this->b1=b0*length;
this->b2=b0*length;
//解析负荷
}
PowerTransformer *Transformer::getTF()
{
return this->tf;
}

View File

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

View File

@ -71,6 +71,8 @@ bool ElementHashtable::child(QXmlStreamReader &reader)
return true;
}
bool ElementHashtable::GoPath()
{
const QHash<QString,BasicElementInfo*> &zwht=this->eleHT;//从配网开始找
@ -101,9 +103,9 @@ bool ElementHashtable::GoPath()
delete this->tpRecorder;
this->tpRecorder=NULL;
}
this->tpRecorder=new TopologyRecorder(this->eleHT,this->FDSet);
this->tpRecorder=new TopologyRecorder(this->eleHT,this->FDSet,this->loadFilePath);
this->tpRecorder->startWithNode(node);
this->tpRecorder->exportTo("");
// this->tpRecorder->exportTo("");
break;
}
}
@ -187,3 +189,8 @@ void ElementHashtable::ShowContainerInfo(const QString& fileName)
std::cerr<<"not open"<<relPath.toStdString()<<std::endl;
}
}
void ElementHashtable::SetLoadFilePath(const QString &path)
{
this->loadFilePath=path;
}

View File

@ -27,7 +27,9 @@ public:
explicit ElementHashtable(QObject *parent = 0);
bool Parse(const QString& xmlPWPath,const QString& xmlZWPath);
bool GoPath();
// void ExportTo(const QString& path);
void SetACLineID(const QString &id);//寻找的线路ID
void SetLoadFilePath(const QString &path);
void SetFDSet(const QVector<QString> &FDSet);//FeeDer集合
void ShowContainerInfo(const QString& fileName);
private:
@ -41,6 +43,7 @@ private:
QString lineID;
QVector<QString> FDSet;
TopologyRecorder *tpRecorder;
QString loadFilePath;
signals:
public slots:

View File

@ -41,6 +41,16 @@ bool LoadMapping::broadcastUpdateByTime(const QTime& time)
return true;
}
QSharedPointer<LoadInfo> LoadMapping::getALoad(const QString& id)
{
return (*this->loadsToLoadInfo)[id];
}
QVector<QSharedPointer<LoadInfo> > LoadMapping::getSubstationLoad(const QString& id)
{
return (*this->loads)[id];
}
bool LoadMapping::load(const QString &loadDir,const QString &matchdDir,const QString &exceptionFile)
{

View File

@ -24,9 +24,12 @@ public:
LoadMapping();
~LoadMapping();
bool broadcastUpdateByTime(const QTime& time);
QSharedPointer<LoadInfo> getALoad(const QString& id);
QVector<QSharedPointer<LoadInfo> > getSubstationLoad(const QString& id);
bool load(const QString& loadDir, const QString &matchdDir, const QString &exceptionFile);
bool readLoads(const QString& dir);
bool readMatch(const QString& dir);
private:
class CG // 它的唯一工作就是在析构函数中删除CSingleton的实例
{

View File

@ -54,18 +54,21 @@ void Task::doAgainstTaskFile(ElementHashtable &eleHT)
}
// //开始解析
sep=line.split(',');
if(sep.length()<3)
if(sep.length()<4)
{
std::cout<<"error: "<<line.toStdString()<<std::endl;
continue;
}
QString lineName=sep.at(0);
QString lineID=sep.at(1);
QString loadDir=sep.at(2);
// std::cout<<lineName.toLocal8Bit().data()<<std::endl;
eleHT.SetLoadFilePath(loadDir);
eleHT.SetACLineID(lineID);
eleHT.SetFDSet(setSep.toVector());
eleHT.GoPath();
eleHT.ShowContainerInfo(lineName);
break;
}
file.close();

View File

@ -1,4 +1,4 @@
727揭주땜菉窟,AC-671678,(FD-2096,)
727泰林东乙线,AC-671678,D:\Project\佛山项目\数据\搭网架参数文件\泰安\泰安负荷\727泰林东乙线,(FD-2096,),
709美的甲线,AC-671399,(FD-2003,)

View File

@ -1,7 +1,7 @@
#include "topologyrecorder.h"
#include <iostream>
//#include <iostream>
#include <QList>
TopologyRecorder::TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT, const QVector<QString> &FDSet, QObject *parent):eleHT(elementHT),FDSet(FDSet)
TopologyRecorder::TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT, const QVector<QString> &FDSet,const QString& loadFilePath, QObject *parent):QObject(parent),eleHT(elementHT),FDSet(FDSet),cimExporter(elementHT,loadFilePath)
{
}
@ -141,9 +141,7 @@ bool TopologyRecorder::startWithNode(const QString& node)
{
// std::cout<<"sw "<<SW->getNamingDescription().toStdString()<<"is close"<<std::endl;
}
Substation *sbb=static_cast<Substation *>(ht[SW->getEquipmentMemberOf_EquipmentContainer()]);
// std::cout<<"sw container"<<sbb->getNamingDescription().toLocal8Bit().data()<<std::endl;
// std::cout<<SW->getID().toStdString()<<std::endl;
terminalA=SW->getTerminalA();
terminalB=SW->getTerminalB();
// std::cout<<"find"<<SW->getID().toStdString()<<std::endl;
@ -231,8 +229,7 @@ bool TopologyRecorder::startWithNode(const QString& node)
if(this->isEquipmentNeeded(equipmentContainer))
{
this->tfs.push_back(tfID);
// fromTo.first=node;
// fromTo.second=tfID;
foundEle=tf;
}
else
@ -245,23 +242,41 @@ bool TopologyRecorder::startWithNode(const QString& node)
}
if(foundEle)
{
Branch *branch=NULL;
QString nextTerminal;
nextTerminal=(terminalA==anotherTerminal)?terminalB:terminalA;
Terminal *nextTerminalP=static_cast<Terminal *>(ht[nextTerminal]);
if(!nextTerminalP)
{
continue;
}
//有可能会访问到重复的元件,所以这里判断一下,如果是已经访问过的就不添加了。
if(this->hasAdded.contains(foundEle->getID()))
{
continue;
}
this->hasAdded[foundEle->getID()]=0;
QString nextNode=nextTerminalP->getConnectivityNode();
fromTo.first=node;
fromTo.second=nextNode;
Branch *branch=NULL;
QString nextTerminal;
Terminal *nextTerminalP;
QString nextNode;
if(typ!=TopologyRecorder::Type::TF)
{
nextTerminal=(terminalA==anotherTerminal)?terminalB:terminalA;
nextTerminalP=static_cast<Terminal *>(ht[nextTerminal]);
if(!nextTerminalP)
{
continue;
}
else
{
nextNode=nextTerminalP->getConnectivityNode();
fromTo.first=node;
fromTo.second=nextNode;
}
}
else
{
nextNode="";
fromTo.first=node;
fromTo.second=foundEle->getID();//用变压器编号做虚拟节点
}
// std::cout<<typ<<" "<<ce.toStdString()<<std::endl;
switch(typ)
{
case TopologyRecorder::Type::AC:
@ -278,13 +293,15 @@ bool TopologyRecorder::startWithNode(const QString& node)
break;
case TopologyRecorder::Type::TF:
branch=new Transformer(fromTo,static_cast<PowerTransformer *>(foundEle),this);
// std::cout<<"add tf"<<std::endl;
this->cimExporter.add(fromTo,static_cast<Transformer *>(branch));
break;
default:
break;
}
// std::cout<<nextNode.toStdString()<<std::endl;
this->startWithNode(nextNode);
if(nextNode!="")
this->startWithNode(nextNode);
}
else
{

View File

@ -30,7 +30,7 @@ class TopologyRecorder:public QObject
};
public:
TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT,const QVector<QString> &FDSet,QObject *parent=0);
TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT, const QVector<QString> &FDSet, const QString &loadFilePath, QObject *parent=0);
~TopologyRecorder();
void showContainerInfo(QTextStream &stream);
bool startWithNode(const QString& node);
@ -40,8 +40,8 @@ private:
const QHash<QString,BasicElementInfo *>& eleHT;
QHash<QString,char> reachedTerminal;
QVector<QString> tfs;
CIMExporter cimExporter;
QVector<QString> FDSet;
CIMExporter cimExporter;
QHash<QString,char> hasAdded;
bool isEquipmentNeeded(const QString& substatinID);
};