diff --git a/testHasttable/dginfo.cpp b/testHasttable/dginfo.cpp new file mode 100644 index 0000000..bcf7528 --- /dev/null +++ b/testHasttable/dginfo.cpp @@ -0,0 +1,44 @@ +#include "dginfo.h" + +DGInfo::DGInfo(double powerFactor):powerFactor(powerFactor) +{ + +} + +DGInfo::~DGInfo() +{ + +} + +QString DGInfo::getAttchedSubstaitonID() +{ + return this->attchedSubstaitonID; +} + +double DGInfo::getCapacity() +{ + return this->capacity; +} + +QString DGInfo::getName() +{ + return this->name; +} + +void DGInfo::setAttchedSubstaitonID(const QString& id) +{ + this->attchedSubstaitonID=id; +} + +void DGInfo::setCapacity(double cap) +{ + this->capacity=cap; +} + +void DGInfo::setName(const QString& name) +{ + this->name=name; +} + + + diff --git a/testHasttable/dginfo.h b/testHasttable/dginfo.h new file mode 100644 index 0000000..e66834e --- /dev/null +++ b/testHasttable/dginfo.h @@ -0,0 +1,25 @@ +#ifndef DGINFO_H +#define DGINFO_H + +#include +class DGInfo +{ +public: + DGInfo(double powerFactor=1); + ~DGInfo(); + QString getAttchedSubstaitonID(); + double getCapacity(); + QString getName(); + void setAttchedSubstaitonID(const QString& id); + void setCapacity(double cap); + void setName(const QString &name); + +private: + double capacity;//单位kvA + QString attchedSubstaitonID; + double powerFactor; + QString name; + +}; + +#endif // DGINFO_H diff --git a/testHasttable/dgmapping.cpp b/testHasttable/dgmapping.cpp new file mode 100644 index 0000000..af583b1 --- /dev/null +++ b/testHasttable/dgmapping.cpp @@ -0,0 +1,67 @@ +#include "dgmapping.h" + +#include + +DGMapping::DGMapping() +{ + +} + +DGMapping::~DGMapping() +{ + +} + +bool DGMapping::load(const QString &filePath) +{ + //格式 + //序号,名称,容量,所属Substation的ID + QFile file(filePath); + QString line; + QStringList sep; + if(file.open(QFile::ReadOnly)) + { + QTextStream reader(&file); + while(!reader.atEnd()) + { + line=reader.readLine().trimmed(); + if(line.length()==0) + { + continue; + } + if(line.startsWith("#")) + { + continue; + } + sep=line.split(','); + if(sep.length()<4) + { + continue; + } + QString name=sep.at(1); + double capacity=sep.at(2).toDouble(); + QString attachedSubID=sep.at(3); + QSharedPointer t(new DGInfo); + t->setName(name); + t->setCapacity(capacity); + t->setAttchedSubstaitonID(attachedSubID); + QVector >& vec=this->ht.get(attachedSubID); + vec.push_back(t); + + } + file.close(); + } + else + { + return false; + } +// QStringList keys; +// keys=this->ht.keys(); +// foreach(QString k,keys) +// { +// std::cout<ht.get(k).at(0)->getAttchedSubstaitonID().toStdString()< +#include +#include +#include +#include +#include +#include "singletonbase.h" +#include "dginfo.h" + +//把DG信息对应到Substation上。 +class DGMapping +{ + class htType:public SingletonBase > ,htType> + { + + }; +public: + DGMapping(); + ~DGMapping(); + bool load(const QString &filePath); +private: + htType ht; +}; + +#endif // DGMAPPING_H diff --git a/testHasttable/main.cpp b/testHasttable/main.cpp index b641391..945f07a 100644 --- a/testHasttable/main.cpp +++ b/testHasttable/main.cpp @@ -3,13 +3,14 @@ #include "regexextract.h" #include "task.h" #include -#include "loadmapping.h" -#include "loadinfo.h" +//#include "loadmapping.h" +//#include "loadinfo.h" +#include "dgmapping.h" int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); // LoadMapping lm; -// lm.load("D:/Project/佛山项目/数据/搭网架参数文件/北滘/北滘负荷","D:/Project/佛山项目/数据/匹配的数据/北滘","D:/Project/佛山项目/数据/exception.txt"); +// lm.load("D:/Project/佛山项目/数据/搭网架参数文件/","D:/Project/佛山项目/数据/匹配的数据/","D:/Project/佛山项目/数据/exception.txt"); // LoadInfo loadInfo; // loadInfo.setLoadPath("D:/Project/佛山项目/数据/搭网架参数文件/泰安/泰安负荷/718发展线/专变/威灵电机工业园电房1.csv"); // loadInfo.updateByTime(QTime(0,15,0)); @@ -18,6 +19,9 @@ int main(int argc, char *argv[]) // RegexExtract re; // re.extract("D:/Project/佛山项目/数据/df8003/df8600/exportfiles/exportmodel_pw.xml"); // re.exportBlocks("./a"); + + DGMapping dgMapping; + dgMapping.load("D:/Project/佛山项目/数据/DG.txt"); // return a.exec(); ElementHashtable eleReader; eleReader.Parse("D:/Project/佛山项目/数据/df8003/df8600/exportfiles/exportmodel_pw.xml","D:/Project/佛山项目/佛山收资/exportmodel_zwyth20141204/exportmodel_zwyth.xml"); diff --git a/testHasttable/singletonbase.h b/testHasttable/singletonbase.h index 0183241..20e0f83 100644 --- a/testHasttable/singletonbase.h +++ b/testHasttable/singletonbase.h @@ -3,12 +3,15 @@ //做一个单例 #include - +#include template class SingletonBase { public: -// SingletonBase(); + SingletonBase() + { + this->initInstance(); + } // ~SingletonBase(); void add(const KeyType& key,const ValueType& val) { @@ -19,11 +22,18 @@ public: { return SingletonBase::ht->contains(key); } - ValueType get(const KeyType& key) + ValueType& get(const KeyType& key) { QHash *t=SingletonBase::ht; return (*t)[key]; } + QList keys() + { + return SingletonBase::ht->keys(); + } + +private: + void initInstance() { if(SingletonBase::ht) diff --git a/testHasttable/testHasttable.pro b/testHasttable/testHasttable.pro index 44f4c73..91a4c33 100644 --- a/testHasttable/testHasttable.pro +++ b/testHasttable/testHasttable.pro @@ -41,7 +41,9 @@ SOURCES += main.cpp \ loadmapping.cpp \ recursedir.cpp \ loadinfo.cpp \ - loadmatchexception.cpp + loadmatchexception.cpp \ + dgmapping.cpp \ + dginfo.cpp HEADERS += \ elementhashtable.h \ @@ -69,7 +71,9 @@ HEADERS += \ recursedir.h \ loadinfo.h \ singletonbase.h \ - loadmatchexception.h + loadmatchexception.h \ + dgmapping.h \ + dginfo.h #release{ DEFINES += QT_NO_DEBUG_OUTPUT