PowerEventDeal.cpp 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236
  1. #include "pch.h"
  2. #include "PowerEventDeal.h"
  3. #include "PublicEqpmtID.h"
  4. #include "YD_Public_OCC.h"
  5. #include <sstream>
  6. #include <iomanip>
  7. extern void GetMainSubStationID( int& nFirstStationID, int& nSecondStationID );
  8. PowerEventDeal::PowerEventDeal()
  9. {
  10. p_SendList=nullptr;
  11. BaseElectricEqpmt::SetTelesignalisationOwner(this);
  12. BaseElectricEqpmt::SetCallBackTelesignalisationFunc(DealTelesignalisation);
  13. BaseElectricEqpmt::SetCallBackDealElcTurnOffAreaFunc(DealElcTurnOffArea);
  14. BaseElectricEqpmt::SetCallBackDeal400VLoadTurnOffFunc(DealDeal400VLoadTurnOff);
  15. ElectricEqpmt_ElcTurnOffAreaMng::SetOwner(this);
  16. ElectricEqpmt_ElcTurnOffAreaMng::SetCallBackEqpmtElcStatus( GetEqpmtElcStatus );
  17. ElectricEqpmt_ElcTurnOffAreaMng::SetCallBackTurnOffArea( TurnOffArea );
  18. IsExamMOde = false;
  19. }
  20. void PowerEventDeal::SetInitInfo(CommandQueue * psendlist,int trian)//?
  21. {
  22. p_SendList =psendlist;
  23. m_trainID = trian;
  24. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->begin();
  25. while (iter!=pElectricEqpmtMap->end())
  26. {
  27. iter->second->SetSendList(psendlist,m_trainID);
  28. iter->second->SetDelayMap(&m_DelayDelMap);
  29. iter++;
  30. }
  31. m_400VLoadMng.SetDelayMap(&m_DelayDelMap);
  32. }
  33. DELAYMAP* PowerEventDeal::GetDelayTimeMap()
  34. {
  35. return &m_DelayDelMap;
  36. }
  37. bool PowerEventDeal::NeedDelayTimeDeal()//?
  38. {
  39. if (m_DelayDelMap.size()>0)
  40. return true;
  41. return false;
  42. }
  43. bool PowerEventDeal::handle_delaytime()//?handle_delaytime()与NeedDelayTimeDeal()的区别
  44. {
  45. std::time_t curtime = std::time(nullptr);
  46. std::tm* local_time = std::localtime(&curtime);
  47. DELAYMAP::iterator iter=m_DelayDelMap.begin();
  48. for (;iter!=m_DelayDelMap.end();iter++)
  49. {
  50. ELEEQPMTMAP::iterator iter1 = pElectricEqpmtMap->find(iter->first);
  51. if (iter1!=pElectricEqpmtMap->end())
  52. {
  53. if (!iter1->second->handle_delaytime(curtime,*pElectricEqpmtMap,iter->second))
  54. {
  55. m_DelayDelMap.erase(iter);
  56. return false;
  57. }
  58. }
  59. }
  60. return true;
  61. }
  62. bool PowerEventDeal::CloseOffSwicth()//?
  63. {
  64. R_Mutex_LOCK(*pEqpmtMapCriticalSection);
  65. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->begin();
  66. for (;iter!=pElectricEqpmtMap->end();iter++)
  67. {
  68. //置开关在关闭时为无电状态,如果不进行此操作,牵引变电所的纵向隔离开关无法断电
  69. if (iter->second->GetBaseType() ==OCC_EQPMTTYPE_35kVBREAKER
  70. || iter->second->GetBaseType() == OCC_EQPMTTYPE_27_5kVBREAKER
  71. || iter->second->GetBaseType() == OCC_EQPMTTYPE_27_5kVSwitch
  72. || iter->second->GetBaseType()==OCC_EQPMTTYPE_ThreePositong_ELCSWICTH
  73. || iter->second->GetBaseType() ==OCC_EQPMTTYPE_BREAKER_DC
  74. || iter->second->GetBaseType()==OCC_EQPMTTYPE_Power_ELCSWICTH
  75. || iter->second->GetBaseType()==OCC_EQPMTTYPE_Mannual_ELCSWICTH
  76. || iter->second->GetBaseType() ==OCC_EQPMTTYPE_400vACControlBreaker
  77. || iter->second->GetBaseType()==OCC_EQPMTTYPE_110kVBreaker
  78. || iter->second->GetBaseType()==OCC_EQPMTTYPE_110kVSwitch) //处理一个元件有三个以上的输入
  79. {
  80. if (iter->second->GetStatus()==Electric_Eqpmt_Status_OFF)
  81. {
  82. iter->second->PowerLost(*pElectricEqpmtMap,iter->first,POWER_EQPMT_INIT);
  83. }
  84. }
  85. }
  86. return true;
  87. }
  88. bool PowerEventDeal::DealEvent(NORMALCMDC NCmd,int EventOper,string Eqpmtid,int parm,const string& str2)//?
  89. {
  90. if (EventOper == Power_Breaker_ProtectAllReset)//add by dengt 处理断路器保护总复归
  91. {
  92. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->begin();
  93. for (; iter != pElectricEqpmtMap->end(); iter++)
  94. {
  95. if (stoi(Eqpmtid) != iter->second->GetSourceStationID())
  96. {
  97. continue;
  98. }
  99. if (iter->second->GetFaultLockStatus() != Electric_Eqpmt_Status_Lock)
  100. {
  101. continue;
  102. }
  103. UpdateEvaOperStatus updateEvaOperStatus;
  104. memset(&updateEvaOperStatus, 0, sizeof(UpdateEvaOperStatus));
  105. updateEvaOperStatus.TrainID = m_trainID;
  106. updateEvaOperStatus.CourseID = GetCourseID();
  107. updateEvaOperStatus.OperItemType = Item_Type_DD;
  108. updateEvaOperStatus.OperItemObject = MajorType_DD;
  109. updateEvaOperStatus.OperClientID = NCmd.paraInt7;
  110. updateEvaOperStatus.OperStuID = MajorType_DD;
  111. string EqpmemtID = iter->second->GetEqpmentID();
  112. string EqpmentName = iter->second->GetEqpmentName();
  113. string StationName = GetStationName(iter->second->GetSourceStationID());
  114. strncpy(updateEvaOperStatus.AssociPara1, EqpmemtID.c_str(), sizeof(updateEvaOperStatus.AssociPara1));
  115. strncpy(updateEvaOperStatus.AssociPara1Name, EqpmentName.c_str(), sizeof(updateEvaOperStatus.AssociPara1Name));
  116. string StationID;
  117. StationID = std::to_string(iter->second->GetSourceStationID());
  118. strncpy(updateEvaOperStatus.AssociPara2, StationID.c_str(), sizeof(updateEvaOperStatus.AssociPara2));
  119. strncpy(updateEvaOperStatus.AssociPara2Name, StationName.c_str(), sizeof(updateEvaOperStatus.AssociPara2Name));
  120. iter->second->ClearSingleProtect(*pElectricEqpmtMap, 0, str2);
  121. updateEvaOperStatus.OperStatus = true;
  122. updateEvaOperStatus.OperItemSubType1 = DD_Operate_Item_SwitchEqpmt; //开关设备操作
  123. updateEvaOperStatus.OperItemSubType2 = Switch_Protect_Reset; //控制闭锁
  124. SendMsgToTech(updateEvaOperStatus);
  125. }
  126. return true;
  127. }
  128. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->find(Eqpmtid);
  129. if (iter!=pElectricEqpmtMap->end())
  130. {
  131. UpdateEvaOperStatus updateEvaOperStatus;
  132. memset(&updateEvaOperStatus,0,sizeof(UpdateEvaOperStatus));
  133. updateEvaOperStatus.TrainID=m_trainID;
  134. updateEvaOperStatus.CourseID=GetCourseID();
  135. updateEvaOperStatus.OperItemType=Item_Type_DD;
  136. updateEvaOperStatus.OperItemObject=MajorType_DD;
  137. updateEvaOperStatus.OperClientID= NCmd.paraInt7;
  138. updateEvaOperStatus.OperStuID=MajorType_DD;
  139. string EqpmemtID=iter->second->GetEqpmentID();
  140. string EqpmentName=iter->second->GetEqpmentName();
  141. string StationName=GetStationName(iter->second->GetSourceStationID());
  142. /*
  143. strcpy(updateEvaOperStatus.AssociPara1,EqpmemtID.GetBuffer());
  144. EqpmemtID.ReleaseBuffer();
  145. string OperDis=StationName+iter->second->GetBaseTypeName()+ EqpmentName;
  146. strcpy(updateEvaOperStatus.AssociPara2,OperDis.GetBuffer());
  147. OperDis.ReleaseBuffer();
  148. */
  149. //mod by yangsong 20200615
  150. strncpy(updateEvaOperStatus.AssociPara1,EqpmemtID.c_str(), sizeof(updateEvaOperStatus.AssociPara1));
  151. strncpy(updateEvaOperStatus.AssociPara1Name,EqpmentName.c_str(), sizeof(updateEvaOperStatus.AssociPara1Name));
  152. string StationID;
  153. StationID = std::to_string(iter->second->GetSourceStationID());
  154. strncpy(updateEvaOperStatus.AssociPara2,StationID.c_str(), sizeof(updateEvaOperStatus.AssociPara2));
  155. strncpy(updateEvaOperStatus.AssociPara2Name,StationName.c_str(), sizeof(updateEvaOperStatus.AssociPara2Name));
  156. //mod end
  157. if (EventOper==POWER_ERORR_OCCAR)
  158. {
  159. //return iter->second->handle_fault(EventOper,*pElectricEqpmtMap,parm);
  160. if (parm==10000)
  161. {
  162. iter->second->CutCommunication(*pElectricEqpmtMap);
  163. iter->second->DealTelesignalisation(10000,iter->second->GetEqpmentID(),1);
  164. iter->second->UpdateEqpmtLightCardStatu(parm);
  165. return true;
  166. }
  167. if (parm==10002)
  168. {
  169. iter->second->CutEqpmtAlarm(*pElectricEqpmtMap,ElcAlarm_TripActType_HighMashgas);
  170. iter->second->DealTelesignalisation(10002,iter->second->GetEqpmentID(),1);
  171. iter->second->UpdateEqpmtLightCardStatu(parm);
  172. return true;
  173. }
  174. return iter->second->CheckErrorToProtect(EventOper,*pElectricEqpmtMap,parm);
  175. }
  176. else if (EventOper==POWER_ERORR_REVERT)
  177. {
  178. if (parm==10000)
  179. {
  180. iter->second->RevertCommunication(*pElectricEqpmtMap);
  181. iter->second->UpdateEqpmtLightCardStatu(-1);
  182. return true;
  183. }
  184. if (parm==10002)
  185. {
  186. iter->second->RevertEqpmtAlarm(*pElectricEqpmtMap,ElcAlarm_TripActType_HighMashgas_Recover);
  187. iter->second->UpdateEqpmtLightCardStatu(parm);
  188. return true;
  189. }
  190. return iter->second->handle_revert(EventOper,*pElectricEqpmtMap,parm);
  191. }
  192. else if (EventOper==Power_Breaker_ProtectReset)//added by zhangjh on 2017.5.17 处理断路器保护复归
  193. {
  194. //for (int i=5000;i<5006;i++) //特殊处理故障编号
  195. //if (!iter->second->getProhibitedReversion())
  196. {
  197. iter->second->ClearSingleProtect(*pElectricEqpmtMap, 0,str2);
  198. updateEvaOperStatus.OperStatus=true;
  199. updateEvaOperStatus.OperItemSubType1=DD_Operate_Item_SwitchEqpmt; //开关设备操作
  200. updateEvaOperStatus.OperItemSubType2=Switch_Protect_Reset; //控制闭锁
  201. SendMsgToTech(updateEvaOperStatus);
  202. }
  203. return true;
  204. }
  205. else if (EventOper==ShieldStatus_Set)
  206. {
  207. iter->second->SetShield( *pElectricEqpmtMap );
  208. updateEvaOperStatus.OperStatus=true;
  209. updateEvaOperStatus.OperItemSubType1=DD_Operate_Item_SwitchEqpmt; //开关设备操作
  210. updateEvaOperStatus.OperItemSubType2=Switch_Contol_Lock; //控制闭锁
  211. SendMsgToTech(updateEvaOperStatus);
  212. }
  213. else if (EventOper==ShieldStatus_Cancle)
  214. {
  215. iter->second->CancleShield( *pElectricEqpmtMap );
  216. updateEvaOperStatus.OperStatus=true;
  217. updateEvaOperStatus.OperItemSubType1=DD_Operate_Item_SwitchEqpmt; //开关设备操作
  218. updateEvaOperStatus.OperItemSubType2=Switch_Contol_UnLock; //闭锁解除
  219. SendMsgToTech(updateEvaOperStatus);
  220. }
  221. else if (EventOper==RemoteLock_Set)
  222. {
  223. //iter->second->SetRemoteLock(*pElectricEqpmtMap,);
  224. }
  225. else if (EventOper==RemoteShut)
  226. {
  227. //modified by zhangjiahua on 2019.4.10
  228. ElectricEqpmt_Breaker *pBreak=(ElectricEqpmt_Breaker*)iter->second;
  229. //if (iter->second->GetAutoBoltID()!="")
  230. if (pBreak->GetAutoBoltID()!="")
  231. {
  232. //ELEEQPMTMAP::iterator iter2 = pElectricEqpmtMap->find(iter->second->GetAutoBoltID());
  233. ELEEQPMTMAP::iterator iter2 = pElectricEqpmtMap->find(pBreak->GetAutoBoltID());
  234. if (iter2!=pElectricEqpmtMap->end())
  235. {
  236. if (iter2->second->GetStatus()==Electric_Eqpmt_Status_ON)
  237. {
  238. iter2->second->UpdateEqpmtStatus(*pElectricEqpmtMap,Electric_Eqpmt_Status_OFF);
  239. }
  240. else if (iter2->second->GetStatus()==Electric_Eqpmt_Status_OFF)
  241. {
  242. iter2->second->UpdateEqpmtStatus(*pElectricEqpmtMap,Electric_Eqpmt_Status_ON);
  243. ElectricEqpmt_PowerBolt* pbolt= (ElectricEqpmt_PowerBolt*)iter2->second;
  244. if ( NULL != pbolt )
  245. {
  246. pbolt->CheckSelfShut( *pElectricEqpmtMap,pbolt->GetRelationBreaker() );
  247. }
  248. }
  249. }
  250. }
  251. }
  252. }
  253. return false;
  254. }
  255. void PowerEventDeal::EqpmtCtrl(NORMALCMDC NCmd,string Eqpmtid,int Status,string Stdid,int CtrlType,int nMark/* = 0*/) //对电力元件的相关状态进行控制执行操作
  256. {
  257. //DealThirdTrackPowerLose();
  258. UpdateEvaOperStatus updateEvaOperStatus;
  259. memset(&updateEvaOperStatus,0,sizeof(UpdateEvaOperStatus));
  260. updateEvaOperStatus.TrainID=m_trainID;
  261. updateEvaOperStatus.CourseID=GetCourseID();
  262. updateEvaOperStatus.OperItemType=Item_Type_DD;
  263. updateEvaOperStatus.OperItemObject=MajorType_DD;
  264. updateEvaOperStatus.OperClientID=NCmd.paraInt7;
  265. updateEvaOperStatus.OperStuID=MajorType_DD;
  266. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->find(Eqpmtid);
  267. if (iter!=pElectricEqpmtMap->end())
  268. {
  269. string EqpmemtID=iter->second->GetEqpmentID();
  270. string EqpmentName=iter->second->GetEqpmentName();
  271. string StationName=GetStationName(iter->second->GetSourceStationID());
  272. //mod by yangsong 20200615
  273. strncpy(updateEvaOperStatus.AssociPara1,EqpmemtID.c_str(), sizeof(updateEvaOperStatus.AssociPara1));
  274. strncpy(updateEvaOperStatus.AssociPara1Name,EqpmentName.c_str(), sizeof(updateEvaOperStatus.AssociPara1Name));
  275. string StationID;
  276. StationID = std::to_string(iter->second->GetSourceStationID());
  277. strncpy(updateEvaOperStatus.AssociPara2,StationID.c_str(), sizeof(updateEvaOperStatus.AssociPara2));
  278. strncpy(updateEvaOperStatus.AssociPara2Name,StationName.c_str(), sizeof(updateEvaOperStatus.AssociPara2Name));
  279. //mod end
  280. if (iter->second->getProhibitedReversion())
  281. {
  282. //CElectricEqpmt_SwicthEqpmt *pEqpmt = (CElectricEqpmt_SwicthEqpmt *)iter->second;
  283. //pEqpmt->UpdateFaultLockStatus(Electric_Eqpmt_Status_Lock);
  284. string EqpmtTypeName = iter->second->GetBaseTypeName(); //设备类型名称
  285. string EqpmtName = iter->second->GetEqpmentName(); //设备名称
  286. int EqpmtSourceStatonID = iter->second->GetSourceStationID(); //设备所属车站ID
  287. int EqpmtType = iter->second->GetBaseType(); //设备类型
  288. int nActType1 = ElcAlarm_TripActType_TouchnetTest_Fail; //“试送失败”报文类型
  289. iter->second->UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType1);
  290. return;
  291. }
  292. else
  293. {
  294. if (iter->second->GetCurErrorNos() > 0)
  295. {
  296. string EqpmtTypeName = iter->second->GetBaseTypeName(); //设备类型名称
  297. string EqpmtName = iter->second->GetEqpmentName(); //设备名称
  298. int EqpmtSourceStatonID = iter->second->GetSourceStationID(); //设备所属车站ID
  299. int EqpmtType = iter->second->GetBaseType(); //设备类型
  300. int nActType1 = ElcAlarm_TripActType_TouchnetTest_Success; //“试送成功”报文类型
  301. iter->second->UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType1);
  302. }
  303. }
  304. //在操作设备之前先进行控制校验 modied by zhangjh
  305. if(CtrlType == CTRLTYPE_MODE || IsExamMOde || iter->second->CheckEqpmtCtrlCase(Status,*pElectricEqpmtMap,0,iter->second->GetOperSubsysID(),m_trainID,iter->second->GetStationID(),iter->second->GetViewID(), CtrlType, nMark)==DH_CmdReplyStatus_Pass || CtrlType == CTRLTYPE_CARD)
  306. {
  307. //查找设备是否关联备自投,有则设置关联备自投为手动控制
  308. ELEEQPMTMAP::iterator iterBolt = pElectricEqpmtMap->find(iter->second->GetAutoBoltID());
  309. if (iterBolt != pElectricEqpmtMap->end())
  310. {
  311. ElectricEqpmt_PowerBolt* pEqpmtBolt = (ElectricEqpmt_PowerBolt*)iterBolt->second;
  312. {
  313. pEqpmtBolt->SetCtrlMode(AutoBolt_CtrlMode_Manual_Manual);
  314. }
  315. }
  316. //新增
  317. if (CtrlType == CTRLTYPE_MODE)
  318. CtrlType = CTRLTYPE_STATUS;
  319. // 设备控制,关联了真实设备后需要延时等待真实设备反馈
  320. if (iter->second->checkReallyEqpmtFlag())
  321. {
  322. iter->second->EqpmtCtrlExecution(Status, *pElectricEqpmtMap, Stdid, CtrlType, nMark);
  323. }
  324. else
  325. {
  326. iter->second->EqpmtCtrl(Status, *pElectricEqpmtMap, Stdid, CtrlType, nMark);
  327. }
  328. updateEvaOperStatus.OperStatus=true;
  329. EqpmtStatusToIBP(iter->first,Status);
  330. //控制结束恢复备自投控制
  331. if (iterBolt != pElectricEqpmtMap->end())
  332. {
  333. ElectricEqpmt_PowerBolt* pEqpmtBolt = (ElectricEqpmt_PowerBolt*)iterBolt->second;
  334. if (Status == Electric_Eqpmt_Status_ON)
  335. {
  336. pEqpmtBolt->SetCtrlMode(AutoBolt_CtrlMode_Auto_Auto);
  337. }
  338. }
  339. }
  340. else
  341. {
  342. updateEvaOperStatus.OperStatus=false;
  343. }
  344. updateEvaOperStatus.OperItemSubType1=DD_Operate_Item_SwitchEqpmt; //开关设备操作
  345. if (Status)
  346. {
  347. updateEvaOperStatus.OperItemSubType2=Switch_On;//合闸
  348. }
  349. else
  350. {
  351. updateEvaOperStatus.OperItemSubType2=Switch_Off;//分闸
  352. }
  353. if (NCmd.cmdType > 0 && OperClient_RealSynch != nMark)
  354. {
  355. SendMsgToTech(updateEvaOperStatus);
  356. }
  357. }
  358. }
  359. void PowerEventDeal::EqpmtCtrlCheck(int ViewID,int SubSys,string Eqpmtid,int Status,int Stdid,int ctrlarea,int grade,int station,int CtrlType) // 检查设备的状态属性
  360. {
  361. ELEEQPMTMAP::iterator iterAutoBolt;
  362. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->find(Eqpmtid);
  363. if (iter!=pElectricEqpmtMap->end())
  364. {
  365. if(IsExamMOde) iter->second->SendExamModeEqpmtCheckStatus(Stdid,SubSys,m_trainID,station,ViewID);
  366. else iter->second->CheckEqpmtCtrlCase(Status,*pElectricEqpmtMap,Stdid,SubSys,m_trainID,station,ViewID,CtrlType);
  367. m_EqpmtStationID = station;
  368. m_StrCheckEqpmt = Eqpmtid;
  369. //modified by zhangjiahua on 2019.4.10
  370. if (iter->second->GetEqpmentType()==Electric_EqpmentType_Breaker)
  371. {
  372. ElectricEqpmt_Breaker *pbreak=(ElectricEqpmt_Breaker*)iter->second;
  373. ELEEQPMTMAP::iterator iterAutoBolt = pElectricEqpmtMap->find(pbreak->GetAutoBoltID());
  374. if (iterAutoBolt != pElectricEqpmtMap->end())
  375. {
  376. iterAutoBolt->second->SetOperViewID(ViewID);
  377. iterAutoBolt->second->SetOperStationID(station);
  378. iterAutoBolt->second->SetOperSubsysID(SubSys);
  379. }
  380. }
  381. //ELEEQPMTMAP::iterator iterAutoBolt = pElectricEqpmtMap->find(iter->second->GetAutoBoltID());
  382. //if (iterAutoBolt != pElectricEqpmtMap->end())
  383. //{
  384. // iterAutoBolt->second->SetOperViewID(ViewID);
  385. // iterAutoBolt->second->SetOperStationID(station);
  386. // iterAutoBolt->second->SetOperSubsysID(SubSys);
  387. //}
  388. iter->second->SetOperViewID(ViewID);
  389. iter->second->SetOperStationID(station);
  390. iter->second->SetOperSubsysID(SubSys);
  391. }
  392. }
  393. PowerEventDeal::~PowerEventDeal()
  394. {
  395. m_DelayDelMap.clear();
  396. }
  397. void PowerEventDeal::SetEqpmtMap(ELEEQPMTMAP* pepmtmap, std::recursive_mutex* psec, EQPMTTELEINFO* pEqpmtTeleInfo) //初始化电力设备列表
  398. {
  399. pElectricEqpmtMap = pepmtmap;
  400. pEqpmtMapCriticalSection = psec;
  401. mptr_EqpmtTeleInfo = pEqpmtTeleInfo;
  402. }
  403. //mod by yangs
  404. //新增整形参数 nDesSysID:消息指定发送系统ID
  405. //将状态变化更新到客户端
  406. void PowerEventDeal::SystemInit(int nDesSysID)
  407. {
  408. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->begin();
  409. for( ; iter != pElectricEqpmtMap->end(); iter++ )
  410. {
  411. if ( iter->second->GetInitStatus() != iter->second->GetStatus())
  412. {
  413. iter->second->UpdateEqpmtStatus( *pElectricEqpmtMap,iter->second->GetStatus(),CTRLTYPE_STATUS,nDesSysID);
  414. }
  415. }
  416. TelesignalisationInit();
  417. }
  418. bool PowerEventDeal::DealWithAutoBoltCtrlMothod(int trainid, string Eqpmtid,int ctrlmode)
  419. {
  420. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->find(Eqpmtid);
  421. if (iter!=pElectricEqpmtMap->end())
  422. {
  423. if (iter->second->GetBaseType() == OCC_EQPMTTYPE_AUTOBOLT)
  424. {
  425. ElectricEqpmt_PowerBolt* pbolt = (ElectricEqpmt_PowerBolt*)iter->second;
  426. //pbolt->m_CtrlMode = ctrlmode;
  427. pbolt->SetCtrlMode(ctrlmode);
  428. pbolt->AutoBoltCheckEqpmtCtrlCase(trainid,*pElectricEqpmtMap,m_subsystemid,pbolt->GetStationID(),pbolt->GetViewID(),m_stdid);
  429. pbolt->UpdateModeStatusShow(*pElectricEqpmtMap,ctrlmode);
  430. if ( NULL != pbolt )
  431. {
  432. pbolt->CheckSelfShut( *pElectricEqpmtMap,pbolt->GetRelationBreaker() );
  433. }
  434. }
  435. }
  436. else
  437. {
  438. return false;
  439. }
  440. return true;
  441. }
  442. void PowerEventDeal::DealTelesignalisation(void* pOwner, int nProtectID, const string& strEqpmtStrID , int nMark )
  443. {
  444. PowerEventDeal* pDeal = (PowerEventDeal*)pOwner;
  445. if ( NULL == pDeal )
  446. {
  447. return;
  448. }
  449. pDeal->DealTelesignalisation( nProtectID, strEqpmtStrID, nMark );
  450. }
  451. void PowerEventDeal::DealTelesignalisation( int nProtectID, const string& strEqpmtStrID, int nMark )
  452. {
  453. m_TelesignalisationMng.DealTelesignalisationMsg( p_SendList, m_trainID, nProtectID, strEqpmtStrID, nMark );
  454. }
  455. void PowerEventDeal::TelesignalisationInit()
  456. {
  457. m_TelesignalisationMng.TelesignalisationInit( p_SendList, m_trainID );
  458. }
  459. bool PowerEventDeal::GetEqpmtElcStatus(void* pOwner, const string& strEqpmtStrID )
  460. {
  461. bool bRet = false;
  462. PowerEventDeal* pThis = (PowerEventDeal*)pOwner;
  463. if ( NULL != pThis )
  464. {
  465. bRet = pThis->GetEqpmtElcStatus(strEqpmtStrID);
  466. }
  467. return bRet;
  468. }
  469. bool PowerEventDeal::GetEqpmtElcStatus( const string& strEqpmtStrID )
  470. {
  471. bool bRet = false;
  472. ELEEQPMTMAP::iterator iterEqpmt = pElectricEqpmtMap->find( strEqpmtStrID );
  473. if ( iterEqpmt != pElectricEqpmtMap->end() )
  474. {
  475. bRet = iterEqpmt->second->IsPower();
  476. }
  477. return bRet;
  478. }
  479. void PowerEventDeal::TurnOffArea(void* pOwner, int nAreaID, int nStationID , int nMark )
  480. {
  481. PowerEventDeal* pThis = (PowerEventDeal*)pOwner;
  482. if ( NULL != pThis )
  483. {
  484. pThis->TurnOffArea( nAreaID, nStationID, nMark );
  485. }
  486. }
  487. void PowerEventDeal::TurnOffArea( int nAreaID, int nStationID , int nMark )
  488. {
  489. // 发送停电区域给环调服务器
  490. OCCCOMMAND tmpSendHC;
  491. tmpSendHC.DesSysType=OCC_SYS_HD_SVR;
  492. tmpSendHC.TrainningID = m_trainID;
  493. tmpSendHC.ScrSysType=OCC_SYS_DD_SVR;
  494. NETELCTURNOFFAREA ElcTurnOffArea;
  495. ElcTurnOffArea.AreaID = nAreaID;
  496. ElcTurnOffArea.StationID = nStationID;
  497. ElcTurnOffArea.Mark = nMark;
  498. tmpSendHC.setPacketValue(&ElcTurnOffArea,OCCCOMMAND::eUpdateTurnOffArea);
  499. p_SendList->push(tmpSendHC);
  500. // 报警
  501. ElcAreaAlarm( nStationID, nMark );
  502. }
  503. void PowerEventDeal::DealElcTurnOffArea(void* pOwner, const string& strEqpmtStrID )
  504. {
  505. PowerEventDeal* pThis = (PowerEventDeal*)pOwner;
  506. if ( NULL != pThis )
  507. {
  508. pThis->m_ElcTurnOffAreaMng.EqpmtOffOccur(strEqpmtStrID);
  509. }
  510. }
  511. void PowerEventDeal::ElcAreaAlarm( int nStationID, bool bPower )
  512. {
  513. if ( 0 == nStationID )
  514. {
  515. }
  516. else
  517. {
  518. ELEEQPMTMAP::iterator iterEqpmt = pElectricEqpmtMap->begin( );
  519. for ( ; iterEqpmt != pElectricEqpmtMap->end(); iterEqpmt++ )
  520. {
  521. if ( OCC_EQPMTTYPE_400vACUncontrolBreaker == iterEqpmt->second->GetBaseType() && nStationID == iterEqpmt->second->GetSourceStationID() )
  522. {
  523. iterEqpmt->second->ElcAreaAlarm(bPower);
  524. }
  525. }
  526. }
  527. }
  528. void PowerEventDeal::DealThirdTrackPowerLose()
  529. {
  530. ELEEQPMTMAP::iterator iterEqpmt1 = pElectricEqpmtMap->begin( );
  531. ELEEQPMTMAP::iterator iterEqpmt2 = pElectricEqpmtMap->begin( );
  532. ELEEQPMTMAP::iterator iterEqpmt3 = pElectricEqpmtMap->begin( );
  533. bool bFlag1 = false;
  534. int nNum1 = -1;
  535. bool bFlag2 = false;
  536. int nNum2 = -1;
  537. int nFirstStation = -1;
  538. int nSecondStation = -1;
  539. GetMainSubStationID(nFirstStation, nSecondStation);
  540. if (iterEqpmt1 !=pElectricEqpmtMap->end() )
  541. {
  542. for ( ; iterEqpmt1 != pElectricEqpmtMap->end(); iterEqpmt1++ )
  543. {
  544. if ( iterEqpmt1->second->GetSourceStationID() == nFirstStation
  545. && iterEqpmt1->second->GetBaseType() == OCC_EQPMTTYPE_35kVMOTHERLINE
  546. && iterEqpmt1->second->GetStatus() == Electric_Eqpmt_Status_OFF)
  547. {
  548. nNum1++;
  549. if (nNum1 == 1)
  550. {
  551. bFlag1 = true;
  552. }
  553. }
  554. else if ( iterEqpmt1->second->GetSourceStationID() == nSecondStation
  555. && iterEqpmt1->second->GetBaseType() == OCC_EQPMTTYPE_35kVMOTHERLINE
  556. && iterEqpmt1->second->GetStatus() == Electric_Eqpmt_Status_OFF)
  557. {
  558. nNum2++;
  559. if (nNum2 == 1)
  560. {
  561. bFlag2 = true;
  562. }
  563. }
  564. }
  565. }
  566. //if (iterEqpmt1 !=pElectricEqpmtMap->end() )
  567. //{
  568. // for ( ; iterEqpmt1 != pElectricEqpmtMap->end(); iterEqpmt1++ )
  569. // {
  570. // //if (iterEqpmt1->second->m_SourceStation == 24 && iterEqpmt1->second->m_type == OCC_EQPMTTYPE_MOTHERLINE && iterEqpmt1->second->GetStatus() == Electric_Eqpmt_Status_OFF)
  571. // if ( iterEqpmt1->second->m_SourceStation == nFirstStation
  572. // && iterEqpmt1->second->m_type == OCC_EQPMTTYPE_MOTHERLINE
  573. // && iterEqpmt1->second->GetStatus() == Electric_Eqpmt_Status_OFF)
  574. // {
  575. // nFirstStation = iterEqpmt1->second->m_SourceStation;
  576. // nNum1++;
  577. // if (nNum1 == 1)
  578. // {
  579. // bFlag1 = true;
  580. // }
  581. // }
  582. // }
  583. //}
  584. //if (iterEqpmt2 !=pElectricEqpmtMap->end() )
  585. //{
  586. // for ( ; iterEqpmt2 != pElectricEqpmtMap->end(); iterEqpmt2++ )
  587. // {
  588. // //if (iterEqpmt2->second->m_SourceStation == 25 && iterEqpmt2->second->m_type == OCC_EQPMTTYPE_MOTHERLINE && iterEqpmt2->second->GetStatus() == Electric_Eqpmt_Status_OFF)
  589. // if ( iterEqpmt2->second->m_SourceStation == nSecondStation
  590. // && iterEqpmt2->second->m_type == OCC_EQPMTTYPE_MOTHERLINE
  591. // && iterEqpmt2->second->GetStatus() == Electric_Eqpmt_Status_OFF)
  592. // {
  593. // nNum2++;
  594. // if (nNum2 == 1)
  595. // {
  596. // bFlag2 = true;
  597. // }
  598. // }
  599. // }
  600. //}
  601. if (bFlag2 && bFlag1)
  602. {
  603. for ( ; iterEqpmt3 != pElectricEqpmtMap->end(); iterEqpmt3++ )
  604. {
  605. if ((iterEqpmt3->second->GetBaseType() == OCC_EQPMTTYPE_TouchNet ||iterEqpmt3->second->GetBaseType() == OCC_EQPMTTYPE_DCPowerLine)
  606. && iterEqpmt3->second->GetStatus() == Electric_Eqpmt_Status_ON)
  607. {
  608. iterEqpmt3->second->PowerLost(*pElectricEqpmtMap,iterEqpmt3->first,POWER_EQPMT_OPERNO);
  609. }
  610. }
  611. }
  612. }
  613. void PowerEventDeal::PowerCutArea( int nAreaID )
  614. {
  615. map<int, ElectricEqpmt_ElcTurnOffArea >::iterator iterArea = m_ElcTurnOffAreaMng.m_mapElcTurnOffArea.find(nAreaID);
  616. if ( iterArea == m_ElcTurnOffAreaMng.m_mapElcTurnOffArea.end() )
  617. {
  618. return;
  619. }
  620. string strInputEqpmtStrID;
  621. for ( int i = 0; i < iterArea->second.m_vecElcTurnOffArea.size(); i++ )
  622. {
  623. strInputEqpmtStrID = iterArea->second.m_vecElcTurnOffArea[i].m_strUnioEqpmtStrID;
  624. NORMALCMDC NCmd;
  625. EqpmtCtrl(NCmd,strInputEqpmtStrID, Electric_Eqpmt_Status_OFF, "系统", CTRLTYPE_STATUS);
  626. }
  627. }
  628. void PowerEventDeal::Deal400VLoad( int nStationID, int nThreeLoadUnitID, int nCutMark )
  629. {
  630. m_400VLoadMng.Deal400VLoad(nStationID, nThreeLoadUnitID, nCutMark);
  631. }
  632. void PowerEventDeal::DealDeal400VLoadTurnOff(void* pOwner, const string& strEqpmtStrID, int nButtonID )
  633. {
  634. PowerEventDeal* pThis = (PowerEventDeal*)pOwner;
  635. if ( NULL != pThis )
  636. {
  637. pThis->m_400VLoadMng.CheckInputEqpmt(pThis->pElectricEqpmtMap, strEqpmtStrID, nButtonID );
  638. }
  639. }
  640. void PowerEventDeal::DealRemoteLock(NORMALCMDC&NCmd)
  641. {
  642. UpdateEvaOperStatus updateEvaOperStatus;
  643. memset(&updateEvaOperStatus,0,sizeof(UpdateEvaOperStatus));
  644. updateEvaOperStatus.TrainID=m_trainID;
  645. updateEvaOperStatus.CourseID=GetCourseID();
  646. updateEvaOperStatus.OperItemType=Item_Type_DD;
  647. updateEvaOperStatus.OperItemObject=MajorType_DD;
  648. updateEvaOperStatus.OperClientID=NCmd.paraInt7;
  649. updateEvaOperStatus.OperStuID=MajorType_DD;
  650. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->find(NCmd.StrPara1);
  651. if (iter!=pElectricEqpmtMap->end())
  652. {
  653. string EqpmemtID=iter->second->GetEqpmentID();
  654. string EqpmentName=iter->second->GetEqpmentName();
  655. string StationName=GetStationName(iter->second->GetSourceStationID());
  656. /*
  657. strcpy(updateEvaOperStatus.AssociPara1,EqpmemtID.GetBuffer());
  658. EqpmemtID.ReleaseBuffer();
  659. string OperDis=StationName+iter->second->GetBaseTypeName()+ EqpmentName;
  660. strcpy(updateEvaOperStatus.AssociPara2,OperDis.GetBuffer());
  661. OperDis.ReleaseBuffer();*/
  662. //mod by yangsong 20200615
  663. strncpy(updateEvaOperStatus.AssociPara1,EqpmemtID.c_str(),sizeof(updateEvaOperStatus.AssociPara1));
  664. strncpy(updateEvaOperStatus.AssociPara1Name,EqpmentName.c_str(), sizeof(updateEvaOperStatus.AssociPara1Name));
  665. string StationID;
  666. StationID = std::to_string(iter->second->GetSourceStationID());
  667. strncpy(updateEvaOperStatus.AssociPara2,StationID.c_str(), sizeof(updateEvaOperStatus.AssociPara2));
  668. strncpy(updateEvaOperStatus.AssociPara2Name,StationName.c_str(), sizeof(updateEvaOperStatus.AssociPara2Name));
  669. //mod end
  670. updateEvaOperStatus.OperItemSubType1=DD_Operate_Item_SwitchEqpmt;
  671. updateEvaOperStatus.OperStatus=true;
  672. updateEvaOperStatus.OperItemSubType2 = -1;
  673. if (NCmd.cmdType==RemoteLock_Set)
  674. {
  675. iter->second->SetRemoteLock(*pElectricEqpmtMap,NCmd.paraInt1,NCmd.paraInt2,NCmd.paraInt3);
  676. switch (NCmd.paraInt3)
  677. {
  678. case RemoteLockType_Off:
  679. {
  680. updateEvaOperStatus.OperItemSubType2=Switch_RemoteLock_Off;//遥信封锁分
  681. }
  682. break;
  683. case RemoteLockType_On:
  684. {
  685. updateEvaOperStatus.OperItemSubType2=Switch_RemoteLock_On;//遥信封锁合
  686. }
  687. break;
  688. case RemoteLockType_Local:
  689. {
  690. updateEvaOperStatus.OperItemSubType2=Switch_RemoteLock_Local;//遥信封锁就地
  691. }
  692. break;
  693. case RemoteLockType_Test:
  694. {
  695. updateEvaOperStatus.OperItemSubType2=Switch_HanderLock_Test;//手车封锁试验
  696. }
  697. break;
  698. case RemoteLockType_Work:
  699. {
  700. updateEvaOperStatus.OperItemSubType2=Switch_HanderLock_Work;//手车封锁工作
  701. }
  702. break;
  703. default:
  704. break;
  705. }
  706. }
  707. else if (NCmd.cmdType==RemoteLock_Cancle)
  708. {
  709. iter->second->CancleRemoteLock(*pElectricEqpmtMap,NCmd.paraInt1,NCmd.paraInt2);
  710. if (NCmd.paraInt3>=0)
  711. {
  712. updateEvaOperStatus.OperItemSubType2 = Switch_RemoteLock_Unlock;//遥信解除
  713. }
  714. }
  715. if (updateEvaOperStatus.OperItemSubType2>=0)
  716. {
  717. SendMsgToTech(updateEvaOperStatus);
  718. }
  719. }
  720. }
  721. string PowerEventDeal::GetStationName(int stationID)
  722. {
  723. string strStationName = "";
  724. ELECSTATIONMAP::iterator iterStation =m_MI_powerstation.find(stationID);
  725. if ( iterStation != m_MI_powerstation.end() )
  726. {
  727. strStationName = iterStation->second.strstationname;
  728. }
  729. return strStationName;
  730. }
  731. void PowerEventDeal::DealPermissionChange(NORMALCMDC&NCmd)
  732. {
  733. ELECSTATIONMAP::iterator iter= m_MI_powerstation.find(NCmd.paraInt1);
  734. if (iter!=m_MI_powerstation.end())
  735. {
  736. iter->second.ctrlarea=NCmd.paraInt2;
  737. UpdateEvaOperStatus updateEvaOperStatus;
  738. memset(&updateEvaOperStatus,0,sizeof(UpdateEvaOperStatus));
  739. updateEvaOperStatus.TrainID=m_trainID;
  740. updateEvaOperStatus.CourseID=GetCourseID();
  741. updateEvaOperStatus.OperItemType=Item_Type_DD;
  742. updateEvaOperStatus.OperItemObject=MajorType_DD;
  743. updateEvaOperStatus.OperClientID=NCmd.paraInt7;
  744. updateEvaOperStatus.OperStuID=MajorType_DD;
  745. string StationID;
  746. StationID = std::to_string(iter->second.stationID);
  747. string StationName=iter->second.strstationname;
  748. strncpy(updateEvaOperStatus.AssociPara1,StationID.c_str(), sizeof(updateEvaOperStatus.AssociPara1));
  749. strncpy(updateEvaOperStatus.AssociPara2,StationName.c_str(), sizeof(updateEvaOperStatus.AssociPara2));
  750. updateEvaOperStatus.OperItemSubType1=DD_Operate_Item_PermissionChange;
  751. if (iter->second.ctrlarea==11) //中心控制
  752. {
  753. updateEvaOperStatus.OperItemSubType2=Permission_OCC;
  754. }
  755. else if (iter->second.ctrlarea==12)//变电所控制
  756. {
  757. updateEvaOperStatus.OperItemSubType2=Permission_Station;
  758. }
  759. updateEvaOperStatus.OperStatus = true;
  760. //SendMsgToTech(updateEvaOperStatus);
  761. }
  762. string AlarmText = "";
  763. int nStation = NCmd.paraInt1;
  764. int nArea = 0;
  765. if (NCmd.paraInt2==11)
  766. {
  767. nArea = ELC_EQPMTCTRL_REMOTE;
  768. AlarmText = "遥控权限切换至主控";
  769. }
  770. else if (NCmd.paraInt2==12)
  771. {
  772. nArea = ELC_EQPMTCTRL_LOCAL;
  773. AlarmText = "遥控权限切换至所控";
  774. }
  775. ELEEQPMTMAP::iterator iterEqpmt = pElectricEqpmtMap->begin();
  776. for (iterEqpmt;iterEqpmt != pElectricEqpmtMap->end();iterEqpmt++)
  777. {
  778. if ((NCmd.paraInt1 != -1) && (iterEqpmt->second->GetSourceStationID() != NCmd.paraInt1))
  779. {
  780. continue;
  781. }
  782. iterEqpmt->second->SetControlArea(nArea);
  783. }
  784. if ( nStation != -1)
  785. {
  786. SendStationAlarmMsgToClient(nStation,AlarmText);
  787. }
  788. else
  789. {
  790. ELECSTATIONMAP::iterator iterStation =m_MI_powerstation.begin();
  791. for ( ;iterStation != m_MI_powerstation.end(); iterStation++)
  792. {
  793. SendStationAlarmMsgToClient(iterStation->second.stationID,AlarmText);
  794. }
  795. }
  796. SendControlPermission();
  797. }
  798. void PowerEventDeal::SendControlPermission()
  799. {
  800. //设置车站设备控制区域
  801. ELECSTATIONMAP::iterator iter= m_MI_powerstation.begin();
  802. for (;iter != m_MI_powerstation.end();iter++)
  803. {
  804. CONTROLPERMISSION controlperssion;
  805. controlperssion.nStationID=iter->second.stationID;
  806. controlperssion.nControlArea=iter->second.ctrlarea;
  807. OCCCOMMAND tmpSendHC;
  808. tmpSendHC.setPacketValue(&controlperssion,OCCCOMMAND::eUpdateSendControlPermission);
  809. tmpSendHC.DesSysType=OCC_SYS_DD_CLIENT;
  810. tmpSendHC.TrainningID = m_trainID;
  811. tmpSendHC.ScrSysType=OCC_SYS_DD_SVR;
  812. p_SendList->push(tmpSendHC);
  813. }
  814. }
  815. void PowerEventDeal::SendMsgToTech(UpdateEvaOperStatus data)
  816. {
  817. OCCCOMMAND NetOrder;
  818. NetOrder.setPacketValue(&data,OCCCOMMAND::eUpdateEvaOperStatus);
  819. NetOrder.TrainningID = m_trainID;
  820. NetOrder.ScrSysType = OCC_SYS_DD_SVR;
  821. NetOrder.DesSysType = OCC_SYS_SERVER_TH;
  822. p_SendList->push(NetOrder);
  823. }
  824. void PowerEventDeal::EqpmetInit()
  825. {
  826. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->begin();
  827. for( ; iter != pElectricEqpmtMap->end(); iter++ )
  828. {
  829. /*if ( iter->second->GetInitStatus() != iter->second->GetStatus())
  830. {
  831. iter->second->UpdateEqpmtStatus( *pElectricEqpmtMap,iter->second->GetInitStatus(), CTRLTYPE_STATUS);
  832. }*/
  833. int status=iter->second->GetInitStatus();
  834. iter->second->SetEqmpInitStatus(status); //状态初始化
  835. iter->second->SetFaultLockStatus(Electric_Eqpmt_Status_UnLock);//故障锁闭初始化
  836. iter->second->SetControlLock(Electric_Eqpmt_Status_UnLock);//控制闭锁初始化
  837. iter->second->SetCommunicationStatus(false);//设置通讯正常
  838. iter->second->SetCardStatus(ELC_EQPMTCARDSTATUS_NORMAL);//设置挂牌正常
  839. iter->second->SetRemoteLockStatus(Electric_Eqpmt_Status_RemoteUnLock);//设置遥信闭锁正常
  840. iter->second->SetControlArea(ELC_EQPMTCTRL_REMOTE);//设置控制方式默认为远程控制
  841. iter->second->ResetInputPower();
  842. //iter->second->UpdateEqpmtStatus( *pElectricEqpmtMap,iter->second->GetStatus(), CTRLTYPE_STATUS);
  843. }
  844. InitEqpmtStatusToIBP();
  845. }
  846. void PowerEventDeal::SetEqpmtTelemeteryValue(string Eqpmtid, int nType, float nValue, int IsReset)
  847. {
  848. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->find(Eqpmtid);
  849. if (iter!=pElectricEqpmtMap->end())
  850. {
  851. if (IsReset != 1)
  852. {
  853. int nBaseType = iter->second->GetBaseType();
  854. int nSubType = iter->second->GetSubType();
  855. string strKey("");
  856. strKey = std::to_string(nBaseType);
  857. EQPMTTELEINFO::iterator iter_tele = mptr_EqpmtTeleInfo->find(strKey);
  858. if (iter_tele == mptr_EqpmtTeleInfo->end())
  859. {
  860. strKey = std::to_string(nBaseType) + "-" + std::to_string(nSubType);
  861. iter_tele = mptr_EqpmtTeleInfo->find(strKey);
  862. }
  863. if(iter_tele != mptr_EqpmtTeleInfo->end())
  864. {
  865. EqpmtTelemeteryValueInfo* ptrTeleInfo = iter_tele->second;
  866. string EppmtTypeName = iter->second->GetBaseTypeName();
  867. string EqpmtName = iter->second->GetEqpmentName();
  868. int EqpmtSourceStatonID = iter->second->GetSourceStationID();
  869. std::string AlarmText = "";
  870. bool IsAlarm = false;
  871. int nActType;
  872. if( 1 == nType )//电压
  873. {
  874. if (nValue < ptrTeleInfo->Excptional_nMinV || nValue > ptrTeleInfo->Excptional_nMaxV)//数值非法
  875. {
  876. std::stringstream ss;
  877. ss << EppmtTypeName << " " << EqpmtName
  878. << " 电压置数 " << std::fixed << std::setprecision(2) << nValue
  879. << " 数值非法";
  880. AlarmText = ss.str();
  881. iter->second->SendMsgNotice(EqpmtSourceStatonID, 10, 2, 2, 0, AlarmText, Eqpmtid);
  882. return;
  883. }
  884. else if (nValue >= ptrTeleInfo->Namol_nMaxV /*&& nValue <= ptrTeleInfo->Excptional_nMaxV*/)
  885. {
  886. nActType = ElcAlarm_TripActType_HighV; //高压
  887. IsAlarm = true;
  888. }
  889. else if (nValue <= ptrTeleInfo->Namol_nMinV/* && nValue >= ptrTeleInfo->Excptional_nMinV*/)
  890. {
  891. nActType = ElcAlarm_TripActType_LowV; //低压
  892. IsAlarm = true;
  893. }
  894. }
  895. else
  896. {
  897. if (nValue < ptrTeleInfo->Excptional_nMinA || nValue > ptrTeleInfo->Excptional_nMaxA)//数值非法
  898. {
  899. std::stringstream ss;
  900. ss << EppmtTypeName << " " << EqpmtName
  901. << " 电流置数 " << std::fixed << std::setprecision(2) << nValue
  902. << " 数值非法";
  903. AlarmText = ss.str();
  904. iter->second->SendMsgNotice(EqpmtSourceStatonID, 10, 2, 2, 0, AlarmText, Eqpmtid);
  905. return;
  906. }
  907. else if (nValue >= ptrTeleInfo->Namol_nMaxA && nValue <= ptrTeleInfo->Excptional_nMaxA)
  908. {
  909. nActType = ElcAlarm_TripActType_HighA; //大电流
  910. IsAlarm = true;
  911. }
  912. }
  913. if(IsAlarm) iter->second->UpdateAlarmType(nBaseType, EppmtTypeName, EqpmtName, EqpmtSourceStatonID,nActType);
  914. }
  915. }
  916. iter->second->UpdateEqpmtTeleValue(Eqpmtid, nType, nValue, IsReset);
  917. }
  918. }
  919. //设置设备定值分区
  920. void PowerEventDeal::DealWith_EqpmtFixedAreaCtrl(string Eqpmtid, int CtrlType, int FixedArea, int SysID)
  921. {
  922. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->find(Eqpmtid);
  923. if (iter != pElectricEqpmtMap->end())
  924. {
  925. string EqpmtTypeName = iter->second->GetBaseTypeName(); //设备类型名称
  926. string EqpmtName = iter->second->GetEqpmentName(); //设备名称
  927. const int EqpmtSourceStatonID = iter->second->GetSourceStationID(); //设备所属车站ID
  928. string AlarmText;
  929. if (CtrlType == 1)
  930. {
  931. //AlarmText.Format("%s%s修改定值区号为 %d", EqpmtTypeName, EqpmtName, FixedArea);
  932. std::stringstream ss;
  933. ss << EqpmtTypeName << EqpmtName
  934. << " 修改定值区号为 " << std::dec << FixedArea;
  935. AlarmText = ss.str();
  936. }
  937. else if (CtrlType == 2)
  938. {
  939. //AlarmText.Format("%s%s确认修改定值区号为 %d", EqpmtTypeName, EqpmtName, FixedArea);
  940. std::stringstream ss;
  941. ss << EqpmtTypeName << EqpmtName
  942. << " 确认修改定值区号为 " << std::dec << FixedArea;
  943. AlarmText = ss.str();
  944. }
  945. else
  946. {
  947. //AlarmText.Format("%s%s撤销修改定值区号", EqpmtTypeName, EqpmtName);
  948. std::stringstream ss;
  949. ss << EqpmtTypeName << EqpmtName
  950. << " 撤销修改定值区号";
  951. AlarmText = ss.str();
  952. }
  953. iter->second->SendMsgNotice(EqpmtSourceStatonID, 10, 2, 2, 0, AlarmText, Eqpmtid);
  954. UpdateEvaOperStatus updateEvaOperStatus;
  955. memset(&updateEvaOperStatus, 0, sizeof(UpdateEvaOperStatus));
  956. updateEvaOperStatus.TrainID = m_trainID;
  957. updateEvaOperStatus.CourseID = GetCourseID();
  958. updateEvaOperStatus.OperItemType = Item_Type_DD;
  959. updateEvaOperStatus.OperItemObject = MajorType_DD;
  960. updateEvaOperStatus.OperClientID = SysID;
  961. updateEvaOperStatus.OperStuID = MajorType_DD;
  962. strncpy(updateEvaOperStatus.AssociPara1, Eqpmtid.c_str(),sizeof(updateEvaOperStatus.AssociPara1));
  963. strncpy(updateEvaOperStatus.AssociPara1Name, EqpmtName.c_str(), sizeof(updateEvaOperStatus.AssociPara1Name));
  964. string StationID;
  965. StationID = std::to_string(iter->second->GetSourceStationID());
  966. strncpy(updateEvaOperStatus.AssociPara2, StationID.c_str(), sizeof(updateEvaOperStatus.AssociPara2));
  967. string StationName = GetStationName(iter->second->GetSourceStationID());
  968. strncpy(updateEvaOperStatus.AssociPara2Name, StationName.c_str(), sizeof(updateEvaOperStatus.AssociPara2Name));
  969. updateEvaOperStatus.OperStatus = CtrlType;
  970. updateEvaOperStatus.OperItemSubType1 = DD_Operate_Item_SwitchEqpmt; //开关设备操作
  971. updateEvaOperStatus.OperItemSubType2 = Switch_EqpmtFixedArea_Set;//定值区设置
  972. SendMsgToTech(updateEvaOperStatus);
  973. }
  974. }
  975. //设置车站通信状态
  976. void PowerEventDeal::DealWith_StationCommunicationStatus(int nStation, int IsReset)
  977. {
  978. int nStatus = 0;
  979. string AlarmText = "车站通信中断"; //报文内容
  980. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->begin();
  981. for ( ;iter!=pElectricEqpmtMap->end(); iter++)
  982. {
  983. if ((nStation == -1 || iter->second->GetSourceStationID() == nStation) && (iter->second->GetBaseType() == OCC_EQPMTTYPE_AUTOBOLT
  984. || iter->second->GetBaseType() == OCC_EQPMTTYPE_35kVBREAKER || iter->second->GetBaseType() == OCC_EQPMTTYPE_110kVBreaker
  985. || iter->second->GetBaseType() == OCC_EQPMTTYPE_110kVSwitch || iter->second->GetBaseType() == OCC_EQPMTTYPE_400vACControlBreaker
  986. || iter->second->GetBaseType() == OCC_EQPMTTYPE_BREAKER_DC ) )
  987. {
  988. if (IsReset)
  989. {
  990. nStatus = 0;
  991. AlarmText = "车站通信恢复"; //报文内容
  992. iter->second->UpdateCommmunicationStatus(nStatus);
  993. iter->second->UpdateEqpmtStatus(*pElectricEqpmtMap,iter->second->GetStatus());
  994. iter->second->UpdateEqpmtLightCardStatu(-1);
  995. }
  996. else
  997. {
  998. nStatus = 1;
  999. AlarmText = "车站通信中断"; //报文内容
  1000. iter->second->UpdateCommmunicationStatus(nStatus);
  1001. iter->second->UpdateEqpmtStatus(*pElectricEqpmtMap,iter->second->GetStatus());
  1002. iter->second->DealTelesignalisation(10000,iter->second->GetEqpmentID(),1);
  1003. iter->second->UpdateEqpmtLightCardStatu(10000);
  1004. }
  1005. }
  1006. }
  1007. if ( nStation != -1)
  1008. {
  1009. SendStationAlarmMsgToClient(nStation,AlarmText);
  1010. }
  1011. else
  1012. {
  1013. ELECSTATIONMAP::iterator iterStation =m_MI_powerstation.begin();
  1014. for ( ;iterStation != m_MI_powerstation.end(); iterStation++)
  1015. {
  1016. SendStationAlarmMsgToClient(iterStation->second.stationID,AlarmText);
  1017. }
  1018. }
  1019. }
  1020. //向客户端发送报警信息
  1021. void PowerEventDeal::SendStationAlarmMsgToClient(int nStation, string AlarmText)
  1022. {
  1023. if (p_SendList!=NULL)
  1024. {
  1025. DHMSGNOTICE DHNotice;
  1026. DHNotice.StationID = nStation;
  1027. DHNotice.Time = GetNumTime_Second_2();
  1028. DHNotice.RegionID = ISCS_SUBSYS_TYPE_ELC;
  1029. DHNotice.Type = 9;
  1030. DHNotice.Level =2;
  1031. strncpy(DHNotice.LabelValue,AlarmText.c_str(), sizeof(DHNotice.LabelValue));
  1032. OCCCOMMAND NetOrder;
  1033. NetOrder.DesSysType = OCC_SYS_DD_CLIENT;
  1034. NetOrder.ScrSysType = OCC_SYS_DD_SVR;
  1035. NetOrder.TrainningID = m_trainID;
  1036. NetOrder.setPacketValue(&DHNotice,OCCCOMMAND::eUpdateDHMsgNotice);
  1037. p_SendList->push(NetOrder);
  1038. }
  1039. }
  1040. void PowerEventDeal::InitEqpmtStatusToIBP()
  1041. {
  1042. ELEEQPMTMAP::iterator iter = pElectricEqpmtMap->begin();
  1043. for( ; iter != pElectricEqpmtMap->end(); iter++ )
  1044. {
  1045. //直流断路器
  1046. if (iter->second->GetBaseType() ==OCC_EQPMTTYPE_BREAKER_DC)
  1047. {
  1048. EqpmtStatusToIBP(iter->first,Electric_Eqpmt_Status_ON);
  1049. }
  1050. }
  1051. }
  1052. void PowerEventDeal::EqpmtStatusToIBP( const std::string& strEqpmtID, int nEqpmtStatus )
  1053. {
  1054. string strKey = MakeCStr_IntKey_2(strEqpmtID, nEqpmtStatus);
  1055. auto iter = m_MIEqpmtStatusToIBPLight.find(strKey);
  1056. if ( iter == m_MIEqpmtStatusToIBPLight.end() )
  1057. {
  1058. return;
  1059. }
  1060. if ( !iter->second.m_strLightingOffIBPkey.empty() )
  1061. {
  1062. int nIBPSysID = iter->second.m_nIBPSysID;
  1063. string strLightingOffIBPkey = iter->second.m_strLightingOffIBPkey;
  1064. int nIBPStationID = iter->second.m_nIBPStationID;
  1065. UpdateIBPLightStatus(nIBPSysID, strLightingOffIBPkey, 0, 0, nIBPStationID);
  1066. }
  1067. if ( !iter->second.m_strLightenIBPKey.empty() )
  1068. {
  1069. int nIBPSysID = iter->second.m_nIBPSysID;
  1070. string strLightingOffIBPkey = iter->second.m_strLightenIBPKey;
  1071. int nIBPStationID = iter->second.m_nIBPStationID;
  1072. UpdateIBPLightStatus(nIBPSysID, strLightingOffIBPkey, 0, 0, nIBPStationID);
  1073. }
  1074. }
  1075. void PowerEventDeal::UpdateIBPLightStatus(int nIBPSysID, std::string& strKey, int nStatus,int nflashFlag,int nIBPIOID)
  1076. {
  1077. vector<string> vecKey;
  1078. string strFindKey = ";";
  1079. if ( !strKey.empty() )
  1080. {
  1081. vecKey = str_split_2( strKey, strFindKey );
  1082. }
  1083. if ( !vecKey.empty() )
  1084. {
  1085. UpdateIBPLightStatus(nIBPSysID, vecKey, nStatus,nflashFlag,nIBPIOID);
  1086. }
  1087. }
  1088. void PowerEventDeal::UpdateIBPLightStatus( int nIBPSysID, vector<std::string>& vecKey, int nStatus,int nflashFlag,int nIBPIOID )
  1089. {
  1090. for ( int i = 0; i < vecKey.size(); i++ )
  1091. {
  1092. UpdateIBPLightStatus( nIBPSysID, stoi(vecKey[i]), nStatus ,nflashFlag,nIBPIOID);
  1093. }
  1094. }
  1095. void PowerEventDeal::UpdateIBPLightStatus( int nIBPSysID, int nKey, int nStatus,int nflashFlag ,int nIBPIOID)
  1096. {
  1097. if(nKey <= 0)
  1098. {
  1099. return;
  1100. }
  1101. OCCCOMMAND tmpOccComand;
  1102. tmpOccComand.DesSysType = OCC_SYS_SERVER_SETSYS;
  1103. tmpOccComand.DesNetID = nIBPSysID;
  1104. tmpOccComand.ScrSysType = OCC_SYS_XD_SVR;
  1105. tmpOccComand.TrainningID = m_trainID;
  1106. tmpOccComand.cmdType = OCCCOMMAND::CMD_CTRL_IBPEQPMT;
  1107. IBPPACKET Net_IBP_SERVER;
  1108. memset(&Net_IBP_SERVER,0,sizeof(Net_IBP_SERVER));
  1109. Net_IBP_SERVER.nIBPID = nKey;
  1110. Net_IBP_SERVER.param1 = nStatus;
  1111. Net_IBP_SERVER.param2 = nflashFlag;
  1112. if (nIBPIOID>0)
  1113. {
  1114. Net_IBP_SERVER.nIBPStationID =nIBPIOID;
  1115. }
  1116. tmpOccComand.setPacketValue(&Net_IBP_SERVER,OCCCOMMAND::CMD_CTRL_IBPEQPMT);
  1117. p_SendList->push(tmpOccComand);
  1118. }