1.加入Task文件,准备批量做。

2.把Task文件接入流程。

Signed-off-by: facat@lab.com <facat@lab.com>
This commit is contained in:
facat@lab.com 2015-01-06 20:51:19 +08:00
parent 96fc5726f7
commit cd22eecbca
9 changed files with 125 additions and 17 deletions

View File

@ -82,7 +82,7 @@ bool ElementHashtable::GoPath()
ite++)
{
BasicElementInfo *p=zwht[*ite];
if(p->getName()=="ACLineSegment" && p->getID()=="AC-591821")
if(p->getName()=="ACLineSegment" && p->getID()==this->lineID)
{
ACLineSegment *ac=static_cast<ACLineSegment *>(p);//BusbarSection也就是线路头节点
QString acTerminal=ac->getTerminalB();
@ -96,7 +96,7 @@ bool ElementHashtable::GoPath()
continue;//有些Terminal是没有Node的
}
std::cout<<node.toStdString()<<std::endl;
TopologyRecorder tpRecorder(this->eleHT);
TopologyRecorder tpRecorder(this->eleHT,this->FDSet);
tpRecorder.startWithNode(node);
tpRecorder.exportTo("");
break;
@ -126,9 +126,9 @@ bool ElementHashtable::parse(const QString& xmlPath)
this->child(reader);//处理根元素下的第一级子元素也就是Substation这一类。
}
loop++;
if(loop>600000){
// if(loop>600000){
// break;
}
// }
}
if(reader.hasError())
@ -154,3 +154,12 @@ bool ElementHashtable::Parse(const QString& xmlPWPath,const QString& xmlZWPath){
// this->parse(xmlZWPath);
return true;
}
void ElementHashtable::SetACLineID(const QString &id)//寻找的线路ID
{
this->lineID=id;
}
void ElementHashtable::SetFDSet(const QVector<QString> &FDSet)//FeeDer集合
{
this->FDSet=FDSet;
}

View File

@ -26,6 +26,8 @@ public:
explicit ElementHashtable(QObject *parent = 0);
bool Parse(const QString& xmlPWPath,const QString& xmlZWPath);
bool GoPath();
void SetACLineID(const QString &id);//寻找的线路ID
void SetFDSet(const QVector<QString> &FDSet);//FeeDer集合
private:
bool child(QXmlStreamReader &reader);
bool setCurrentHashTable(QHash<QString,BasicElementInfo *> *t);
@ -34,6 +36,8 @@ private:
QHash<QString,BasicElementInfo *> mainStationHT;//记录主站的元素
NodeToTerminal nodeToTerminal;
QHash<QString,BasicElementInfo *> *currentHT;
QString lineID;
QVector<QString> FDSet;
signals:
public slots:

View File

@ -1,17 +1,16 @@
#include <QCoreApplication>
#include <elementhashtable.h>
#include "regexextract.h"
#include "task.h"
#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
ElementHashtable eleReader;
eleReader.Parse("D:/Project/佛山项目/佛山收资/exportmodel_pw/df8003/df8600/exportfiles/exportmodel_pw.xml","D:/Project/佛山项目/佛山收资/exportmodel_zwyth20141204/exportmodel_zwyth.xml");
// eleReader.parse("D:/Project/佛山项目/佛山收资/按元素分/BusbarSectionb.xml");
eleReader.GoPath();
// RegexExtract regexExt;
// regexExt.extract("D:/Project/佛山项目/佛山收资/exportmodel_pw/df8003/df8600/exportfiles/exportmodel_pw.xml");
// regexExt.exportBlocks("ThermalGeneratingUnit.xml");
// eleReader.GoPath();
Task task;
task.doAgainstTaskFile(eleReader);
std::cout<<"Finished."<<std::endl;
return a.exec();
}

74
testHasttable/task.cpp Normal file
View File

