ElectricEqpmt_BreakRailPotential.cpp 28 KB

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