diff --git a/testHasttable/cimexporter.cpp b/testHasttable/cimexporter.cpp index f96319c..1c11614 100644 --- a/testHasttable/cimexporter.cpp +++ b/testHasttable/cimexporter.cpp @@ -58,6 +58,8 @@ void CIMExporter::add(const QPair& fromTo,DG* dg) void CIMExporter::exportTo(const QString& path,const QString &rootID) { + char seperator='\t'; + QString endLine="\r\n"; //输出到文件 QFile fd(path); if(fd.open(QFile::WriteOnly)) @@ -91,11 +93,27 @@ void CIMExporter::exportTo(const QString& path,const QString &rootID) this->idToNumber(this->sw); this->idToNumber(this->tf); this->idToNumber(this->dg); - //开始按要求输出 - //先输出线路 + //开始按iPso格式要求输出 QTextStream writer(&fd); - writer<number.keys().length()<line.first().fromNum; + writer<<1<::iterator ite=this->line.begin(); ite!=this->line.end(); ite++) @@ -106,12 +124,19 @@ void CIMExporter::exportTo(const QString& path,const QString &rootID) continue; } // writer<length<<"\t"<id<<"\t"; - writer<r<x<b1<b2<::iterator ite=this->sw.begin(); ite!=this->sw.end(); @@ -121,18 +146,26 @@ void CIMExporter::exportTo(const QString& path,const QString &rootID) { continue; } - writer<fromNum<<"\t"; - writer<toNum<<"\t"; - writer<<"type"<<"\t"; + writer<fromNum<toNum<sw->r<sw->x<sw->b1<sw->b2<id<<"\t"; - writer<<0<<"\r\n"; +// writer<<0<<"\r\n"; } - //输出负荷 + writer<<0<loadDir); QStringList files; files=recurseDir.getFiles(); //只取文件名 + QStringList baseNames; foreach(QString file,files) { @@ -144,9 +177,14 @@ void CIMExporter::exportTo(const QString& path,const QString &rootID) baseNames< groudBranch;//first is g, second is b. + QList nodePQ;//节点注入功率,也就是负荷或者发电机 - writer<::iterator ite=this->tf.begin(); ite!=this->tf.end(); @@ -177,11 +215,24 @@ void CIMExporter::exportTo(const QString& path,const QString &rootID) { // std::cout<fromNum<<"\t"; - writer<toNum<<"\t"; - writer<<"type"<<"\t"; + writer<fromNum<toNum<tf->r<tf->x<tf->ratio<toNum, ite->tf->g1,ite->tf->b1));//都只用g1,b1的数据 + //保存节点注入功率 + nodePQ.push_back(CIMExporter::NodePQ(ite->toNum,p->get3PhP(),p->get3PhQ())); +// writer<<"type"<<"\t"; // writer<id<<"\t"; - writer<getMVA()<<"\r\n"; +// writer<getMVA()<<"\r\n"; //加到LoadExport中 LoadExporter loadExporter; loadExporter.add(targetBasename.baseName(),p); @@ -190,16 +241,88 @@ void CIMExporter::exportTo(const QString& path,const QString &rootID) } } + + writer<<0<::iterator ite=this->dg.begin(); ite!=this->dg.end(); ite++) { - writer<fromNum<<"\t"; - writer<toNum<<"\t"; - writer<dg->capacity<<"\r\n"; + //保存到节点注入功率中 + nodePQ.push_back(CIMExporter::NodePQ(ite->toNum,-ite->dg->capacity,-ite->dg->capacity) ); +// writer<fromNum<<"\t"; +// writer<toNum<<"\t"; +// writer<dg->capacity<<"\r\n"; } + + //iPso 开始输出注入功率 + CIMExporter::NodePQ *nodePQPointer=new CIMExporter::NodePQ[this->number.keys().length()]; + foreach(CIMExporter::NodePQ n,nodePQ) + { + int nodeNum=n.nodeNum; + if(nodeNum>this->number.keys().length()) + { + std::cout<<"number of nodePQ is beyond node number."<number.keys().length();i++) + { + writer<topologyTest(); fd.close(); + } diff --git a/testHasttable/cimexporter.h b/testHasttable/cimexporter.h index d661ff5..947395c 100644 --- a/testHasttable/cimexporter.h +++ b/testHasttable/cimexporter.h @@ -27,6 +27,29 @@ //class Substation; class CIMExporter { + class NodePQ + { + public: + NodePQ():nodeNum(0),P(0),Q(0) + {} + explicit NodePQ(int nodeNum,double P,double Q):nodeNum(nodeNum),P(P),Q(Q) + {} + int nodeNum; + double P; + double Q; + + }; + + class GroundBranch + { + public: + explicit GroundBranch(int nodeNum,double g,double b):nodeNum(nodeNum),g(g),b(b) + {} + int nodeNum; + double g; + double b; + + }; public: explicit CIMExporter(const QHash& eleHT,const QString& loadDir);