68 lines
1.4 KiB
C++
68 lines
1.4 KiB
C++
|
|
#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;
|
|||
|
|
}
|
|||
|
|
|