#include "pch.h" #include "ElectricDataBaseManger.h" #include "math.h" #include "PublicEqpmtID.h" #include "YD_Public_OCC.h" #include #include #include // 用于std::fixed等格式化 #define ISCS_SUBELCMSG_ALLLINEVIEW 101 //ViewID视图ID(一次主接线的视图ID) #define ISCS_SUBELCMSG_ALLLINE1500VVIEW 16 //全线1500V系统视图 add by hcz 2015-10-12 #define ISCS_SUBELCMSG_XMALLLINEVIEW 2101 //ViewID视图ID(厦门一次主接线的视图ID) added by zhangjh on 2016.12.28 ElectricDataBaseManger::ElectricDataBaseManger(void) { m_pDataBase=nullptr; m_CourseID=-1;//课程ID } ElectricDataBaseManger::~ElectricDataBaseManger(void) { } bool ElectricDataBaseManger::SavePowerValue(int trainid,int stationid,string eqpmtName,int datatype,double tvalue) {//保存电力计算数据 if (tvalue<0.0001) { return false; } int64_t time = GetNumTime_Second_2(); std::stringstream ss; ss << "insert into Table_PowerValue(EqpmtName,TrianID,StationID,DataType,Value,OccTime) values('" << eqpmtName << "'," << trainid << "," << stationid << "," << datatype << "," << std::fixed /*<< std::setprecision(6)*/<< tvalue << "," // 控制浮点数格式,精度 << time << ")"; std::string strSql = ss.str(); if(!m_pDataBase->DirectExecute(strSql))//adCmdText = 1,执行SQL语句增加文本 { return false; } return true; } void ElectricDataBaseManger::setDDServerConfig(string configItem, string configValue) { if (configItem == "DataAssociationView") { SetDataAssociationView(configValue); } if (configItem == "EqpmtStartID") { SetEqpmtStartID(stoi(configValue)); } if (configItem == "MainViewID_35kV") { m_nMainViewID_35kV = stoi(configValue); } if (configItem == "MainViewID_1500V") { m_nMainViewID_1500V = stoi(configValue); } if (configItem == "MainViewID_400V") { m_nMainViewID_400V = stoi(configValue); } if (configItem == "Power_Station_Nums") { Power_Station_Nums = stoi(configValue); } if (configItem == "All_Power_Station_Nums") { All_Power_Station_Nums = stoi(configValue); } if (configItem == "Node_Matric_Collom") { NODE_MATRIC_COLLOM = stoi(configValue); } if (configItem == "Node_Matric_Row") { NODE_MATRIC_ROW = stoi(configValue); } if (configItem == "Max_SigleArrowTrain_Nums") { Max_SigleArrowTrain_Nums = stoi(configValue); } if (configItem == "Voltage_Calculate_InitValueV") { Voltage_Calculate_InitValueV = stoi(configValue); } } bool ElectricDataBaseManger::initDDServerConfigInfo() { std::stringstream ss; ss << "Select * from Table_DDServerConfigInfo where RunLineID = " << m_nLineID ; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { std::string sConfigItem = "", sConfigValue = ""; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { sConfigItem = query_result->GetFieldValue("ConfigItem", std::string("")); sConfigValue = query_result->GetFieldValue("ConfigValue", std::string("")); setDDServerConfig(sConfigItem, sConfigValue); } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::initBaseEqpmtDefineInfo() { std::stringstream ss; ss << "Select * from Table_BaseEqpmtDefineInfo where RunLineID = " << m_nLineID; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { int nEqpmtType = -1, nEqpmtID = -1; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { nEqpmtType = query_result->GetFieldValue("EqpmtDefineTypeID", int(-1)); nEqpmtID = query_result->GetFieldValue("EqpmtTypeID", int(-1)); SetEqpmtTypeID(nEqpmtType, nEqpmtID); } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::GetPowerStationFromDB(ELECSTATIONMAP& stationmap)//从数据库中获取电站信息数据 { std::string strSql="truncate table Table_PowerValue"; if(!m_pDataBase->DirectExecute(strSql)) { return false; } std::stringstream ss; ss << "Select * from Table_StationInfo where RunLineID = " << m_nLineID; strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { PowerStationInfo pt;//电站信息 for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { pt.stationID = query_result->GetFieldValue("StationID", int(-1)); pt.nextstationid = query_result->GetFieldValue("NextStation", int(-1)); pt.strstationname = query_result->GetFieldValue("StationName", std::string("")); pt.stationType = query_result->GetFieldValue("Type", int(-1)); pt.ctrlarea = query_result->GetFieldValue("ControlArea", int(-1)); stationmap.insert(ELECSTATIONMAP::value_type(pt.stationID, pt)); } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::GetEqpmt_TouchNet_Track_Relation_FromDB(DCSysMG& DcSys) {//从数据库获取接触网与轨道之间的关系数据 std::stringstream ss; ss << "Select * from Table_TouchNet_Track_Relation where RunLineID = " << m_nLineID; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { Track_Section tracksec; string sTouchNetID = ""; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { tracksec.TrackID = query_result->GetFieldValue("TrackLineID", int(-1));//轨道线路ID tracksec.StartPos = query_result->GetFieldValue("StartPos", int(-1));//轨道起始位置 tracksec.EndPos = query_result->GetFieldValue("EndPos", int(-1));//轨道终点 tracksec.Index = query_result->GetFieldValue("index", int(-1));//索引 sTouchNetID = query_result->GetFieldValue("TouchNetID", std::string("")); DcSys.AdjustTouchNetRelation(sTouchNetID, tracksec); } catch (const std::exception&) { return false; } } } std::stringstream ss_2; ss_2 << "Select * from Table_TouchNetHeadTailInfo where RunLineID = " << m_nLineID; strSql = ss_2.str(); std::shared_ptr query_result_2 = { 0 }; query_result_2 = m_pDataBase->DirectQuery(strSql); if (query_result_2) { int nArrow = -1, nLineType = -1; string sLineID = ""; for (query_result_2->MoveFirst(); !query_result_2->IsEOF(); query_result_2->MoveNext()) { try { nArrow = query_result_2->GetFieldValue("Arrow", int(-1)); nLineType = query_result_2->GetFieldValue("LineType", int(-1)); sLineID = query_result_2->GetFieldValue("LineID", std::string("")); //根据列车运行方向,线路类型和线路ID设置接触网的头尾节点 DcSys.SetHeadTailTouchNet(nArrow, nLineType, sLineID); } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::GetEqpmt_TouchNet_FromDB(ELEEQPMTMAP* ElectricEqpmtMap,TOUCHNETMAP* TouchNetMap) {//从数据库获取接触网信息 std::stringstream ss; ss << "Select * from Table_TouchNetInfo,Table_EqpmtBaseInfo where Table_EqpmtBaseInfo.RunLineID = " << m_nLineID << "and Table_EqpmtBaseInfo.StrID=Table_TouchNetInfo.StrID"; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { ProtectEqpmtRelationMAP::iterator iterProtect; string strEqpmtID = ""; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { CElectricEqpmt_Line_TouchNet* pUnit = new CElectricEqpmt_Line_TouchNet; strEqpmtID = query_result->GetFieldValue("StrID", std::string("")); pUnit->SetEqpmentID(strEqpmtID); pUnit->SetStatus(query_result->GetFieldValue("Status", int(-1))); pUnit->SetEqmpInitStatus(query_result->GetFieldValue("Status", int(-1))); pUnit->SetStationID(query_result->GetFieldValue("StationID", int(-1))); pUnit->SetViewID(query_result->GetFieldValue("ViewID", int(-1))); pUnit->SetBaseType(query_result->GetFieldValue("EqpmtType", int(-1))); pUnit->SetEqpmentName(query_result->GetFieldValue("Name", std::string(""))); pUnit->SetStartStation(query_result->GetFieldValue("StartStationID", int(-1))); pUnit->SetEndStation(query_result->GetFieldValue("EndStationID", int(-1))); pUnit->SetIndex(query_result->GetFieldValue("Index", int(-1))); pUnit->SetRunDirection(query_result->GetFieldValue("Kind", int(-1)));//类型 上行还是下行 for (iterProtect = m_ProtectEqpmtRelationMap.lower_bound(strEqpmtID); iterProtect != m_ProtectEqpmtRelationMap.upper_bound(strEqpmtID); iterProtect++) { pUnit->AddProtect(iterProtect->second.ProtectStrID, iterProtect->second.EventID); } ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); TouchNetMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::GetEqpmt_InPutRelation_FromDB(ELEEQPMTMAP* ElectricEqpmtMap) {//获取设备输入关系 std::stringstream ss; ss << "Select * from Table_InPutRelation where RunLineID = " << m_nLineID; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { ProtectEqpmtRelationMAP::iterator iterProtect; std::string strsourceid = "", strinputid = ""; int relation = -1; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { strsourceid = query_result->GetFieldValue("StrID", std::string("")); strinputid = query_result->GetFieldValue("InputEqpmtStrID", std::string("")); relation = query_result->GetFieldValue("Relation", int(-1)); // 查找源设备 ELEEQPMTMAP::iterator iter = ElectricEqpmtMap->find(strsourceid); if (iter == ElectricEqpmtMap->end()) { continue; } // 查找目标设备 ELEEQPMTMAP::iterator iter1 = ElectricEqpmtMap->find(strinputid); if (iter1 == ElectricEqpmtMap->end()) { continue; } if (relation == EQPMT_RELATIONTYPE_INPUT) //输入关系 { iter->second->AddInputRelation(strinputid); iter1->second->AddOutputRelation(strsourceid); } if (relation == EQPMT_RELATIONTYPE_AUTOBOLTLSWITCH) //备自投开关 左 { if (iter->second->GetBaseType() == OCC_EQPMTTYPE_AUTOBOLT) { ElectricEqpmt_PowerBolt* pbolt = (ElectricEqpmt_PowerBolt*)iter->second; pbolt->SetLeftInputBreak(strinputid); //设置左边输入断路器 //pbolt->m_CtrlMode = AutoBolt_CtrlMode_Auto_Auto; //默认为自投自复 pbolt->SetCtrlMode(AutoBolt_CtrlMode_Auto_Auto); } iter1->second->SetAutoBoltID(strsourceid); iter1->second->SetMotherAutoBolt(strsourceid); if (iter1->second->GetEqpmentType() == Electric_EqpmentType_Breaker) { ElectricEqpmt_Breaker* pbreak = (ElectricEqpmt_Breaker*)iter1->second; pbreak->SetRelationBreakerType(EQPMT_RELATIONTYPE_AUTOBOLTLSWITCH); //设置断路器为类型为左进线 } } if (relation == EQPMT_RELATIONTYPE_AUTOBOLTRSWITCH) //备自投开关 右 { if (iter->second->GetBaseType() == OCC_EQPMTTYPE_AUTOBOLT) //电源开关 { ElectricEqpmt_PowerBolt* pbolt = (ElectricEqpmt_PowerBolt*)iter->second; pbolt->SetRightInputBreak(strinputid); //pbolt->m_CtrlMode = AutoBolt_CtrlMode_Auto_Auto; //默认为自投自复 pbolt->SetCtrlMode(AutoBolt_CtrlMode_Auto_Auto); } iter1->second->SetAutoBoltID(strsourceid); iter1->second->SetMotherAutoBolt(strsourceid); if (iter1->second->GetEqpmentType() == Electric_EqpmentType_Breaker) { ElectricEqpmt_Breaker* pbreak = (ElectricEqpmt_Breaker*)iter1->second; pbreak->SetRelationBreakerType(EQPMT_RELATIONTYPE_AUTOBOLTRSWITCH);//设置断路器为类型为右进线 } } if (relation == EQPMT_RELATIONTYPE_AUTOBOLT) //备自投关系类型锁 { if (iter->second->GetBaseType() == OCC_EQPMTTYPE_AUTOBOLT) { ElectricEqpmt_PowerBolt* pbolt = (ElectricEqpmt_PowerBolt*)iter->second; pbolt->SetRelationBreaker(strinputid); //设置断路器 //pbolt->m_CtrlMode = AutoBolt_CtrlMode_Auto_Auto; //默认为自投自复 pbolt->SetCtrlMode(AutoBolt_CtrlMode_Auto_Auto); } iter1->second->SetAutoBoltID(strsourceid); iter1->second->SetMotherAutoBolt(strsourceid); if (iter1->second->GetEqpmentType() == Electric_EqpmentType_Breaker) { ElectricEqpmt_Breaker* pbreak = (ElectricEqpmt_Breaker*)iter1->second; pbreak->SetRelationBreakerType(EQPMT_RELATIONTYPE_AUTOBOLT); //设置断路器为类型为母联 } } if (relation == EQPMT_RELATIONTYPE_NEXTAUTOBOLT) //下一个备自投 { if (iter->second->GetBaseType() == OCC_EQPMTTYPE_AUTOBOLT) { ElectricEqpmt_PowerBolt* pbolt = (ElectricEqpmt_PowerBolt*)iter->second; pbolt->SetNextBolt(strinputid); //pbolt->m_CtrlMode = AutoBolt_CtrlMode_Auto_Auto; //默认为自投自复 pbolt->SetCtrlMode(AutoBolt_CtrlMode_Auto_Auto); } } if (relation == EQPMT_RELATIONTYPE_AUTOBOLTAASWITCH || relation == EQPMT_RELATIONTYPE_AUTOBOLTAMSWITCH || relation == EQPMT_RELATIONTYPE_AUTOBOLTMMSWITCH) //备自投模式关联设备 { if (iter->second->GetBaseType() == OCC_EQPMTTYPE_AUTOBOLT) { ElectricEqpmt_PowerBolt* pbolt = (ElectricEqpmt_PowerBolt*)iter->second; pbolt->SetModeStatusShowEqpmt(strinputid, relation); //设置备自投模式关联设备 } } } catch (const std::exception&) { return false; } } } return true; } //获取接地开关相关元件信息 add by yangs bool ElectricDataBaseManger::GetEqpmt_EarthSwitchRelation_FromDB(ELEEQPMTMAP* ElectricEqpmtMap) { std::stringstream ss; ss << "Select * from Table_EarthSwitchRelation where RunLineID = " << m_nLineID; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { ProtectEqpmtRelationMAP::iterator iterProtect; std::string strsourceid = "", strinputid = ""; int relation = -1; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { strsourceid = query_result->GetFieldValue("StrID", std::string("")); strinputid = query_result->GetFieldValue("InputEqpmtStrID", std::string("")); relation = query_result->GetFieldValue("Relation", int(-1)); ELEEQPMTMAP::iterator iter = ElectricEqpmtMap->find(strsourceid); if (iter == ElectricEqpmtMap->end()) { continue; } ELEEQPMTMAP::iterator iter1 = ElectricEqpmtMap->find(strinputid); if (iter1 == ElectricEqpmtMap->end()) { continue; } if (relation == EQPMT_RELATIONTYPE_EARTHSWITCH) //断路器关联接地开关 { iter->second->SetEarthSwitchID(strinputid); } if (relation == EQPMT_RELATIONTYPE_EARTHSWITCHINPUT) //接地开关关联的输入 { iter->second->SetEarthSwitchRelationSwitch(strinputid); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::InitDC_StationInfo(DCSysMG& DcSys)//初始化直流车站信息 { std::stringstream ss; ss << "Select * from Table_DCStationInfo where RunLineID = " << m_nLineID; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { Dc_PowerStation DcStationInfo; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { DcStationInfo.SetWorkArea(1);//设置工区 DcStationInfo.SetID(query_result->GetFieldValue("StationID", int(-1)));//设置车站ID DcStationInfo.SetName(query_result->GetFieldValue("StationName", std::string("")));//设置车站名字 DcStationInfo.SetNearStation(query_result->GetFieldValue("PreStationID", int(-1)), query_result->GetFieldValue("NextStationID",int(-1)));//设置临近车站,此处为前一个和下一个车站 DcStationInfo.SetUpTouchNetID(query_result->GetFieldValue("UpTouchNetID",std::string("")));//设置上行接触网ID DcStationInfo.SetDownTouchNetID(query_result->GetFieldValue("DownTouchNetID", std::string("")));//设置下行接触 ID DcStationInfo.SetFeedBackLineLen(stod(query_result->GetFieldValue("upfeedbacklineLenght",std::string(""))), stod(query_result->GetFieldValue("downfeedbacklineLenght",std::string(""))));//设置馈线长度 DcStationInfo.SetContactNetLineLen(stod(query_result->GetFieldValue("upprelineLenght",std::string(""))), stod(query_result->GetFieldValue("downprelineLenght",std::string(""))), stod(query_result->GetFieldValue("downnextlineLenght",std::string(""))), stod(query_result->GetFieldValue("upnextlineLenght", std::string(""))));//设置接触线的长度 //added by zhangjiahua DcStationInfo.SetOverZoneUpSwitchID(query_result->GetFieldValue("OverZoneUpSwitchID",std::string(""))); //设置上行越区隔离开关图元ID DcStationInfo.SetOverZoneDownSwitchID(query_result->GetFieldValue("OverZoneDownSwitchID", std::string(""))); //设置下行越区隔离开关图元ID //xyx新增 begin DcStationInfo.SetFeedUpPreBreakerID(query_result->GetFieldValue("FeedUpPreBreakerID", std::string(""))); //设置上行前一直流馈线断路器图元ID DcStationInfo.SetFeedUpNextBreakerID(query_result->GetFieldValue("FeedUpNextBreakerID", std::string(""))); //设置上行后一直流馈线断路器图元ID DcStationInfo.SetFeedDownPreBreakerID(query_result->GetFieldValue("FeedDownPreBreakerID", std::string(""))); //设置下行前一直流馈线断路器图元ID DcStationInfo.SetFeedDownNextBreakerID(query_result->GetFieldValue("FeedDownNextBreakerID", std::string(""))); //设置下行前一直流馈线断路器图元ID DcStationInfo.SetRectierToTouchNetUnitID(query_result->GetFieldValue("DCPositiveBusID", std::string(""))); //设置直流正极母线图元ID DcStationInfo.SetRectierToRailwayUnitID(query_result->GetFieldValue("DCNegativeBusID", std::string(""))); //设置直流负极母线图元ID DcStationInfo.SetFirstDCInputBreakerUnitID(query_result->GetFieldValue("FirstInputBreakerID", std::string(""))); //设置直流进线开关I图元ID DcStationInfo.SetSecondDCInputBreakerUnitID(query_result->GetFieldValue("SecondInputBreakerID", std::string(""))); //设置直流进线开关II图元ID //xyx新增 end DcSys.AddStationInfo(DcStationInfo);//增加车站信息 } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::InitAc_PowerLineInfo(ACSysMG& AcSys)//初始化交流电力线信息 { //根据基准值计算相应的标幺值,S为视载功率,即容量 double Iac = OCC_POWER_Sacbase/(sqrt(3.0)*OCC_POWER_Vacbase);//交流侧电流基准值,(出自王大论文P25) double Zac = OCC_POWER_Vacbase/(sqrt(3.0)*Iac); double Yac = 1/Zac; AcSys.SetYBZ(Iac,Zac,Yac,OCC_POWER_Sacbase,OCC_POWER_Vacbase); std::stringstream ss; ss << "Select * from Table_PowerLine where LineCalID = " << m_nLineID; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { int nID = -1, category = -1, status = 0; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { nID = query_result->GetFieldValue("ID", int(-1)); if (nID > 0) { PowerLine* pline = new PowerLine; string name = query_result->GetFieldValue("StrID", std::string("")); //int id = atoi((LPCSTR)(_bstr_t)r_set1->GetCollect("ID")); category = query_result->GetFieldValue("Category", int(-1)); status = query_result->GetFieldValue("Status", int(-1)); pline->SetEqpmtInfo(nID, category, status, name); pline->SetLenght(query_result->GetFieldValue("Lenght", int(-1))); double R = stod(query_result->GetFieldValue("R", std::string(""))) / Zac; double X = stod(query_result->GetFieldValue("X", std::string(""))) / Zac; double B = stod(query_result->GetFieldValue("B", std::string(""))) / Yac;//导纳虚部的计算 R = OCC_POWER_R_RATE * pline->GetLenght();//电阻率的实部 X = OCC_POWER_X_RATE * pline->GetLenght();//电阻率的虚部 pline->SetBgkLineID(query_result->GetFieldValue("GraphUnitLineID", int(-1))); pline->SetRXB(R, X, B); pline->SetLineID(query_result->GetFieldValue("LlineID", int(-1)), query_result->GetFieldValue("RlineID", int(-1))); pline->SetBranchGraphUnitID(query_result->GetFieldValue("BranchGraphUnitID", std::string(""))); //设置支路对应图元ID xyx新增 AcSys.AddEqpmtData(pline); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::InitAc_PowerCalNodeInfo(ACSysMG& AcSys)//初始化交流计算节点信息 { std::stringstream ss; ss << "Select * from Table_PowerCalNode where LineCalID = " << m_nLineID; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { CalNode PQNode;//计算节点类 PQNode.ID = query_result->GetFieldValue("NodeID", int(-1));//节点ID PQNode.BgkID = query_result->GetFieldValue("MotherLineID",std::string(""));//母线ID PQNode.Category = query_result->GetFieldValue("Category", int(-1));//节点类型 PQNode.Position = query_result->GetFieldValue("Position", int(-1));//节点位置 PQNode.strName = query_result->GetFieldValue("strName", std::string(""));//节点名称 PQNode.StationID = query_result->GetFieldValue("StationID",int(-1));//车站ID PQNode.Index = query_result->GetFieldValue("Index", int(-1));//节点索引 PQNode.Pis = stod(query_result->GetFieldValue("Pi", std::string("")));//第i节点的有功功率 PQNode.Qis = stod(query_result->GetFieldValue("Qi", std::string(""))); double P = stod(query_result->GetFieldValue("ConsumePowerR", std::string(""))) / OCC_POWER_Sacbase;//消耗功率的实部 double Q = stod(query_result->GetFieldValue("ConsumePowerX", std::string(""))) / OCC_POWER_Sacbase; PQNode.ConsumePowerR = P;//有功功率 PQNode.ConsumePowerX = Q; PQNode.E = stod(query_result->GetFieldValue("E", std::string("")));//系统修正变量 PQNode.F = stod(query_result->GetFieldValue("F", std::string(""))); PQNode.m_IniE = PQNode.E; PQNode.m_IniF = PQNode.F; PQNode.InputV = stod(query_result->GetFieldValue("InputV", std::string("")));//输入电压 PQNode.inputlineid = query_result->GetFieldValue("InputLineID", std::string(""));//输入线ID PQNode.outputlineid = query_result->GetFieldValue("OuputLineID", std::string(""));//输出线ID std::stringstream ss_2; ss_2 << "Select * from Table_NodeRelation where NodeID = " << PQNode.ID; std::string strSql_2 = ss_2.str(); std::shared_ptr query_result_2 = { 0 }; query_result_2 = m_pDataBase->DirectQuery(strSql_2); if (query_result_2) { for (query_result_2->MoveFirst(); !query_result_2->IsEOF(); query_result_2->MoveNext()) { try { PQNode.m_Relations.push_back(query_result_2->GetFieldValue("InLineID", int(-1))); } catch (const std::exception&) { } } } std::stringstream ss_3; ss_3 << "Select * from Table_NodeRelationLine where NodeID = " << PQNode.ID << " and RunLineID = " << m_nLineID; std::string strSql_3 = ss_3.str(); std::shared_ptr query_result_3 = { 0 }; query_result_3 = m_pDataBase->DirectQuery(strSql_3); if (query_result_3) { for (query_result_3->MoveFirst(); !query_result_3->IsEOF(); query_result_3->MoveNext()) { try { SubLine subline; subline.breakerid = query_result_3->GetFieldValue("RelaBreaker", std::string(""));//断路器ID //表中的断路器名称 subline.tranformid = query_result_3->GetFieldValue("RelaTranform", std::string(""));//变压器ID //表中的变压器名称 subline.BaseP = subline.P = stod(query_result_3->GetFieldValue("P", std::string("")));//有功功率基准值 subline.BaseQ = subline.Q = stod(query_result_3->GetFieldValue("Q", std::string("")));//无功功率基准值 subline.type = query_result_3->GetFieldValue("Type",int(-1));//子线类型 PQNode.m_SubLines.push_back(subline); } catch (const std::exception&) { } } } //xyx新增 begin 增加与母线节点相关联的开关图元ID //查找节点ID与PQ节点ID一致的 std::stringstream ss_4; ss_4 << "Select * from Table_LineSwitch where BusID = %d = " << PQNode.ID; std::string strSql_4 = ss_4.str(); std::shared_ptr query_result_4 = { 0 }; query_result_4 = m_pDataBase->DirectQuery(strSql_4); if (query_result_4) { for (query_result_4->MoveFirst(); !query_result_4->IsEOF(); query_result_4->MoveNext()) { try { PQNode.m_RelationsSwitch.push_back(query_result_4->GetFieldValue("SwitchID", std::string(""))); } catch (const std::exception&) { } } } //xyx新增 end AcSys.AddPQNodeData(PQNode); } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::InitAc_PowerLineSwitch(ACSysMG& AcSys) { std::stringstream ss; ss << "Select * from Table_LineSwitch where RunLineID = " << m_nLineID; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { int LineID = query_result->GetFieldValue("LineID", int(-1)); map::iterator iter = AcSys.m_EqpmtInfoMap.find(LineID); if (iter != AcSys.m_EqpmtInfoMap.end()) { PowerLine* pLine = (PowerLine*)iter->second; pLine->AddSwitchID(query_result->GetFieldValue("SwitchID", std::string(""))); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::GetTrackRelationXDData( TrackRelationXDMAP& trackrelationxdmap ) { std::stringstream ss; ss << "Select * from Table_TrackRelationXD where RunLineID = " << m_nLineID; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { TrackRelationXD* ptrackrelationxd = nullptr; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { ptrackrelationxd = new TrackRelationXD; ptrackrelationxd->m_strID = query_result->GetFieldValue("StrID", std::string("")); ptrackrelationxd->m_stationID = query_result->GetFieldValue("StationID", int(-1)); ptrackrelationxd->m_StationName = query_result->GetFieldValue("StationName", std::string("")); ptrackrelationxd->m_Direction = query_result->GetFieldValue("Direction", int(-1)); ptrackrelationxd->m_IsPower = query_result->GetFieldValue("IsPower", int(-1)); ptrackrelationxd->m_SectionNo = query_result->GetFieldValue("SectionNo", int(-1)); ptrackrelationxd->m_NoID = query_result->GetFieldValue("NoID", int(-1)); trackrelationxdmap.insert(make_pair(ptrackrelationxd->m_strID, ptrackrelationxd)); } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::GetEqpmtsFromDB( ELEEQPMTMAP* ElectricEqpmtMap ) { if (ElectricEqpmtMap->size()>0) { ElectricEqpmtMap->clear(); } if (!InitLogicRelationData()) { return FALSE; } if(!GetEqpmtsBeeLineFromDB(ElectricEqpmtMap) || !GetEqpmtsPicUnitFromDB(ElectricEqpmtMap)) { return false; } if (!AddProtectingEqpmt(ElectricEqpmtMap)) { return false; } return true; } bool ElectricDataBaseManger::GetEqpmtsBeeLineFromDB(/* _RecordsetPtr r_set,*/ELEEQPMTMAP* ElectricEqpmtMap ) { string strEqpmtID; ProtectEqpmtRelationMAP::iterator iterProtect; EqpmtCtrlUnionMAP::iterator iterCtrlUnion; int nEqpmtType; int nSubEqpmtType; std::stringstream ss; if (m_nLineID == 300) { ss << "Select * from Table_EqpmtBaseInfo,Table_BaseGraphInfo where Table_BaseGraphInfo.Type = " << OCC_GRAPHUNIT_TYPE_LINE << " and Table_EqpmtBaseInfo.EqpmtType = Table_BaseGraphInfo.ID"; } else if (m_nLineID == 200) { ss << "Select * from Table_EqpmtBaseInfo,Table_BaseGraphInfo where Table_EqpmtBaseInfo.EqpmtType = Table_BaseGraphInfo.ID and RunLineID = " << m_nLineID << " and Table_BaseGraphInfo.type=501 and 2000000 > Table_BaseGraphInfo.ID"; } else { ss << "Select * from Table_EqpmtBaseInfo,Table_BaseGraphInfo where Table_EqpmtBaseInfo.EqpmtType = Table_BaseGraphInfo.ID and RunLineID = " << m_nLineID << " and Table_BaseGraphInfo.type = 501 and " << m_nEqpmtStartID << " < Table_BaseGraphInfo.ID and ViewID in(" << m_strDataAssociationView << ")"; } std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { BaseElectricEqpmt* pUnit = nullptr; //ElectricEqpmt_Line* pLine=new ElectricEqpmt_Line; nEqpmtType = query_result->GetFieldValue("EqpmtType", int(-1)); nSubEqpmtType = query_result->GetFieldValue("SubEqpmtType", int(-1)); if (nEqpmtType == OCC_EQPMTTYPE_110kVACMLine) //110kV母线 { CElectricEqpmt_Line_110kV_BusLine* pLine = new CElectricEqpmt_Line_110kV_BusLine; pUnit = pLine; } else if (nEqpmtType == OCC_EQPMTTYPE_110kvPowerLine) //110kV输电线 { if (nSubEqpmtType == Electric_PowerLine_Input) //进线 { CElectricEqpmt_Line_110kV_PowerLine_Input* pLine = new CElectricEqpmt_Line_110kV_PowerLine_Input; pUnit = pLine; pUnit->SetSubTypeName("进线"); } else { CElectricEqpmt_Line_110kV_PowerLine* pLine = new CElectricEqpmt_Line_110kV_PowerLine; pUnit = pLine; pUnit->SetSubTypeName("输电线"); } } else if (nEqpmtType == OCC_EQPMTTYPE_35kVMOTHERLINE) //35kv母线 { CElectricEqpmt_Line_35kV_BusLine* pLine = new CElectricEqpmt_Line_35kV_BusLine; pUnit = pLine; } else if (nEqpmtType == OCC_EQPMTTYPE_35kvACPowerLine) //35kv输电线 { if (nSubEqpmtType == Electric_PowerLine_Input) { CElectricEqpmt_Line_35kV_PowerLine_Input* pLine = new CElectricEqpmt_Line_35kV_PowerLine_Input; pUnit = pLine; pUnit->SetSubTypeName("进线"); } else if (nSubEqpmtType == Electric_PowerLine_Output) { CElectricEqpmt_Line_35kV_PowerLine_Output* pLine = new CElectricEqpmt_Line_35kV_PowerLine_Output; pUnit = pLine; pUnit->SetSubTypeName("出线"); } else if (nSubEqpmtType == Electric_PowerLine_Feeder) { CElectricEqpmt_Line_35kV_PowerLine_Feeder* pLine = new CElectricEqpmt_Line_35kV_PowerLine_Feeder; pUnit = pLine; pUnit->SetSubTypeName("馈线"); } else { ElectricEqpmt_Line* pLine = new ElectricEqpmt_Line; pUnit = pLine; pUnit->SetSubTypeName("输电线"); } } else if (nEqpmtType == OCC_EQPMTTYPE_400vACMLine) //400V母线 { CElectricEqpmt_Line_400V_BusLine* pLine = new CElectricEqpmt_Line_400V_BusLine; pUnit = pLine; } else if (nEqpmtType == OCC_EQPMTTYPE_400vACPowerLine) //400v输电线 { if (nSubEqpmtType == Electric_PowerLine_Input) { CElectricEqpmt_Line_400V_PowerLine_Input* pLine = new CElectricEqpmt_Line_400V_PowerLine_Input; pUnit = pLine; pUnit->SetSubTypeName("进线"); } else if (nSubEqpmtType == Electric_PowerLine_Feeder) { CElectricEqpmt_Line_400V_PowerLine_Feeder* pLine = new CElectricEqpmt_Line_400V_PowerLine_Feeder; pUnit = pLine; pUnit->SetSubTypeName("馈线"); } else { ElectricEqpmt_Line* pLine = new ElectricEqpmt_Line; pUnit = pLine; pUnit->SetSubTypeName("输电线"); } } else if (nEqpmtType == OCC_EQPMTTYPE_1500vDCMLine) //直流正级母线 { CElectricEqpmt_Line_DC_Positive_BusLine* pLine = new CElectricEqpmt_Line_DC_Positive_BusLine; pUnit = pLine; } else if (nEqpmtType == OCC_EQPMTTYPE_1500VNegativeBusLine) //直流负极母线 { CElectricEqpmt_Line_DC_Negative_BusLine* pLine = new CElectricEqpmt_Line_DC_Negative_BusLine; pUnit = pLine; } else if (nEqpmtType == OCC_EQPMTTYPE_TouchNet) //接触网/轨 { CElectricEqpmt_Line_TouchNet* pLine = new CElectricEqpmt_Line_TouchNet; pUnit = pLine; } else if (nEqpmtType == OCC_EQPMTTYPE_Track) //回流轨 { CElectricEqpmt_Line_Track* pLine = new CElectricEqpmt_Line_Track; pUnit = pLine; } else if (nEqpmtType == OCC_EQPMTTYPE_DCPowerLine) //直流输电线 { if (nSubEqpmtType == Electric_PowerLine_Input) { CElectricEqpmt_Line_DC_PowerLine_Input* pLine = new CElectricEqpmt_Line_DC_PowerLine_Input; pUnit = pLine; pUnit->SetSubTypeName("进线"); } else if (nSubEqpmtType == Electric_PowerLine_Feeder) { CElectricEqpmt_Line_DC_PowerLine_Feeder* pLine = new CElectricEqpmt_Line_DC_PowerLine_Feeder; pUnit = pLine; pUnit->SetSubTypeName("馈线"); } else { ElectricEqpmt_Line* pLine = new ElectricEqpmt_Line; pUnit = pLine; pUnit->SetSubTypeName("输电线"); } } else if (nEqpmtType == OCC_EQPMTTYPE_DC_ReturnLine) //回流线 { CElectricEqpmt_Line_DC_ReturnLine* pLine = new CElectricEqpmt_Line_DC_ReturnLine; pUnit = pLine; } else if (nEqpmtType == OCC_EQPMTTYPE_TouchNet) { CElectricEqpmt_Line_TouchNet* pLine = new CElectricEqpmt_Line_TouchNet; pUnit = pLine; } else { ElectricEqpmt_Line* pLine = new ElectricEqpmt_Line; pUnit = pLine; } strEqpmtID = query_result->GetFieldValue("StrID", std::string("")); pUnit->SetEqpmentID(strEqpmtID); if (pUnit != nullptr) { pUnit->SetBaseTypeName(query_result->GetFieldValue("StrName", std::string(""))); pUnit->SetStatus(query_result->GetFieldValue("Status", int(-1))); pUnit->SetEqmpInitStatus(query_result->GetFieldValue("Status", int(-1))); if (pUnit->GetStatus() == Electric_Eqpmt_Status_ON) { pUnit->SetPower(true); } else if (pUnit->GetStatus() == Electric_Eqpmt_Status_OFF) { pUnit->SetPower(false); } pUnit->SetStationID(query_result->GetFieldValue("StationID", int(-1))); pUnit->SetViewID(query_result->GetFieldValue("ViewID", int(-1))); pUnit->SetBaseType(query_result->GetFieldValue("EqpmtType", int(-1))); pUnit->SetEqpmentName(query_result->GetFieldValue("Name", std::string(""))); pUnit->SetSourceStationID(query_result->GetFieldValue("SourceStation", int(-1))); pUnit->SetControlType(query_result->GetFieldValue("CtrlType", int(-1))); //添加保护设备 if (pUnit->GetStationID() == 0 && (pUnit->GetViewID() == m_nMainViewID_35kV || pUnit->GetViewID() == m_nMainViewID_1500V || pUnit->GetViewID() == m_nMainViewID_400V)) { for (iterProtect = m_ProtectEqpmtRelationMap.lower_bound(strEqpmtID); iterProtect != m_ProtectEqpmtRelationMap.upper_bound(strEqpmtID); iterProtect++) { pUnit->AddProtect(iterProtect->second.ProtectStrID, iterProtect->second.EventID); } } //添加联控设备 for (iterCtrlUnion = m_EqpmtCtrlUnionMap.lower_bound(strEqpmtID); iterCtrlUnion != m_EqpmtCtrlUnionMap.upper_bound(strEqpmtID); iterCtrlUnion++) { pUnit->AddCtrlUnoin(iterCtrlUnion->second.m_OpeStatus, iterCtrlUnion->second.m_PreEqpmtID, iterCtrlUnion->second.m_PreStatus, iterCtrlUnion->second.m_Relation, iterCtrlUnion->second.m_DelayTime, iterCtrlUnion->second.m_Index); } ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::GetEqpmtsPicUnitFromDB( ELEEQPMTMAP* ElectricEqpmtMap ) { string strEqpmtID; string strkey; ProtectValueMap::iterator iterProtectValue; AutoActUnionMAP::iterator iterAutoActUnion; InPutRelationDataMAP::iterator iterHanderRela; EqpmtCtrlAreaRelationMAP::iterator iterEqpmCtrlAreaRela; ProtectEqpmtRelationMAP::iterator iterProtect; EqpmtCtrlUnionMAP::iterator iterCtrlUnion; std::stringstream ss; if (m_nLineID == 300) { ss << "Select * from Table_EqpmtBaseInfo,Table_BaseGraphInfo where Table_BaseGraphInfo.Type = " << OCC_GRAPHUNIT_TYPE_PIC << " and Table_EqpmtBaseInfo.EqpmtType = Table_BaseGraphInfo.ID"; } else if (m_nLineID == 200) { ss << "Select * from Table_EqpmtBaseInfo,Table_BaseGraphInfo where Table_EqpmtBaseInfo.EqpmtType = Table_BaseGraphInfo.ID and RunLineID = " << m_nLineID << " and Table_BaseGraphInfo.type=500 and 2000000 > Table_BaseGraphInfo.ID";//昆明项目特殊处理 add by chenht } else { ss << "Select * from Table_EqpmtBaseInfo,Table_BaseGraphInfo where Table_EqpmtBaseInfo.EqpmtType = Table_BaseGraphInfo.ID and RunLineID = " << m_nLineID << " and Table_BaseGraphInfo.type = 500 and " << m_nEqpmtStartID << " < Table_BaseGraphInfo.ID and Table_EqpmtBaseInfo.ViewID in(" << m_strDataAssociationView << ")"; } std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { BaseElectricEqpmt* pUnit = nullptr; strEqpmtID = query_result->GetFieldValue("StrID", std::string("")); int type = query_result->GetFieldValue("EqpmtType", int(-1)); //设备类型即各图元的ID int subtype = query_result->GetFieldValue("SubEqpmtType", int(-1)); //设备子类型 if (type == OCC_EQPMTTYPE_35kVLineInOutlet || type == OCC_EQPMTTYPE_400VLineInOutlet || type == OCC_EQPMTTYPE_110kVLineInOutlet || type == OCC_EQPMTTYPE_1500VNegativeBusLine || type == OCC_EQPMTTYPE_DC_ReturnLine) { ElectricEqpmt_Line* pLine = new ElectricEqpmt_Line; pUnit = pLine; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } //Noted by zhangjiahua on 2019.4.9 ElectricEqpmt_Breaker* pBaseBreak = nullptr; if (type == OCC_EQPMTTYPE_110kVBreaker) //110kv断路器 { if (subtype == Electric_Breaker_Input) { CElectricEqpmt_Breaker_110kV_Input* pBreak = new CElectricEqpmt_Breaker_110kV_Input; pBaseBreak = pBreak; } else if (subtype == Electric_Breaker_Circuit) { CElectricEqpmt_Breaker_110kV_Circuit* pBreak = new CElectricEqpmt_Breaker_110kV_Circuit; pBaseBreak = pBreak; } else { pBaseBreak = new ElectricEqpmt_Breaker; } pBaseBreak->SetEqpmentType(Electric_EqpmentType_Breaker); } //add by dengt 27.5kv增加故障保护 if (type == OCC_EQPMTTYPE_27_5kVBREAKER) //27.5kv断路器 { pBaseBreak = new ElectricEqpmt_Breaker; pBaseBreak->SetEqpmentType(Electric_EqpmentType_Breaker); } else if (type == OCC_EQPMTTYPE_35kVBREAKER) //35kv断路器 { if (subtype == Electric_Breaker_Input) { CElectricEqpmt_Breaker_35kV_Input* pBreak = new CElectricEqpmt_Breaker_35kV_Input; pBaseBreak = pBreak; } else if (subtype == Electric_Breaker_Output) { CElectricEqpmt_Breaker_35kV_Output* pBreak = new CElectricEqpmt_Breaker_35kV_Output; pBaseBreak = pBreak; } else if (subtype == Electric_Breaker_Feeder) { CElectricEqpmt_Breaker_35kV_Feeder* pBreak = new CElectricEqpmt_Breaker_35kV_Feeder; pBaseBreak = pBreak; } else if (subtype == Electric_Breaker_Circuit) { CElectricEqpmt_Breaker_35kV_Circuit* pBreak = new CElectricEqpmt_Breaker_35kV_Circuit; pBaseBreak = pBreak; } else { pBaseBreak = new ElectricEqpmt_Breaker; } pBaseBreak->SetEqpmentType(Electric_EqpmentType_Breaker); } else if (type == OCC_EQPMTTYPE_400vACControlBreaker) //400V断路器 { if (subtype == Electric_Breaker_Input) { CElectricEqpmt_Breaker_400V_Input* pBreak = new CElectricEqpmt_Breaker_400V_Input; pBaseBreak = pBreak; } else if (subtype == Electric_Breaker_Feeder) { CElectricEqpmt_Breaker_400V_Feeder* pBreak = new CElectricEqpmt_Breaker_400V_Feeder; pBaseBreak = pBreak; } else if (subtype == Electric_Breaker_Circuit) { CElectricEqpmt_Breaker_400V_Circuit* pBreak = new CElectricEqpmt_Breaker_400V_Circuit; pBaseBreak = pBreak; } else { pBaseBreak = new ElectricEqpmt_Breaker; } pBaseBreak->SetEqpmentType(Electric_EqpmentType_Breaker); } else if (type == OCC_EQPMTTYPE_BREAKER_DC) { if (subtype == Electric_Breaker_Input) { CElectricEqpmt_Breaker_DC_Input* pBreak = new CElectricEqpmt_Breaker_DC_Input; pBaseBreak = pBreak; } else if (subtype == Electric_Breaker_Feeder) { CElectricEqpmt_Breaker_DC_Feeder* pBreak = new CElectricEqpmt_Breaker_DC_Feeder; pBaseBreak = pBreak; } else { CElectricEqpmt_Breaker_DC* pBreak = new CElectricEqpmt_Breaker_DC; pBaseBreak = pBreak; } //pBaseBreak->SetEqpmentType(Electric_EqpmentType_Breaker); } if (pBaseBreak != nullptr) { pBaseBreak->SetEqpmentID(strEqpmtID); //if (atoi((LPCSTR)(_bstr_t)r_set->GetCollect("StationID"))==0) //花溪没有假线,不做车站限制 ---delete by dt 20250208 { for (iterProtectValue = m_ProtectValueMap.lower_bound(strEqpmtID); iterProtectValue != m_ProtectValueMap.upper_bound(strEqpmtID); iterProtectValue++) { pBaseBreak->AddProtectRelation(iterProtectValue->second); } for (iterAutoActUnion = m_AutoActUnionMap.lower_bound(strEqpmtID); iterAutoActUnion != m_AutoActUnionMap.upper_bound(strEqpmtID); iterAutoActUnion++) { pBaseBreak->AddActUnoin(iterAutoActUnion->second.m_Sstatus, iterAutoActUnion->second.m_DEqpmtID, iterAutoActUnion->second.m_Dstatus, iterAutoActUnion->second.m_EventID);//added by zhangjh on 2017.4.29 修改遍历map的方式 } } iterHanderRela = m_HanderRelationDataMap.find(strEqpmtID); if (iterHanderRela != m_HanderRelationDataMap.end()) { pBaseBreak->SetBreakHandID(iterHanderRela->second.m_InputEqpmtStrID); } iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID); if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end()) { pBaseBreak->SetControlArea(iterEqpmCtrlAreaRela->second); } if (UpdateEqpmtBaseInfo(query_result, pBaseBreak)) { ElectricEqpmtMap->insert(make_pair(pBaseBreak->GetEqpmentID(), pBaseBreak)); } } else if (type == OCC_EQPMTTYPE_MainLineElement) //主所线路元件 { CElectricEqpmt_SwicthEqpmt* pswitch = new CElectricEqpmt_SwicthEqpmt; pUnit = pswitch; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_PowerTransformer) //动力变压器 { //ElectricEqpmt_Transformer* pTransfrom=new ElectricEqpmt_Transformer; //modified by zhangjiahua on 2019.4.9 CElectricEqpmt_Transformer_Power* pTransfrom = new CElectricEqpmt_Transformer_Power; pUnit = pTransfrom; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_MainTransformer) //主变压器 { //ElectricEqpmt_Transformer* pTransfrom=new ElectricEqpmt_Transformer; //modified by zhangjiahua on 2019.4.9 CElectricEqpmt_Transformer_Main* pTransfrom = new CElectricEqpmt_Transformer_Main; pUnit = pTransfrom; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_TractionTransformer) //牵引变压器 { //ElectricEqpmt_Transformer* pTransfrom=new ElectricEqpmt_Transformer; //modified by zhangjiahua on 2019.4.9 CElectricEqpmt_Transformer_Traction* pTransfrom = new CElectricEqpmt_Transformer_Traction; pUnit = pTransfrom; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_ThreePositong_ELCSWICTH || type == OCC_EQPMTTYPE_110kVSwitch) //三工位隔离开关 { CElectricEqpmt_IsolatingSwitch_ThreePosition* pIsolatingSwitch = new CElectricEqpmt_IsolatingSwitch_ThreePosition; pUnit = pIsolatingSwitch; pUnit->SetEqpmentID(strEqpmtID); iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID); if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end()) { pIsolatingSwitch->SetControlArea(iterEqpmCtrlAreaRela->second); } if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_Power_ELCSWICTH || type == OCC_EQPMTTYPE_27_5kVSwitch) //电动隔离开关 { CElectricEqpmt_IsolatingSwitch_Power* pIsolatingSwitch = new CElectricEqpmt_IsolatingSwitch_Power; pUnit = pIsolatingSwitch; pUnit->SetEqpmentID(strEqpmtID); iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID); if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end()) { pIsolatingSwitch->SetControlArea(iterEqpmCtrlAreaRela->second); } if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_Mannual_ELCSWICTH) //手动隔离开关 { CElectricEqpmt_IsolatingSwitch_Manual* pIsolatingSwitch = new CElectricEqpmt_IsolatingSwitch_Manual; pUnit = pIsolatingSwitch; pUnit->SetEqpmentID(strEqpmtID); iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID); if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end()) { pIsolatingSwitch->SetControlArea(iterEqpmCtrlAreaRela->second); } if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_400vACControlBreaker) //400V断路器 { ElectricEqpmt_Breaker* pBreak = new ElectricEqpmt_Breaker; pUnit = pBreak; pUnit->SetEqpmentID(strEqpmtID); //if (atoi((LPCSTR)(_bstr_t)r_set->GetCollect("StationID"))==0) //张家华 { //add 400断路器保护信息//20230131 for (iterProtectValue = m_ProtectValueMap.lower_bound(strEqpmtID); iterProtectValue != m_ProtectValueMap.upper_bound(strEqpmtID); iterProtectValue++) { pBreak->AddProtectRelation(iterProtectValue->second); } for (iterAutoActUnion = m_AutoActUnionMap.lower_bound(strEqpmtID); iterAutoActUnion != m_AutoActUnionMap.upper_bound(strEqpmtID); iterAutoActUnion++) { pBreak->AddActUnoin(iterAutoActUnion->second.m_Sstatus, iterAutoActUnion->second.m_DEqpmtID, iterAutoActUnion->second.m_Dstatus, iterAutoActUnion->second.m_EventID);//added by zhangjh on 2017.4.29 修改遍历map的方式 } } pBreak->SetEqpmentType(Electric_EqpmentType_Breaker); iterHanderRela = m_HanderRelationDataMap.find(strEqpmtID); if (iterHanderRela != m_HanderRelationDataMap.end()) { pBreak->SetBreakHandID(iterHanderRela->second.m_StrID); } iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID); if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end()) { pBreak->SetControlArea(iterEqpmCtrlAreaRela->second); } if (UpdateEqpmtBaseInfo(query_result, pBreak)) { ElectricEqpmtMap->insert(make_pair(pBreak->GetEqpmentID(), pBreak)); } } else if (type == OCC_EQPMTTYPE_400vACUncontrolBreaker) //400V不可控断路器 { ElectricEqpmt_Breaker* pBreak = new ElectricEqpmt_Breaker; pUnit = pBreak; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_AUTOBOLT_110KV) //110kv备自投 { CElectricEqpmt_PowerBolt_110kV* pbolt = new CElectricEqpmt_PowerBolt_110kV; pUnit = pbolt; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_AUTOBOLT) { if (subtype == Electric_AutoBolt_35kV) { CElectricEqpmt_PowerBolt_35kV* pbolt = new CElectricEqpmt_PowerBolt_35kV; pUnit = pbolt; } else if (subtype == Electric_AutoBolt_110kV) { CElectricEqpmt_PowerBolt_110kV* pbolt = new CElectricEqpmt_PowerBolt_110kV; pUnit = pbolt; } else if (subtype == Electric_AutoBolt_400V) { CElectricEqpmt_PowerBolt_400V* pbolt = new CElectricEqpmt_PowerBolt_400V; pUnit = pbolt; } else { ElectricEqpmt_PowerBolt* pbolt = new ElectricEqpmt_PowerBolt; pUnit = pbolt; } if (pUnit != nullptr) { pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } } else if (type == OCC_EQPMTTYPE_BREAKER_DC) //1500V断路器 { //ElectricEqpmt_Breaker* pBreak=new ElectricEqpmt_Breaker; CElectricEqpmt_Breaker_DC* pBreak = new CElectricEqpmt_Breaker_DC; pUnit = pBreak; pUnit->SetEqpmentID(strEqpmtID); for (iterProtectValue = m_ProtectValueMap.lower_bound(strEqpmtID); iterProtectValue != m_ProtectValueMap.upper_bound(strEqpmtID); iterProtectValue++) { pBreak->AddProtectRelation(iterProtectValue->second); } for (iterAutoActUnion = m_AutoActUnionMap.lower_bound(strEqpmtID); iterAutoActUnion != m_AutoActUnionMap.upper_bound(strEqpmtID); iterAutoActUnion++) { pBreak->AddActUnoin(iterAutoActUnion->second.m_Sstatus, iterAutoActUnion->second.m_DEqpmtID, iterAutoActUnion->second.m_Dstatus, iterAutoActUnion->second.m_EventID);//added by zhangjh on 2017.4.29 修改遍历map的方式 } iterHanderRela = m_HanderRelationDataMap.find(strEqpmtID); if (iterHanderRela != m_HanderRelationDataMap.end()) { pBreak->SetBreakHandID(iterHanderRela->second.m_StrID); } iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID); if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end()) { pBreak->SetControlArea(iterEqpmCtrlAreaRela->second); } if (UpdateEqpmtBaseInfo(query_result, pBreak)) { ElectricEqpmtMap->insert(make_pair(pBreak->GetEqpmentID(), pBreak)); } } else if (type == OCC_EQPMTTYPE_1500vRectifier) //整流器 { ElectricEqpmt_Rectifier* pRectfier = new ElectricEqpmt_Rectifier; pUnit = pRectfier; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_Power_ELCSWICTH || type == OCC_EQPMTTYPE_27_5kVSwitch/*|| type == OCC_EQPMTTYPE_1500vMannualIsolationSwitch*/) //1500v电动隔离开关 { CElectricEqpmt_SwicthEqpmt* pSwicthEqpmt = new CElectricEqpmt_SwicthEqpmt; pUnit = pSwicthEqpmt; pUnit->SetEqpmentID(strEqpmtID); //AddCtrlType(pSwicthEqpmt); iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID); if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end()) { pSwicthEqpmt->SetControlArea(iterEqpmCtrlAreaRela->second); } if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (OCC_EQPMTTYPE_EarthBrake == type || OCC_EQPMTTYPE_GroundDevice == type) { ElectricEqpmt_EarthSwitch* pEarthBrake = new ElectricEqpmt_EarthSwitch; pUnit = pEarthBrake; pUnit->SetEqpmentID(strEqpmtID); //AddCtrlType(pEarthBrake); iterEqpmCtrlAreaRela = m_EqpmtCtrlAreaRelationMap.find(strEqpmtID); if (iterEqpmCtrlAreaRela != m_EqpmtCtrlAreaRelationMap.end()) { pEarthBrake->SetControlArea(iterEqpmCtrlAreaRela->second); } if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_BREAKER_HANDER) //手车 { ElectricEqpmt_BreakHand* pHandr = new ElectricEqpmt_BreakHand; pUnit = pHandr; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_Potential_Transformer) //// 母线电压互感器 { ElectricEqpmt_Transformer* pLine = new ElectricEqpmt_Transformer; pUnit = pLine; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_SettingGroup) //// 整定值组 { ElectricEqpmt_SettingGroup* pSettingGroup = new ElectricEqpmt_SettingGroup; pUnit = pSettingGroup; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_StationThreeLoadCut) { ElectricEqpmt_StationThreeLoadCut* pStationThreeLoadCut = new ElectricEqpmt_StationThreeLoadCut; pUnit = pStationThreeLoadCut; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_StationControlPermission) { CElectricEqpmt_ControlPermission* pControlPermission = new CElectricEqpmt_ControlPermission; pUnit = pControlPermission; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_BreakRailPotential) //轨电位 { ElectricEqpmt_BreakRailPotential* pBreak = new ElectricEqpmt_BreakRailPotential; pUnit = pBreak; pUnit->SetEqpmentID(strEqpmtID); for (iterProtectValue = m_ProtectValueMap.lower_bound(strEqpmtID); iterProtectValue != m_ProtectValueMap.upper_bound(strEqpmtID); iterProtectValue++) { pBreak->AddProtectRelation(iterProtectValue->second); } for (iterAutoActUnion = m_AutoActUnionMap.lower_bound(strEqpmtID); iterAutoActUnion != m_AutoActUnionMap.upper_bound(strEqpmtID); iterAutoActUnion++) { pBreak->AddActUnoin(iterAutoActUnion->second.m_Sstatus, iterAutoActUnion->second.m_DEqpmtID, iterAutoActUnion->second.m_Dstatus, iterAutoActUnion->second.m_EventID);//added by zhangjh on 2017.4.29 修改遍历map的方式 } if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_AutoBoltSoftPlate) //备自投软压板 { CElectricEqpmt_SwicthEqpmt* pSwicthEqpmt = new CElectricEqpmt_SwicthEqpmt; pUnit = pSwicthEqpmt; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else if (type == OCC_EQPMTTYPE_ReclosingSoftPlate) //重合闸软压板 { CElectricEqpmt_SwicthEqpmt* pSwicthEqpmt = new CElectricEqpmt_SwicthEqpmt; pUnit = pSwicthEqpmt; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } else { //mod by yangs 没有对应类的设备暂时用基础类代替 pUnit = new BaseElectricEqpmt; pUnit->SetEqpmentID(strEqpmtID); if (UpdateEqpmtBaseInfo(query_result, pUnit)) { ElectricEqpmtMap->insert(make_pair(pUnit->GetEqpmentID(), pUnit)); } } } catch (...) { return false; } } } return true; } bool ElectricDataBaseManger::GetEqpmtsProtects() { string strSql = "Select Table_ProtectRelation.*,Table_ProtectValue.*,Table_FaultInfo.* " "from Table_ProtectRelation,Table_ProtectValue,Table_FaultInfo " "where Table_ProtectRelation.ProtectID=Table_ProtectValue.ID and Table_FaultInfo.protectno = Table_ProtectRelation.ProtectID"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { string eqpmtid; ProtectValue protect; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { eqpmtid = query_result->GetFieldValue("EqpmtID", std::string("")); protect.pretectid = query_result->GetFieldValue("ProtectID", int(-1)); protect.faultid = query_result->GetFieldValue("faultno", int(-1)); protect.faulttype = query_result->GetFieldValue("type", int(-1)); protect.PRI = query_result->GetFieldValue("PRI", int(-1)); protect.delaytime = query_result->GetFieldValue("DelayTime", int(-1)); protect.kind = query_result->GetFieldValue("Kind", int(-1)); protect.strname = query_result->GetFieldValue("StrName", std::string("")); protect.status = query_result->GetFieldValue("Status", int(-1)); protect.strfaultname = query_result->GetFieldValue("faultname", std::string("")); protect.breakerRejection = query_result->GetFieldValue("BreakerRejection", int(-1)); protect.protectDisplayContent = query_result->GetFieldValue("ProtectDisplayContent", std::string("")); protect.trippingDisplayContent = query_result->GetFieldValue("TrippingDisplayContent", std::string("")); protect.trippingRepeatShut = query_result->GetFieldValue("TrippingRepeatShut", int(-1)); protect.nPermanentFault = query_result->GetFieldValue("PermanentFault", int(-1)); m_ProtectValueMap.insert(make_pair(eqpmtid, protect)); } catch (...) { return false; } } } return true; } bool ElectricDataBaseManger::GetEqpmtsActUnions() { string strSql = "Select * from Table_AutoActUnion order by SEqpmtID"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { string strkey = ""; string preStrtemp = ""; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { AutoActUnion autoactunion; autoactunion.m_SEqpmtID = query_result->GetFieldValue("SEqpmtID", std::string("")); autoactunion.m_Sstatus = query_result->GetFieldValue("Sstatus", int(-1)); autoactunion.m_Dstatus = query_result->GetFieldValue("Dstatus", int(-1)); autoactunion.m_DEqpmtID = query_result->GetFieldValue("DEqpmtID", std::string("")); autoactunion.m_EventID = query_result->GetFieldValue("EventID", int(-1)); preStrtemp = autoactunion.m_SEqpmtID; m_AutoActUnionMap.insert(make_pair(preStrtemp, autoactunion)); } catch (...) { return false; } } } return true; } bool ElectricDataBaseManger::GetEqpmtsHander() { std::stringstream ss; ss << "Select * from Table_InPutRelation where Relation = " << EQPMT_RELATIONTYPE_BREAKHANDER; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { InPutRelationData inputrelationdata; inputrelationdata.m_StrID = query_result->GetFieldValue("StrID", std::string("")); inputrelationdata.m_InputEqpmtStrID = query_result->GetFieldValue("InputEqpmtStrID", std::string("")); inputrelationdata.m_RunLineID = query_result->GetFieldValue("RunLineID", int(-1)); inputrelationdata.m_Relation = query_result->GetFieldValue("Relation", int(-1)); m_HanderRelationDataMap.insert(make_pair(inputrelationdata.m_StrID, inputrelationdata)); } catch (...) { return false; } } } return true; } bool ElectricDataBaseManger::GetEqpmtsCtrlType() //待优化、可以直接存储到图片设备中 { std::string strSql = "Select * from Table_EqpmtCtrlArea"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { std::string EqpmtStrID = ""; int nCtrlArea = -1; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { EqpmtStrID = query_result->GetFieldValue("EqpmtStrID", std::string("")); nCtrlArea = query_result->GetFieldValue("CtrlArea", int(-1)); m_EqpmtCtrlAreaRelationMap.insert(make_pair(EqpmtStrID, nCtrlArea)); } catch (...) { return false; } } } return true; } bool ElectricDataBaseManger::GetEqpmtsProtectEqpmts() { std::string strSql = "Select * from Table_ProtectEqpmt"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { ProtectCtrl protectCtrl; std::string EqpmtStrID = ""; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { protectCtrl.ProtectStrID = query_result->GetFieldValue("ProtectID", std::string("")); protectCtrl.EventID = query_result->GetFieldValue("EventID", int(-1)); EqpmtStrID = query_result->GetFieldValue("EqpmtID", std::string("")); m_ProtectEqpmtRelationMap.insert(make_pair(EqpmtStrID, protectCtrl)); } catch (...) { return false; } } } return true; } bool ElectricDataBaseManger::GetEqpmtsCtrlUnions() { std::string strSql = "Select * from Table_EqpmtCtrlUnion order by OperEqpmtID"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { string strkey; string preStrtemp = ""; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { EqpmtCtrlUnion eqpmtctrlunion; eqpmtctrlunion.m_OperEqpmtID = query_result->GetFieldValue("OperEqpmtID", std::string("")); eqpmtctrlunion.m_PreEqpmtID = query_result->GetFieldValue("PreEpmtID", std::string("")); eqpmtctrlunion.m_OpeStatus = query_result->GetFieldValue("OpeStatus", int(-1)); eqpmtctrlunion.m_PreStatus = query_result->GetFieldValue("PreStatus", int(-1)); eqpmtctrlunion.m_DelayTime = query_result->GetFieldValue("DelayTime", int(-1)); eqpmtctrlunion.m_Relation = query_result->GetFieldValue("Relation", int(-1)); eqpmtctrlunion.m_Index = query_result->GetFieldValue("IndexNum", int(-1)); preStrtemp = eqpmtctrlunion.m_OperEqpmtID; m_EqpmtCtrlUnionMap.insert(make_pair(eqpmtctrlunion.m_OperEqpmtID, eqpmtctrlunion)); } catch (...) { return false; } } } return true; } bool ElectricDataBaseManger::InitLogicRelationData() { if (!GetEqpmtsCtrlUnions()) { return false; } else if (!GetEqpmtsProtectEqpmts()) { return false; } else if (!GetEqpmtsCtrlType()) { return false; } else if (!GetEqpmtsHander()) { return false; } else if (!GetEqpmtsActUnions()) { return false; } else if (!GetEqpmtsProtects()) { return false; } return true; } bool ElectricDataBaseManger::UpdateEqpmtBaseInfo(std::shared_ptr r_set,BaseElectricEqpmt* pUnit ) { ProtectEqpmtRelationMAP::iterator iterProtect; EqpmtCtrlUnionMAP::iterator iterCtrlUnion; string strtemp; string strkey; int num =-1; int stationid; try { pUnit->SetBaseTypeName(r_set->GetFieldValue("StrName", std::string(""))); pUnit->SetStatus(r_set->GetFieldValue("Status", int(-1))); pUnit->SetEqmpInitStatus(r_set->GetFieldValue("Status", int(-1))); if (pUnit->GetStatus()==Electric_Eqpmt_Status_ON) { pUnit->SetPower(true); } else if (pUnit->GetStatus()==Electric_Eqpmt_Status_OFF) { pUnit->SetPower(false); } pUnit->SetStationID(r_set->GetFieldValue("StationID", int(-1))); pUnit->SetViewID(r_set->GetFieldValue("ViewID", int(-1))); pUnit->SetBaseType(r_set->GetFieldValue("EqpmtType", int(-1))); pUnit->SetEqpmentName(r_set->GetFieldValue("Name", std::string(""))); pUnit->SetControlType(r_set->GetFieldValue("CtrlType", int(-1))); pUnit->SetSourceStationID(r_set->GetFieldValue("SourceStation", int(-1))); string strEqpmtID = r_set->GetFieldValue("StrID", std::string("")); for (iterProtect=m_ProtectEqpmtRelationMap.lower_bound(strEqpmtID);iterProtect!=m_ProtectEqpmtRelationMap.upper_bound(strEqpmtID);iterProtect++) { pUnit->AddProtect(iterProtect->second.ProtectStrID, iterProtect->second.EventID ); } strtemp = strEqpmtID; stationid = r_set->GetFieldValue("StationID", int(-1)); EqpmtCtrlUnionMAP::iterator CtrilUnion=m_EqpmtCtrlUnionMap.begin();//added by zhangjh on 2017.3.20 for (iterCtrlUnion=m_EqpmtCtrlUnionMap.lower_bound(strtemp);iterCtrlUnion!=m_EqpmtCtrlUnionMap.upper_bound(strtemp);iterCtrlUnion++) { pUnit->AddCtrlUnoin(iterCtrlUnion->second.m_OpeStatus,iterCtrlUnion->second.m_PreEqpmtID,iterCtrlUnion->second.m_PreStatus, iterCtrlUnion->second.m_Relation,iterCtrlUnion->second.m_DelayTime,iterCtrlUnion->second.m_Index); } } catch (...) { return false; } return true; } bool ElectricDataBaseManger::GetRepeatShutData() { std::string strSql = "Select * from Table_RepeatShut"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { int nEqpmtType = 0; int nIndex = 0; int nDelayTime = 0; int nOneTime = 0; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { nEqpmtType = query_result->GetFieldValue("EqpmtType", int(-1)); nIndex = query_result->GetFieldValue("Index", int(-1)); nDelayTime = query_result->GetFieldValue("DelayTime", int(-1)); nOneTime = query_result->GetFieldValue("OneTime", int(-1)); ElectricEqpmt_Breaker::AddRepeatShut(nEqpmtType, nIndex, nDelayTime, nOneTime); } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::GetErrorToProtectData() { std::string strSql = "Select * from Table_FaultInfo"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { BaseElectricEqpmt::ClearErrorToProtectMAP(); ErrorToProtectMAP* pMapErrorToProtect = BaseElectricEqpmt::GetErrorToProtectMAP(); ErrorToProtectMAP::iterator iterErrorToProtect; int nProtectID = -1; ErrorToProtect errorToProtect; int nBreakerRejection = 0; bool bSelfLost = false; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { errorToProtect.nErrorID = query_result->GetFieldValue("faultno", int(-1)); nBreakerRejection = query_result->GetFieldValue("BreakerRejection", int(-1)); // BreakerRejection在此范围内,表示故障发生时,故障设备是否跳闸,2表示需要跳闸 if (2 == nBreakerRejection) { bSelfLost = true; } else { bSelfLost = false; } nProtectID = query_result->GetFieldValue("protectno", int(-1)); errorToProtect.nErrorType = query_result->GetFieldValue("type", int(-1)); iterErrorToProtect = pMapErrorToProtect->find(errorToProtect.nErrorID); if (iterErrorToProtect != pMapErrorToProtect->end()) { iterErrorToProtect->second.AddProtectClass(nProtectID); if (bSelfLost) { iterErrorToProtect->second.SelfLost(true); } else { iterErrorToProtect->second.SelfLost(false); } } else { errorToProtect.Clear(); errorToProtect.strFaultName = query_result->GetFieldValue("faultname", std::string("")); errorToProtect.AddProtectClass(nProtectID); if (bSelfLost) { errorToProtect.SelfLost(true); } else { errorToProtect.SelfLost(false); } pMapErrorToProtect->insert(make_pair(errorToProtect.nErrorID, errorToProtect)); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::UpdateProtectLockingEqpmt( ELEEQPMTMAP* ElectricEqpmtMap ) { std::string strSql = "Select * from Table_ProtectLockingEqpmt"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { string strCurEqpmtStrID; string strProtectLockingEqpmtID; int nProtectID; string strProtectLockingText; ELEEQPMTMAP::iterator iterEqpmt; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { strCurEqpmtStrID = query_result->GetFieldValue("CurEqpmtStrID", std::string("")); strProtectLockingEqpmtID = query_result->GetFieldValue("ProtectLockingEqpmtID", std::string("")); nProtectID = query_result->GetFieldValue("ProtectID", int(-1)); strProtectLockingText = query_result->GetFieldValue("LockingText", std::string("")); iterEqpmt = ElectricEqpmtMap->find(strCurEqpmtStrID); if (iterEqpmt != ElectricEqpmtMap->end()) { iterEqpmt->second->AddProtectLockingEqpmt(strProtectLockingEqpmtID, nProtectID, strProtectLockingText); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::UpdateFaultSceneLockingEqpmt(ELEEQPMTMAP* ElectricEqpmtMap) { std::string strSql = "Select * from Table_FaultSceneLockingEqpmt"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { string strCurEqpmtStrID; string strProtectLockingEqpmtID; int nProtectID; ELEEQPMTMAP::iterator iterEqpmt; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { strCurEqpmtStrID = query_result->GetFieldValue("CurEqpmtStrID", std::string("")); strProtectLockingEqpmtID = query_result->GetFieldValue("ProtectLockingEqpmtID", std::string("")); nProtectID = query_result->GetFieldValue("ProtectID", int(-1)); iterEqpmt = ElectricEqpmtMap->find(strCurEqpmtStrID); if (iterEqpmt != ElectricEqpmtMap->end()) { iterEqpmt->second->AddFaultSceneLockingEqpmt(strProtectLockingEqpmtID, nProtectID); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::LoadTelesignalisationData( ElectricEqpmt_TelesignalisationMng& telesignalisationMng, ELEEQPMTMAP* ElectricEqpmtMap) { std::string strSql = "Select * from Table_TelProtectShow"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { ElectricEqpmt_TelProtectShow telProtectShow; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { telProtectShow.m_nProtectShowID = query_result->GetFieldValue("ProtectShowID", int(-1)); telProtectShow.m_nRecoverStatus = query_result->GetFieldValue("RecoverStatus", int(-1)); telProtectShow.m_nProtectStatus = query_result->GetFieldValue("ProtectStatus", int(-1)); telProtectShow.m_strRecoverShowText = query_result->GetFieldValue("RecoverShowText", std::string("")); telProtectShow.m_strProtectShowText = query_result->GetFieldValue("ProtectShowText", std::string("")); telProtectShow.m_nRecoverColor = query_result->GetFieldValue("RecoverColor", int(-1)); telProtectShow.m_nProtectColor = query_result->GetFieldValue("ProtectColor", int(-1)); ElectricEqpmt_Telesignalisation::AddTelProtectShow(telProtectShow); } catch (const std::exception&) { return false; } } } std::string strSql_2 = "Select * from Table_Telesignalisation"; std::shared_ptr query_result_2 = { 0 }; query_result_2 = m_pDataBase->DirectQuery(strSql_2); if (query_result_2) { ElectricEqpmt_Telesignalisation telesignalisation; ELEEQPMTMAP::iterator iterEqpmt; int nMark = 0; for (query_result_2->MoveFirst(); !query_result_2->IsEOF(); query_result_2->MoveNext()) { try { telesignalisation.m_nProtectID = query_result_2->GetFieldValue("ProtectID", int(-1)); telesignalisation.m_strEqpmtStrID = query_result_2->GetFieldValue("EqpmtStrID", std::string("")); telesignalisation.m_nStationID = query_result_2->GetFieldValue("StationID", int(-1)); telesignalisation.m_nViewID = query_result_2->GetFieldValue("ViewID", int(-1)); telesignalisation.m_strDestEqpmtStrID = query_result_2->GetFieldValue("DestEqpmtStrID", std::string("")); telesignalisation.m_nProtectShowID = query_result_2->GetFieldValue("PrptectShowID", int(-1)); telesignalisation.m_nPropertyPageCtrlID = query_result_2->GetFieldValue("PropertyPageCtrlID", int(-1)); iterEqpmt = ElectricEqpmtMap->find(telesignalisation.m_strEqpmtStrID); nMark = 0; if (iterEqpmt != ElectricEqpmtMap->end()) { if (Electric_Eqpmt_Status_OFF == telesignalisation.m_nProtectID && Electric_Eqpmt_Status_OFF == iterEqpmt->second->GetStatus()) { nMark = 1; } else if (Electric_Eqpmt_Status_ON == telesignalisation.m_nProtectID && Electric_Eqpmt_Status_ON == iterEqpmt->second->GetStatus()) { nMark = 1; } } telesignalisationMng.AddStationEqpmtTelesignalisation(telesignalisation, nMark); } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::LoadElcTurnOffAreaData( ELEEQPMTMAP* ElectricEqpmtMap, ElectricEqpmt_ElcTurnOffAreaMng& elcTurnOffAreaMng ) { std::string strSql = "Select * from Table_ElcTurnOffArea"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { string strEqpmtStrID; ELEEQPMTMAP::iterator iterEqpmt; int nAreaID = -1, nStationID = -1; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { strEqpmtStrID = query_result->GetFieldValue("EqpmtStrID", std::string("")); nAreaID = query_result->GetFieldValue("OffArea", int(-1)); nStationID = query_result->GetFieldValue("StationID", int(-1)); elcTurnOffAreaMng.AddElcTurnOffArea(nAreaID,nStationID,strEqpmtStrID); iterEqpmt = ElectricEqpmtMap->find(strEqpmtStrID); if (iterEqpmt != ElectricEqpmtMap->end()) { iterEqpmt->second->SetRelationElcTurnOffArea(nAreaID); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::LoadElcEqpmtAutoBoltLogic( ELEEQPMTMAP* ElectricEqpmtMap ) { std::string strSql = "Select * from Table_AutoBoltLogic"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { int nType = -1; string strEqpmtID = ""; string strOutPutBreaker = ""; ELEEQPMTMAP::iterator iterEqpmt; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { strEqpmtID = query_result->GetFieldValue("InputBreaker", std::string("")); iterEqpmt = ElectricEqpmtMap->find(strEqpmtID); if (iterEqpmt != ElectricEqpmtMap->end()) { nType = query_result->GetFieldValue("LogicType", int(-1)); strOutPutBreaker = query_result->GetFieldValue("OutputBreaker", std::string("")); iterEqpmt->second->AddOutLineElectricEqpmt(nType, strOutPutBreaker); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::LoadStation400VLoadMng( ElectricEqpmt_Station400VLoadMng* pStation400VLoadMng, ELEEQPMTMAP* ElectricEqpmtMap ) { if ( nullptr == pStation400VLoadMng ) { return true; } std::string strSql = "Select * from Table_400Load"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { int nStationID = -1; int nButtonID = -1; string strEqpmtID = ""; string strInputEqpmtStrID = ""; string strRelationBolt = ""; ELEEQPMTMAP::iterator iterEqpmt; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { nStationID = query_result->GetFieldValue("StationID", int(-1)); strEqpmtID = query_result->GetFieldValue("StrID", std::string("")); strInputEqpmtStrID = query_result->GetFieldValue("InputStrID", std::string("")); nButtonID = query_result->GetFieldValue("ButtonID", int(-1)); strRelationBolt = query_result->GetFieldValue("RelationBolt", std::string("")); pStation400VLoadMng->Add400VLoadData(nStationID, strEqpmtID, strInputEqpmtStrID, nButtonID, strRelationBolt); iterEqpmt = ElectricEqpmtMap->find(strInputEqpmtStrID); if (iterEqpmt != ElectricEqpmtMap->end()) { iterEqpmt->second->Set400VLoadID(nButtonID); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::AddProtectingEqpmt(ELEEQPMTMAP* ElectricEqpmtMap) { ProtectEqpmtRelationMAP::iterator iterProtect=m_ProtectEqpmtRelationMap.begin(); for (;iterProtect!=m_ProtectEqpmtRelationMap.end();iterProtect++) { ELEEQPMTMAP::iterator eqpmt=ElectricEqpmtMap->find(iterProtect->second.ProtectStrID); if (eqpmt!=ElectricEqpmtMap->end()) { eqpmt->second->AddFaultEqpmt(iterProtect->first); } } return true; } bool ElectricDataBaseManger::GetMultiModeData(MULTIMODEMAP& multimodemap) { std::string strSql = "Select * from Table_MultiModeInfo"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { int modeid = -1; int multimodeid = -1; int type = -1; string multimodename = ""; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { multimodeid = query_result->GetFieldValue("MultiModeID", int(-1)); multimodename = query_result->GetFieldValue("MultiModeName", std::string("")); modeid = query_result->GetFieldValue("ModeID", int(-1)); type = query_result->GetFieldValue("Type", int(-1)); MULTIMODEMAP::iterator iter = multimodemap.find(multimodeid); if (iter == multimodemap.end()) { MULTIMODEINFO multimodeinfo; multimodeinfo.m_nMultiModeID = multimodeid; multimodeinfo.m_strMultiModeName = multimodename; multimodeinfo.m_nType = type; multimodeinfo.m_vecModeID.push_back(modeid); multimodemap.insert(make_pair(multimodeid, multimodeinfo)); } else { iter->second.m_vecModeID.push_back(modeid); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::GetModeInfoData(MODEDATAMAP& modemap,MODEIDDATAMAP& modeidmap ) { std::stringstream ss; ss << "Select * from Table_EqpmtModeCtrl, Table_ModeInfo " << "where Table_EqpmtModeCtrl.ModeID = Table_ModeInfo.ModeID and Table_ModeInfo.StationID = 0 and RunLineID = " << m_nLineID; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { MODEDATA mode; mode.dstatus = query_result->GetFieldValue("EqpmtStatus", int(-1)); mode.index = query_result->GetFieldValue("CtrlIndex", int(-1)); mode.strid = query_result->GetFieldValue("EqpmtID", std::string("")); mode.modeid = query_result->GetFieldValue("ModeID", int(-1)); mode.station = query_result->GetFieldValue("StationID", int(-1)); mode.viewid = query_result->GetFieldValue("ViewID", int(-1)); mode.modename = query_result->GetFieldValue("ModeName", std::string("")); mode.statusname = query_result->GetFieldValue("EqpmtStatusName", std::string("")); mode.strModeShowID = query_result->GetFieldValue("ModeShowID", std::string("")); mode.strModeShowCode = query_result->GetFieldValue("ModeShowCode", std::string("")); modemap.insert(make_pair(Make2IntKey(mode.modeid, mode.index), mode)); MODEIDDATAMAP::iterator iter1 = modeidmap.find(mode.modeid); if (iter1 == modeidmap.end()) { modeidmap.insert(make_pair(mode.modeid, map())); iter1 = modeidmap.find(mode.modeid); } map::iterator iter2 = iter1->second.find(mode.index); if (iter2 == iter1->second.end()) { iter1->second.insert(make_pair(mode.index, mode)); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::GetEqpmtAlarmInfoFromDB(ELCEQPMTALARMINFOMAP* ElcEqpmtAlarmInfoMap) { std::string strSql = "Select * from Table_EqpmtAlarmInfo"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { ELCEQPMTALARMINFO ElcEqpmtAlarmInfo; ElcEqpmtAlarmInfo.m_nEqpmtType = query_result->GetFieldValue("EqpmtType", int(-1)); ElcEqpmtAlarmInfo.m_strAlrmText = query_result->GetFieldValue("AlarmText", std::string("")); ElcEqpmtAlarmInfo.m_nAlarmLevel = query_result->GetFieldValue("AlarmLevel", int(-1)); ElcEqpmtAlarmInfo.m_nAlarmType = query_result->GetFieldValue("AlarmType", int(-1)); ElcEqpmtAlarmInfo.m_nAlarmSystem = query_result->GetFieldValue("AlramSystem", int(-1)); ElcEqpmtAlarmInfo.m_nTripActType = query_result->GetFieldValue("TripActType", int(-1)); ElcEqpmtAlarmInfo.m_nIsFault = query_result->GetFieldValue("IsFault", int(-1)); ElcEqpmtAlarmInfo.m_strTripText = query_result->GetFieldValue("TripText", std::string("")); ElcEqpmtAlarmInfo.m_strProtectLock = query_result->GetFieldValue("LockingText", std::string("")); ELCEQPMTALARMINFOMAP::iterator iter1 = ElcEqpmtAlarmInfoMap->find(ElcEqpmtAlarmInfo.m_nEqpmtType); if (iter1 == ElcEqpmtAlarmInfoMap->end()) { ElcEqpmtAlarmInfoMap->insert(make_pair(ElcEqpmtAlarmInfo.m_nEqpmtType, ELCEQPMTALARMACTTYPEMAP())); iter1 = ElcEqpmtAlarmInfoMap->find(ElcEqpmtAlarmInfo.m_nEqpmtType); } ELCEQPMTALARMACTTYPEMAP::iterator iter2 = iter1->second.find(ElcEqpmtAlarmInfo.m_nTripActType); if (iter2 == iter1->second.end()) { iter1->second.insert(make_pair(ElcEqpmtAlarmInfo.m_nTripActType, ElcEqpmtAlarmInfo)); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::LoadElcToEnvRelaData( ELEEQPMTMAP* ElectricEqpmtMap, ElectricEqpmt_ElcTurnOffAreaMng& elcTurnOffAreaMng ) { std::string strSql = "Select * from Table_ElcToEnvRelaInfo"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { ELEEQPMTMAP::iterator iterEqpmt; int nStationID = -1; int nAreaID = -1; string strEqpmtStrID; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { nStationID = query_result->GetFieldValue("StationID", int(-1)); nAreaID = query_result->GetFieldValue("CtrlAreaID", int(-1)); strEqpmtStrID = query_result->GetFieldValue("ElcEqpmtStrID", std::string("")); elcTurnOffAreaMng.AddElcToRelaData(nStationID, nAreaID, strEqpmtStrID); ELEEQPMTMAP::iterator iterEqpmt; iterEqpmt = ElectricEqpmtMap->find(strEqpmtStrID); if (iterEqpmt != ElectricEqpmtMap->end()) { iterEqpmt->second->SetElcToEnvCtrlArea(nAreaID); } } } return true; } bool ElectricDataBaseManger::GetEqpmtTelemeteryValue(EQPMTTELEINFO& mapTeleInfo) { std::string strSql = "Select * from Table_EqpmtTelemeteryValue"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { EQPMTTELEINFO::iterator iter; EqpmtTelemeteryValueInfo* ptrEqpmtTeleInfo; string strKey(""); for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { ptrEqpmtTeleInfo = new EqpmtTelemeteryValueInfo; ptrEqpmtTeleInfo->nType = query_result->GetFieldValue("Type", int(-1)); ptrEqpmtTeleInfo->nSubType = query_result->GetFieldValue("SubType", int(-1)); ptrEqpmtTeleInfo->Namol_nMaxV = query_result->GetFieldValue("NormalMax_V", int(-1)); ptrEqpmtTeleInfo->Namol_nMinV = query_result->GetFieldValue("NormalMin_V", int(-1)); ptrEqpmtTeleInfo->Namol_nMaxA = query_result->GetFieldValue("NormalMax_A", int(-1)); ptrEqpmtTeleInfo->Namol_nMinA = query_result->GetFieldValue("NormalMin_A", int(-1)); ptrEqpmtTeleInfo->Excptional_nMaxV = query_result->GetFieldValue("ExceptionalMax_V", int(-1)); ptrEqpmtTeleInfo->Excptional_nMinV = query_result->GetFieldValue("ExceptionalMin_V", int(-1)); ptrEqpmtTeleInfo->Excptional_nMaxA = query_result->GetFieldValue("ExceptionalMax_A", int(-1)); ptrEqpmtTeleInfo->Excptional_nMinA = query_result->GetFieldValue("ExceptionalMin_A", int(-1)); strKey = std::to_string(ptrEqpmtTeleInfo->nType); if (mapTeleInfo.find(strKey) == mapTeleInfo.end()) { mapTeleInfo.insert(make_pair(strKey, ptrEqpmtTeleInfo)); } else { std::stringstream sss; sss << ptrEqpmtTeleInfo->nType << "_" << ptrEqpmtTeleInfo->nSubType; strKey = sss.str(); mapTeleInfo.insert(make_pair(strKey, ptrEqpmtTeleInfo)); } } catch (const std::exception&) { return false; } } } return true; } bool ElectricDataBaseManger::GetElectric_EqpmtStatusToIBPLight_FromDB(MapIndex_ElcEqpmtStatusToIBPLight& MIEqpmtStatusToIBPLight) { std::string strSql = "Select * from Table_EqpmtStatusToIBPLight"; std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { MIEqpmtStatusToIBPLight.clear(); CElcEqpmtStatusToIBPLight eqpmtStatusToIBPLight; string strKey(""); for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { eqpmtStatusToIBPLight.m_strEqpmtID = query_result->GetFieldValue("EqpmtStrID", std::string("")); eqpmtStatusToIBPLight.m_nEqpmtStatus = query_result->GetFieldValue("EqpmtStatus", int(-1)); eqpmtStatusToIBPLight.m_strStatusName = query_result->GetFieldValue("StatusName", std::string("")); eqpmtStatusToIBPLight.m_strLightenIBPKey = query_result->GetFieldValue("LightenIBPKey", std::string("")); eqpmtStatusToIBPLight.m_strLightingOffIBPkey = query_result->GetFieldValue("LightingOffIBPkey", std::string("")); eqpmtStatusToIBPLight.m_nIBPSysID = query_result->GetFieldValue("IBPSysID", int(-1)); eqpmtStatusToIBPLight.m_nEventEqpmtID = query_result->GetFieldValue("EventEqpmtID", int(-1)); eqpmtStatusToIBPLight.m_nEventID = query_result->GetFieldValue("EventID", int(-1)); eqpmtStatusToIBPLight.m_nIBPStationID = query_result->GetFieldValue("IBPIOID", int(-1)); strKey = MakeCStr_IntKey_2(eqpmtStatusToIBPLight.m_strEqpmtID, eqpmtStatusToIBPLight.m_nEqpmtStatus); MIEqpmtStatusToIBPLight.insert(make_pair(strKey, eqpmtStatusToIBPLight)); } catch (const std::exception&) { return false; } } } return true; } //加载仿真设备与真实设备映射数据 bool ElectricDataBaseManger::loadRealEqpmtRelationFromDB(ELEEQPMTMAP* ElectricEqpmtMap) { std::stringstream ss; ss << "Select * from Table_RealEqpmtRelation where RunLineID = " << m_nLineID; std::string strSql = ss.str(); std::shared_ptr query_result = { 0 }; query_result = m_pDataBase->DirectQuery(strSql); if (query_result) { string strEqpmtID = ""; ELEEQPMTMAP::iterator iterEqpmt; for (query_result->MoveFirst(); !query_result->IsEOF(); query_result->MoveNext()) { try { strEqpmtID = query_result->GetFieldValue("StrID", std::string("")); iterEqpmt = ElectricEqpmtMap->find(strEqpmtID); if (iterEqpmt != ElectricEqpmtMap->end()) { iterEqpmt->second->setReallyEqpmtFlag(); } } catch (const std::exception&) { return false; } } } return true; }