1.如果负荷路径为空就不打开。

2.把所有负荷24时段输出到一个文件中。

Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
dmy@lab 2015-02-05 16:00:42 +08:00
parent 3345e00fbd
commit 29828700d2
13 changed files with 126 additions and 8 deletions

View File

@ -182,12 +182,16 @@ void CIMExporter::exportTo(const QString& path,const QString &rootID)
writer<<"type"<<"\t";
// writer<<ite->id<<"\t";
writer<<tf->getMVA()<<"\r\n";
//加到LoadExport中
LoadExporter loadExporter;
loadExporter.add(targetBasename.baseName(),p);
break;
}
}
}
//列出DG
writer<<QStringLiteral("分布式电源")<<"\r\n";
for(QList<DGStru>::iterator ite=this->dg.begin();
ite!=this->dg.end();
ite++)

View File

@ -21,6 +21,7 @@
#include "topologytest.h"
#include "elementreduction.h"
#include "loadmatchexception.h"
#include "special/loadexporter.h"
#include <cmath>
//#include "elementhashtable.h"
//class Substation;

View File

@ -189,7 +189,7 @@ void ElementHashtable::ShowContainerInfo(const QString& fileName)
}
else
{
std::cerr<<"not open"<<relPath.toStdString()<<std::endl;
std::cerr<<"show container info not open"<<relPath.toStdString()<<std::endl;
}
}

View File

@ -51,7 +51,6 @@ void ElementReduction::doIt(const QString& rootID)
// QFile file("1.xml");
// if(file.open(QFile::WriteOnly))
// {
//// root.setContent(&file);
// QTextStream writer(&file);
// root.save(writer,4);

View File

@ -138,7 +138,7 @@ bool LoadInfo::updateByTime(const QTime& time)
}
else
{
std::cout<<filePath.toLocal8Bit().data()<<"not open"<<std::endl;
std::cout<<filePath.toLocal8Bit().data()<<"update by time not open->"<<filePath.toLocal8Bit().data() <<std::endl;
}
return ret;

View File

@ -36,6 +36,11 @@ bool LoadMapping::broadcastUpdateByTime(const QTime& time)
)
{
QSharedPointer<LoadInfo> t=(*LoadMapping::loadsToLoadInfo)[*ite];
if(t->getLoadPath().trimmed().length()==0)
{
continue;
}
// std::cout<<"aa "<<ite->toLocal8Bit().data()<<" "<<t->getLoadPath().toLocal8Bit().data()<<std::endl;
t->updateByTime(time);
}
return true;

View File

@ -8,6 +8,7 @@
#include "dgmapping.h"
//#include "topologytest.h"
//#include "recursedir.h"
#include "special/loadexporter.h"
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
@ -147,6 +148,8 @@ int main(int argc, char *argv[])
// eleReader.GoPath();
Task task;
task.doAgainstTaskFile(eleReader);
LoadExporter loadExporter;
loadExporter.toSingleFile("D:/MyPro/cimforreduceloss/testHasttable/output/pan/load/singlefile.txt");
std::cout<<"Finished."<<std::endl;
return a.exec();
}

View File

