#include "cimexporter.h" #include CIMExporter::CIMExporter() { } void CIMExporter::add(const QPair& fromTo,Line* line) { CIMExporter::LineStru lineStru; lineStru.line=line; lineStru.fromID=fromTo.first; lineStru.toID=fromTo.second; this->line.push_back(lineStru); } void CIMExporter::add(const QPair& fromTo,Switch* sw) { CIMExporter::SwitchStru switchStru; switchStru.sw=sw; switchStru.fromID=fromTo.first; switchStru.toID=fromTo.second; this->sw.push_back(switchStru); } void CIMExporter::add(const QPair& fromTo,Transformer* tf) { CIMExporter::TransformerStru tfStru; tfStru.tf=tf; tfStru.fromID=fromTo.first; tfStru.toID=fromTo.second; this->tf.push_back(tfStru); } void CIMExporter::exportTo(const QString& path) { return; //先给所有节点都编号 this->idToNumber(this->line); this->idToNumber(this->sw); this->idToNumber(this->tf); //开始按要求输出 //先输出线路 for(QList::iterator ite=this->line.begin(); ite!=this->line.end(); ite++) { LineStru l=*ite; std::cout<r<<","<x<<","<g1<<","<g2< void CIMExporter::idToNumber(QList &s)//把所有元件的标识进行编号 { for(typename QList::iterator ite=s.begin(); ite!=s.end(); ite++ ) { T _t=*ite; _t.fromNum=this->numberIt(_t.fromID); _t.toNum=this->numberIt(_t.toID); *ite=_t; } } int CIMExporter::numberIt(const QString& id) { if(this->number.contains(id)) { return this->number.value(id); } else { int n=this->number.values().length()+1; this->number[id]=n; return n; } }