From 29828700d28bca9ffc42ac165e7e0e8b9e82c68b Mon Sep 17 00:00:00 2001 From: "dmy@lab" Date: Thu, 5 Feb 2015 16:00:42 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A6=82=E6=9E=9C=E8=B4=9F=E8=8D=B7=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E4=B8=BA=E7=A9=BA=E5=B0=B1=E4=B8=8D=E6=89=93=E5=BC=80?= =?UTF-8?q?=E3=80=82=202.=E6=8A=8A=E6=89=80=E6=9C=89=E8=B4=9F=E8=8D=B724?= =?UTF-8?q?=E6=97=B6=E6=AE=B5=E8=BE=93=E5=87=BA=E5=88=B0=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E4=B8=AD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: dmy@lab --- testHasttable/cimexporter.cpp | 4 ++ testHasttable/cimexporter.h | 1 + testHasttable/elementhashtable.cpp | 2 +- testHasttable/elementreduction.cpp | 1 - testHasttable/loadinfo.cpp | 2 +- testHasttable/loadmapping.cpp | 5 ++ testHasttable/main.cpp | 3 ++ testHasttable/special/loadexporter.cpp | 71 ++++++++++++++++++++++++++ testHasttable/special/loadexporter.h | 33 ++++++++++++ testHasttable/task.cpp | 2 +- testHasttable/task.txt | 2 +- testHasttable/testHasttable.pro | 6 ++- testHasttable/topologyrecorder.cpp | 2 +- 13 files changed, 126 insertions(+), 8 deletions(-) create mode 100644 testHasttable/special/loadexporter.cpp create mode 100644 testHasttable/special/loadexporter.h diff --git a/testHasttable/cimexporter.cpp b/testHasttable/cimexporter.cpp index 1820927..f96319c 100644 --- a/testHasttable/cimexporter.cpp +++ b/testHasttable/cimexporter.cpp @@ -182,12 +182,16 @@ void CIMExporter::exportTo(const QString& path,const QString &rootID) writer<<"type"<<"\t"; // writer<id<<"\t"; writer<getMVA()<<"\r\n"; + //加到LoadExport中 + LoadExporter loadExporter; + loadExporter.add(targetBasename.baseName(),p); break; } } } //列出DG + writer<::iterator ite=this->dg.begin(); ite!=this->dg.end(); ite++) diff --git a/testHasttable/cimexporter.h b/testHasttable/cimexporter.h index 2dabd1d..d661ff5 100644 --- a/testHasttable/cimexporter.h +++ b/testHasttable/cimexporter.h @@ -21,6 +21,7 @@ #include "topologytest.h" #include "elementreduction.h" #include "loadmatchexception.h" +#include "special/loadexporter.h" #include //#include "elementhashtable.h" //class Substation; diff --git a/testHasttable/elementhashtable.cpp b/testHasttable/elementhashtable.cpp index 0e1b48b..2081b5e 100644 --- a/testHasttable/elementhashtable.cpp +++ b/testHasttable/elementhashtable.cpp @@ -189,7 +189,7 @@ void ElementHashtable::ShowContainerInfo(const QString& fileName) } else { - std::cerr<<"not open"<"< t=(*LoadMapping::loadsToLoadInfo)[*ite]; + if(t->getLoadPath().trimmed().length()==0) + { + continue; + } +// std::cout<<"aa "<toLocal8Bit().data()<<" "<getLoadPath().toLocal8Bit().data()<updateByTime(time); } return true; diff --git a/testHasttable/main.cpp b/testHasttable/main.cpp index ffcbff1..e02a73a 100644 --- a/testHasttable/main.cpp +++ b/testHasttable/main.cpp @@ -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."< +LoadExporter::LoadExporter() +{ + +} + +LoadExporter::~LoadExporter() +{ + +} + +void LoadExporter::add(const QString& fileName, QSharedPointer loadInfo) +{ + this->ht.add(fileName,loadInfo); +// if(loadInfo->getLoadPath().trimmed().length()==0) +// { +// std::cout<<"fd"< > > 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 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(P,Q) ); + } + } + + QFile file(filePath); + if(file.open(QFile::WriteOnly)) + { + QTextStream stream(&file); + QStringList keys; + keys=loadSequence.keys(); + foreach(QString key, keys) + { + stream< > loadList=loadSequence[key]; + int seq=0; + for(QList >::iterator ite=loadList.begin();ite!=loadList.end();ite++) + { + stream<<"["<first<<"&&"<second<<")"<<","; + } + stream<<"\t\n"; + } + file.close(); + } + else + { + std::cout<<"cannot create file to export load."< +#include +#include +#include +#include +#include +#include +#include +#include + +class LoadExporter +{ + class HT_TYPE:public SingletonBase,HT_TYPE > + {}; +public: + LoadExporter(); + ~LoadExporter(); + void add(const QString &fileName, QSharedPointer loadInfo); + void toSingleFile(const QString& filePath); + void updateByTime(const QTime &time); +private: + HT_TYPE ht; + +}; + +#endif // LOADEXPORTER_H diff --git a/testHasttable/task.cpp b/testHasttable/task.cpp index fe5b8c4..acabaa6 100644 --- a/testHasttable/task.cpp +++ b/testHasttable/task.cpp @@ -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(); } diff --git a/testHasttable/task.txt b/testHasttable/task.txt index a2bcdd5..9df1e1c 100644 --- a/testHasttable/task.txt +++ b/testHasttable/task.txt @@ -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,) diff --git a/testHasttable/testHasttable.pro b/testHasttable/testHasttable.pro index 61a64e8..6167c07 100644 --- a/testHasttable/testHasttable.pro +++ b/testHasttable/testHasttable.pro @@ -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 diff --git a/testHasttable/topologyrecorder.cpp b/testHasttable/topologyrecorder.cpp index 4df1504..2adc45c 100644 --- a/testHasttable/topologyrecorder.cpp +++ b/testHasttable/topologyrecorder.cpp @@ -28,7 +28,7 @@ bool TopologyRecorder::addDG(const QString& substationID, const QString &fromNod // std::cout<<"from node"<getName(),this); this->cimExporter.add(fromTo,DGP); -// std::cout<<"add "<<_DG->getName().toLocal8Bit().data()<getName().toLocal8Bit().data()<<" to "<usedDG[_DG->getName()]=0;//用过了,做个记号 } return true;