From d810b413a1d058b6d9546437a75856ad6fabd934 Mon Sep 17 00:00:00 2001 From: "facat@lab.com" Date: Fri, 21 Nov 2014 16:54:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: facat@lab.com --- .gitignore | 3 + CIMforReduceLoss.pro | 39 ++ cimparserbatch.cpp | 317 +++++++++ cimparserbatch.h | 34 + derivedqthread.cpp | 30 + derivedqthread.h | 28 + main.cpp | 18 + readxml/DealData.cpp | 185 ++++++ readxml/Interface.cpp | 240 +++++++ readxml/callmain.cpp | 23 + readxml/head.h | 324 +++++++++ readxml/input.cpp | 1162 +++++++++++++++++++++++++++++++++ readxml/linetypeparser.cpp | 68 ++ readxml/linetypeparser.h | 33 + readxml/mainfun.cpp | 117 ++++ readxml/nn06302000.csv | 768 ++++++++++++++++++++++ readxml/output.cpp | 422 ++++++++++++ readxml/output1.cpp | 37 ++ readxml/output2.cpp | 25 + readxml/output3.cpp | 21 + readxml/output4.cpp | 16 + readxml/output5.cpp | 33 + readxml/output6.cpp | 60 ++ readxml/output7.cpp | 144 ++++ readxml/qt_readxml.cpp | 62 ++ readxml/qt_readxml.h | 114 ++++ readxml/topology.cpp | 390 +++++++++++ readxml/transformerparser.cpp | 231 +++++++ readxml/transformerparser.h | 67 ++ 29 files changed, 5011 insertions(+) create mode 100644 .gitignore create mode 100644 CIMforReduceLoss.pro create mode 100644 cimparserbatch.cpp create mode 100644 cimparserbatch.h create mode 100644 derivedqthread.cpp create mode 100644 derivedqthread.h create mode 100644 main.cpp create mode 100644 readxml/DealData.cpp create mode 100644 readxml/Interface.cpp create mode 100644 readxml/callmain.cpp create mode 100644 readxml/head.h create mode 100644 readxml/input.cpp create mode 100644 readxml/linetypeparser.cpp create mode 100644 readxml/linetypeparser.h create mode 100644 readxml/mainfun.cpp create mode 100644 readxml/nn06302000.csv create mode 100644 readxml/output.cpp create mode 100644 readxml/output1.cpp create mode 100644 readxml/output2.cpp create mode 100644 readxml/output3.cpp create mode 100644 readxml/output4.cpp create mode 100644 readxml/output5.cpp create mode 100644 readxml/output6.cpp create mode 100644 readxml/output7.cpp create mode 100644 readxml/qt_readxml.cpp create mode 100644 readxml/qt_readxml.h create mode 100644 readxml/topology.cpp create mode 100644 readxml/transformerparser.cpp create mode 100644 readxml/transformerparser.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a8de601 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.pro.user* +*.bak +*.orig \ No newline at end of file diff --git a/CIMforReduceLoss.pro b/CIMforReduceLoss.pro new file mode 100644 index 0000000..9217b26 --- /dev/null +++ b/CIMforReduceLoss.pro @@ -0,0 +1,39 @@ +QT += core + +QT -= gui + +TARGET = Qt_AsyCallExtApp +CONFIG += console +CONFIG -= app_bundle + +TEMPLATE = app + + +SOURCES += main.cpp \ + derivedqthread.cpp \ + cimparserbatch.cpp \ + readxml/transformerparser.cpp \ + readxml/topology.cpp \ + readxml/qt_readxml.cpp \ + readxml/output5.cpp \ + readxml/output4.cpp \ + readxml/output3.cpp \ + readxml/output2.cpp \ + readxml/output1.cpp \ + readxml/output.cpp \ + readxml/mainfun.cpp \ + readxml/linetypeparser.cpp \ + readxml/input.cpp \ + readxml/DealData.cpp \ + readxml/callmain.cpp \ + readxml/Interface.cpp \ + readxml/output6.cpp \ + readxml/output7.cpp + +HEADERS += \ + derivedqthread.h \ + cimparserbatch.h \ + readxml/transformerparser.h \ + readxml/qt_readxml.h \ + readxml/linetypeparser.h \ + readxml/head.h diff --git a/cimparserbatch.cpp b/cimparserbatch.cpp new file mode 100644 index 0000000..a99e260 --- /dev/null +++ b/cimparserbatch.cpp @@ -0,0 +1,317 @@ +#include "cimparserbatch.h" +#include "derivedqthread.h" +#include +int callmain(char *arg); +CIMParserBatch::CIMParserBatch() +{ +} + +void CIMParserBatch::parser(const QString& dir, const QString &scadaDataFilePath) +{ + QDir qdir(dir); + QStringList filter; + filter<<"*"; + this->mdirList=qdir.entryInfoList(filter,QDir::NoDotAndDotDot | QDir::AllDirs); + this->mite=this->mdirList.constBegin();//后面会用到,就是dir文件下的所有文件 + this->ReadscadaData(scadaDataFilePath); + //this->ExecuteParserApp(NULL); + //this->GenerateBatchFile("c:/parser.bat"); + this->CallFunParser(); +} + +QString CIMParserBatch::FindXML(const QString& dir) +{ + + QDir qdir(dir); + QStringList filter; + filter<<"*.xml"; + QFileInfoList xmlList; + xmlList=qdir.entryInfoList(filter); + if(xmlList.size()>1) + { + std::cout<deleteLater(); + //先把上一次解析得到的文件拷回去 + QFileInfoList fileList=this->FindiPsoPrefixedFile("c:/parser"); + QFileInfo info; + info=*(this->mite);//原始文件的路径 + if(fileList.size()<6) + { + + std::cout<mScada.contains(lineName)) + { + QTextStream stream(&pqi); + FeederData feederData=this->mScada[lineName]; + stream<mite++; + + + } + if(this->mite==this->mdirList.constEnd()) + { + std::cout<<"job finished."<mite); + dir=fileInfo.absoluteFilePath(); + xmlFile=this->FindXML(dir); + if(xmlFile=="") + { + return; + } + QFile::remove("c:/parser/parser.xml"); + QFile::copy(xmlFile,"c:/parser/parser.xml"); + std::cout<<"prepare to parse "<connect(_thread,SIGNAL(finishedptr(QThread*)),this,SLOT(ExecuteParserApp(QThread*))); + _thread->start(); + + +} + +QFileInfoList CIMParserBatch::FindiPsoPrefixedFile(const QString& dir) +{ + QDir qdir(dir); + QStringList filter; + filter<<"iPso_*"; + return qdir.entryInfoList(filter);//如果找不到iPso开头的文件,返回的QFileInfoList长度为0。 +} +void CIMParserBatch::ReadscadaData(const QString& dataPath) +{ + QString line; + QStringList sep; + QFile file(dataPath); + if(file.open(QIODevice::ReadOnly)) + { + QTextStream stream(&file); + while(!stream.atEnd()) + { + line=stream.readLine(); + line=line.simplified(); + line.trimmed(); + sep=line.split(' '); + if(sep.size()<3) + { + std::cout<<"scada file format error!"<exit(); + } + FeederData feederData; + feederData.p=sep.at(1).toDouble(); + feederData.q=sep.at(2).toDouble(); + this->mScada.insert(sep.at(0),feederData); + + } + file.close(); + } + else + { + std::cout<<"scada File not open. This file may not exist."<mite!=this->mdirList.constEnd()) + { + info=*(this->mite); + fullFilePath=info.absoluteFilePath(); + xmlFile=this->FindXML(fullFilePath); + //stream<<"call "; + stream<<"E:/lineloss/console/readxml1.exe "; + stream<mite++; + } + bat.close(); + } + std::cout<<"job finished."<mite!=this->mdirList.constEnd()) + { + + QString xmlFile; + QString dir;//有xml文件的dir + QFileInfo fileInfo=*(this->mite); + dir=fileInfo.absoluteFilePath(); + xmlFile=this->FindXML(dir); + if(xmlFile=="") + { + return; + } + //QFile::remove("c:/parser/parser.xml"); + //QFile::copy(xmlFile,"c:/parser/parser.xml"); + std::cout<<"prepare to parse "<(xmlFile.toStdString().c_str())); + //先把上一次解析得到的文件拷回去 + //QFileInfoList fileList=this->FindiPsoPrefixedFile("c:/parser"); + QFileInfo info(xmlFile); +// info=*(this->mite);//原始文件的路径 +// if(fileList.size()<6) +// { + +// std::cout<mScada.contains(lineName)) + { + QTextStream stream(&pqi); + FeederData feederData=this->mScada[lineName]; + stream<mite++; + } + + + std::cout<<"job finished."< +#include +#include +#include +#include +#include +class CIMParserBatch:public QObject +{ + Q_OBJECT +public: + typedef struct + { + double p; + double q; + }FeederData; + CIMParserBatch(); + void parser(const QString& dir,const QString& scadaDataFilePath); +private: + QString FindXML(const QString& dir);//返回的是绝对路径 + QFileInfoList FindiPsoPrefixedFile(const QString& dir);//得到那些解析得到的文体局,是有前缀的。 + void ReadscadaData(const QString& dataPath); + void GenerateBatchFile(const QString& batFilePath);//直接生成一个bat文件算了。 + void CallFunParser(); +private slots: + void ExecuteParserApp(QThread *); +private: + QFileInfoList::const_iterator mite;//parser函数里用的 + QFileInfoList mdirList; + QHash mScada; +}; + +#endif // CIMPARSERBATCH_H diff --git a/derivedqthread.cpp b/derivedqthread.cpp new file mode 100644 index 0000000..b0f7144 --- /dev/null +++ b/derivedqthread.cpp @@ -0,0 +1,30 @@ +#include "derivedqthread.h" +#include +int callmain(char *args); +DerivedQThread::DerivedQThread(const QString &exe, QObject *parent) : + QThread(parent),mExe(exe) +{ + connect(this,SIGNAL(finished()),this,SLOT(customedfinished())); +} + +void DerivedQThread::run() +{ + QDateTime dateTime; + QTime second; + dateTime=QDateTime::currentDateTime(); + second=QTime::currentTime(); + QString id; + id=dateTime.toString(); + id+=QString::number(second.second()); + id+=QString::number(second.msec()); + this->mid=QCryptographicHash::hash ( id.toLatin1(), QCryptographicHash::Md5 ).toHex(); + //QProcess::execute(this->mExe); + //char s; + //std::string exe=this->mExe.toStdString(); + callmain("c:/parser/parser.xml"); +} + +void DerivedQThread::customedfinished() +{ + emit this->finishedptr(this); +} diff --git a/derivedqthread.h b/derivedqthread.h new file mode 100644 index 0000000..6981641 --- /dev/null +++ b/derivedqthread.h @@ -0,0 +1,28 @@ +#ifndef DERIVEDQTHREAD_H +#define DERIVEDQTHREAD_H + +#include +#include +#include +#include +#include +class DerivedQThread : public QThread +{ + Q_OBJECT +public: + explicit DerivedQThread(const QString &exe, QObject *parent = 0); + void run(); +public: + QString mid; +protected: + QString mExe; + + +signals: + void finishedptr(QThread *); +protected slots: + void customedfinished(); + +}; + +#endif // DERIVEDQTHREAD_H diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..fb6b924 --- /dev/null +++ b/main.cpp @@ -0,0 +1,18 @@ +#include +#include "cimparserbatch.h" +int main(int argc, char *argv[]) +{ + QCoreApplication a(argc, argv); + // QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GBK")); + // QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK")); + // QTextCodec::setCodecForTr(QTextCodec::codecForName("GBK")); + CIMParserBatch batch; + batch.parser("C:/4","C:/200027_.txt"); + //batch.parser("C:/20","C:/scada/040039_.txt"); + //batch.parser("C:/20","C:/scada/080004_.txt"); + //batch.parser("C:/20","C:/scada/120001_.txt"); + //batch.parser("C:/20","C:/scada/160020_.txt"); + //batch.parser("C:/20","C:/scada/200027_.txt"); + + return a.exec(); +} diff --git a/readxml/DealData.cpp b/readxml/DealData.cpp new file mode 100644 index 0000000..c9711b0 --- /dev/null +++ b/readxml/DealData.cpp @@ -0,0 +1,185 @@ +#include "head.h" +#include "transformerparser.h" +#include "linetypeparser.h" +#include "qt_readxml.h" +void Qt_readxml::XmlReaderDealData() +{ + qDebug()<<"Get Transformer Power:"; + int trans_no=power_transformer.size(); + double UN=10.5; + base_power[0].basePower=100; + double SB=base_power[0].basePower; + //double SB=100; + //QString transPowerData="E:\\line loss\\nn06302000.csv"; + QString transPowerData="E:\\line loss\\lz00.csv"; + QString transParaData="E:\\line loss\\trans.csv"; + QString lineParaData="E:\\line loss\\LineType.txt"; + if(!QFile::exists(transPowerData)) + { + //std::cout<<"nn06302000 "<<"not found."<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(b.right(a-1))); + power_transformer[i].UB=base_voltage[it->no].nominalVoltage; + double UB=power_transformer[i].UB; + if (!power_transformer[i].ratedMVA) + { + power_transformer[i].ratedMVA=630; + } + double ratedMVA=power_transformer[i].ratedMVA/1000; + if (power_transformer[i].Model.trimmed()=="") + { + power_transformer[i].Model="S11-M"; + } + power_transformer[i].APower=TransformerParser::GetTransformerAPower(transPowerData,power_transformer[i].Serial_Number); + power_transformer[i].BPower=TransformerParser::GetTransformerBPower(transPowerData,power_transformer[i].Serial_Number); + power_transformer[i].CPower=TransformerParser::GetTransformerCPower(transPowerData,power_transformer[i].Serial_Number); + power_transformer[i].Pk=TransformerParser::GetDisTransformerPk(transParaData,power_transformer[i].Model); + power_transformer[i].Uk=TransformerParser::GetDisTransformerUk(transParaData,power_transformer[i].Model); + double Pk=power_transformer[i].Pk; + double Uk=power_transformer[i].Uk; + power_transformer[i].AReactivePower=TransformerParser::GetTransformerAReactivePower(transPowerData,power_transformer[i].Serial_Number); + power_transformer[i].BReactivePower=TransformerParser::GetTransformerBReactivePower(transPowerData,power_transformer[i].Serial_Number); + power_transformer[i].CReactivePower=TransformerParser::GetTransformerCReactivePower(transPowerData,power_transformer[i].Serial_Number); + power_transformer[i].P0=TransformerParser::GetDisTransformerP0(transParaData,power_transformer[i].Model); + power_transformer[i].I0=TransformerParser::GetDisTransformerI0(transParaData,power_transformer[i].Model); + double P0=power_transformer[i].P0; + double I0=power_transformer[i].I0; + + if (!power_transformer[i].Uk && !power_transformer[i].Pk) + { + QString newModel=power_transformer[i].Model+"-"+QString::number(ratedMVA*1000); + power_transformer[i].Pk=TransformerParser::GetDisTransformerPk(transParaData,newModel); + power_transformer[i].Uk=TransformerParser::GetDisTransformerUk(transParaData,newModel); + power_transformer[i].P0=TransformerParser::GetDisTransformerP0(transParaData,newModel); + power_transformer[i].I0=TransformerParser::GetDisTransformerI0(transParaData,newModel); + Pk=power_transformer[i].Pk; + Uk=power_transformer[i].Uk; + P0=power_transformer[i].P0; + I0=power_transformer[i].I0; + } + + if (!power_transformer[i].Uk && !power_transformer[i].Pk) + { +// QString newModel="S11-M"; +// power_transformer[i].Pk=TransformerParser::GetDisTransformerPk(transParaData,newModel); +// power_transformer[i].Uk=TransformerParser::GetDisTransformerUk(transParaData,newModel); +// power_transformer[i].P0=TransformerParser::GetDisTransformerP0(transParaData,newModel); +// power_transformer[i].I0=TransformerParser::GetDisTransformerI0(transParaData,newModel); +// Pk=power_transformer[i].Pk; +// Uk=power_transformer[i].Uk; +// P0=power_transformer[i].P0; +// I0=power_transformer[i].I0; + + Pk=0.0001; + Uk=0.0001; + P0=0.0001; + I0=0.0001; + } + + power_transformer[i].r=(Pk*UB*UB/(1000*ratedMVA*ratedMVA))*SB/(UN*UN); + power_transformer[i].x=(Uk*UB*UB/(100*ratedMVA))*SB/(UN*UN); //在这,UN为基准电压,UB为额定电压 + power_transformer[i].g=(P0/(1000*UB*UB))*(UN*UN)/SB; + power_transformer[i].b=(I0*ratedMVA/(100*UB*UB))*(UN*UN)/SB; + } + + qDebug()<<"Get Line Parameters:"; + + int ac_no=acline_segment.size(); + for (int i=0;i::iterator it = find_if(list1.begin(), list1.end(), vector_finder(b.right(a-1))); + acline_segment[i].UB=base_voltage[it->no].nominalVoltage; + double UB=acline_segment[i].UB; + std::vector::iterator ac = find_if(ac_kind.begin(), ac_kind.end(), ac_finder(acline_segment[i].GIS_ID)); + double length=acline_segment[i].LongLength/(ac->quantity); + acline_segment[i].secLength = length; + if (!length) + { + length=0.3; + acline_segment[i].LongLength=length; + acline_segment[i].secLength = length; + } + if (acline_segment[i].Model.left(4)=="YJV-") + { + acline_segment[i].Model=acline_segment[i].Model.insert(3,"22"); + } + else if (acline_segment[i].Model.left(5)=="YJLV-") + { + acline_segment[i].Model=acline_segment[i].Model.insert(4,"22"); + } + else if (acline_segment[i].Model.left(9)=="JKLGYJ-10") + { + acline_segment[i].Model=acline_segment[i].Model+"/2"; + } + else if (acline_segment[i].Model.left(9)=="JKLGYJ-16") + { + acline_segment[i].Model=acline_segment[i].Model+"/3"; + } + else if (acline_segment[i].Model.left(9)=="JKLGYJ-25") + { + acline_segment[i].Model=acline_segment[i].Model+"/4"; + } + else if (acline_segment[i].Model.left(9)=="JKLGYJ-35") + { + acline_segment[i].Model=acline_segment[i].Model+"/6"; + } + else if (acline_segment[i].Model.left(9)=="JKLGYJ-50") + { + acline_segment[i].Model=acline_segment[i].Model+"/8"; + } + else if (acline_segment[i].Model.left(9)=="JKLGYJ-70") + { + acline_segment[i].Model=acline_segment[i].Model+"/10"; + } + else if (acline_segment[i].Model.left(9)=="JKLGYJ-95") + { + acline_segment[i].Model=acline_segment[i].Model+"/20"; + } + else if (acline_segment[i].Model.left(10)=="JKLGYJ-120") + { + acline_segment[i].Model=acline_segment[i].Model+"/20"; + } + else if (acline_segment[i].Model.left(10)=="JKLGYJ-150") + { + acline_segment[i].Model=acline_segment[i].Model+"/20"; + } + else if (acline_segment[i].Model.left(10)=="JKLGYJ-185") + { + acline_segment[i].Model=acline_segment[i].Model+"/25"; + } + else if (acline_segment[i].Model.left(10)=="JKLGYJ-240") + { + acline_segment[i].Model=acline_segment[i].Model+"/30"; + } + else if (acline_segment[i].Model.left(10)=="JKLGYJ-300") + { + acline_segment[i].Model=acline_segment[i].Model+"/50"; + } + acline_segment[i].x=(LineTypeParser::GetReactance(lineParaData,acline_segment[i].Model)*length)*SB/(UN*UN); + acline_segment[i].r=(LineTypeParser::GetResistance(lineParaData,acline_segment[i].Model)*length)*SB/(UN*UN); + + if (acline_segment[i].r==0 && acline_segment[i].x==0) + { + acline_segment[i].r=0.8*length*SB/(UN*UN); + acline_segment[i].x=0.7*length*SB/(UN*UN); +// acline_segment[i].r=0.01; +// acline_segment[i].x=0.01; + } + total_length=total_length+length; + } +} diff --git a/readxml/Interface.cpp b/readxml/Interface.cpp new file mode 100644 index 0000000..d83c8a2 --- /dev/null +++ b/readxml/Interface.cpp @@ -0,0 +1,240 @@ +#include "head.h" +#include "transformerparser.h" +#include "linetypeparser.h" +#include "qt_readxml.h" +void Qt_readxml::XmlReaderInterface() +{ + int subNo = substation.size(); + for (int i=0;i::iterator it = find_if(list1.begin(), list1.end(), vector_finder(b.right(a-1))); + L.CIMID = circuit[it->no].ID; + L.MemberOf = circuit[it->no].Substations_res[0]; + dis_line.push_back(L); + + //ȷͷ + // int breakerNo = breaker.size(); + // int headBus; + // for (int i=0;i=0) + { + depth = depth + acline_segment[j].secLength; + j = acline_segment[j].foreheadI; + } + acline_segment[i].depth = depth; + } + + //ұѹӽڶ + int transNo = power_transformer.size(); + for (int i=0;i +#include +//#include "./line_loss.h" +#include "mainfun.cpp" +#include +int callmain(char * args) +{ + //QApplication a(argn,args); + //line_loss w(0); + //w.show(); + //std::cout< +#include +#include +#include +#include +#include +#include +#include +#include + +class total +{ + public: + QString ID; + QString description; + QString name; + int flag; + std::vector Terminal_res; + int island; +}; + +class List +{ + public: + QString ID; + QString name; + int no; + int flag; +}; + +class AC_kind + { + public: + QString GIS_ID; + int quantity; + int calculateTimes; +}; + + +class Substation:public total +{ + public: + std::vector MemberOf_SubControlArea_res; + QString GIS_type; +}; + +class Terminal:public total +{ + public: + std::vector ConductingEquipment_res; + std::vector ConnectivityNode_res; + +}; + + +class BaseVoltage:public total +{ + public: + double nominalVoltage; + std::vector BasePower_res; +}; + +class BasePower:public total +{ + public: + double basePower; +}; + +class ConnectivityNode:public total +{ + public: + std::vector MemberOf_EquipmentContainer_res; +}; + +class ACLineSegment:public total +{ + public: + double LongLength; + double secLength; //每节段长度 + int foreheadI; //上一节段是第i号线路 + double depth; //节段的深度 + QString Model; + std::vector BaseVoltage_res; + int link_from; + int link_to; + std::vector MemberOf_EquipmentContainer_res; + double r; + double x; + double UB; + QString GIS_ID; + QString foreheadLine; + +}; + +class LoadBreakSwitch:public total +{ + public: + QString normalOpen; + std::vector MemberOf_EquipmentContainer_res; + std::vector BaseVoltage_res; + std::vector Circuits_res; +}; + +class BusbarSection:public total +{ + public: + QString Normal_Voltage; + std::vector MemberOf_EquipmentContainer_res; + std::vector BaseVoltage_res; + double PG; + double QG; + double PL; + double QL; + double UB; + int busSequence; +}; + +class Disconnector:public total +{ + public: + QString normalOpen; + std::vector MemberOf_EquipmentContainer_res; + std::vector BaseVoltage_res; + std::vector Circuits_res; +}; + +class PowerTransformer:public total +{ + public: + std::vector MemberOf_EquipmentContainer_res; + std::vector Circuits_res; + std::vector BaseVoltage_res; + QString Serial_Number; + int link_1; + int link_2; + int link_3; + int low; + double ratedMVA; + double APower; + double BPower; + double CPower; + QString Model; + double r; + double x; + double Pk; + double Uk; + double UB; + double AReactivePower; + double BReactivePower; + double CReactivePower; + double g; + double b; + double P0; + double I0; + bool isPublic; + QString foreheadLine; + QString type; + +}; + +class TransformerWinding:public total +{ + public: + std::vector MemberOf_PowerTransformer_res; + std::vector BaseVoltage_res; +}; + +class GroundDisconnector:public total +{ + public: + QString normalOpen; + std::vector Circuits_res; + std::vector BaseVoltage_res; + std::vector MemberOf_EquipmentContainer_res; +}; + +class CompositeSwitch:public total +{ + public: + QString CompositeSwitchType; + std::vector Circuits_res; +}; + +class Circuit:public total +{ + public: + std::vector Substations_res; +}; + +class Bay:public total +{ + public: + std::vector MemberOf_Substation_res; + std::vector BaseVoltage_res; +}; + +class Connector:public total +{ + public: + std::vector MemberOf_EquipmentContainer_res; + int link_from; + int link_to; +}; + +class Fuse:public total +{ + public: + QString normalOpen; + std::vector BaseVoltage_res; + std::vector Circuits_res; +}; + +class Pole:public total +{ + public: + std::vector BaseVoltage_res; + std::vector Circuits_res; +}; + +class Breaker:public total + { + public: + int GIS_ID; + std::vector BaseVoltage_res; + std::vector MemberOf_EquipmentContainer_res; +}; + +class vector_finder //得到与ID号相对应的索引 +{ + public: + vector_finder(QString a):m_i_a(a){} + bool operator ()(const std::vector::value_type &value) + { + return value.ID == m_i_a; + } + private: + QString m_i_a; +}; + +class ac_finder +{ + public: + ac_finder(QString a):m_i_a(a){} + bool operator ()(const std::vector::value_type &value) + { + return value.GIS_ID == m_i_a; + } + private: + QString m_i_a; +}; + +class bus_finder +{ + public: + bus_finder(int a):m_i_a(a){} + bool operator ()(const std::vector::value_type &value) + { + return value.low == m_i_a; + } + private: + int m_i_a; +}; + +class DisSubstation +{ + public: + QString Name; + QString CIMID; + QString Description; + QString MemberOf; +}; + +class DisLine +{ + public: + QString Name; + QString CIMID; + QString Owner; + QString MemberOf; +}; + +class DisSecNode +{ + public: + QString Name; + QString ID; + QString FatherID; + QString LineType; + QString LineID; + double Depth; + double UnitR; + double SecLong; + double G; + double B; +}; + +class DisTrans +{ + public: + QString ID; + QString Name; + QString SecNode; + double Ps; + double P0; + double Up; + double Ip; + double RunRate; + QString Type; + QString UserType; + QString LineID; + double S; +}; + +#endif + + + + + + + diff --git a/readxml/input.cpp b/readxml/input.cpp new file mode 100644 index 0000000..084ab51 --- /dev/null +++ b/readxml/input.cpp @@ -0,0 +1,1162 @@ +#include "head.h" + +//extern vector substation; +//extern vector terminal; +//extern vector base_voltage; +//extern vector base_power; +//extern vector connectivity_node; +//extern vector acline_segment; +//extern vector busbar_section; +//extern vector disconnector; +//extern vector power_transformer; +//extern vector transformer_winding; +//extern vector list1; +//extern vector ground_disconnector; +//extern vector composite_switch; +//extern vector circuit; +//extern vector bay; +//extern vector connector; +//extern vector fuse; +//extern vector pole; +//extern vector load_break_switch; +//extern vector breaker; +//extern vector ac_kind; + +//extern int i1; +//extern int i2; +//extern int i3; +//extern int i4; +//extern int i5; +//extern int i6; +//extern int i7; +//extern int i8; +//extern int i9; +//extern int i10; +//extern int i11; +//extern int i12; +//extern int i13; +//extern int i14; +//extern int i15; +//extern int i16; +//extern int i17; +//extern int i18; +//extern int i19; + + +//extern QStringRef R1; +#include "qt_readxml.h" +bool Qt_readxml::XmlReaderreadFile(QIODevice *file) +{ + setDevice(file); + //std::cout<<"XmlReaderreadFile"<close(); + return 0; +} + +void Qt_readxml::XmlReaderFormList(int i,QString name1,QString id) +{ + //std::cout<<"XmlReaderFormList"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(S.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "Substation") + { + substation.push_back(S); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + S.description=readElementText(); + } + else if(name()=="Naming.name") + { + S.name=readElementText(); + } + else if(name()=="Substation.MemberOf_SubControlArea") + { + R1=attributes().value("resource"); + S.MemberOf_SubControlArea_res.push_back(R1.toString()); + } + else if(name()=="GIS_type") + { + S.GIS_type=readElementText(); + } + } + } + QString name1="substation"; + XmlReaderFormList(i1,name1,S.ID); + i1++; + } +} + +void Qt_readxml::XmlReaderread_Terminal() +{ + //std::cout<<"XmlReaderread_Terminal"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "Terminal") + { + terminal.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="Terminal.ConductingEquipment") + { + R1=attributes().value("resource"); + T1.ConductingEquipment_res.push_back(R1.toString()); + } + else if(name()=="Terminal.ConnectivityNode") + { + R1=attributes().value("resource"); + T1.ConnectivityNode_res.push_back(R1.toString()); + } + } + } + QString name1="terminal"; + XmlReaderFormList(i2,name1,T1.ID); + i2++; + } +} + +void Qt_readxml::XmlReaderread_BaseVoltage() +{ + //std::cout<<"XmlReaderread_BaseVoltage"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "BaseVoltage") + { + base_voltage.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="nominalVoltage") + { + T1.nominalVoltage=readElementText().toDouble(); + } + else if(name()=="BaseVoltage.BasePower") + { + R1=attributes().value("resource"); + T1.BasePower_res.push_back(R1.toString()); + } + } + } + QString name1="base_voltage"; + XmlReaderFormList(i3,name1,T1.ID); + i3++; + } +} + +void Qt_readxml::XmlReaderread_BasePower() +{ + //std::cout<<"XmlReaderread_BasePower"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "BasePower") + { + base_power.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="BasePower.basePower") + { + T1.basePower=readElementText().toDouble(); + } + } + } + QString name1="base_power"; + XmlReaderFormList(i4,name1,T1.ID); + i4++; + } +} + +void Qt_readxml::XmlReaderread_ConnectivityNode() +{ + //std::cout<<"XmlReaderread_ConnectivityNode"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "ConnectivityNode") + { + connectivity_node.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="MemberOf_EquipmentContainer") + { + R1=attributes().value("resource"); + T1.MemberOf_EquipmentContainer_res.push_back(R1.toString()); + } + } + } + QString name1="connectivity_node"; + XmlReaderFormList(i5,name1,T1.ID); + i5++; + } +} + +void Qt_readxml::XmlReaderread_ACLineSegment() +{ + //std::cout<<"XmlReaderread_ACLineSegment"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "ACLineSegment") + { + acline_segment.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="LongLength") + { + T1.LongLength=readElementText().toDouble(); + } + else if(name()=="Model") + { + T1.Model=readElementText(); + } + else if(name()=="ConductingEquipment.BaseVoltage") + { + R1=attributes().value("resource"); + T1.BaseVoltage_res.push_back(R1.toString()); + } + else if(name()=="MemberOf_EquipmentContainer") + { + R1=attributes().value("resource"); + T1.MemberOf_EquipmentContainer_res.push_back(R1.toString()); + } + else if(name()=="GIS_ID") + { + T1.GIS_ID=readElementText(); + } + } + } + QString name1="acline_segment"; + XmlReaderFormList(i6,name1,T1.ID); + i6++; + } +} + +void Qt_readxml::XmlReaderread_BusbarSection() +{ + //std::cout<<"XmlReaderread_BusbarSection"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "BusbarSection") + { + busbar_section.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="Normal_Voltage") + { + T1.Normal_Voltage=readElementText(); + } + else if(name()=="ConductingEquipment.BaseVoltage") + { + R1=attributes().value("resource"); + T1.BaseVoltage_res.push_back(R1.toString()); + } + else if(name()=="MemberOf_EquipmentContainer") + { + R1=attributes().value("resource"); + T1.MemberOf_EquipmentContainer_res.push_back(R1.toString()); + } + } + } + QString name1="busbar_section"; + XmlReaderFormList(i7,name1,T1.ID); + i7++; + } +} + +void Qt_readxml::XmlReaderread_Disconnector() +{ + //std::cout<<"XmlReaderread_Disconnector"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "Disconnector") + { + disconnector.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="Switch.normalOpen") + { + T1.normalOpen=readElementText(); + } + else if(name()=="ConductingEquipment.BaseVoltage") + { + R1=attributes().value("resource"); + T1.BaseVoltage_res.push_back(R1.toString()); + } + else if(name()=="MemberOf_EquipmentContainer") + { + R1=attributes().value("resource"); + T1.MemberOf_EquipmentContainer_res.push_back(R1.toString()); + } + else if(name()=="PowerSystemResource.Circuits") + { + R1=attributes().value("resource"); + T1.Circuits_res.push_back(R1.toString()); + } + } + } + QString name1="disconnector"; + XmlReaderFormList(i8,name1,T1.ID); + i8++; + } +} + +void Qt_readxml::XmlReaderread_PowerTransformer() +{ + //std::cout<<"XmlReaderread_PowerTransformer"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "PowerTransformer") + { + power_transformer.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="ratedMVA") + { + T1.ratedMVA=readElementText().toDouble(); + } + else if(name()=="ConductingEquipment.BaseVoltage") + { + R1=attributes().value("resource"); + T1.BaseVoltage_res.push_back(R1.toString()); + } + else if(name()=="MemberOf_EquipmentContainer") + { + R1=attributes().value("resource"); + T1.MemberOf_EquipmentContainer_res.push_back(R1.toString()); + } + else if(name()=="PowerSystemResource.Circuits") + { + R1=attributes().value("resource"); + T1.Circuits_res.push_back(R1.toString()); + } + else if (name()=="Serial_Number") + { + T1.Serial_Number=readElementText(); + } + else if (name()=="Model") + { + T1.Model=readElementText(); + } + else if (name()=="Type") + { + if(readElementText()=="public") + { + T1.isPublic=true; + } + else + { + T1.isPublic=false; + } + } + } + } + QString name1="power_transformer"; + XmlReaderFormList(i9,name1,T1.ID); + i9++; + } +} + + +void Qt_readxml::XmlReaderread_TransformerWinding() +{ + //std::cout<<"XmlReaderread_TransformerWinding"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "TransformerWinding") + { + transformer_winding.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="TransformerWinding.MemberOf_PowerTransformer") + { + R1=attributes().value("resource"); + T1.MemberOf_PowerTransformer_res.push_back(R1.toString()); + } + else if(name()=="ConductingEquipment.BaseVoltage") + { + R1=attributes().value("resource"); + T1.BaseVoltage_res.push_back(R1.toString()); + } + } + } + QString name1="transformer_winding"; + XmlReaderFormList(i10,name1,T1.ID); + i10++; + } +} + +void Qt_readxml::XmlReaderread_GroundDisconnector() +{ + //std::cout<<"XmlReaderread_GroundDisconnector"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "GroundDisconnector") + { + ground_disconnector.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="Switch.normalOpen") + { + T1.normalOpen=readElementText(); + } + else if(name()=="ConductingEquipment.BaseVoltage") + { + R1=attributes().value("resource"); + T1.BaseVoltage_res.push_back(R1.toString()); + } + else if(name()=="MemberOf_EquipmentContainer") + { + R1=attributes().value("resource"); + T1.MemberOf_EquipmentContainer_res.push_back(R1.toString()); + } + else if(name()=="PowerSystemResource.Circuits") + { + R1=attributes().value("resource"); + T1.Circuits_res.push_back(R1.toString()); + } + } + } + QString name1="ground_disconnector"; + XmlReaderFormList(i11,name1,T1.ID); + i11++; + } +} + +void Qt_readxml::XmlReaderread_CompositeSwitch() +{ + //std::cout<<"XmlReaderread_CompositeSwitch"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "CompositeSwitch") + { + composite_switch.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="CompositeSwitchType") + { + T1.CompositeSwitchType=readElementText(); + } + else if(name()=="PowerSystemResource.Circuits") + { + R1=attributes().value("resource"); + T1.Circuits_res.push_back(R1.toString()); + } + } + } + QString name1="composite_switch"; + XmlReaderFormList(i12,name1,T1.ID); + i12++; + } +} + +void Qt_readxml::XmlReaderread_Circuit() +{ + //std::cout<<"XmlReaderread_Circuit"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "Circuit") + { + circuit.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="Substations") + { + R1=attributes().value("resource"); + T1.Substations_res.push_back(R1.toString()); + } + } + } + QString name1="circuit"; + XmlReaderFormList(i13,name1,T1.ID); + i13++; + } +} + +void Qt_readxml::XmlReaderread_Bay() +{ + //std::cout<<"XmlReaderread_Bay"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "Bay") + { + bay.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="ConductingEquipment.BaseVoltage") + { + R1=attributes().value("resource"); + T1.BaseVoltage_res.push_back(R1.toString()); + } + else if(name()=="VoltageLevel.MemberOf_Substation") + { + R1=attributes().value("resource"); + T1.MemberOf_Substation_res.push_back(R1.toString()); + } + } + } + QString name1="bay"; + XmlReaderFormList(i14,name1,T1.ID); + i14++; + } +} + +void Qt_readxml::XmlReaderread_Connector() +{ + //std::cout<<"XmlReaderread_Connector"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "Connector") + { + connector.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="MemberOf_EquipmentContainer") + { + R1=attributes().value("resource"); + T1.MemberOf_EquipmentContainer_res.push_back(R1.toString()); + } + } + } + QString name1="connector"; + XmlReaderFormList(i15,name1,T1.ID); + i15++; + } +} + +void Qt_readxml::XmlReaderread_Fuse() +{ + // std::cout<<"XmlReaderread_Fuse"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "Fuse") + { + fuse.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="normalOpen") + { + T1.normalOpen=readElementText(); + } + else if(name()=="ConductingEquipment.BaseVoltage") + { + R1=attributes().value("resource"); + T1.BaseVoltage_res.push_back(R1.toString()); + } + else if(name()=="PowerSystemResource.Circuits") + { + R1=attributes().value("resource"); + T1.Circuits_res.push_back(R1.toString()); + } + } + } + QString name1="fuse"; + XmlReaderFormList(i16,name1,T1.ID); + i16++; + } +} + +void Qt_readxml::XmlReaderread_Pole() +{ + //std::cout<<"XmlReaderread_Pole"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "Pole") + { + pole.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="ConductingEquipment.BaseVoltage") + { + R1=attributes().value("resource"); + T1.BaseVoltage_res.push_back(R1.toString()); + } + else if(name()=="PowerSystemResource.Circuits") + { + R1=attributes().value("resource"); + T1.Circuits_res.push_back(R1.toString()); + } + } + } + QString name1="pole"; + XmlReaderFormList(i17,name1,T1.ID); + i17++; + } +} + +void Qt_readxml::XmlReaderread_LoadBreakSwitch() +{ + //std::cout<<"XmlReaderread_LoadBreakSwitch"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "LoadBreakSwitch" ) + { + load_break_switch.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="normalOpen") + { + T1.normalOpen=readElementText(); + } + else if(name()=="MemberOf_EquipmentContainer") + { + R1=attributes().value("resource"); + T1.MemberOf_EquipmentContainer_res.push_back(R1.toString()); + } + else if(name()=="ConductingEquipment.BaseVoltage") + { + R1=attributes().value("resource"); + T1.BaseVoltage_res.push_back(R1.toString()); + } + else if(name()=="PowerSystemResource.Circuits") + { + R1=attributes().value("resource"); + T1.Circuits_res.push_back(R1.toString()); + } + } + } + QString name1="load_break_switch"; + XmlReaderFormList(i18,name1,T1.ID); + i18++; + } +} + +void Qt_readxml::XmlReaderread_Breaker() +{ + //std::cout<<"XmlReaderread_Breaker"<::iterator it = find_if(list1.begin(), list1.end(), vector_finder(T1.ID)); //得到与ID号相对应的元素 + if(it==list1.end()) + { + while(!atEnd()) + { + readNext(); + if(isEndElement()) + { + if(name() == "Breaker" ) + { + breaker.push_back(T1); + break; + } + } + if(isStartElement()) + { + if(name()=="Naming.description") + { + T1.description=readElementText(); + } + else if(name()=="Naming.name") + { + T1.name=readElementText(); + } + else if(name()=="MemberOf_EquipmentContainer") + { + R1=attributes().value("resource"); + T1.MemberOf_EquipmentContainer_res.push_back(R1.toString()); + } + else if(name()=="ConductingEquipment.BaseVoltage") + { + R1=attributes().value("resource"); + T1.BaseVoltage_res.push_back(R1.toString()); + } + } + } + QString name1="breaker"; + XmlReaderFormList(i19,name1,T1.ID); + i19++; + } +} diff --git a/readxml/linetypeparser.cpp b/readxml/linetypeparser.cpp new file mode 100644 index 0000000..9d8ead2 --- /dev/null +++ b/readxml/linetypeparser.cpp @@ -0,0 +1,68 @@ +#include "linetypeparser.h" +#include +//#include +QSharedPointer LineTypeParser::msharedPointer=QSharedPointer(); + +LineTypeParser::LineTypeParser(QObject *parent) : + QObject(parent) +{ +} + + +void LineTypeParser::ReadData(const QString &file) +{ + if(!QFile::exists(file)) + { + //QMessageBox::warning(0,"警告","线路型号文件不存在!"); + return; + + } + QFile _file(file); + if(_file.open(QIODevice::ReadOnly)) + { + QString line; + QStringList sep; + QTextStream stream(&_file); + while(!stream.atEnd()) + { + line=stream.readLine(); + sep=line.split(','); + LineParameter linePara; + linePara.x=0.4; + linePara.r=sep.at(8).toDouble(); + QHash *hash=LineTypeParser::msharedPointer.data();//仅仅为了后面使用方便。 + QString lineType=sep.at(1); + lineType.remove(0,1); + lineType.remove(lineType.length()-1,1); + (*hash)[lineType.trimmed()]=linePara; + + } + _file.close(); + } +} + +double LineTypeParser::GetReactance(const QString &file, const QString &type) +{ + + if(LineTypeParser::msharedPointer.isNull()) + { + LineTypeParser::msharedPointer=QSharedPointer(new HashType); + LineTypeParser::ReadData(file); + } + QHash hash=*LineTypeParser::msharedPointer;//仅仅为了后面使用方便。 + return hash[type.trimmed()].x; + +} + +double LineTypeParser::GetResistance(const QString &file, const QString &type) +{ + + if(LineTypeParser::msharedPointer.isNull()) + { + LineTypeParser::msharedPointer=QSharedPointer(new HashType); + LineTypeParser::ReadData(file); + } + QHash hash=*LineTypeParser::msharedPointer;//仅仅为了后面使用方便。 + return hash[type.trimmed()].r; + +} diff --git a/readxml/linetypeparser.h b/readxml/linetypeparser.h new file mode 100644 index 0000000..f7d38df --- /dev/null +++ b/readxml/linetypeparser.h @@ -0,0 +1,33 @@ +#ifndef LINETYPEPARSER_H +#define LINETYPEPARSER_H + +#include +#include +#include +#include +#include +class LineTypeParser : public QObject +{ + Q_OBJECT + typedef struct + { + double x; + double r; + } LineParameter; + typedef QHash HashType; +private: + static QSharedPointer msharedPointer; +public: + static double GetReactance(const QString &file,const QString &type); + static double GetResistance(const QString &file,const QString &type); +private: + explicit LineTypeParser(QObject *parent = 0); + static void ReadData(const QString &file); + +signals: + +public slots: + +}; + +#endif // LINETYPEPARSR_H diff --git a/readxml/mainfun.cpp b/readxml/mainfun.cpp new file mode 100644 index 0000000..ade15ea --- /dev/null +++ b/readxml/mainfun.cpp @@ -0,0 +1,117 @@ +#include +#include +#include "head.h" +#include "transformerparser.h" +#include "linetypeparser.h" +#include +#include +#include +#include +//extern vector ResContainer; +//extern vector Notfound; + +//extern int i1; +//extern int i2; +//extern int i3; +//extern int i4; +//extern int i5; +//extern int i6; +//extern int i7; +//extern int i8; +//extern int i9; +//extern int i10; +//extern int i11; +//extern int i12; +//extern int i13; +//extern int i14; +//extern int i15; +//extern int i16; +//extern int i17; +//extern int i18; +//extern int i19; +#include "qt_readxml.h" +int mainfun(const QString &CIMFile) +{ +// QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GBK")); +// QTextCodec::setCodecForLocale(QTextCodec::codecForName("GBK")); +// QTextCodec::setCodecForTr(QTextCodec::codecForName("GBK")); + //QCoreApplication a(argc, argv); + //QTextCodec::setCodecForTr(QTextCodec::codecForName("gb18030")); + //QString CircuitName="朝电914"; + std::cout<<"parseing "< +#include +using namespace std; +bool Qt_readxml::XmlReaderwriteFile(QIODevice *file_output) +{ + //std::cout<<"XmlReaderwriteFile"<totalBus) + { + totalBus=acline_segment[i].link_to; + maxIsland=acline_segment[i].island; + } + } + for (int i=0;itotalBus) + { + totalBus=power_transformer[i].link_2; + maxIsland=power_transformer[i].island; + } + } + for (int i=0;ibusNo) + // busNo=acline_segment[i].link_from; + // if (acline_segment[i].link_to>busNo) + // busNo=acline_segment[i].link_to; + // } + // for (int i=0;ibusNo) + // busNo=power_transformer[i].link_1; + // if (power_transformer[i].link_2>busNo) + // busNo=power_transformer[i].link_2; + // } + // double basePower= base_power[0].basePower; + // //out<::iterator it = find_if(power_transformer.begin(), power_transformer.end(), bus_finder(busbar_section[i].flag)); //得到与ID号相对应的元素 + // if(it!=power_transformer.end()) + // { + // double PL=((it->APower)+(it->BPower)+(it->CPower))/(base_power[0].basePower*1000); + // double QL=((it->AReactivePower)+(it->BReactivePower)+(it->CReactivePower))/(base_power[0].basePower*1000); + // if (PL==0 && QL==0) + // { + // out<total_length; + return 0; +} diff --git a/readxml/output6.cpp b/readxml/output6.cpp new file mode 100644 index 0000000..521b563 --- /dev/null +++ b/readxml/output6.cpp @@ -0,0 +1,60 @@ +#include "head.h" +//int extern balance_node; +#include "qt_readxml.h" +#include +#include +using namespace std; +bool Qt_readxml::XmlReaderContactPoint(QIODevice *file7) +{ + QTextStream out(file7); + for (int j=1;j<=totalBus;j++) + { + int count=0; + int line=acline_segment.size(); + vector lineOfCircuit; + for (int i=0;i +#include +using namespace std; +bool Qt_readxml::XmlReaderDisnetReconfig(QIODevice *file8) +{ + //std::cout<<"XmlReaderwriteFile"< +#include +#include "head.h" +class Qt_readxml : public QXmlStreamReader +{ +public: + Qt_readxml(); +public: + std::vector ResContainer; + std::vector Notfound; + std::vector substation; + std::vector terminal; + std::vector base_voltage; + std::vector base_power; + std::vector connectivity_node; + std::vector acline_segment; + std::vector busbar_section; + std::vector disconnector; + std::vector power_transformer; + std::vector transformer_winding; + std::vector list1; + std::vector ground_disconnector; + std::vector composite_switch; + std::vector circuit; + std::vector bay; + std::vector connector; + std::vector fuse; + std::vector pole; + std::vector load_break_switch; + std::vector breaker; + std::vector ac_kind; + std::vector dis_substation; + std::vector dis_line; + std::vector dis_sec_node; + std::vector dis_trans; + std::vector busContainer; + std::vector nextBus; + double total_length; + QStringRef R1; + QString str; + int i1; + int i2; + int i3; + int i4; + int i5; + int i6; + int i7; + int i8; + int i9; + int i10; + int i11; + int i12; + int i13; + int i14; + int i15; + int i16; + int i17; + int i18; + int i19; + QString cn; + int bus_no; + int balance_node; + int k; + int isAcnode; //是否为孤点的标记,1为是孤点 + int maxIsland; //最大的拓扑岛 + int totalLine; + int totalBus; + /////////////////////// + bool XmlReaderreadFile(QIODevice *file); + void XmlReaderread(); + void XmlReaderTopologyAnalyse(); + void XmlReaderDealData(); + void XmlReaderInterface(); + bool XmlReaderwriteFile(QIODevice *file1); + bool XmlReaderzero_rx(QIODevice *file2); + bool XmlReadernone_trans_pq(QIODevice *file3); + bool XmlReadernone_trans_rx(QIODevice *file4); + bool XmlReaderline_info(QIODevice *file5); + bool XmlReadertrans_info(QIODevice *file6); + bool XmlReaderTotalLineLenghth(QIODevice *file);//杜孟远加的 + bool XmlReaderContactPoint(QIODevice *file7); + bool XmlReaderDisnetReconfig(QIODevice *file8); + void XmlReaderread_Substation(); + void XmlReaderread_Terminal(); + void XmlReaderread_BaseVoltage(); + void XmlReaderread_BasePower(); + void XmlReaderread_VoltageLevel(); + void XmlReaderread_ConnectivityNode(); + void XmlReaderread_ACLineSegment(); + void XmlReaderread_LoadBreakSwitch(); + void XmlReaderread_BusbarSection(); + void XmlReaderread_Disconnector(); + void XmlReaderread_PowerTransformer(); + void XmlReaderread_TransformerWinding(); + void XmlReaderread_GroundDisconnector(); + void XmlReaderread_CompositeSwitch(); + void XmlReaderread_Circuit(); + void XmlReaderread_Bay(); + void XmlReaderread_Connector(); + void XmlReaderread_Fuse(); + void XmlReaderread_Pole(); + void XmlReaderread_Breaker(); + void XmlReaderFormList(int i,QString name1,QString id); + void XmlReaderInputResource(int i); + int XmlReaderFindResource(int j, int n, int sign); + void XmlReaderFindResource1(int i); + void XmlReaderFindResource2(int i); + void XmlReaderdeal_ac(); + +}; + +#endif // QT_READXML_H diff --git a/readxml/topology.cpp b/readxml/topology.cpp new file mode 100644 index 0000000..b6f06d8 --- /dev/null +++ b/readxml/topology.cpp @@ -0,0 +1,390 @@ +#include "head.h" +#include + +//extern vector ResContainer; +//extern vector Notfound; +//extern QString cn; +//extern int bus_no; +//extern int balance_node; +//extern int k; +#include "qt_readxml.h" +void Qt_readxml::XmlReaderTopologyAnalyse() + +{ + k=0; + bus_no=busbar_section.size(); + int terminal_no=terminal.size(); + ResContainer.clear(); + Notfound.clear(); + for (int i=0;i::iterator it = find_if(list1.begin(), list1.end(), vector_finder(ResContainer[0].remove(0,1))); //得到与ID号相对应的元素 + if(it!=list1.end()) + { + QString a; + type=it->name; + if (type=="busbar_section") + { + busbar_section[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="substation") + { + substation[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="connectivity_node") + { + connectivity_node[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="acline_segment") + { + acline_segment[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="disconnector") + { + disconnector[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="power_transformer") + { + power_transformer[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="transformer_winding") + { + transformer_winding[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="ground_disconnector") + { + ground_disconnector[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="composite_switch") + { + composite_switch[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="circuit") + { + circuit[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="bay") + { + bay[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="connector") + { + connector[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="fuse") + { + fuse[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="pole") + { + pole[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="load_break_switch") + { + load_break_switch[it->no].Terminal_res.push_back(terminal[i].ID); + } + else if (type=="breaker") + { + breaker[it->no].Terminal_res.push_back(terminal[i].ID); + } + } + //else if(ResContainer[0].left(2)=="CN") + else + { + ConnectivityNode CN; + CN.ID = ResContainer[0]; + CN.Terminal_res.push_back(terminal[i].ID); + CN.flag = 0; + connectivity_node.push_back(CN); + QString name="connectivity_node"; + XmlReaderFormList(i5,name,CN.ID); + i5++; + Notfound.push_back(ResContainer[0]); + } + + ResContainer.erase(ResContainer.begin()); + } + } + int i=0; + if (!bus_no) + { + BusbarSection T1; + T1.flag=0; + T1.BaseVoltage_res.push_back(acline_segment[i].BaseVoltage_res[0]); + T1.Terminal_res.push_back(acline_segment[i].Terminal_res[0]); + T1.busSequence=0; + busbar_section.push_back(T1); + bus_no++; + } + int ac_no=acline_segment.size(); + + for (int i=0;i::iterator it = find_if(ac_kind.begin(), ac_kind.end(), ac_finder(acline_segment[i].GIS_ID)); //得到与ID号相对应的元素 + if(it==ac_kind.end()) + { + AC_kind A; + A.GIS_ID=acline_segment[i].GIS_ID; + A.quantity=1; + A.calculateTimes=0; + ac_kind.push_back(A); + } + else + { + (it->quantity)++; + } + } + + int j=0; + for (i=0;i::iterator it = find_if(list1.begin(), list1.end(), vector_finder(ResContainer[0])); //得到与ID号相对应的元素 + ResContainer.erase(ResContainer.begin()); + if(it!=list1.end()) + { + type=it->name; + if (type=="terminal" && !terminal[it->no].flag) + { + terminal[it->no].flag=n; + terminal[it->no].island=j; + ResContainer.push_back(terminal[it->no].ConductingEquipment_res[0].remove(0,1)); + ResContainer.push_back(terminal[it->no].ConnectivityNode_res[0].remove(0,1)); + } + + else if (type=="connectivity_node" && !connectivity_node[it->no].flag) + { + connectivity_node[it->no].flag=n; + connectivity_node[it->no].island = j; + int no1=connectivity_node[it->no].Terminal_res.size(); + if (no1) + { + for (int m=0;mno].Terminal_res[m]); + } + } + } + + else if (type=="acline_segment") + { + isAcnode = 0; + acline_segment[it->no].island=j; + if (!acline_segment[it->no].link_from) + { + acline_segment[it->no].link_from=n; + nextBus.push_back(acline_segment[it->no].ID); + sign=0; + } + else if (!acline_segment[it->no].link_to) + { + int no1=acline_segment[it->no].Terminal_res.size(); + if (no1) + { + for (int m=0;mno].Terminal_res[m]); + } + } + acline_segment[it->no].link_to=n; + sign=0; + std::vector::iterator ac = find_if(ac_kind.begin(), ac_kind.end(), ac_finder(acline_segment[it->no].GIS_ID)); + (ac->calculateTimes)++; + } + } + + else if (type=="load_break_switch" && !load_break_switch[it->no].flag) + { + load_break_switch[it->no].flag=n; + load_break_switch[it->no].island=j; + int no1=load_break_switch[it->no].Terminal_res.size(); + if (no1) + { + for (int m=0;mno].Terminal_res[m]); + } + } + + } + + else if (type=="disconnector" && !disconnector[it->no].flag) + { + disconnector[it->no].flag=n; + disconnector[it->no].island=j; + int no1=disconnector[it->no].Terminal_res.size(); + if (no1) + { + for (int m=0;mno].Terminal_res[m]); + } + } + } + + else if (type=="transformer_winding"&& !transformer_winding[it->no].flag) + { + isAcnode = 0; + int a=transformer_winding[it->no].MemberOf_PowerTransformer_res[0].length(); + QString b=transformer_winding[it->no].MemberOf_PowerTransformer_res[0]; + std::vector::iterator trans = find_if(list1.begin(), list1.end(), vector_finder(b.right(a-1))); + transformer_winding[it->no].island = j; + transformer_winding[it->no].flag = n; + if (!power_transformer[trans->no].link_1) + { + power_transformer[trans->no].link_1=n; + power_transformer[trans->no].island=j; + sign=0; + //isAcnode = 0; + if (transformer_winding[it->no].description=="低压侧绕组") + { + power_transformer[trans->no].low=n; + } + int winding_no=transformer_winding.size(); + for (int m=0;mno)) + { + nextBus.push_back(transformer_winding[m].ID); + } + } + } + else if (!power_transformer[trans->no].link_2&&power_transformer[trans->no].link_1!=n) + { + power_transformer[trans->no].link_2=n; + sign=0; + //isAcnode = 0; + if (transformer_winding[it->no].description=="低压侧绕组") + { + power_transformer[trans->no].low=n; + } + if (transformer_winding[it->no].Terminal_res.size()) + { + ResContainer.push_back(transformer_winding[it->no].Terminal_res[0]); + } + } + else if (!power_transformer[trans->no].link_3&&power_transformer[trans->no].link_2!=n &&power_transformer[trans->no].link_1!=n) + { + power_transformer[trans->no].link_3=n; + sign=0; + //isAcnode = 0; + if (transformer_winding[it->no].description=="低压侧绕组") + { + power_transformer[trans->no].low=n; + } + if (transformer_winding[it->no].Terminal_res.size()) + { + ResContainer.push_back(transformer_winding[it->no].Terminal_res[0]); + } + } + } + + else if (type=="connector" && !connector[it->no].flag) + { + connector[it->no].link_from=n; + connector[it->no].island=j; + int no1=connector[it->no].Terminal_res.size(); + if (no1) + { + for (int m=0;mno].Terminal_res[m]); + } + + } + } + + else if (type=="fuse" && !fuse[it->no].flag) + { + fuse[it->no].flag=n; + fuse[it->no].island=j; + int no1=fuse[it->no].Terminal_res.size(); + if (no1) + for (int m=0;mno].Terminal_res[m]); + } + } + + else if (type=="ground_disconnector" && !ground_disconnector[it->no].flag) + { + ground_disconnector[it->no].flag=n; + ground_disconnector[it->no].island=j; + int no1=ground_disconnector[it->no].Terminal_res.size(); + for (int m=0;mno].Terminal_res[m]); + } + } + + else if (type=="breaker" && !breaker[it->no].flag) + { + breaker[it->no].flag=n; + breaker[it->no].island=j; + int no1=breaker[it->no].Terminal_res.size(); + if (no1) + { + for (int m=0;mno].Terminal_res[m]); + } + } + } + else if (type=="busbar_section" && !busbar_section[it->no].flag) + { + int no1=busbar_section[it->no].Terminal_res.size(); + if (no1) + { + for (int m=0;mno].Terminal_res[m]); + } + } + busbar_section[it->no].flag=n; + busbar_section[it->no].island=j; + //balance_node=n; + } + } + } + while (ResContainer.size()) + { + XmlReaderFindResource(j,n,sign); + } + return sign; +} diff --git a/readxml/transformerparser.cpp b/readxml/transformerparser.cpp new file mode 100644 index 0000000..a466d3b --- /dev/null +++ b/readxml/transformerparser.cpp @@ -0,0 +1,231 @@ +#include "transformerparser.h" +//QHash *TransformerParser::mTransHash=NULL; +//#include +QSharedPointer > TransformerParser::msharedPoint=QSharedPointer >(); +QSharedPointer > TransformerParser::mTransRXsharedPoint=QSharedPointer >(); +TransformerParser::TransformerParser(QObject *parent) : + QObject(parent) +{ +} + +double TransformerParser::GetTransformerAPower(const QString &file,const QString &id) +{ + if(TransformerParser::msharedPoint.isNull()) + { + TransformerParser::msharedPoint=QSharedPointer >(new QHash); + TransformerParser::ReadData(file); + } + QHash *pHash=TransformerParser::msharedPoint.data();//仅仅为了后面使用方便。 + if(pHash->contains("id")) + { + qDebug()<<"found\n"; + } + return (*pHash)[id.trimmed()].A; + + +} + +double TransformerParser::GetTransformerBPower(const QString &file,const QString &id) +{ + if(TransformerParser::msharedPoint.isNull()) + { + TransformerParser::msharedPoint=QSharedPointer >(new QHash); + TransformerParser::ReadData(file); + } + QHash *pHash=TransformerParser::msharedPoint.data();//仅仅为了后面使用方便。 + return (*pHash)[id.trimmed()].B; + +} + +double TransformerParser::GetTransformerCPower(const QString &file,const QString &id) +{ + if(TransformerParser::msharedPoint.isNull()) + { + TransformerParser::msharedPoint=QSharedPointer >(new QHash); + TransformerParser::ReadData(file); + } + QHash *pHash=TransformerParser::msharedPoint.data();//仅仅为了后面使用方便。 + return (*pHash)[id.trimmed()].C; + + +} + + +bool TransformerParser::ReadData(const QString &file) +{ + if(!QFile::exists(file)) + { + // QMessageBox::warning(0,"警告","变压器参数文件不存在!"); + return false; + + } + QFile _file(file); + if(_file.open(QIODevice::ReadOnly)) + { + QString line; + QStringList sep; + QTextStream stream(&_file); +// stream.readLine();//跳过第一行 +// stream.readLine();//跳过第二行 + while(!stream.atEnd()) + { + line=stream.readLine(); + sep=line.split(','); + ThreePhrasePower power; + bool ok; + power.A=sep.at(14).toDouble(&ok); + if(!ok) + { + continue; + } + power.B=sep.at(15).toDouble(&ok); + if(!ok) + { + continue; + } + power.C=sep.at(16).toDouble(&ok); + if(!ok) + { + continue; + } + power.RA=sep.at(18).toDouble(&ok); + if(!ok) + { + continue; + } + power.RB=sep.at(19).toDouble(&ok); + if(!ok) + { + continue; + } + power.RC=sep.at(20).toDouble(&ok); + if(!ok) + { + continue; + } + QHash *pHash=TransformerParser::msharedPoint.data();//仅仅为了后面使用方便。 + pHash->insert(sep.at(1).trimmed(),power); + + } + _file.close(); + return true; + } + return false; +} + +bool TransformerParser::ReadRXData(const QString &file) +{ + if(!QFile::exists(file)) + { + //QMessageBox::warning(0,"警告","变压器功率文件不存在!"); + return false; + + } + QFile _file(file); + if(_file.open(QIODevice::ReadOnly)) + { + QString line; + QStringList sep; + QTextStream stream(&_file); + while(!stream.atEnd()) + { + line=stream.readLine(); + sep=line.split(','); + TransRX x; + x.Pk=sep.at(2).toDouble(); + x.Uk=sep.at(4).toDouble(); + x.P0=sep.at(1).toDouble(); + x.I0=sep.at(3).toDouble(); + if(x.Uk==0) + { + x.Uk=4; + } + QHash *pHash=TransformerParser::mTransRXsharedPoint.data();//仅仅为了后面使用方便。 + pHash->insert(sep.at(0).trimmed(),x); + } + _file.close(); + return true; + } + return false; +} + +double TransformerParser::GetDisTransformerPk(const QString &file, const QString &id) +{ + if(TransformerParser::mTransRXsharedPoint.isNull()) + { + TransformerParser::mTransRXsharedPoint=QSharedPointer >(new QHash); + TransformerParser::ReadRXData(file); + } + QHash *pHash=TransformerParser::mTransRXsharedPoint.data();//仅仅为了后面使用方便。 + return (*pHash)[id.trimmed()].Pk; + +} + +double TransformerParser::GetDisTransformerUk(const QString &file, const QString &id) +{ + if(TransformerParser::mTransRXsharedPoint.isNull()) + { + TransformerParser::mTransRXsharedPoint=QSharedPointer >(new QHash); + TransformerParser::ReadRXData(file); + } + QHash *pHash=TransformerParser::mTransRXsharedPoint.data();//仅仅为了后面使用方便。 + return (*pHash)[id.trimmed()].Uk; + +} + +double TransformerParser::GetTransformerAReactivePower(const QString &file, const QString &id) +{ + if(TransformerParser::msharedPoint.isNull()) + { + TransformerParser::msharedPoint=QSharedPointer >(new QHash); + TransformerParser::ReadData(file); + } + QHash *pHash=TransformerParser::msharedPoint.data();//仅仅为了后面使用方便。 + return (*pHash)[id.trimmed()].RA; +} + +double TransformerParser::GetTransformerBReactivePower(const QString &file, const QString &id) +{ + if(TransformerParser::msharedPoint.isNull()) + { + TransformerParser::msharedPoint=QSharedPointer >(new QHash); + TransformerParser::ReadData(file); + } + QHash *pHash=TransformerParser::msharedPoint.data();//仅仅为了后面使用方便。 + return (*pHash)[id.trimmed()].RB; +} + +double TransformerParser::GetTransformerCReactivePower(const QString &file, const QString &id) +{ + if(TransformerParser::msharedPoint.isNull()) + { + TransformerParser::msharedPoint=QSharedPointer >(new QHash); + TransformerParser::ReadData(file); + } + QHash *pHash=TransformerParser::msharedPoint.data();//仅仅为了后面使用方便。 + return (*pHash)[id.trimmed()].RC; +} + +double TransformerParser::GetDisTransformerP0(const QString &file, const QString &id) +{ + if(TransformerParser::mTransRXsharedPoint.isNull()) + { + TransformerParser::mTransRXsharedPoint=QSharedPointer >(new QHash); + TransformerParser::ReadRXData(file); + } + QHash *pHash=TransformerParser::mTransRXsharedPoint.data();//仅仅为了后面使用方便。 + return (*pHash)[id.trimmed()].P0; + +} + +double TransformerParser::GetDisTransformerI0(const QString &file, const QString &id) +{ + if(TransformerParser::mTransRXsharedPoint.isNull()) + { + TransformerParser::mTransRXsharedPoint=QSharedPointer >(new QHash); + TransformerParser::ReadRXData(file); + } + QHash *pHash=TransformerParser::mTransRXsharedPoint.data();//仅仅为了后面使用方便。 + return (*pHash)[id.trimmed()].I0; + +} diff --git a/readxml/transformerparser.h b/readxml/transformerparser.h new file mode 100644 index 0000000..f8c08f0 --- /dev/null +++ b/readxml/transformerparser.h @@ -0,0 +1,67 @@ +#ifndef TRANSFORMERPARSER_H +#define TRANSFORMERPARSER_H + + +/*****************************/ +/* 这是一个单件(Singlton)类 */ +/*****************************/ +#include +#include +#include +#include +#include +#include +#include +class TransformerParser : public QObject +{ + Q_OBJECT +public: + +private: + //static bool mFileOpened; + typedef struct + { + double A;//有功 + double B;//有功 + double C;//有功 + double RA;//无功 + double RB;//无功 + double RC;//无功 + } ThreePhrasePower; + + typedef struct + { + double Pk; + double Uk; + double P0; + double I0; + } TransRX; + static QSharedPointer > msharedPoint;//功率 + static QSharedPointer > mTransRXsharedPoint;//阻抗 +public: + static double GetTransformerAPower(const QString &file, const QString &id); + static double GetTransformerBPower(const QString &file, const QString &id); + static double GetTransformerCPower(const QString &file, const QString &id); + static double GetTransformerAReactivePower(const QString &file, const QString &id); + static double GetTransformerBReactivePower(const QString &file, const QString &id); + static double GetTransformerCReactivePower(const QString &file, const QString &id); + static double GetDisTransformerPk(const QString &file, const QString &id); + static double GetDisTransformerUk(const QString &file, const QString &id); + static double GetDisTransformerP0(const QString &file, const QString &id); + static double GetDisTransformerI0(const QString &file, const QString &id); +private: + explicit TransformerParser(QObject *parent = 0); + //static QHash *mTransHash; + static bool ReadData(const QString &file); + static bool ReadRXData(const QString &file);//读阻抗 + + +signals: + +public slots: + +}; + + + +#endif // TRANSFORMERPARSER_H