149 lines
5.6 KiB
C++
149 lines
5.6 KiB
C++
#include "topologyrecorder.h"
|
|
#include <iostream>
|
|
TopologyRecorder::TopologyRecorder(const QHash<QString,BasicElementInfo *>& elementHT):eleHT(elementHT)
|
|
{
|
|
}
|
|
|
|
bool TopologyRecorder::startWithNode(const QString& node)
|
|
{
|
|
if(node=="")
|
|
{
|
|
return true;
|
|
}
|
|
const QHash<QString,BasicElementInfo*> &ht=this->eleHT;
|
|
QString anotherTerminal;
|
|
QVector<QString> anotherTerminalVector;
|
|
anotherTerminalVector=this->nodeToTerminal.value(node);//一个Node可以找到多个与之相连的Terminal
|
|
for(int atI=0;atI<anotherTerminalVector.length();atI++)
|
|
{
|
|
bool foundCate=false;
|
|
anotherTerminal=anotherTerminalVector.at(atI);
|
|
if(this->reachedTerminal.contains(anotherTerminal))
|
|
{
|
|
// std::cout<<anotherTerminal.toStdString()<<"reached"<<std::endl; //@1
|
|
continue;
|
|
}
|
|
this->reachedTerminal[anotherTerminal]=0;
|
|
// std::cout<<"anotherTerminal"<<anotherTerminal.toStdString()<<std::endl;//@1
|
|
Terminal *anotherTerminalP=static_cast<Terminal *>(ht[anotherTerminal]);
|
|
QString ce;
|
|
ce=anotherTerminalP->getConductingEquipment();
|
|
// std::cout<<ce.toStdString()<<"from "<<anotherTerminal.toStdString() <<std::endl;//@1
|
|
QPair<QString,QString> fromTo;
|
|
QString terminalA;
|
|
QString terminalB;
|
|
//通过ACSegmentLine的ID来找Terminal。下同。
|
|
if(ce.startsWith("AC"))
|
|
{
|
|
QString acID=ce;
|
|
fromTo.first=node;
|
|
fromTo.second=acID;
|
|
ACLineSegment *AC=static_cast<ACLineSegment *>(ht[acID]);
|
|
if(!AC)
|
|
{
|
|
// std::cout<<"can not find "<<acID.toStdString()<<std::endl;//@1
|
|
continue;
|
|
}
|
|
terminalA=AC->getTerminalA();
|
|
terminalB=AC->getTerminalB();
|
|
std::cout<<"find"<<AC->getID().toStdString()<<std::endl;
|
|
std::cout<<AC->getNamingDescription().toStdString()<<std::endl;
|
|
foundCate=true;
|
|
}
|
|
if(ce.startsWith("SW"))
|
|
{
|
|
QString swID=ce;
|
|
fromTo.first=node;
|
|
fromTo.second=swID;
|
|
Breaker *SW=static_cast<Breaker *>(ht[swID]);
|
|
if(!SW)
|
|
{
|
|
// std::cout<<"can not SW "<<swID.toStdString()<<std::endl;//@1
|
|
continue;
|
|
}
|
|
//显示开关状态
|
|
if(SW->getOpenState()==true)
|
|
{
|
|
std::cout<<"sw "<<SW->getNamingDescription().toStdString()<<"is open"<<std::endl;
|
|
}
|
|
else
|
|
{
|
|
std::cout<<"sw "<<SW->getNamingDescription().toStdString()<<"is close"<<std::endl;
|
|
}
|
|
terminalA=SW->getTerminalA();
|
|
terminalB=SW->getTerminalB();
|
|
std::cout<<"find"<<SW->getID().toStdString()<<std::endl;
|
|
foundCate=true;
|
|
}
|
|
if(ce.startsWith("BS"))
|
|
{
|
|
//看找到那个Substation了
|
|
BusbarSection *bs=static_cast<BusbarSection *>(ht[ce]);
|
|
if(bs==NULL)
|
|
{
|
|
std::cout<<"not find bussection"<<ce.toStdString()<<std::endl;
|
|
}
|
|
else
|
|
{
|
|
QString container=bs->getEquipmentMemberOf_EquipmentContainer();
|
|
Substation *sfd=static_cast<Substation *>(ht[container]);
|
|
if(sfd==NULL)
|
|
{
|
|
std::cout<<"can not find"<<container.toStdString()<<std::endl;
|
|
}
|
|
else
|
|
{
|
|
std::cout<<"encounter "<<sfd->getNamingDescription().toStdString()<<std::endl;
|
|
}
|
|
}
|
|
continue;
|
|
}
|
|
if(ce.startsWith("TF"))
|
|
{
|
|
QString tfID=ce;
|
|
PowerTransformer *tf=static_cast<PowerTransformer *>(ht[tfID]);
|
|
std::cout<<"TF"<<tf->getNamingDescription().toStdString()<<std::endl;
|
|
//判断一下这个变压器是不是我们需要的
|
|
QString equipmentContainer;
|
|
equipmentContainer=tf->getEquipmentMemberOf_EquipmentContainer();
|
|
Substation *sfd=static_cast<Substation *>(ht[equipmentContainer]);
|
|
if(sfd==NULL)
|
|
{
|
|
std::cout<<"can not find"<<equipmentContainer.toStdString()<<std::endl;
|
|
}
|
|
else
|
|
{
|
|
QString feederID=sfd->getSubstationMemberOf_Feeder();
|
|
if(feederID!="FD-2003")
|
|
{
|
|
std::cout<<tf->getNamingDescription().toStdString()<<"not belong"<<std::endl;
|
|
}
|
|
}
|
|
// foundCate=true;
|
|
}
|
|
if(foundCate)
|
|
{
|
|
this->branch.push_back(fromTo);
|
|
QString nextTerminal;
|
|
nextTerminal=(terminalA==anotherTerminal)?terminalB:terminalA;
|
|
// std::cout<<"new Terminal"<<nextTerminal.toStdString()<<std::endl;//@1
|
|
Terminal *nextTerminalP=static_cast<Terminal *>(ht[nextTerminal]);
|
|
if(!nextTerminalP)
|
|
{
|
|
// std::cout<<"can not terminal "<<nextTerminal.toStdString()<<std::endl;//@1
|
|
continue;
|
|
}
|
|
QString nextNode=nextTerminalP->getConnectivityNode();
|
|
// std::cout<<"next node"<<nextNode.toStdString()<<"from"<<nextTerminal.toStdString()<<std::endl;//@1
|
|
this->startWithNode(nextNode);
|
|
}
|
|
else
|
|
{
|
|
std::cout<<"not found cate "<<ce.toStdString()<<std::endl;
|
|
continue;
|
|
}
|
|
|
|
}
|
|
return true;
|
|
}
|