加入忽略一些负荷的功能。

Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
dmy@lab 2015-01-16 16:27:05 +08:00
parent 9faa1cce49
commit 491f5e2276
5 changed files with 35 additions and 3 deletions

View File

@ -18,22 +18,40 @@ LoadMapping::~LoadMapping()
bool LoadMapping::load(const QString &loadDir,const QString &matchdDir,const QString &exceptionFile) bool LoadMapping::load(const QString &loadDir,const QString &matchdDir,const QString &exceptionFile)
{ {
if(LoadMapping::ht->keys().length()>0) if(LoadMapping::ht->keys().length()>0)
{ {
return true;//只执行一次 return true;//只执行一次
} }
if(!QFileInfo::exists(loadDir)|!QFileInfo::exists(matchdDir)|!QFileInfo::exists(exceptionFile)) if(!QFileInfo::exists(loadDir))
{ {
std::cout<<"load file not exists."<<std::endl;
return false; return false;
} }
if(!QFileInfo::exists(matchdDir))
{
std::cout<<"match file not exists."<<std::endl;
return false;
}
if(!QFileInfo::exists(exceptionFile))
{
std::cout<<"match file not exists."<<std::endl;
return false;
}
if(!this->readMatch(matchdDir)) if(!this->readMatch(matchdDir))
{ {
std::cout<<"read match failed"<<std::endl;
return false; return false;
} }
this->loadMatchException.init(exceptionFile);
if(!this->readLoads(loadDir)) if(!this->readLoads(loadDir))
{ {
std::cout<<"read load failed"<<std::endl;
return false; return false;
} }
return true; return true;
} }
@ -57,6 +75,12 @@ bool LoadMapping::readLoads(const QString &dir)
continue; continue;
} }
QString fileName=fileInfo.baseName(); QString fileName=fileInfo.baseName();
if(this->loadMatchException.contains(fileName))
{
std::cout<<"ignore "<<fileName.toLocal8Bit().data()<<std::endl;
continue;
}
if(!this->loadsToLoadInfo.contains(fileName)) if(!this->loadsToLoadInfo.contains(fileName))
{ {
std::cout<<filePath.toLocal8Bit().data()<<" no match."<<std::endl; std::cout<<filePath.toLocal8Bit().data()<<" no match."<<std::endl;

View File

@ -14,6 +14,7 @@
#include "recursedir.h" #include "recursedir.h"
#include "loadinfo.h" #include "loadinfo.h"
#include "loadmatchexception.h"
//这是一个单例 //这是一个单例
class LoadMapping class LoadMapping
{ {
@ -37,6 +38,7 @@ private:
static QHash<QString,QVector<double> > *ht; static QHash<QString,QVector<double> > *ht;
QHash<QString,QVector<QSharedPointer<LoadInfo> > > loads; QHash<QString,QVector<QSharedPointer<LoadInfo> > > loads;
QHash<QString,QSharedPointer<LoadInfo> > loadsToLoadInfo; QHash<QString,QSharedPointer<LoadInfo> > loadsToLoadInfo;
LoadMatchException loadMatchException;
}; };
#endif // LOADMAPPING_H #endif // LOADMAPPING_H

View File

@ -1,6 +1,6 @@
#include "loadmatchexception.h" #include "loadmatchexception.h"
#include <iostream>
QHash<QString,char > *LoadMatchException::ht=NULL; QHash<QString,char > *LoadMatchException::ht=NULL;
LoadMatchException::LoadMatchException() LoadMatchException::LoadMatchException()
{ {
@ -14,6 +14,7 @@ LoadMatchException::~LoadMatchException()
bool LoadMatchException::contains(const QString& key) bool LoadMatchException::contains(const QString& key)
{ {
return LoadMatchException::ht->contains(key); return LoadMatchException::ht->contains(key);
} }
@ -36,6 +37,10 @@ bool LoadMatchException::init(const QString& exceptionFilePath)
} }
file.close(); file.close();
} }
else
{
std::cout<<"cannot open exception file "<<exceptionFilePath.toStdString()<<std::endl;
}
return true; return true;
} }

View File

@ -6,6 +6,7 @@
#include <QHash> #include <QHash>
#include <QFile> #include <QFile>
#include <QTextStream> #include <QTextStream>
class LoadMatchException class LoadMatchException
{ {
public: public:

View File

@ -8,7 +8,7 @@ int main(int argc, char *argv[])
{ {
QCoreApplication a(argc, argv); QCoreApplication a(argc, argv);
LoadMapping lm; LoadMapping lm;
lm.load("D:/Project/佛山项目/数据/搭网架参数文件/泰安/泰安负荷","D:/Project/佛山项目/数据/匹配的数据",""); lm.load("D:/Project/佛山项目/数据/搭网架参数文件/泰安/泰安负荷","D:/Project/佛山项目/数据/匹配的数据","D:/Project/佛山项目/数据/exception.txt");
// ReadWrite aa; // ReadWrite aa;
// RegexExtract re; // RegexExtract re;