1.给Singleton的模板加了点功能。
2.添加了处理DG的功能。 Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
parent
15718e1990
commit
07cfaef632
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#ifndef DGINFO_H
|
||||
#define DGINFO_H
|
||||
|
||||
#include <QString>
|
||||
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
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
#include "dgmapping.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
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<DGInfo> t(new DGInfo);
|
||||
t->setName(name);
|
||||
t->setCapacity(capacity);
|
||||
t->setAttchedSubstaitonID(attachedSubID);
|
||||
QVector<QSharedPointer<DGInfo> >& 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<<this->ht.get(k).at(0)->getAttchedSubstaitonID().toStdString()<<std::endl;
|
||||
|
||||
// }
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
#ifndef DGMAPPING_H
|
||||
#define DGMAPPING_H
|
||||
#include <QString>
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
#include <QSharedPointer>
|
||||
#include "singletonbase.h"
|
||||
#include "dginfo.h"
|
||||
|
||||
//把DG信息对应到Substation上。
|
||||
class DGMapping
|
||||
{
|
||||
class htType:public SingletonBase<QString,QVector<QSharedPointer<DGInfo> > ,htType>
|
||||
{
|
||||
|
||||
};
|
||||
public:
|
||||
DGMapping();
|
||||
~DGMapping();
|
||||
bool load(const QString &filePath);
|
||||
private:
|
||||
htType ht;
|
||||
};
|
||||
|
||||
#endif // DGMAPPING_H
|
||||
|
|
@ -3,13 +3,14 @@
|
|||
#include "regexextract.h"
|
||||
#include "task.h"
|
||||
#include <iostream>
|
||||
#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");
|
||||
|
|
|
|||
|
|
@ -3,12 +3,15 @@
|
|||
|
||||
//做一个单例
|
||||
#include <QHash>
|
||||
|
||||
#include <QList>
|
||||
template<typename KeyType,typename ValueType,typename ChildType>
|
||||
class SingletonBase
|
||||
{
|
||||
public:
|
||||
// SingletonBase();
|
||||
SingletonBase()
|
||||
{
|
||||
this->initInstance();
|
||||
}
|
||||
// ~SingletonBase();
|
||||
void add(const KeyType& key,const ValueType& val)
|
||||
{
|
||||
|
|
@ -19,11 +22,18 @@ public:
|
|||
{
|
||||
return SingletonBase<KeyType,ValueType,ChildType>::ht->contains(key);
|
||||
}
|
||||
ValueType get(const KeyType& key)
|
||||
ValueType& get(const KeyType& key)
|
||||
{
|
||||
QHash<KeyType,ValueType> *t=SingletonBase<KeyType,ValueType,ChildType>::ht;
|
||||
return (*t)[key];
|
||||
}
|
||||
QList<KeyType> keys()
|
||||
{
|
||||
return SingletonBase<KeyType,ValueType,ChildType>::ht->keys();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void initInstance()
|
||||
{
|
||||
if(SingletonBase<KeyType,ValueType,ChildType>::ht)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue