修复LoadInfo中成员变量没有初始化的bug

Signed-off-by: dmy@lab <dmy@lab.lab>
This commit is contained in:
dmy@lab 2015-02-06 15:31:00 +08:00
parent 29828700d2
commit 1f9734d727
4 changed files with 42 additions and 4 deletions

View File

@ -3,6 +3,11 @@
LoadInfo::LoadInfo(double powerFactor):powerFactor(powerFactor)
{
this->pqA=QPair<double,double>(0,0);
this->pqB=QPair<double,double>(0,0);
this->pqC=QPair<double,double>(0,0);
this->ph3P=0;
this->ph3Q=0;
}
LoadInfo::~LoadInfo()
@ -30,6 +35,18 @@ QPair<double,double> LoadInfo::getPQ(double current)
return QPair<double,double>(p,q);
}
double LoadInfo::get3PhP()
{
// std::cout<<"get p "<<this->ph3P<<std::endl;
return this->ph3P;
}
double LoadInfo::get3PhQ()
{
// std::cout<<"get q "<<this->ph3Q<<std::endl;
return this->ph3Q;
}
double LoadInfo::getPA()
{
return this->pqA.first;
@ -128,6 +145,22 @@ bool LoadInfo::updateByTime(const QTime& time)
this->pqA=pqA;
this->pqB=pqB;
this->pqC=pqC;
bool ok3PhP;
bool ok3PhQ;
this->ph3P=this->trimDoubleQuotation(sep.at(5)).toDouble(&ok3PhP);
if(!ok3PhP)
{
this->ph3P=0;
}
// std::cout<<"nb "<<sep.at(5).toStdString()<<std::endl;
// std::cout<<this->ph3P<<std::endl;
this->ph3Q=this->trimDoubleQuotation(sep.at(6)).toDouble(&ok3PhQ);
if(!ok3PhQ)
{
this->ph3Q=0;
}
// std::cout<<"nb "<<sep.at(6).toStdString()<<std::endl;
// std::cout<<this->ph3Q<<std::endl;
ret=true;
break;
}

View File

@ -18,12 +18,15 @@ public:
void setLoadName(const QString &name);
void setLoadPath(const QString &path);
bool updateByTime(const QTime& time);
double get3PhP();
double get3PhQ();
double getPA();
double getPB();
double getPC();
double getQA();
double getQB();
double getQC();
private:
bool isStartWithTime(const QString& str);
QString trimDoubleQuotation(const QString& str);
@ -33,6 +36,8 @@ private:
QPair<double,double> pqA;
QPair<double,double> pqB;
QPair<double,double> pqC;
double ph3P;
double ph3Q;
QPair<double,double> getPQ(double current);
};

View File

@ -149,7 +149,7 @@ int main(int argc, char *argv[])
Task task;
task.doAgainstTaskFile(eleReader);
LoadExporter loadExporter;
loadExporter.toSingleFile("D:/MyPro/cimforreduceloss/testHasttable/output/pan/load/singlefile.txt");
loadExporter.toSingleFile("D:/MyPro/cimforreduceloss/testHasttable/output/pan/load/singlefile.csv");
std::cout<<"Finished."<<std::endl;
return a.exec();
}

View File

@ -33,8 +33,8 @@ void LoadExporter::toSingleFile(const QString& filePath)
foreach(QString key, keys)
{
QSharedPointer<LoadInfo> p=this->ht.get(key);
double P=p->getPA()+p->getPB()+p->getPC();
double Q=p->getQA()+p->getQB()+p->getQC();
double P=p->get3PhP();//p->getPA()+p->getPB()+p->getPC();
double Q=p->get3PhQ();//p->getQA()+p->getQB()+p->getQC();
loadSequence[key].push_back(QPair<double,double>(P,Q) );
}
}
@ -52,7 +52,7 @@ void LoadExporter::toSingleFile(const QString& filePath)
int seq=0;
for(QList<QPair<double,double> >::iterator ite=loadList.begin();ite!=loadList.end();ite++)
{
stream<<"["<<seq++<<"]"<<"("<<ite->first<<"&&"<<ite->second<<")"<<",";
stream<<"["<<seq++<<"],"<<ite->first<<","<<ite->second<<",";
}
stream<<"\t\n";
}