2014-12-26 21:21:58 +08:00
|
|
|
#include "cimexporter.h"
|
2014-12-28 17:49:16 +08:00
|
|
|
#include <iostream>
|
2014-12-26 21:21:58 +08:00
|
|
|
CIMExporter::CIMExporter()
|
|
|
|
|
{
|
|
|
|
|
}
|
2014-12-28 16:40:57 +08:00
|
|
|
|
|
|
|
|
void CIMExporter::add(const QPair<QString,QString>& fromTo,Line* line)
|
|
|
|
|
{
|
|
|
|
|
CIMExporter::LineStru lineStru;
|
|
|
|
|
lineStru.line=line;
|
|
|
|
|
lineStru.fromID=fromTo.first;
|
|
|
|
|
lineStru.toID=fromTo.second;
|
2014-12-28 17:16:29 +08:00
|
|
|
this->line.push_back(lineStru);
|
2014-12-28 16:40:57 +08:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void CIMExporter::add(const QPair<QString,QString>& fromTo,Switch* sw)
|
|
|
|
|
{
|
|
|
|
|
CIMExporter::SwitchStru switchStru;
|
|
|
|
|
switchStru.sw=sw;
|
|
|
|
|
switchStru.fromID=fromTo.first;
|
|
|
|
|
switchStru.toID=fromTo.second;
|
2014-12-28 17:16:29 +08:00
|
|
|
this->sw.push_back(switchStru);
|
2014-12-28 16:40:57 +08:00
|
|
|
}
|
|
|
|
|
void CIMExporter::add(const QPair<QString,QString>& fromTo,Transformer* tf)
|
|
|
|
|
{
|
|
|
|
|
CIMExporter::TransformerStru tfStru;
|
|
|
|
|
tfStru.tf=tf;
|
|
|
|
|
tfStru.fromID=fromTo.first;
|
|
|
|
|
tfStru.toID=fromTo.second;
|
2014-12-28 17:16:29 +08:00
|
|
|
this->tf.push_back(tfStru);
|
2014-12-28 16:40:57 +08:00
|
|
|
}
|
2014-12-28 16:56:45 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
void CIMExporter::exportTo(const QString& path)
|
|
|
|
|
{
|
2015-01-17 22:31:06 +08:00
|
|
|
return;
|
2014-12-28 17:16:29 +08:00
|
|
|
//先给所有节点都编号
|
|
|
|
|
this->idToNumber(this->line);
|
|
|
|
|
this->idToNumber(this->sw);
|
|
|
|
|
this->idToNumber(this->tf);
|
2014-12-28 17:49:16 +08:00
|
|
|
//开始按要求输出
|
2015-01-15 20:05:44 +08:00
|
|
|
//先输出线路
|
2014-12-28 17:49:16 +08:00
|
|
|
for(QList<CIMExporter::LineStru>::iterator ite=this->line.begin();
|
|
|
|
|
ite!=this->line.end();
|
|
|
|
|
ite++)
|
|
|
|
|
{
|
|
|
|
|
LineStru l=*ite;
|
|
|
|
|
std::cout<<l.fromID.toStdString()<<" "<<l.fromNum<<" ";
|
|
|
|
|
std::cout<<l.toID.toStdString()<<" "<<l.toNum<<std::endl;
|
2015-01-15 20:05:44 +08:00
|
|
|
std::cout<<l.line->r<<","<<l.line->x<<","<<l.line->g1<<","<<l.line->g2<<std::endl;
|
2014-12-28 17:49:16 +08:00
|
|
|
}
|
2015-01-15 20:05:44 +08:00
|
|
|
//输出负荷
|
|
|
|
|
|
2014-12-28 16:56:45 +08:00
|
|
|
|
2014-12-28 17:16:29 +08:00
|
|
|
|
|
|
|
|
}
|
2015-01-15 17:19:06 +08:00
|
|
|
|
2014-12-28 17:16:29 +08:00
|
|
|
template<typename T>
|
|
|
|
|
void CIMExporter::idToNumber(QList<T> &s)//把所有元件的标识进行编号
|
|
|
|
|
{
|
|
|
|
|
for(typename QList<T>::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;
|
|
|
|
|
}
|
2014-12-28 16:56:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|