ElectricEqpmt_Breaker.cpp 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942
  1. #include "pch.h"
  2. #include "ElectricEqpmt_Breaker.h"
  3. #include "ElectricEqpmt_PowerBolt.h"
  4. map<int, BreakerDelayTime> ElectricEqpmt_Breaker::mapBreakerDelayTime;
  5. map<string,string> ElectricEqpmt_Breaker::m_mapCheckedEqpmtStrID;
  6. bool ElectricEqpmt_Breaker::handle_delaytime(time_t& time, map<string, BaseElectricEqpmt*>& eqpmtmap, const DelayTimeInfo& delayparm)
  7. {
  8. // 添加设备控制延时判断
  9. bool bRet = CElectricEqpmt_SwicthEqpmt::handle_delaytime(time, eqpmtmap, delayparm);
  10. if (!bRet)
  11. {
  12. return false; //处理的是控制延时
  13. }
  14. //xyx新增begin
  15. string EqpmtTypeName = GetBaseTypeName(); //设备类型名称
  16. string EqpmtName = GetEqpmentName(); //设备名称
  17. int EqpmtSourceStatonID = GetSourceStationID(); //设备所属车站ID
  18. int EqpmtType = GetBaseType(); //设备类型
  19. //xyx新增end
  20. if (delayparm.type==Auto_DelayTime_InitCtrl) //主动联控类型处理方法
  21. {
  22. // 时间间隔判断
  23. if (time - delayparm.occartime <= delayparm.delaydur)
  24. return true;
  25. ELEEQPMTMAP::iterator iter;
  26. // 如果目联备自投退出则主动联控不生效
  27. if ( !m_strMotherAutoBolt.empty() && (GetSubType() == Electric_Breaker_Circuit || GetSubType() == Electric_Breaker_Input))
  28. {
  29. iter = eqpmtmap.find( m_strMotherAutoBolt );
  30. if ( iter != eqpmtmap.end() )
  31. {
  32. if ( !iter->second->GetStatus())
  33. {
  34. return false;
  35. }
  36. }
  37. }
  38. iter = eqpmtmap.find(delayparm.srcid);
  39. if (iter!= eqpmtmap.end())
  40. {
  41. if (iter->second->GetStatus()!=delayparm.srcstatus)
  42. {
  43. return false;
  44. }
  45. }
  46. ResetCtrlMark();
  47. //xyx修改begin
  48. if (delayparm.destatus==Electric_Eqpmt_Status_ON&&GetStatus()!=Electric_Eqpmt_Status_ON)//目标状态为合闸,设备显示状态不为合闸则对其送电
  49. {
  50. TurnOn(eqpmtmap);
  51. int nActType1 = ElcAlarm_TripActType_SelfClose; //“自复”合闸报文类型
  52. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType1);
  53. }
  54. if (delayparm.destatus==Electric_Eqpmt_Status_OFF&&GetStatus()!=Electric_Eqpmt_Status_OFF) //目标状态为分闸,设备显示状态不为分闸则对其送电
  55. {
  56. TurnOff(eqpmtmap,Auto_DelayTime_InitCtrl);
  57. int nActType2 = ElcAlarm_TripActType_SelfOpen; //“自切”分闸报文类型
  58. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType2);
  59. }
  60. //xyx修改end
  61. return false;
  62. }
  63. if (delayparm.type==Auto_DelayTime_RepeatShut) //重合闸类型处理方法
  64. {
  65. switch (RepeatShut)
  66. {
  67. case Auto_RepeatShut_Status_START: //重合闸开始
  68. {
  69. //string strtext;
  70. //strtext.Format("%s%s重合闸开始",GetTypeName(),GetName());
  71. //SendMsgNotice(m_SourceStation,m_Region,3,DH_MSGCATEGORY_SYS,strtext,GetStrID());
  72. RepeatShutST = time;
  73. LastShutST = time;
  74. RepeatShut =Auto_RepeatShut_Status_WAIT;
  75. ResetRepeatShutIndex();
  76. }
  77. break;
  78. case Auto_RepeatShut_Status_WAIT:
  79. {
  80. //CTimeSpan Timespan=CTimeSpan(0,0,0,Auto_RepeatShut_Dur_Time); //备自投动作时间>线路电源侧后备保护动作时间+线路重合闸时间
  81. // CTimeSpan Timespan=CTimeSpan(0,0,0, GetCurIndexDelayTime() );
  82. if (LastShutST+ GetCurIndexDelayTime() < time)
  83. {
  84. if (GetStatus()==Electric_Eqpmt_Status_OFF)
  85. {
  86. TurnOn(eqpmtmap);
  87. //xyx屏蔽begin
  88. // string text;
  89. // text.Format(" %s %s 自动重合闸 位置 合闸",GetBaseTypeName(),GetEqpmentName());
  90. // SendMsgNotice(GetSourceStationID(),GetRegion(),2,DH_MSGCATEGORY_SOE,text,GetEqpmentID());
  91. //xyx屏蔽end
  92. //xyx修改begin
  93. int nActType1 = ElcAlarm_TripActType_Close; //“合闸”报文类型
  94. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType1);
  95. //xyx修改end
  96. }
  97. RepeatShut =Auto_RepeatShut_Status_SHUT;
  98. LastShutST = time;
  99. MoveNextRepeatShutIndex();
  100. }
  101. }
  102. break;
  103. case Auto_RepeatShut_Status_SHUT:
  104. {
  105. RepeatShut = Auto_RepeatShut_Status_JUDGE;
  106. }
  107. break;
  108. case Auto_RepeatShut_Status_JUDGE:
  109. {
  110. //CTimeSpan Timespan=CTimeSpan(0,0,0, GetCurIndexDelayTime() );
  111. if (LastShutST + GetCurIndexDelayTime() < time)
  112. {
  113. if (delayparm.faultType == Fault_Type_Fever)
  114. {
  115. TurnOff(eqpmtmap, delayparm.faultID);
  116. //xyx屏蔽begin
  117. //string text;
  118. //text.Format(" %s %s 位置 分闸",GetBaseTypeName(),GetEqpmentName());
  119. //SendMsgNotice(GetSourceStationID(),GetRegion(),1,DH_MSGCATEGORY_SOE,text);
  120. //xyx屏蔽end
  121. //xyx修改begin
  122. int nActType2 = ElcAlarm_TripActType_Open; ////重合闸“分闸”报文类型
  123. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType2);
  124. //xyx修改end
  125. MoveNextRepeatShutIndex();
  126. RepeatShut=Auto_RepeatShut_Status_BREAK;
  127. //CTimeSpan Timespan=CTimeSpan(0,0,0,Auto_RepeatShut_All_Time);
  128. //CTimeSpan Timespan=CTimeSpan(0,0,0,GetAllRepeatShutTime());
  129. if (time >RepeatShutST + GetAllRepeatShutTime())
  130. {
  131. //xyx屏蔽begin
  132. //string strtext;
  133. //strtext.Format(" %s %s 重合闸不成功",GetBaseTypeName(), GetEqpmentName() );
  134. //SendMsgNotice(GetSourceStationID(),GetRegion(),1,DH_MSGCATEGORY_SYS,strtext);
  135. //xyx屏蔽end
  136. //xyx修改begin
  137. int nActType3 = ElcAlarm_TripActType_RepeatShut_Fail; //“重合闸不成功”报文类型
  138. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType3);
  139. //xyx修改end
  140. RepeatShut = Auto_RepeatShut_Status_Lock;
  141. }
  142. }
  143. else if(delayparm.faultType == Fault_Type_OneTime)
  144. {
  145. //xyx屏蔽begin
  146. //string strtext;
  147. //strtext.Format(" %s %s 重合闸成功",GetBaseTypeName(), GetEqpmentName() );
  148. //SendMsgNotice(GetSourceStationID(),GetRegion(),1,DH_MSGCATEGORY_SYS,strtext);
  149. //xyx屏蔽end
  150. //xyx修改begin
  151. int nActType4 = ElcAlarm_TripActType_RepeatShut_Success; //“重合闸成功”报文类型
  152. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType4);
  153. //xyx修改end
  154. RepeatShut = Auto_RepeatShut_Status_SUCCESS;
  155. }
  156. }
  157. }
  158. break;
  159. case Auto_RepeatShut_Status_BREAK:
  160. {
  161. LastShutST = time;
  162. RepeatShut =Auto_RepeatShut_Status_WAIT;
  163. }
  164. break;
  165. case Auto_RepeatShut_Status_Lock:
  166. {
  167. RepeatShut =Auto_RepeatShut_Status_NONE;
  168. //UpdateLockStatus(Electric_Eqpmt_Status_Lock);
  169. UpdateFaultLockStatus(Electric_Eqpmt_Status_Lock);
  170. UpdateEqpmtLightCardStatu(delayparm.faultID);
  171. UpdateEqpmtStatus(eqpmtmap,Electric_Eqpmt_Status_OFF);
  172. ResetRepeatShutIndex();
  173. return false;
  174. }
  175. break;
  176. case Auto_RepeatShut_Status_SUCCESS:
  177. {
  178. RepeatShut =Auto_RepeatShut_Status_NONE;
  179. ResetRepeatShutIndex();
  180. return false;
  181. }
  182. break;
  183. }
  184. }
  185. return true;
  186. }
  187. ElectricEqpmt_Breaker::ElectricEqpmt_Breaker()
  188. {
  189. RepeatShut=Auto_RepeatShut_Status_NONE;
  190. ActiveProtectIndex=-1;
  191. ResetRepeatShutIndex();
  192. SetEqpmentType(Electric_EqpmentType_Breaker);
  193. }
  194. bool ElectricEqpmt_Breaker::AddProtectRelation(ProtectValue& protect)
  195. {
  196. SettingProtects.push_back(protect);
  197. return true;
  198. }
  199. void ElectricEqpmt_Breaker::SetRepeatShut(int shutstatus)
  200. {
  201. RepeatShut = shutstatus;
  202. }
  203. void ElectricEqpmt_Breaker::SetCommunicationStatus(map<string,BaseElectricEqpmt*>& ElectricEqpmtMap)
  204. {
  205. UpdateCommmunicationStatus(1);
  206. UpdateEqpmtStatus(ElectricEqpmtMap,GetStatus());
  207. //xyx屏蔽begin
  208. //string text;
  209. //text.Format(" %s %s 通讯中断",GetBaseTypeName(),GetEqpmentName());
  210. //SendMsgNotice(GetSourceStationID(),GetRegion(),3,DH_MSGCATEGORY_SOE,text);
  211. //xyx屏蔽end
  212. //xyx修改begin
  213. string EqpmtTypeName = GetBaseTypeName(); //设备类型名称
  214. string EqpmtName = GetEqpmentName(); //设备名称
  215. int EqpmtSourceStatonID = GetSourceStationID(); //设备所属车站ID
  216. int EqpmtType = GetBaseType(); //设备类型
  217. int nActType = ElcAlarm_TripActType_Comloss; //“通讯中断”报文类型
  218. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType);
  219. //xyx修改end
  220. }
  221. void ElectricEqpmt_Breaker::CancleCommunicationStatus(map<string,BaseElectricEqpmt*>& ElectricEqpmtMap)
  222. {
  223. UpdateCommmunicationStatus(0);
  224. UpdateEqpmtStatus(ElectricEqpmtMap,GetStatus());
  225. //xyx屏蔽begin
  226. //string text;
  227. //text.Format(" %s %s 通讯恢复",GetBaseTypeName(),GetEqpmentName());
  228. //SendMsgNotice(GetSourceStationID(),GetRegion(),2,DH_MSGCATEGORY_SOE,text);
  229. //xyx屏蔽end
  230. //xyx修改begin
  231. string EqpmtTypeName = GetBaseTypeName(); //设备类型名称
  232. string EqpmtName = GetEqpmentName(); //设备名称
  233. int EqpmtSourceStatonID = GetSourceStationID(); //设备所属车站ID
  234. int EqpmtType = GetBaseType(); //设备类型
  235. int nActType = ElcAlarm_TripActType_ComRecovery; //“通讯恢复”报文类型
  236. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType);
  237. //xyx修改end
  238. }
  239. int ElectricEqpmt_Breaker::CheckAutoUnionStatus(int errorid,ELEEQPMTMAP& ElectricEqpmtMap, const ProtectValue& protectValue, bool bAutoRelation/* = true */)
  240. {
  241. for (int i=0;i<m_ActUnions.size();i++)
  242. {
  243. //if (m_ActUnions[i].OperStatus==GetStatus())
  244. {
  245. if (m_ActUnions[i].EventID==protectValue.pretectid)
  246. {
  247. ELEEQPMTMAP::iterator iter = ElectricEqpmtMap.find(m_ActUnions[i].PreEqpmtID);
  248. if (iter==ElectricEqpmtMap.end())
  249. return -1;
  250. iter->second->CheckTripping(ElectricEqpmtMap,protectValue);
  251. //add by yangs 20230702
  252. iter->second->OccarSearchError(protectValue.faultid);
  253. }
  254. }
  255. }
  256. return 0;
  257. }
  258. int ElectricEqpmt_Breaker::EqpmtAutoBreak(ELEEQPMTMAP& ElectricEqpmtMap,const ProtectValue& protectValue, bool bAutoRelation /*= true*/ )
  259. {
  260. // 故障跳闸变更控制方式为系统控制
  261. ResetCtrlMark();
  262. //add by yangs 20230702
  263. OccarSearchError(protectValue.faultid);
  264. //if (m_status==Electric_Eqpmt_Status_ON)
  265. {
  266. if ( protectValue.breakerRejection || !bAutoRelation )
  267. {
  268. if (GetStatus()==Electric_Eqpmt_Status_ON)
  269. {
  270. TurnOff(ElectricEqpmtMap, protectValue.faultid );
  271. //add by yangs 20230111
  272. string EqpmtTypeName = GetBaseTypeName(); //设备类型名称
  273. string EqpmtName = GetEqpmentName(); //设备名称
  274. int EqpmtSourceStatonID = GetSourceStationID(); //设备所属车站ID
  275. int EqpmtType = GetBaseType(); //设备类型
  276. int nActType1 = ElcAlarm_TripActType_Open; //“分闸”报文类型
  277. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType1);
  278. }
  279. }
  280. if (ActiveProtectIndex>=0&&ActiveProtectIndex<SettingProtects.size())
  281. {
  282. if(RepeatShut==Auto_RepeatShut_Status_NONE)
  283. {
  284. if (SettingProtects[ActiveProtectIndex].kind==Protect_Kind_Main)
  285. {
  286. RepeatShut =Auto_RepeatShut_Status_START;
  287. DelayTimeInfo delay;
  288. delay.type=Auto_DelayTime_RepeatShut;
  289. delay.faultType = SettingProtects[ActiveProtectIndex].faulttype;
  290. delay.faultID = SettingProtects[ActiveProtectIndex].faultid;
  291. p_DelayTimeMap->insert(make_pair(GetEqpmentID(),delay));
  292. }
  293. else
  294. {
  295. //UpdateLockStatus(Electric_Eqpmt_Status_Lock);
  296. UpdateFaultLockStatus(Electric_Eqpmt_Status_Lock);
  297. UpdateEqpmtLightCardStatu(protectValue.pretectid);
  298. }
  299. if ( protectValue.breakerRejection || !bAutoRelation )
  300. {
  301. UpdateEqpmtStatus(ElectricEqpmtMap,Electric_Eqpmt_Status_OFF);
  302. }
  303. else
  304. {
  305. // 失灵拒动时更新失败锁闭状态
  306. UpdateEqpmtStatus(ElectricEqpmtMap, GetStatus());
  307. }
  308. }
  309. }
  310. // 设置是否可以复归
  311. //add by yangs 20230701
  312. if( protectValue.nPermanentFault == 1){
  313. setProhibitedReversion();
  314. }
  315. }
  316. if ( bAutoRelation )
  317. {
  318. // 只联跳一层关系
  319. CheckAutoUnionStatus(protectValue.faultid, ElectricEqpmtMap, protectValue, false);
  320. }
  321. // 遥信功能设置
  322. DealTelesignalisation( protectValue.pretectid, GetEqpmentID(), 1);
  323. return 0;
  324. }
  325. void ElectricEqpmt_Breaker::CalculateValue(double inputv,double inputI,ELEEQPMTMAP* PEqpmtMap)
  326. {
  327. InputVoltage=inputv;
  328. InputElectricity=inputI;
  329. if (GetStatus()==Electric_Eqpmt_Status_ON)
  330. {
  331. OutputVoltage=InputVoltage;
  332. OutputElectricity=InputElectricity;
  333. }
  334. else
  335. {
  336. OutputVoltage=0;
  337. OutputElectricity=0;
  338. }
  339. std::map<string,string>::iterator iter=OutputEqpmtIDMap.begin();
  340. for (;iter!=OutputEqpmtIDMap.end();iter++)
  341. {
  342. ELEEQPMTMAP::iterator Eqpmtiter;
  343. Eqpmtiter=PEqpmtMap->find(iter->first);
  344. if (Eqpmtiter!=PEqpmtMap->end())
  345. {
  346. Eqpmtiter->second->CalculateValue(OutputVoltage,OutputElectricity,PEqpmtMap);
  347. }
  348. }
  349. }
  350. bool ElectricEqpmt_Breaker::CheckProtect(ELEEQPMTMAP& ElectricEqpmtMap,int errorid,int protectid,bool bAutoRelation/* = true*/ )
  351. {
  352. for (size_t i=0;i<SettingProtects.size();i++)
  353. {
  354. if (SettingProtects[i].faultid==errorid&&SettingProtects[i].pretectid==protectid&&SettingProtects[i].status==Protect_Status_ON)
  355. {
  356. ActiveProtectIndex=i;
  357. //xyx屏蔽begin
  358. //string strtext;
  359. //strtext.Format("%s %s 动作",GetEqpmentName(), SettingProtects[ActiveProtectIndex].protectDisplayContent );
  360. //SendMsgNotice(GetSourceStationID(),GetRegion(),1,DH_MSGCATEGORY_SYS,strtext,GetEqpmentID());
  361. //xyx屏蔽end
  362. //xyx修改begin
  363. string EqpmtTypeName = GetBaseTypeName(); //设备类型名称
  364. string EqpmtName = GetEqpmentName(); //设备名称
  365. int EqpmtSourceStatonID = GetSourceStationID(); //设备所属车站ID
  366. int EqpmtType = GetBaseType(); //设备类型
  367. int nActType = SettingProtects[i].pretectid; //“保护”类型报文类型
  368. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType);
  369. //xyx修改end
  370. EqpmtAutoBreak(ElectricEqpmtMap, SettingProtects[i], bAutoRelation);
  371. return true;
  372. }
  373. }
  374. return false;
  375. }
  376. int ElectricEqpmt_Breaker::GetActiveProtectID()
  377. {
  378. if (ActiveProtectIndex<SettingProtects.size()&&ActiveProtectIndex>=0)
  379. {
  380. return SettingProtects[ActiveProtectIndex].pretectid;
  381. }
  382. return -1;
  383. }
  384. bool ElectricEqpmt_Breaker::handle_checkprotect(int eventOper,ELEEQPMTMAP& eqpmtmap,int errorid,int protectid)
  385. {
  386. if (GetStatus()==Electric_Eqpmt_Status_Error||GetControlLock()==Electric_Eqpmt_Status_Lock)
  387. {
  388. if (GetStatus()==Electric_Eqpmt_Status_ON)
  389. {
  390. for (size_t i=0;i<ProtectVecs.size();i++)
  391. {
  392. if ( ProtectVecs[i].EventID == protectid )
  393. {
  394. ELEEQPMTMAP::iterator iter = eqpmtmap.find(ProtectVecs[i].ProtectStrID);
  395. if (iter==eqpmtmap.end())
  396. continue;
  397. iter->second->handle_checkprotect(eventOper,eqpmtmap,errorid,protectid);
  398. }
  399. }
  400. //xyx屏蔽begin
  401. //string strtext;
  402. //strtext.Format("%s%s拒动",GetBaseTypeName(),GetEqpmentName());
  403. //SendMsgNotice(GetSourceStationID(),GetRegion(),1,DH_MSGCATEGORY_SYS,strtext);
  404. //xyx屏蔽end
  405. //xyx修改begin
  406. string EqpmtTypeName = GetBaseTypeName(); //设备类型名称
  407. string EqpmtName = GetEqpmentName(); //设备名称
  408. int EqpmtSourceStatonID = GetSourceStationID(); //设备所属车站ID
  409. int EqpmtType = GetBaseType(); //设备类型
  410. int nActType = protectid; //“失灵拒动”报文类型
  411. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType);
  412. //xyx修改end
  413. }
  414. }
  415. else if (eventOper==POWER_ERORR_OCCAR)
  416. {
  417. CheckProtect(eqpmtmap,errorid,protectid);
  418. }
  419. return true;
  420. }
  421. ElectricEqpmt_PowerBolt* ElectricEqpmt_Breaker::GetBoltInShut(ELEEQPMTMAP& eqpmtmap)
  422. {
  423. int count =0;
  424. std::map<string,InputLineInfo>::iterator iter = InputEqpmtIDMap.begin();
  425. for (;iter!=InputEqpmtIDMap.end();iter++)
  426. {
  427. if (iter->second.InputPower)
  428. {
  429. count++;
  430. }
  431. }
  432. ElectricEqpmt_PowerBolt* pbolt=NULL;
  433. ELEEQPMTMAP::iterator iterbolt = eqpmtmap.find(GetAutoBoltID());
  434. if (iterbolt!=eqpmtmap.end())
  435. {
  436. if (GetStatus()==Electric_Eqpmt_Status_OFF && count==1&&InputEqpmtIDMap.size()==2)
  437. {
  438. if (iterbolt->second->GetBaseType()==OCC_EQPMTTYPE_AUTOBOLT)
  439. {
  440. pbolt=(ElectricEqpmt_PowerBolt*)iterbolt->second;
  441. }
  442. }
  443. }
  444. return pbolt;
  445. }
  446. ElectricEqpmt_PowerBolt* ElectricEqpmt_Breaker::GetBoltInOff(ELEEQPMTMAP& eqpmtmap)
  447. {
  448. int count =0;
  449. std::map<string,InputLineInfo>::iterator iter = InputEqpmtIDMap.begin();
  450. for (;iter!=InputEqpmtIDMap.end();iter++)
  451. {
  452. if (iter->second.InputPower)
  453. {
  454. count++;
  455. }
  456. }
  457. ElectricEqpmt_PowerBolt* pbolt=NULL;
  458. ELEEQPMTMAP::iterator iterbolt = eqpmtmap.find(GetAutoBoltID());
  459. if (iterbolt!=eqpmtmap.end())
  460. {
  461. if (GetStatus()==Electric_Eqpmt_Status_ON && count==2&&InputEqpmtIDMap.size()==2)
  462. {
  463. if (iterbolt->second->GetBaseType()==OCC_EQPMTTYPE_AUTOBOLT)
  464. {
  465. pbolt=(ElectricEqpmt_PowerBolt*)iterbolt->second;
  466. }
  467. }
  468. }
  469. return pbolt;
  470. }
  471. void ElectricEqpmt_Breaker::SetRemoteLock(ELEEQPMTMAP& ElectricEqpmtMap,int status,int ctrlArea,int lockType)
  472. {
  473. SetControlArea(ctrlArea);
  474. UpdateRemoteLockStatus(Electric_Eqpmt_Status_RemoteLock);
  475. if (RemoteLockType_Off==lockType)
  476. {
  477. UpdateEqpmtStatus(ElectricEqpmtMap,Electric_Eqpmt_Status_OFF);
  478. }
  479. else if (RemoteLockType_On==lockType)
  480. {
  481. UpdateEqpmtStatus(ElectricEqpmtMap,Electric_Eqpmt_Status_ON);
  482. }
  483. else if (RemoteLockType_Test==lockType)
  484. {
  485. string str=GetBreakHandleID();
  486. ELEEQPMTMAP::iterator iter=ElectricEqpmtMap.find(str);
  487. if (iter!=ElectricEqpmtMap.end())
  488. {
  489. iter->second->UpdateEqpmtStatus(ElectricEqpmtMap,Electric_Eqpmt_Status_OFF);
  490. }
  491. }
  492. else if (RemoteLockType_Work==lockType)
  493. {
  494. string str=GetBreakHandleID();
  495. ELEEQPMTMAP::iterator iter=ElectricEqpmtMap.find(str);
  496. if (iter!=ElectricEqpmtMap.end())
  497. {
  498. iter->second->UpdateEqpmtStatus(ElectricEqpmtMap,Electric_Eqpmt_Status_ON);
  499. }
  500. }
  501. else if (RemoteLockType_Local==lockType)
  502. {
  503. UpdateEqpmtStatus(ElectricEqpmtMap,GetStatus());
  504. }
  505. /*if(status<=1)
  506. {
  507. UpdateEqpmtStatus(ElectricEqpmtMap,status);
  508. }
  509. else
  510. {
  511. if (status==OCC_BREAKERHAND_STATUS_TEST)
  512. {
  513. string str=GetBreakHandleID();
  514. ELEEQPMTMAP::iterator iter=ElectricEqpmtMap.find(str);
  515. if (iter!=ElectricEqpmtMap.end())
  516. {
  517. iter->second->UpdateEqpmtStatus(ElectricEqpmtMap,0);
  518. }
  519. }
  520. if (status==OCC_BREAKERHAND_STATUS_WORK)
  521. {
  522. string str=GetBreakHandleID();
  523. ELEEQPMTMAP::iterator iter=ElectricEqpmtMap.find(str);
  524. if (iter!=ElectricEqpmtMap.end())
  525. {
  526. iter->second->UpdateEqpmtStatus(ElectricEqpmtMap,1);
  527. }
  528. }
  529. }*/
  530. }
  531. void ElectricEqpmt_Breaker::CancleRemoteLock(ELEEQPMTMAP& ElectricEqpmtMap,int status,int ctrlArea)
  532. {
  533. SetControlArea(ctrlArea);
  534. UpdateRemoteLockStatus(Electric_Eqpmt_Status_RemoteUnLock);
  535. UpdateEqpmtStatus(ElectricEqpmtMap,status);
  536. }
  537. bool ElectricEqpmt_Breaker::CheckTripping( ELEEQPMTMAP& ElectricEqpmtMap, const ProtectValue& protectValue )
  538. {
  539. if ( Electric_Eqpmt_Status_ON == GetStatus())
  540. {
  541. // 联跳是直接跳闸,不受保护等其他因素影响
  542. TurnOff(ElectricEqpmtMap, protectValue.faultid );
  543. }
  544. // 判断联跳设备是否需要重合闸
  545. if ( protectValue.kind==Protect_Kind_Main && protectValue.trippingRepeatShut )
  546. {
  547. RepeatShut =Auto_RepeatShut_Status_START;
  548. DelayTimeInfo delay;
  549. delay.type=Auto_DelayTime_RepeatShut;
  550. delay.faultType = protectValue.faulttype;
  551. delay.faultID = protectValue.faultid;
  552. p_DelayTimeMap->insert(make_pair(GetEqpmentID(),delay));
  553. }
  554. else
  555. {
  556. //UpdateLockStatus(Electric_Eqpmt_Status_Lock);
  557. UpdateFaultLockStatus(Electric_Eqpmt_Status_Lock);
  558. UpdateEqpmtLightCardStatu(protectValue.pretectid);
  559. UpdateEqpmtStatus(ElectricEqpmtMap,Electric_Eqpmt_Status_OFF);
  560. }
  561. // 设置是否可以复归
  562. //add by yangs 20230701
  563. if( protectValue.nPermanentFault == 1){
  564. setProhibitedReversion();
  565. }
  566. // 联跳报文
  567. //xyx屏蔽begin
  568. //string strtext;
  569. //strtext.Format("%s %s 动作",GetEqpmentName(),protectValue.trippingDisplayContent);
  570. //SendMsgNotice(GetSourceStationID(),GetRegion(),1,DH_MSGCATEGORY_SYS,strtext,GetEqpmentID());
  571. //xyx屏蔽end
  572. //xyx修改begin
  573. string EqpmtTypeName = GetBaseTypeName(); //设备类型名称
  574. string EqpmtName = GetEqpmentName(); //设备名称
  575. int EqpmtSourceStatonID = GetSourceStationID(); //设备所属车站ID
  576. int EqpmtType = GetBaseType(); //设备类型
  577. ELCEQPMTALARMINFOMAP::iterator iterAlarmEqpmtType = m_EqpmtAlarmInfoMap->find(EqpmtType);
  578. if (iterAlarmEqpmtType!=m_EqpmtAlarmInfoMap->end())
  579. {
  580. ELCEQPMTALARMACTTYPEMAP mapAlarmActType = iterAlarmEqpmtType->second;
  581. ELCEQPMTALARMACTTYPEMAP::iterator iterAlarmActType=mapAlarmActType.begin();
  582. for (;iterAlarmActType!=mapAlarmActType.end();iterAlarmActType++)
  583. {
  584. if (protectValue.pretectid==iterAlarmActType->first) //保护联跳报文更新
  585. {
  586. iterAlarmActType->second.m_strAlrmText = iterAlarmActType->second.m_strTripText; //将联跳报文赋给显示的报文
  587. UpdateAlarmInfo(EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,iterAlarmActType->second);
  588. }
  589. }
  590. }
  591. //xyx修改end
  592. // 联跳遥信
  593. DealTelesignalisation( protectValue.pretectid, GetEqpmentID(), 1);
  594. return false;
  595. }
  596. bool ElectricEqpmt_Breaker::IsFault()
  597. {
  598. bool bRet = false;
  599. if ( Electric_Eqpmt_Status_Lock == GetControlLock() )
  600. {
  601. bRet = true;
  602. }
  603. return bRet;
  604. }
  605. void ElectricEqpmt_Breaker::UnLockTrippingEqpmt( ELEEQPMTMAP& ElectricEqpmtMap )
  606. {
  607. if ( Electric_Eqpmt_Status_Lock == GetFaultLockStatus() )
  608. {
  609. //UpdateLockStatus(Electric_Eqpmt_Status_UnLock);
  610. UpdateFaultLockStatus(Electric_Eqpmt_Status_UnLock);
  611. UpdateEqpmtStatus(ElectricEqpmtMap,GetStatus());
  612. UpdateEqpmtLightCardStatu(-1);
  613. }
  614. }
  615. void ElectricEqpmt_Breaker::AddRepeatShut( int nEqpmtType, int nIndex, int nDelayTime, int nOneTime )
  616. {
  617. map<int, BreakerDelayTime>::iterator iter = mapBreakerDelayTime.find( nEqpmtType );
  618. if ( iter == mapBreakerDelayTime.end() )
  619. {
  620. BreakerDelayTime breakerDelayTime;
  621. breakerDelayTime.AddIndexDelayTime( nIndex, nDelayTime );
  622. breakerDelayTime.EqpmtType = nEqpmtType;
  623. breakerDelayTime.OneTime = nOneTime;
  624. mapBreakerDelayTime.insert( make_pair(nEqpmtType, breakerDelayTime) );
  625. }
  626. else
  627. {
  628. iter->second.AddIndexDelayTime(nIndex, nDelayTime);
  629. }
  630. }
  631. int ElectricEqpmt_Breaker::GetAllRepeatShutTime()
  632. {
  633. int nRet = 0;
  634. map<int, BreakerDelayTime>::iterator iter = mapBreakerDelayTime.find( GetBaseType() );
  635. if ( iter != mapBreakerDelayTime.end() )
  636. {
  637. nRet = iter->second.GetAllTime()+2;
  638. }
  639. return nRet;
  640. }
  641. int ElectricEqpmt_Breaker::GetDelayTime( int nIndex )
  642. {
  643. int nRet = 0;
  644. map<int, BreakerDelayTime>::iterator iter = mapBreakerDelayTime.find( GetBaseType() );
  645. if ( iter != mapBreakerDelayTime.end() )
  646. {
  647. nRet = iter->second.GetDelayTime( nIndex );
  648. }
  649. return nRet;
  650. }
  651. int ElectricEqpmt_Breaker::GetOneTime()
  652. {
  653. int nRet = 0;
  654. map<int, BreakerDelayTime>::iterator iter = mapBreakerDelayTime.find( GetBaseType() );
  655. if ( iter != mapBreakerDelayTime.end() )
  656. {
  657. nRet = iter->second.GetOneTime( );
  658. }
  659. return nRet;
  660. }
  661. int ElectricEqpmt_Breaker::GetCurIndexDelayTime()
  662. {
  663. int nRet = 0;
  664. map<int, BreakerDelayTime>::iterator iter = mapBreakerDelayTime.find( GetBaseType() );
  665. if ( iter != mapBreakerDelayTime.end() )
  666. {
  667. nRet = iter->second.GetDelayTime( RepeatShutIndex );
  668. }
  669. return nRet;
  670. }
  671. void ElectricEqpmt_Breaker::EqpmtCtrl( int status,ELEEQPMTMAP& ElectricEqpmtMap,string Stdid,int CtrlType, int nMark /*= 0*/ )
  672. {
  673. CElectricEqpmt_SwicthEqpmt::EqpmtCtrl(status,ElectricEqpmtMap,Stdid,CtrlType,nMark);
  674. if ( Eqpmt_Operation_OFF == status && nMark )
  675. {
  676. if ( !m_mapCheckedEqpmtStrID.empty() )
  677. {
  678. m_mapCheckedEqpmtStrID.clear();
  679. }
  680. CheckOutLineElectricEqpmt(ElectricEqpmtMap,nMark);
  681. }
  682. }
  683. void ElectricEqpmt_Breaker::CheckOutLineElectricEqpmt( ELEEQPMTMAP& ElectricEqpmtMap, int nMark /*= 0*/ )
  684. {
  685. // 防止无限递归:一个设备只检验一次
  686. map<string,string>::iterator iter = m_mapCheckedEqpmtStrID.find(GetEqpmentID());
  687. if ( iter != m_mapCheckedEqpmtStrID.end() )
  688. {
  689. //string strTip;
  690. //strTip.Format("重复的循环,数据异常,重复设备编号为%s\n", GetEqpmentID() );
  691. m_mapCheckedEqpmtStrID.clear();
  692. return;
  693. }
  694. else
  695. {
  696. m_mapCheckedEqpmtStrID.insert( make_pair(GetEqpmentID(), GetEqpmentID()) );
  697. }
  698. // 先进行35KV出线设备检测
  699. ELEEQPMTMAP::iterator iterOutLineEqpmt;
  700. for( int i = 0; i < m_vecOutLineElectricEqpmt.size(); i++ )
  701. {
  702. if ( EQPMTTYPE_35KV == m_vecOutLineElectricEqpmt[i].m_nType )
  703. {
  704. // 35KV断路器:根据顺序进行出线设备跳闸和备自投合闸信息检测
  705. PowerCutOutLineElectricEqpmt_35KV( ElectricEqpmtMap, m_vecOutLineElectricEqpmt[i].m_strEqpmtID );
  706. }
  707. if ( nMark )
  708. {
  709. if ( EQPMTTYPE_400V == m_vecOutLineElectricEqpmt[i].m_nType )
  710. {
  711. PowerCutOutLineElectricEqpmt_400V(ElectricEqpmtMap, m_vecOutLineElectricEqpmt[i].m_strEqpmtID );
  712. }
  713. }
  714. }
  715. }
  716. void ElectricEqpmt_Breaker::PowerCutOutLineElectricEqpmt_35KV( ELEEQPMTMAP& ElectricEqpmtMap, const string& strOutLineElectricEqpmtStrID )
  717. {
  718. // 如果是输出是本站则检测后续
  719. ELEEQPMTMAP::iterator iterOutLine = ElectricEqpmtMap.find(strOutLineElectricEqpmtStrID);
  720. if ( iterOutLine == ElectricEqpmtMap.end() )
  721. {
  722. return;
  723. }
  724. if ( GetSourceStationID() == iterOutLine->second->GetSourceStationID() )
  725. {
  726. iterOutLine->second->CheckOutLineElectricEqpmt(ElectricEqpmtMap);
  727. return;
  728. }
  729. // 1. 已经处于分位则结束
  730. if ( Eqpmt_Operation_OFF == iterOutLine->second->GetStatus() )
  731. {
  732. return;
  733. }
  734. // 2. 合闸状态则断开:断开后检测本站35KV目联是否能够自投
  735. iterOutLine->second->EqpmtCtrl( Eqpmt_Operation_OFF, ElectricEqpmtMap, "系统", CTRLTYPE_STATUS);
  736. // 3.断开后检测本站35KV目联是否能够自投,如果能则退出,否则继续检查下一个站
  737. if ( iterOutLine->second->BoltPowerIn_35KV(ElectricEqpmtMap, strOutLineElectricEqpmtStrID) )
  738. {
  739. }
  740. else
  741. {
  742. // 4. 本站备自投不满足投入条件,则该站400进线开关跳闸
  743. iterOutLine->second->PowerCutCurElectricEqpmt_400V(ElectricEqpmtMap);
  744. // 5.继续检测下级站
  745. iterOutLine->second->CheckOutLineElectricEqpmt(ElectricEqpmtMap);
  746. }
  747. }
  748. void ElectricEqpmt_Breaker::PowerCutOutLineElectricEqpmt_400V( ELEEQPMTMAP& ElectricEqpmtMap, const string& strOutLineElectricEqpmtStrID )
  749. {
  750. // 如果当前设备处于闭合状态,则自动断开
  751. ELEEQPMTMAP::iterator iterEqpmt = ElectricEqpmtMap.find(strOutLineElectricEqpmtStrID);
  752. if ( iterEqpmt != ElectricEqpmtMap.end() )
  753. {
  754. if ( Eqpmt_Operation_ON == iterEqpmt->second->GetStatus() )
  755. {
  756. iterEqpmt->second->EqpmtCtrl( Eqpmt_Operation_OFF, ElectricEqpmtMap, "系统", CTRLTYPE_STATUS);
  757. }
  758. }
  759. }
  760. void ElectricEqpmt_Breaker::PowerCutCurElectricEqpmt_400V( ELEEQPMTMAP& ElectricEqpmtMap )
  761. {
  762. ELEEQPMTMAP::iterator iterOutLineEqpmt;
  763. for( int i = 0; i < m_vecOutLineElectricEqpmt.size(); i++ )
  764. {
  765. if ( EQPMTTYPE_400V == m_vecOutLineElectricEqpmt[i].m_nType )
  766. {
  767. PowerCutOutLineElectricEqpmt_400V(ElectricEqpmtMap, m_vecOutLineElectricEqpmt[i].m_strEqpmtID );
  768. }
  769. }
  770. }
  771. bool ElectricEqpmt_Breaker::BoltPowerIn_35KV( ELEEQPMTMAP& ElectricEqpmtMap, const string& strOutLineElectricEqpmtStrID )
  772. {
  773. ELEEQPMTMAP::iterator iterbolt = ElectricEqpmtMap.find(m_strMotherAutoBolt);
  774. if ( iterbolt == ElectricEqpmtMap.end() )
  775. {
  776. return false;
  777. }
  778. bool bRet = false;
  779. ElectricEqpmt_PowerBolt* pbolt= (ElectricEqpmt_PowerBolt*)iterbolt->second;
  780. if ( NULL != pbolt )
  781. {
  782. bRet = pbolt->CheckBoltRelationLRBreak_On(ElectricEqpmtMap);
  783. }
  784. return bRet;
  785. }
  786. bool ElectricEqpmt_Breaker::PowerCut(ELEEQPMTMAP& eqpmtmap,string sourceid,int offcase)
  787. {
  788. int count =0;
  789. string id;
  790. std::map<string,InputLineInfo>::iterator iter = InputEqpmtIDMap.begin();
  791. for (;iter!=InputEqpmtIDMap.end();iter++)
  792. {
  793. if (sourceid==iter->first)
  794. {
  795. iter->second.InputPower = false;
  796. }
  797. if (iter->second.InputPower)
  798. {
  799. count++;
  800. id = iter->first;
  801. }
  802. }
  803. if (GetStatus()==Electric_Eqpmt_Status_ON)
  804. {
  805. if (count==1)
  806. {
  807. ELEEQPMTMAP::iterator iter3 = eqpmtmap.find(id);
  808. if (iter3!=eqpmtmap.end())
  809. {
  810. iter3->second->PowerCut(eqpmtmap,GetEqpmentID(),offcase);
  811. }
  812. }
  813. if (count<1)
  814. {
  815. PowerLost(eqpmtmap,GetEqpmentID(),offcase);
  816. }
  817. }
  818. return true;
  819. }
  820. bool ElectricEqpmt_Breaker::PowerIn(ELEEQPMTMAP& eqpmtmap,string sourceid)
  821. {
  822. std::map<string,InputLineInfo>::iterator iter = InputEqpmtIDMap.begin();
  823. for (;iter!=InputEqpmtIDMap.end();iter++)
  824. {
  825. if (sourceid==iter->first)
  826. {
  827. iter->second.InputPower = true;
  828. }
  829. }
  830. if (GetStatus()==Electric_Eqpmt_Status_ON)
  831. {
  832. SetPower(true);
  833. UpdateEqpmtStatus(eqpmtmap, Electric_Eqpmt_Status_ON, CTRLTYPE_ElcCut); //向客户端更新开关设备带电状态add by yangs
  834. string EqpmtTypeName = GetBaseTypeName(); //设备类型名称
  835. string EqpmtName = GetEqpmentName(); //设备名称
  836. int EqpmtSourceStatonID = GetSourceStationID(); //设备所属车站ID
  837. int EqpmtType = GetBaseType(); //设备类型
  838. if (EqpmtType == OCC_EQPMTTYPE_35kVBREAKER)
  839. {
  840. int nActType1 = ElcAlarm_TripActType_TransLineOnPower;
  841. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType1);
  842. UpdateEqpmtPower(GetEqpmentID(),ElcAlarm_TripActType_TransLineOnPower);
  843. }
  844. std::map<string,string>::iterator iter2 = OutputEqpmtIDMap.begin();
  845. for (;iter2!=OutputEqpmtIDMap.end();iter2++)
  846. {
  847. if (iter2->first!=sourceid)
  848. {
  849. ELEEQPMTMAP::iterator iter3 = eqpmtmap.find(iter2->first);
  850. if (iter3!=eqpmtmap.end())
  851. {
  852. iter3->second->PowerIn(eqpmtmap,GetEqpmentID());
  853. }
  854. }
  855. }
  856. }
  857. DealElcTurnOffArea();
  858. return true;
  859. }
  860. bool ElectricEqpmt_Breaker::PowerLost(ELEEQPMTMAP& eqpmtmap,string sourceid,int offcase)
  861. {
  862. SetPower(false);
  863. UpdateEqpmtStatus(eqpmtmap, Electric_Eqpmt_Status_OFF, CTRLTYPE_ElcCut); //向客户端更新开关设备带电状态add by yangs
  864. if (POWER_EQPMT_INIT != offcase)
  865. {
  866. string EqpmtTypeName = GetBaseTypeName(); //设备类型名称
  867. string EqpmtName = GetEqpmentName(); //设备名称
  868. int EqpmtSourceStatonID = GetSourceStationID(); //设备所属车站ID
  869. int EqpmtType = GetBaseType(); //设备类型
  870. if (EqpmtType == OCC_EQPMTTYPE_35kVBREAKER)
  871. {
  872. int nActType1 = ElcAlarm_TripActType_TransLineLosePower;
  873. UpdateAlarmType(EqpmtType,EqpmtTypeName,EqpmtName,EqpmtSourceStatonID,nActType1);
  874. UpdateEqpmtPower(GetEqpmentID(),ElcAlarm_TripActType_TransLineLosePower);
  875. }
  876. }
  877. std::map<string,string>::iterator iter = OutputEqpmtIDMap.begin(); //OutputEqpmtIDMap为 sourceid的输出设备
  878. for (;iter!=OutputEqpmtIDMap.end();iter++)
  879. {
  880. ELEEQPMTMAP::iterator iter1 = eqpmtmap.find(iter->first);
  881. if (iter1==eqpmtmap.end())
  882. continue;
  883. if (POWER_EQPMT_INIT == offcase)
  884. offcase = POWER_EQPMT_OPERNO;
  885. iter1->second->PowerCut(eqpmtmap,GetEqpmentID(),offcase);
  886. }
  887. DealElcTurnOffArea();
  888. return true;
  889. }