@ -0,0 +1,74 @@
#include "task.h"
#include <iostream>
Task::Task()
{
this->taskFile="./../task.txt";
}
void Task::doAgainstTaskFile(ElementHashtable &eleHT)
{
QFile file(this->taskFile);
QString line;
QStringList sep;
if(file.open(QFile::ReadOnly))
{
QTextStream reader(&file);
while(!reader.atEnd())
{
line=reader.readLine();
line=line.trimmed();
if(line.startsWith("#"))
{
continue;
}
if(line.length()==0)//空行
{
continue;
}
//先吧括号里面的取出来
QRegularExpression regExp("\\((.*)\\)");
QRegularExpressionMatch match=regExp.match(line);
QString _set;
if(match.hasMatch())
{
_set=match.captured(0);
// std::cout<<_set.toStdString()<<std::endl;
}
else
{
std::cout<<"error: "<<line.toStdString()<<std::endl;
continue;
}
//处理一下set
_set.replace("(","");
_set.replace(")","");
QStringList _setSplit=_set.split(',');
QStringList setSep;
foreach (QString v, _setSplit) {
if(v.trimmed().length()==0)
{
continue;
}
std::cout<<v.toStdString()<<std::endl;
setSep.push_back(v);
}
// //开始解析
sep=line.split(',');
if(sep.length()<3)
{
std::cout<<"error: "<<line.toStdString()<<std::endl;
continue;
}
QString lineID=sep.at(1);
eleHT.SetACLineID(lineID);
eleHT.SetFDSet(setSep.toVector());
eleHT.GoPath();
break;
}
file.close();
}
else
{
std::cerr<<this->taskFile.toStdString()<<"not open"<<std::endl;
}
}

19
testHasttable/task.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef TASK_H
#define TASK_H
#include <QString>
#include <QFile>
#include <QTextStream>
#include <QStringList>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include "elementhashtable.h"
class Task
{
public:
Task();
void doAgainstTaskFile(ElementHashtable &eleHT);
private:
QString taskFile;
};
#endif // TASK_H

View File

@ -1,6 +1,6 @@
709美的甲线,AC-671399,(FD-2003,)
720美的乙线,AC-671401,(FD-2003,)
715北都联络线,AC-975725|AC-456393,(FD-2050,)
#715北都联络线,AC-975725|AC-456393,(FD-2050,)
705林港I线,AC-591832,(FD-2049,)
719林港IV线,AC-591838,(FD-2055,)
721南源线,AC-591821,(FD-2014,FD-2019,FD-2000,)
@ -13,7 +13,7 @@
719广水Ⅱ线,AC-831217,(FD-2048,)
714东兴线,AC-591825,(FD-2019,)
712金茂线,AC-671400,(FD-2004,)
707林港Ⅲ线,AC-591861,()没有svg
#707林港Ⅲ线,AC-591861,()没有svg
723开发区线,AC-591839,(FD-2056,)
711新城Ⅱ线,AC-831181,(FD-2045,)
706林港Ⅱ线,AC-591827,(FD-2023,)
@ -45,7 +45,7 @@
718发展线,AC-671672,(FD-1997)
705广水线,AC-831215,(FD-2048)
719广水Ⅱ线,AC-831217,(FD-2048)
704广水Ⅲ线,AC-591831,()无svg
#704广水Ⅲ线,AC-591831,()无svg
703港前北线,AC-671661,(FD-1992,FD-1998)
730泰港乙线,AC-903666,(FD-58442,FD-2025)
716兴业南线,AC-591810,(FD-1994,FD-58443)

View File

@ -36,7 +36,8 @@ SOURCES += main.cpp \
element/branch.cpp \
element/line.cpp \
element/transformer.cpp \
element/switch.cpp
element/switch.cpp \
task.cpp
HEADERS += \
elementhashtable.h \
@ -58,7 +59,8 @@ HEADERS += \
element/branch.h \
element/line.h \
element/transformer.h \
element/switch.h
element/switch.h \
task.h
#release{
DEFINES += QT_NO_DEBUG_OUTPUT

View File

@ -1,7 +1,7 @@
#include "topologyrecorder.h"
#include <iostream>
#include <QList>
TopologyRecorder::TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT, QObject *parent):eleHT(elementHT)
TopologyRecorder::TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT, const QVector<QString> &FDSet, QObject *parent):eleHT(elementHT),FDSet(FDSet)
{
}
@ -51,7 +51,7 @@ bool TopologyRecorder::isEquipmentNeeded(const QString& substatinID)
else
{
QString feederID=sfd->getSubstationMemberOf_Feeder();
return feederID=="FD-2014"||sfd->getNamingDescription()=="V馈线站";
return this->FDSet.contains(feederID) ||sfd->getNamingDescription()=="V馈线站";
}
return false;
}

View File

@ -29,7 +29,7 @@ class TopologyRecorder:public QObject
};
public:
TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT,QObject *parent=0);
TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT,const QVector<QString> &FDSet,QObject *parent=0);
~TopologyRecorder();
bool startWithNode(const QString& node);
void exportTo(const QString& path);
@ -39,6 +39,7 @@ private:
QHash<QString,char> reachedTerminal;
QVector<QString> tfs;
CIMExporter cimExporter;
QVector<QString> FDSet;
bool isEquipmentNeeded(const QString& substatinID);
};