@ -0,0 +1,71 @@
#include "loadexporter.h"
#include <iostream>
LoadExporter::LoadExporter()
{
}
LoadExporter::~LoadExporter()
{
}
void LoadExporter::add(const QString& fileName, QSharedPointer<LoadInfo> loadInfo)
{
this->ht.add(fileName,loadInfo);
// if(loadInfo->getLoadPath().trimmed().length()==0)
// {
// std::cout<<"fd"<<std::endl;
// }
}
void LoadExporter::toSingleFile(const QString& filePath)
{
//先按时间形成一个List
QHash<QString,QList<QPair<double,double> > > loadSequence;
//24个时段
for(int i=0;i<24;i++)
{
QTime time(i,0);
this->updateByTime(time);
QStringList keys;
keys=this->ht.keys();
foreach(QString key, keys)
{
QSharedPointer<LoadInfo> p=this->ht.get(key);
double P=p->getPA()+p->getPB()+p->getPC();
double Q=p->getQA()+p->getQB()+p->getQC();
loadSequence[key].push_back(QPair<double,double>(P,Q) );
}
}
QFile file(filePath);
if(file.open(QFile::WriteOnly))
{
QTextStream stream(&file);
QStringList keys;
keys=loadSequence.keys();
foreach(QString key, keys)
{
stream<<key<<",";
QList<QPair<double,double> > loadList=loadSequence[key];
int seq=0;
for(QList<QPair<double,double> >::iterator ite=loadList.begin();ite!=loadList.end();ite++)
{
stream<<"["<<seq++<<"]"<<"("<<ite->first<<"&&"<<ite->second<<")"<<",";
}
stream<<"\t\n";
}
file.close();
}
else
{
std::cout<<"cannot create file to export load."<<std::endl;
}
}
void LoadExporter::updateByTime(const QTime &time)
{
LoadMapping loadMapping;
loadMapping.broadcastUpdateByTime(time);
}

View File

@ -0,0 +1,33 @@
#ifndef LOADEXPORTER_H
#define LOADEXPORTER_H
#include "loadinfo.h"
#include "singletonbase.h"
#include "loadmapping.h"
//把所有按潘国超的要求输出到一个文件中。2015.02.5
#include <QString>
#include <QSharedPointer>
#include <QTime>
#include <QFile>
#include <QTextStream>
#include <QStringList>
#include <QList>
#include <QHash>
#include <QPair>
class LoadExporter
{
class HT_TYPE:public SingletonBase<QString,QSharedPointer<LoadInfo>,HT_TYPE >
{};
public:
LoadExporter();
~LoadExporter();
void add(const QString &fileName, QSharedPointer<LoadInfo> loadInfo);
void toSingleFile(const QString& filePath);
void updateByTime(const QTime &time);
private:
HT_TYPE ht;
};
#endif // LOADEXPORTER_H

View File

@ -71,7 +71,7 @@ void Task::doAgainstTaskFile(ElementHashtable &eleHT)
eleHT.GoPath();
eleHT.ExportTo(QString("D:/MyPro/cimforreduceloss/testHasttable/output/pan/")+sep.at(0)+".txt");
eleHT.ShowContainerInfo(lineName);
break;
// break;
}
file.close();
}

View File

@ -1,4 +1,4 @@
727泰林东乙线,AC-671678,D:\Project\佛山项目\数据\搭网架参数文件\泰安\泰安负荷\727泰林东乙线,(FD-2096,)
713泰林东甲线,AC-671669,D:\Project\佛山项目\数据\搭网架参数文件\泰安\泰安负荷\713泰林东甲线,(FD-2098,FD-2096)
709美的甲线,AC-671399,D:\Project\佛山项目\数据\搭网架参数文件\北滘\北滘负荷\709美的甲线、720美的乙线,(FD-2003,)

View File

@ -46,7 +46,8 @@ SOURCES += main.cpp \
dginfo.cpp \
topologytest.cpp \
elementreduction.cpp \
element/dg.cpp
element/dg.cpp \
special/loadexporter.cpp
HEADERS += \
elementhashtable.h \
@ -80,7 +81,8 @@ HEADERS += \
topologytest.h \
elementreduction.h \
element/commontype.h \
element/dg.h
element/dg.h \
special/loadexporter.h
#release{
DEFINES += QT_NO_DEBUG_OUTPUT

View File

@ -28,7 +28,7 @@ bool TopologyRecorder::addDG(const QString& substationID, const QString &fromNod
// std::cout<<"from node"<<fromNodeID.toStdString()<<std::endl;
DG *DGP=new DG(fromTo,capacity,_DG->getName(),this);
this->cimExporter.add(fromTo,DGP);
// std::cout<<"add "<<_DG->getName().toLocal8Bit().data()<<std::endl;
std::cout<<"add "<<_DG->getName().toLocal8Bit().data()<<" to "<<substationID.toStdString() <<std::endl;
this->usedDG[_DG->getName()]=0;//用过了,做个记号
}
return true;