run_status.c 44 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700
  1. /******************************************************************************
  2. 版权所有:
  3. 文件名称: run_status.c
  4. 文件版本: 01.01
  5. 创建作者: xxxxxx
  6. 创建日期: 2013-05-20
  7. 功能说明: 内部运行状态处理
  8. 其它说明:
  9. 修改记录:
  10. */
  11. /*------------------------------- 头文件 --------------------------------------
  12. */
  13. #include "head.h"
  14. /*------------------------------- 宏定义 --------------------------------------
  15. */
  16. enum
  17. {
  18. DIS_HEX, // 16进制
  19. DIS_DEC, // 10进制
  20. DIS_BIN, // 2进制
  21. DIS_NUM
  22. };
  23. #define INSTU_FILE_VERSION 0X01010101 //内部状态文件版本
  24. enum
  25. {
  26. RMTSTU_NULL, // 遥控器空闲态
  27. RMTSTU_ULOCK, // 遥控器解锁态
  28. RMTSTU_FZ, // 遥控器分闸态
  29. RMTSTU_HZ, // 遥控器合闸态
  30. RMTSTU_NUM,
  31. };
  32. /*------------------------------ 类型结构 -------------------------------------
  33. */
  34. /*------------------------------ 全局变量 -------------------------------------
  35. */
  36. u8 g_di_index[EQU_SLOT_NUM_MAX][16]; // 开入的应用功能与硬件对应关系
  37. //struct di_stu g_di_stu; // 开入的实时状态
  38. struct run_stu g_run_stu; // 内部运行状态
  39. struct rmt_oprate g_rmt_op; // 遥控器
  40. TIMERELAY g_tJLSDTime; // 交流失电定时器
  41. // 内部状态描述
  42. struct instu g_instu_desc[] =
  43. {
  44. {DIS_HEX, "重合充电", &g_run_stu.cd},
  45. {DIS_DEC, "交流失电", &g_run_stu.dcjlsd},
  46. {DIS_DEC, "交流失电带延时", &g_run_stu.dcjlsd_t},
  47. };
  48. const int INSTU_NUM = sizeof( g_instu_desc ) / sizeof(g_instu_desc[0]);
  49. /*------------------------------ 函数声明 -------------------------------------
  50. */
  51. int _rmt_key_app(u32 dStep);
  52. int _rst_key_app(void);
  53. int _create_instu_file(void);
  54. /*------------------------------ 外部函数 -------------------------------------
  55. 外部函数供其它实体文件引用,必须仔细检查传入参数的合法性.
  56. */
  57. /******************************************************************************
  58. 函数名称: run_status_init
  59. 函数版本: 01.01
  60. 创建作者: xxxxxx
  61. 创建日期: 2015-10-23
  62. 函数说明: 内部运行状态初始化。
  63. 参数说明: 无
  64. 返回值: 成功返回0.
  65. 修改记录:
  66. */
  67. int run_status_init(void)
  68. {
  69. int slot, i,sw;
  70. u16 no=0;
  71. for (slot=0; slot<EQU_SLOT_NUM_MAX; slot++)
  72. {
  73. memset(&g_di_index[slot], INDEX_INVALLID, 16);
  74. }
  75. memset(&g_run_stu,0,sizeof(g_run_stu));
  76. // 检查装置配置
  77. if(equ_config_null())
  78. {
  79. return -1;
  80. }
  81. run_status_check(0);
  82. for (i=0; i<PUB_DI_NUM; i++)
  83. {
  84. no = g_sw_pub.di_cfg_index[i];
  85. if ((short)no != INDEX_INVALLID)
  86. {
  87. g_di_index[g_equ_config_di[no].slot][g_equ_config_di[no].index] = i;
  88. }
  89. }
  90. for (sw=0; sw<g_sw_num; sw++)
  91. {
  92. for (i=0; i<SW_DI_NUM; i++)
  93. {
  94. no = g_sw[sw].di_cfg_index[i];
  95. if ((short)no != INDEX_INVALLID)
  96. {
  97. g_di_index[g_equ_config_di[no].slot][g_equ_config_di[no].index] = i+PUB_DI_NUM+SW_DI_NUM*sw;
  98. }
  99. }
  100. }
  101. // 远方无配置,置无效
  102. if (((short)g_sw_pub.di_cfg_index[PUB_DI_YF] == INDEX_INVALLID)
  103. && ((short)g_sw_pub.di_cfg_index[PUB_DI_JD] == INDEX_INVALLID))
  104. {
  105. g_run_stu.yf = 0;
  106. }
  107. // 就地无配置,置无效
  108. if ((short)g_sw_pub.di_cfg_index[PUB_DI_YF] == INDEX_INVALLID)
  109. {
  110. g_run_stu.jd = 0;
  111. }
  112. // 复归无配置,置分
  113. if ((short)g_sw_pub.di_cfg_index[PUB_DI_RST] == INDEX_INVALLID)
  114. {
  115. g_run_stu.fg = 0;
  116. }
  117. // 电池交流失电无配置,置分
  118. if ((short)g_sw_pub.di_cfg_index[PUB_DI_DCJLSD] == INDEX_INVALLID)
  119. {
  120. g_run_stu.dcjlsd = 0;
  121. }
  122. // 电源故障无配置,置分
  123. if ((short)g_sw_pub.di_cfg_index[PUB_DI_DCDYGZ] == INDEX_INVALLID)
  124. {
  125. g_run_stu.dcdygz = 0;
  126. }
  127. // 电池欠压无配置,置分
  128. if ((short)g_sw_pub.di_cfg_index[PUB_DI_DCQY] == INDEX_INVALLID)
  129. {
  130. g_run_stu.dcqy = 0;
  131. }
  132. // 电池活化无配置,置分
  133. if ((short)g_sw_pub.di_cfg_index[PUB_DI_DCHHZT] == INDEX_INVALLID)
  134. {
  135. g_run_stu.dchh = 0;
  136. }
  137. if ((short)g_sw_pub.di_cfg_index[PUB_DI_JS] == INDEX_INVALLID)
  138. {
  139. g_run_stu.js = 0;
  140. }
  141. if ((short)g_sw_pub.di_cfg_index[PUB_DI_BHALL] == INDEX_INVALLID)
  142. {
  143. g_run_stu.bhall = 1;
  144. }
  145. if ((short)g_sw_pub.di_cfg_index[PUB_DI_JX] == INDEX_INVALLID)
  146. {
  147. g_run_stu.bjx = 0;
  148. }
  149. // 复归+解锁
  150. if ((short)g_sw_pub.di_cfg_index[PUB_DI_RST_JS] == INDEX_INVALLID)
  151. {
  152. g_run_stu.fg_js = 0;
  153. }
  154. #ifdef YX_DI_ERROR
  155. if ((short)g_sw_pub.di_cfg_index[PUB_DI_ERROR] == INDEX_INVALLID)
  156. {
  157. g_run_stu.yxEnable = 1;
  158. }
  159. #endif
  160. g_run_stu.kz_out_tt = 1;
  161. #ifdef KZ_OUT_TT
  162. if ((short)g_sw_pub.di_cfg_index[PUB_KZ_OUT_TT] == INDEX_INVALLID)
  163. {
  164. g_run_stu.kz_out_tt = 1;
  165. }
  166. #endif
  167. g_run_stu.mb_yuk = 0;
  168. g_run_stu.mb_fz = 0;
  169. g_run_stu.mb_hz = 0;
  170. for (sw=0; sw<g_sw_num; sw++)
  171. {
  172. RUN_STU_SW *prun=&g_tRelay[sw].run_stu;
  173. #ifdef GD_AREA_ZHONGSHAN_FTU
  174. prun->bs_bhz=false;
  175. #endif
  176. // 合位无配置,置无效
  177. if ((short)g_sw[sw].di_cfg_index[SW_DI_KRHW] == INDEX_INVALLID)
  178. {
  179. prun->hw = 0;
  180. }
  181. // 分位无配置,置无效
  182. if ((short)g_sw[sw].di_cfg_index[SW_DI_KRTW] == INDEX_INVALLID)
  183. {
  184. prun->tw = 0;
  185. }
  186. // 合闸位置无配置,置无效
  187. if ((short)g_sw[sw].di_cfg_index[SW_DI_HZWZ] == INDEX_INVALLID)
  188. {
  189. prun->hzw = 0;
  190. }
  191. // 跳闸位置无配置,置无效
  192. if ((short)g_sw[sw].di_cfg_index[SW_DI_TZWZ] == INDEX_INVALLID)
  193. {
  194. prun->tzw = 0;
  195. }
  196. #ifdef SWITCH_GLJD_LED
  197. // 隔离刀闸无配置,置无效
  198. if ((short)g_sw[sw].di_cfg_index[SW_DI_GLDZ1] == INDEX_INVALLID)
  199. {
  200. prun->gldz = 0;
  201. }
  202. // 接地刀闸无配置,置无效
  203. if ((short)g_sw[sw].di_cfg_index[SW_DI_JDDZ] == INDEX_INVALLID)
  204. {
  205. prun->jddz = 0;
  206. }
  207. #endif
  208. // 未储能无配置,置合
  209. if ((short)g_sw[sw].di_cfg_index[SW_DI_CN] == INDEX_INVALLID)
  210. {
  211. prun->wcn = 1;
  212. }
  213. //气压低为配置,置分
  214. if ((short)g_sw[sw].di_cfg_index[SW_DI_QYD] == INDEX_INVALLID)
  215. {
  216. prun->qyd = 0;
  217. }
  218. // 控制回路断线开入
  219. if ((short)g_sw[sw].di_cfg_index[SW_DI_KZDX] == INDEX_INVALLID)
  220. {
  221. prun->kzdx= 0;
  222. }
  223. // PT1瞬压无配置,置无效
  224. if ((short)g_sw[sw].di_cfg_index[SW_DI_PT1SY] == INDEX_INVALLID)
  225. {
  226. prun->pt1uf = 0;
  227. }
  228. // PT2瞬压无配置,置无效
  229. if ((short)g_sw[sw].di_cfg_index[SW_DI_PT2SY] == INDEX_INVALLID)
  230. {
  231. prun->pt2uf = 0;
  232. }
  233. if ((short)g_sw[sw].di_cfg_index[SW_DI_SH] == INDEX_INVALLID)
  234. {
  235. prun->sw_sh = 0;
  236. }
  237. if ((short)g_sw[sw].di_cfg_index[SW_DI_SF] == INDEX_INVALLID)
  238. {
  239. prun->sw_sf = 0;
  240. }
  241. if ((short)g_sw[sw].di_cfg_index[SW_DI_BHZTT] == INDEX_INVALLID)
  242. {
  243. prun->bhztt = 1;
  244. }
  245. // 保护投退无配置,置合
  246. if ((short)g_sw[sw].di_cfg_index[SW_DI_BHTT] == INDEX_INVALLID)
  247. {
  248. prun->bhtt = prun->bhztt;
  249. }
  250. #ifdef JZS_FUNCTION
  251. if ((short)g_sw[sw].di_cfg_index[SW_DI_JZS_TT] == INDEX_INVALLID)
  252. {
  253. prun->jzs_tt = 1;
  254. }
  255. #endif
  256. // FA投退无配置,置合
  257. if ((short)g_sw[sw].di_cfg_index[SW_DI_FA_TT] == INDEX_INVALLID)
  258. {
  259. prun->fatt = prun->bhztt;
  260. }
  261. // 就地FA闭锁压板
  262. if ((short)g_sw[sw].di_cfg_index[SW_DI_FA_BS_TT] == INDEX_INVALLID)
  263. {
  264. //g_sw[sw].di_cfg_index[SW_DI_FA_BS_TT] = 0;//0为允许就地FA功能,
  265. }
  266. // 智能FA投退无配置,置合
  267. if ((short)g_sw[sw].di_cfg_index[SW_DI_FA_GOOSE] == INDEX_INVALLID)
  268. {
  269. #ifdef TY_BH_FA
  270. prun->fa_g_tt = 1;
  271. #else
  272. prun->fa_g_tt = prun->bhztt;
  273. #endif
  274. }
  275. // 重合闸无配置,置合
  276. if ((short)g_sw[sw].di_cfg_index[SW_DI_CHZ] == INDEX_INVALLID)
  277. {
  278. prun->chzyb = 1;
  279. }
  280. // 频率解列压板无配置,置合
  281. if ((short)g_sw[sw].di_cfg_index[SW_DI_FREQ_VOL] == INDEX_INVALLID)
  282. {
  283. prun->freq_vol = 1;
  284. }
  285. // 安全自动控制压板无配置,置合
  286. if ((short)g_sw[sw].di_cfg_index[SW_DI_SAFE_AUTO] == INDEX_INVALLID)
  287. {
  288. prun->safe_auto = 1;
  289. }
  290. prun->fa_start_hz = 1;
  291. //#ifdef GD_AREA_ZHUHAI_V2
  292. #if defined GD_AREA_ZHUHAI_V2 || defined GD_AREA_JIEYANG || defined GD_AREA_LIAONING_2021
  293. if ((short)g_sw[sw].di_cfg_index[SW_DI_B_SW] == INDEX_INVALLID)
  294. {
  295. prun->fa_start_hz = 1;
  296. }
  297. #endif
  298. if ((short)g_sw[sw].di_cfg_index[SW_DI_KGYF] == INDEX_INVALLID)
  299. {
  300. prun->kgyf = 0;
  301. }
  302. // 联络分段配置
  303. if ((short)g_sw[sw].di_cfg_index[SW_DI_FA_LS] == INDEX_INVALLID)
  304. {
  305. prun->fa_ls = pRunSet->tSwSet[sw].bTT_fa_LL;
  306. }
  307. if ((short)g_sw[sw].di_cfg_index[SW_DI_BSCH] == INDEX_INVALLID)
  308. {
  309. prun->bsch = 0;
  310. }
  311. if ((short)g_sw[sw].di_cfg_index[SW_DI_TQ] == INDEX_INVALLID)
  312. {
  313. prun->bTQ = 1;
  314. }
  315. prun->tytq = 0;
  316. #ifdef TYTQ_DI_YB
  317. if ((short)g_sw[sw].di_cfg_index[SW_DI_TYTQ] == INDEX_INVALLID)
  318. {
  319. prun->tytq = 0;
  320. }
  321. #endif
  322. //闭锁联络
  323. prun->bsfal = 0;
  324. #ifdef BS_FAL_DI_YB
  325. if ((short)g_sw[sw].di_cfg_index[SW_DI_BS_FAL] == INDEX_INVALLID)
  326. {
  327. prun->bsfal = 0;
  328. }
  329. #endif
  330. }
  331. _create_instu_file();
  332. //init valid yb
  333. run_status_check(0);
  334. return 0;
  335. }
  336. /******************************************************************************
  337. 函数名称: run_status_exit
  338. 函数版本: 01.01
  339. 创建作者: xxxxxx
  340. 创建日期: 2015-10-23
  341. 函数说明: 内部运行状态退出。
  342. 参数说明: 无
  343. 返回值: 成功返回0.
  344. 修改记录:
  345. */
  346. int run_status_exit(void)
  347. {
  348. return 0;
  349. }
  350. /******************************************************************************
  351. 函数名称: rmt_key_init
  352. 函数版本: 01.01
  353. 创建作者: xxxxxx
  354. 创建日期: 2015-05-13
  355. 函数说明: 遥控器按键初始化
  356. 参数说明: 无
  357. 返回值: 成功返回0.
  358. 修改记录:
  359. */
  360. int rmt_key_init(void)
  361. {
  362. memset(&g_rmt_op, 0, sizeof(g_rmt_op));
  363. return 0;
  364. }
  365. // 动作总的状态
  366. int run_status_dz_all(void)
  367. {
  368. int i;
  369. int ret=0;
  370. for(i=0; i<g_sw_num; i++)
  371. {
  372. RUN_STU_SW *prun=&g_tRelay[i].run_stu;
  373. if(prun->dz)
  374. {
  375. return prun->dz;
  376. }
  377. }
  378. return ret;
  379. }
  380. /******************************************************************************
  381. 函数名称: run_status_check
  382. 函数版本: 01.01
  383. 创建作者: xxxxxx
  384. 创建日期: 2015-10-23
  385. 函数说明: 内部运行状态识别
  386. 参数说明: 无
  387. 返回值: 成功返回0.
  388. 修改记录:
  389. */
  390. int run_status_check(u32 dStep)
  391. {
  392. bool bTHWCNState; // 弹簧未储能告警
  393. bool bTWYL; // 跳位有流
  394. int sw;
  395. bool bY,bY1;
  396. #ifdef FUNC_LARGECURRENT_BS_CHZ
  397. bool bIBSCHZ;
  398. #endif
  399. u8 sw_sh[SWITCH_NUM_MAX],sw_sf[SWITCH_NUM_MAX];
  400. u8 stu_yf,stu_jd;
  401. struct equ_config_di *ecd;
  402. #ifdef YX_DI_ERROR
  403. if ((short)g_sw_pub.di_cfg_index[PUB_DI_ERROR] != INDEX_INVALLID)
  404. {
  405. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_ERROR]];
  406. g_run_stu.yxEnable= dido_di_is_on(ecd->slot,ecd->index);
  407. }
  408. if(g_run_stu.yxEnable ==0)
  409. return 0;
  410. #endif
  411. stu_yf = 0;
  412. if ((short)g_sw_pub.di_cfg_index[PUB_DI_YF] != INDEX_INVALLID)
  413. {
  414. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_YF]];
  415. stu_yf = dido_di_is_on(ecd->slot,ecd->index);
  416. }
  417. stu_jd = 0;
  418. if ((short)g_sw_pub.di_cfg_index[PUB_DI_JD] != INDEX_INVALLID)
  419. {
  420. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_JD]];
  421. stu_jd = dido_di_is_on(ecd->slot,ecd->index);
  422. g_run_stu.jd = dido_di_is_on(ecd->slot,ecd->index);
  423. }
  424. if (((short)g_sw_pub.di_cfg_index[PUB_DI_YF] != INDEX_INVALLID)
  425. && ((short)g_sw_pub.di_cfg_index[PUB_DI_JD] != INDEX_INVALLID))
  426. {
  427. g_run_stu.yf = stu_yf;
  428. g_run_stu.jd = stu_jd;
  429. }
  430. else if (((short)g_sw_pub.di_cfg_index[PUB_DI_YF] != INDEX_INVALLID)
  431. && ((short)g_sw_pub.di_cfg_index[PUB_DI_JD] == INDEX_INVALLID))
  432. {
  433. g_run_stu.yf = stu_yf;
  434. g_run_stu.jd = !g_run_stu.yf;
  435. }
  436. else if (((short)g_sw_pub.di_cfg_index[PUB_DI_YF] == INDEX_INVALLID)
  437. && ((short)g_sw_pub.di_cfg_index[PUB_DI_JD] != INDEX_INVALLID))
  438. {
  439. g_run_stu.yf = (!stu_jd);
  440. g_run_stu.jd = !g_run_stu.yf;
  441. }
  442. else
  443. {
  444. g_run_stu.yf = 0;
  445. }
  446. if ((short)g_sw_pub.di_cfg_index[PUB_DI_RST] != INDEX_INVALLID)
  447. {
  448. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_RST]];
  449. g_run_stu.fg = dido_di_is_on(ecd->slot,ecd->index);
  450. }
  451. if ((short)g_sw_pub.di_cfg_index[PUB_DI_DCJLSD] != INDEX_INVALLID)
  452. {
  453. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_DCJLSD]];
  454. g_run_stu.dcjlsd = dido_di_is_on(ecd->slot,ecd->index);
  455. if(g_run_stu.dcjlsd)
  456. {
  457. if(log_flag.mdygd)
  458. {
  459. load_hs_log_rcd(TYPE_MAIN_POW,true,NULL,"Main power disconnect",0);
  460. log_flag.mdygd = false;
  461. }
  462. if(!log_flag.sdygd)
  463. {
  464. load_hs_log_rcd(TYPE_STANDBY_POW,true,NULL,"Standby power supply",1);
  465. log_flag.sdygd = true;
  466. }
  467. }
  468. else
  469. {
  470. if(!log_flag.mdygd)
  471. {
  472. load_hs_log_rcd(TYPE_MAIN_POW,true,NULL,"Main power supply",1);
  473. log_flag.mdygd = true;
  474. }
  475. if(log_flag.sdygd)
  476. {
  477. load_hs_log_rcd(TYPE_STANDBY_POW,true,NULL,"Standby power disconnect",0);
  478. log_flag.sdygd = false;
  479. }
  480. }
  481. }
  482. if ((short)g_sw_pub.di_cfg_index[PUB_DI_DCDYGZ] != INDEX_INVALLID)
  483. {
  484. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_DCDYGZ]];
  485. g_run_stu.dcdygz = dido_di_is_on(ecd->slot,ecd->index);
  486. }
  487. if ((short)g_sw_pub.di_cfg_index[PUB_DI_DCQY] != INDEX_INVALLID)
  488. {
  489. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_DCQY]];
  490. g_run_stu.dcqy = dido_di_is_on(ecd->slot,ecd->index);
  491. }
  492. if ((short)g_sw_pub.di_cfg_index[PUB_DI_DCHHZT] != INDEX_INVALLID)
  493. {
  494. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_DCHHZT]];
  495. g_run_stu.dchh = dido_di_is_on(ecd->slot,ecd->index);
  496. }
  497. if ((short)g_sw_pub.di_cfg_index[PUB_DI_JS] != INDEX_INVALLID)
  498. {
  499. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_JS]];
  500. g_run_stu.js = dido_di_is_on(ecd->slot,ecd->index);
  501. }
  502. if ((short)g_sw_pub.di_cfg_index[PUB_DI_BHALL] != INDEX_INVALLID)
  503. {
  504. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_BHALL]];
  505. g_run_stu.bhall= dido_di_is_on(ecd->slot,ecd->index);
  506. }
  507. if ((short)g_sw_pub.di_cfg_index[PUB_DI_JX] != INDEX_INVALLID)
  508. {
  509. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_JX]];
  510. g_run_stu.bjx= dido_di_is_on(ecd->slot,ecd->index);
  511. }
  512. if ((short)g_sw_pub.di_cfg_index[PUB_DI_REBOOT] != INDEX_INVALLID)
  513. {
  514. u8 reboot;
  515. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_REBOOT]];
  516. reboot= dido_di_is_on(ecd->slot,ecd->index);
  517. if(reboot)
  518. {
  519. rt_printf("装置复位\r\n");
  520. watchdog_reset_cpu(2); //装置复位
  521. }
  522. }
  523. #ifdef KZ_OUT_TT
  524. if ((short)g_sw_pub.di_cfg_index[PUB_KZ_OUT_TT] != INDEX_INVALLID)
  525. {
  526. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_KZ_OUT_TT]];
  527. g_run_stu.kz_out_tt = dido_di_is_on(ecd->slot,ecd->index);
  528. }
  529. #endif
  530. if ((short)g_sw_pub.di_cfg_index[PUB_DI_RST_JS] != INDEX_INVALLID)
  531. {
  532. ecd = &g_equ_config_di[g_sw_pub.di_cfg_index[PUB_DI_RST_JS]];
  533. g_run_stu.fg_js = dido_di_is_on(ecd->slot,ecd->index);
  534. if(g_run_stu.fg_js)
  535. {
  536. g_run_stu.fg=1;
  537. g_run_stu.js=1;
  538. }
  539. else
  540. {
  541. g_run_stu.fg=0;
  542. g_run_stu.js=0;
  543. }
  544. }
  545. _rst_key_app();
  546. _rmt_key_app(dStep);
  547. g_run_stu.rmt_A = (g_rmt_op.key == (1<<RMT_A));
  548. g_run_stu.rmt_B = (g_rmt_op.key == (1<<RMT_B));
  549. g_run_stu.rmt_C = (g_rmt_op.key == (1<<RMT_C));
  550. g_run_stu.rmt_D = (g_rmt_op.key == (1<<RMT_D));
  551. g_run_stu.phayy = OverRelay(g_ui[PUB_AC_UA1].fz, pRunSet->dUPowerFz, pRunSet->dUPowerFz_fh, g_run_stu.phayy);
  552. g_run_stu.phbyy = OverRelay(g_ui[PUB_AC_UB1].fz, pRunSet->dUPowerFz, pRunSet->dUPowerFz_fh, g_run_stu.phbyy);
  553. g_run_stu.phcyy = OverRelay(g_ui[PUB_AC_UC1].fz, pRunSet->dUPowerFz, pRunSet->dUPowerFz_fh, g_run_stu.phcyy);
  554. for(sw=0;sw<g_sw_num;sw++)
  555. {
  556. TRELAY_T *pR=&g_tRelay[sw];
  557. RUN_STU_SW *prun=&pR->run_stu;
  558. TSWST *pSW =&pR->tSWST;
  559. TLOSTVOT_T *pSWLV = &g_tRelay[sw].tLostVot;
  560. TSWST *pSWST =&g_tRelay[sw].tSWST;
  561. bool pt1cyy,pt2cyy;
  562. static bool bhtt,fatt,fa_g_tt,fa_ls;
  563. if ((short)g_sw[sw].di_cfg_index[SW_DI_KRHW] != INDEX_INVALLID)
  564. {
  565. //g_run_stu.hw[sw] = (g_di_stu.sw_di[sw] & (1<<SW_DI_KRHW))?1:0;
  566. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_KRHW]];
  567. prun->hw = dido_di_is_on(ecd->slot,ecd->index);
  568. }
  569. if ((short)g_sw[sw].di_cfg_index[SW_DI_KRTW] != INDEX_INVALLID)
  570. {
  571. //g_run_stu.tw[sw] = (g_di_stu.sw_di[sw] & (1<<SW_DI_KRTW))?1:0;
  572. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_KRTW]];
  573. prun->tw = dido_di_is_on(ecd->slot,ecd->index);
  574. }
  575. if ((short)g_sw[sw].di_cfg_index[SW_DI_HZWZ] != INDEX_INVALLID)
  576. {
  577. //g_run_stu.hw[sw] = (g_di_stu.sw_di[sw] & (1<<SW_DI_KRHW))?1:0;
  578. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_HZWZ]];
  579. prun->hzw = dido_di_is_on(ecd->slot,ecd->index);
  580. }
  581. if ((short)g_sw[sw].di_cfg_index[SW_DI_TZWZ] != INDEX_INVALLID)
  582. {
  583. //g_run_stu.tw[sw] = (g_di_stu.sw_di[sw] & (1<<SW_DI_KRTW))?1:0;
  584. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_TZWZ]];
  585. prun->tzw = dido_di_is_on(ecd->slot,ecd->index);
  586. }
  587. #ifdef SWITCH_GLJD_LED
  588. if ((short)g_sw[sw].di_cfg_index[SW_DI_GLDZ1] != INDEX_INVALLID)
  589. {
  590. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_GLDZ1]];
  591. prun->gldz = dido_di_is_on(ecd->slot,ecd->index);
  592. }
  593. if ((short)g_sw[sw].di_cfg_index[SW_DI_JDDZ] != INDEX_INVALLID)
  594. {
  595. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_JDDZ]];
  596. prun->jddz = dido_di_is_on(ecd->slot,ecd->index);
  597. }
  598. #endif
  599. if ((short)g_sw[sw].di_cfg_index[SW_DI_CN] != INDEX_INVALLID)
  600. {
  601. //g_run_stu.wcn[sw] = (g_di_stu.sw_di[sw] & (1<<SW_DI_CN))?1:0;
  602. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_CN]];
  603. prun->wcn = dido_di_is_on(ecd->slot,ecd->index);
  604. }
  605. #ifdef DISP_DOUBLE_CN
  606. if ((short)g_sw[sw].di_cfg_index[SW_DI_YCN] != INDEX_INVALLID&&(short)g_sw[sw].di_cfg_index[SW_DI_CN] == INDEX_INVALLID)//2020-10-8 只配置了已储能遥信
  607. {
  608. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_YCN]];
  609. prun->wcn = !dido_di_is_on(ecd->slot,ecd->index);//已储能取反
  610. }
  611. #endif
  612. if ((short)g_sw[sw].di_cfg_index[SW_DI_QYD] != INDEX_INVALLID)
  613. {
  614. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_QYD]];
  615. prun->qyd= dido_di_is_on(ecd->slot,ecd->index);
  616. }
  617. if ((short)g_sw[sw].di_cfg_index[SW_DI_KZDX] != INDEX_INVALLID)
  618. {
  619. //g_run_stu.wcn[sw] = (g_di_stu.sw_di[sw] & (1<<SW_DI_CN))?1:0;
  620. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_KZDX]];
  621. prun->kzdx= dido_di_is_on(ecd->slot,ecd->index);
  622. }
  623. if ((short)g_sw[sw].di_cfg_index[SW_DI_PT1SY] != INDEX_INVALLID)
  624. {
  625. //g_run_stu.pt1uf[sw] = (g_di_stu.sw_di[sw] & (1<<SW_DI_PT1SY))?1:0;
  626. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_PT1SY]];
  627. prun->pt1uf = dido_di_is_on(ecd->slot,ecd->index);
  628. }
  629. if ((short)g_sw[sw].di_cfg_index[SW_DI_PT2SY] != INDEX_INVALLID)
  630. {
  631. //g_run_stu.pt2uf[sw] = (g_di_stu.sw_di[sw] & (1<<SW_DI_PT2SY))?1:0;
  632. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_PT2SY]];
  633. prun->pt2uf = dido_di_is_on(ecd->slot,ecd->index);
  634. }
  635. sw_sh[sw] = 0;
  636. if ((short)g_sw[sw].di_cfg_index[SW_DI_SH] != INDEX_INVALLID)
  637. {
  638. //sw_sh[sw] = (g_di_stu.sw_di[sw] & (1<<SW_DI_SH))?1:0;
  639. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_SH]];
  640. sw_sh[sw] = dido_di_is_on(ecd->slot,ecd->index);
  641. }
  642. sw_sf[sw] = 0;
  643. if ((short)g_sw[sw].di_cfg_index[SW_DI_SF] != INDEX_INVALLID)
  644. {
  645. // sw_sf[sw] = (g_di_stu.sw_di[sw] & (1<<SW_DI_SF))?1:0;
  646. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_SF]];
  647. sw_sf[sw] = dido_di_is_on(ecd->slot,ecd->index);
  648. }
  649. if (((short)g_sw[sw].di_cfg_index[SW_DI_KRHW] != INDEX_INVALLID)
  650. && ((short)g_sw[sw].di_cfg_index[SW_DI_KRTW] != INDEX_INVALLID))
  651. {
  652. prun->sw = (prun->hw<<1) | prun->tw;
  653. }
  654. else if (((short)g_sw[sw].di_cfg_index[SW_DI_KRHW] != INDEX_INVALLID)
  655. && ((short)g_sw[sw].di_cfg_index[SW_DI_KRTW] == INDEX_INVALLID))
  656. {
  657. if (prun->hw) prun->sw = 2;
  658. if (!prun->hw) prun->sw = 1;
  659. prun->tw = !prun->hw;
  660. }
  661. else if (((short)g_sw[sw].di_cfg_index[SW_DI_KRHW] == INDEX_INVALLID)
  662. && ((short)g_sw[sw].di_cfg_index[SW_DI_KRTW] != INDEX_INVALLID))
  663. {
  664. if (prun->tw) prun->sw = 1;
  665. if (!prun->tw) prun->sw = 2;
  666. prun->hw = !prun->tw;
  667. }
  668. else
  669. {
  670. prun->sw = 0;
  671. }
  672. if ((short)g_sw[sw].di_cfg_index[SW_DI_BHZTT] != INDEX_INVALLID)
  673. {
  674. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_BHZTT]];
  675. prun->bhztt = dido_di_is_on(ecd->slot,ecd->index);
  676. //#ifdef GD_AREA_ECZD_2020//2020指导意见使用停用FA及保护
  677. #if defined GD_AREA_ECZD_2020 || defined GD_AREA_MAIN_2020
  678. prun->bhztt= !prun->bhztt;
  679. #endif
  680. }
  681. if ((short)g_sw[sw].di_cfg_index[SW_DI_BHTT] != INDEX_INVALLID)
  682. {
  683. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_BHTT]];
  684. prun->bhtt = dido_di_is_on(ecd->slot,ecd->index)&&prun->bhztt;
  685. prun->bh_yx = dido_di_is_on(ecd->slot,ecd->index);
  686. }
  687. if ((short)g_sw[sw].di_cfg_index[SW_DI_FA_TT] != INDEX_INVALLID )
  688. {
  689. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_FA_TT]];
  690. prun->fatt = dido_di_is_on(ecd->slot,ecd->index)&&prun->bhztt;
  691. prun->fa_yx = dido_di_is_on(ecd->slot,ecd->index);
  692. }
  693. if ((short)g_sw[sw].di_cfg_index[SW_DI_FA_BS_TT] != INDEX_INVALLID )
  694. {
  695. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_FA_BS_TT]];
  696. if(dido_di_is_on(ecd->slot,ecd->index) == 1)//闭锁FA压板 广东电网提出预留此功能
  697. prun->fatt=0;//闭锁FA信号产生,强制退出就地FA功能
  698. }
  699. if ((short)g_sw[sw].di_cfg_index[SW_DI_FA_GOOSE] != INDEX_INVALLID)
  700. {
  701. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_FA_GOOSE]];
  702. #ifdef TY_BH_FA
  703. prun->fa_g_tt = dido_di_is_on(ecd->slot,ecd->index);
  704. #else
  705. prun->fa_g_tt = dido_di_is_on(ecd->slot,ecd->index)&&prun->bhztt;
  706. #endif
  707. prun->fa_g_yx = dido_di_is_on(ecd->slot,ecd->index);
  708. }
  709. if ((short)g_sw[sw].di_cfg_index[SW_DI_CHZ] != INDEX_INVALLID)
  710. {
  711. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_CHZ]];
  712. prun->chzyb = (dido_di_is_on(ecd->slot,ecd->index));
  713. }
  714. if ((short)g_sw[sw].di_cfg_index[SW_DI_FREQ_VOL] != INDEX_INVALLID)
  715. {
  716. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_FREQ_VOL]];
  717. prun->freq_vol = dido_di_is_on(ecd->slot,ecd->index);
  718. //#ifdef GD_AREA_ECZD_2020//2020指导意见使用停用解列压板
  719. #if defined GD_AREA_ECZD_2020 || defined GD_AREA_MAIN_2020
  720. prun->freq_vol = !prun->freq_vol;
  721. #endif
  722. }
  723. if ((short)g_sw[sw].di_cfg_index[SW_DI_SAFE_AUTO] != INDEX_INVALLID)
  724. {
  725. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_SAFE_AUTO]];
  726. prun->safe_auto = dido_di_is_on(ecd->slot,ecd->index);
  727. }
  728. #ifdef JZS_FUNCTION
  729. if ((short)g_sw[sw].di_cfg_index[SW_DI_JZS_TT] != INDEX_INVALLID)
  730. {
  731. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_JZS_TT]];
  732. prun->jzs_tt = dido_di_is_on(ecd->slot,ecd->index);
  733. //if(prun->jzs_tt)//集中式投入,强制进入保护模式
  734. // prun->bhtt=1;
  735. }
  736. #endif
  737. //#ifdef GD_AREA_ZHUHAI_V2
  738. #if defined GD_AREA_ZHUHAI_V2 || defined GD_AREA_JIEYANG || defined GD_AREA_LIAONING_2021
  739. if ((short)g_sw[sw].di_cfg_index[SW_DI_B_SW] != INDEX_INVALLID)
  740. {
  741. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_B_SW]];
  742. prun->fa_start_hz = dido_di_is_on(ecd->slot,ecd->index);
  743. }
  744. #endif
  745. if ((short)g_sw[sw].di_cfg_index[SW_DI_KGYF] != INDEX_INVALLID)
  746. {
  747. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_KGYF]];
  748. prun->kgyf= dido_di_is_on(ecd->slot,ecd->index);
  749. }
  750. if ((short)g_sw[sw].di_cfg_index[SW_DI_FA_LS] != INDEX_INVALLID)
  751. {
  752. int dat;
  753. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_FA_LS]];
  754. dat= dido_di_is_on(ecd->slot,ecd->index);
  755. prun->fa_ls =dat;
  756. }
  757. else
  758. {
  759. prun->fa_ls = pRunSet->tSwSet[sw].bTT_fa_LL;
  760. }
  761. if ((short)g_sw[sw].di_cfg_index[SW_DI_BSCH] != INDEX_INVALLID)
  762. {
  763. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_BSCH]];
  764. prun->bsch = dido_di_is_on(ecd->slot,ecd->index);
  765. }
  766. if ((short)g_sw[sw].di_cfg_index[SW_DI_TQ] != INDEX_INVALLID)
  767. {
  768. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_TQ]];
  769. prun->bTQ = dido_di_is_on(ecd->slot,ecd->index);
  770. //#ifdef GD_AREA_ECZD_2020//2020指导意见使用停用同期压板
  771. #if defined GD_AREA_ECZD_2020 || defined GD_AREA_MAIN_2020
  772. prun->bTQ = !prun->bTQ;
  773. #endif
  774. }
  775. #ifdef TYTQ_DI_YB
  776. if ((short)g_sw[sw].di_cfg_index[SW_DI_TYTQ] != INDEX_INVALLID)
  777. {
  778. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_TYTQ]];
  779. prun->tytq = dido_di_is_on(ecd->slot,ecd->index);
  780. }
  781. #endif
  782. #ifdef BS_FAL_DI_YB
  783. if ((short)g_sw[sw].di_cfg_index[SW_DI_BS_FAL] != INDEX_INVALLID)
  784. {
  785. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_BS_FAL]];
  786. prun->bsfal = dido_di_is_on(ecd->slot,ecd->index);
  787. }
  788. #endif
  789. //相间且零序小于有流值,才认为线路无流
  790. pSW->uSWST.bFlag.bSXWL = LowRelay(g_sw[sw].m2_max,pRunSet->dIWL_SQR[sw],pRunSet->dIWL_SQR[sw],false) && LowRelay(g_ui[UI_SW_INDEX_BEGIN(sw)+SW_AC_I0].m2[0],pRunSet->dIWL_SQR[sw],pRunSet->dIWL_SQR[sw],false);
  791. // 外部开入合位,跳位判断
  792. pSW->uSWST.bFlag.bDIHW = (prun->sw==2 )?true:false;
  793. pSW->uSWST.bFlag.bDITW = (prun->sw==1 )?true:false;
  794. // 三相跳位,合闸位置
  795. pSW->uSWST.bFlag.bTZWZ = pSW->uSWST.bFlag.bDITW && pSW->uSWST.bFlag.bSXWL;
  796. pSW->uSWST.bFlag.bHZWZ = pSW->uSWST.bFlag.bDIHW || (!pSW->uSWST.bFlag.bSXWL);
  797. // 手合加速判断
  798. RunTR(&pSW->tTRunST_20s1s,pSW->uSWST.bFlag.bTZWZ,dStep);
  799. pSW->uSWST.bFlag.bSHJS = pSW->tTRunST_20s1s.boolTrip
  800. && (!pSW->uSWST.bFlag.bTZWZ);
  801. if((bhtt!=prun->bhtt)
  802. ||(fatt!=prun->fatt)
  803. ||(fa_g_tt!=prun->fa_g_tt)
  804. ||(fa_ls!=prun->fa_ls))
  805. {
  806. bhtt=prun->bhtt;
  807. fatt=prun->fatt;
  808. fa_g_tt=prun->fa_g_tt;
  809. fa_ls=prun->fa_ls;
  810. }
  811. // 曾有压判断,用于失压分闸
  812. pt1cyy = OverRelay(g_sw_pub.m2_max[2], pRunSet->tSwSet[sw].dU_fa_YY,pRunSet->tSwSet[sw].dU_fa_YY_fh, prun->pt1yy);
  813. //pt2cyy = OverRelay(g_sw_pub.m2_max[3], pRunSet->tSwSet[sw].dU_fa_YY, pRunSet->tSwSet[sw].dU_fa_YY_fh, prun->pt2yy);
  814. pt2cyy = OverRelay(g_sw_pub.m2_max[3], pRunSet->tSwSet[sw].dU_fa_YY2, pRunSet->tSwSet[sw].dU_fa_YY2_fh, prun->pt2yy);
  815. prun->pt1yy = pt1cyy;
  816. prun->pt2yy = pt2cyy;
  817. if(g_equ_config_ac[0].type-1==PUB_AC_UAB2 || g_equ_config_ac[0].type-1==PUB_AC_UA2)
  818. RunTR(&pSWLV->tCYY25ms0ms, pt2cyy||pSWST->uSWST.bFlag.bCYY, dStep);
  819. else
  820. RunTR(&pSWLV->tCYY25ms0ms, pt1cyy||pSWST->uSWST.bFlag.bCYY, dStep);
  821. pSWST->uSWST.bFlag.bCYY = pSWLV->tCYY25ms0ms.boolTrip&&pSW->uSWST.bFlag.bHZWZ;
  822. RunTR(&pR->tgoc.tCYY3sdelayms, pt1cyy||pt2cyy, dStep);
  823. pR->tgoc.psta.bFlag.bCYY =pR->tgoc.tCYY3sdelayms.boolTrip;
  824. // 弹簧未储能告警处理
  825. bTHWCNState = (pR->run_stu.wcn && pRunSet->tSwSet[sw].bTT_WCN);
  826. RunTR(&pSW->tTWCNGJ1s, bTHWCNState, dStep);
  827. pSW->uSWST.bFlag.bWCN = pSW->tTWCNGJ1s.boolTrip;
  828. // 控制回路告警处理
  829. #if 0
  830. bY = ((prun->tzw==0&&prun->hzw==0)||(prun->tzw==1&&prun->hzw==1))
  831. && ((short)g_sw[sw].di_cfg_index[SW_DI_HZWZ] != INDEX_INVALLID)
  832. && ((short)g_sw[sw].di_cfg_index[SW_DI_TZWZ] != INDEX_INVALLID)
  833. && pRunSet->tSwSet[sw].bTT_KZHL;
  834. bY1=pR->run_stu.kzdx&& pRunSet->tSwSet[sw].bTT_KZHL;
  835. #else//控制回路断线 1、控制回路断线遥信输入 2、HQ&TQ错误态&未知态 3、开关位置错误态&未知态
  836. if( ((short)g_sw[sw].di_cfg_index[SW_DI_HZWZ] != INDEX_INVALLID)&& ((short)g_sw[sw].di_cfg_index[SW_DI_TZWZ] != INDEX_INVALLID))//配置了HQ&TQ
  837. bY = (((prun->tzw==0&&prun->hzw==0)||(prun->tzw==1&&prun->hzw==1))&& pRunSet->tSwSet[sw].bTT_KZHL); //HQ&TQ错误
  838. else if( ((short)g_sw[sw].di_cfg_index[SW_DI_KRHW] != INDEX_INVALLID)&& ((short)g_sw[sw].di_cfg_index[SW_DI_KRTW] != INDEX_INVALLID))//必须配置开关双位置状态
  839. bY = (((prun->tw==0&&prun->hw==0)||(prun->tw==1&&prun->hw==1))&& pRunSet->tSwSet[sw].bTT_KZHL); //开关位置错误
  840. else
  841. bY = false;
  842. bY1=pR->run_stu.kzdx && pRunSet->tSwSet[sw].bTT_KZHL;
  843. #endif
  844. RunTR(&pSW->tTKZHLGJ1s, (bY||bY1), dStep);
  845. pSW->uSWST.bFlag.bKZHL = pSW->tTKZHLGJ1s.boolTrip;
  846. // 跳位有流告警处理
  847. bTWYL = (pSW->uSWST.bFlag.bDITW && (!pSW->uSWST.bFlag.bSXWL));
  848. RunTR(&pSW->tTTWYL_10S1S, bTWYL, dStep);
  849. pSW->uSWST.bFlag.bTWYL = pSW->tTTWYL_10S1S.boolTrip;
  850. // 每3秒才可进行一次手合动作,且仅能保持10ms
  851. RunTR(&pSW->tSHz3s10ms, (!sw_sh[sw]), dStep);
  852. pR->run_stu.sw_sh = (pSW->tSHz3s10ms.boolTrip && sw_sh[sw]&& g_run_stu.jd );
  853. // 每3秒才可进行一次手分动作
  854. RunTR(&pSW->tSTz3s10ms, (!sw_sf[sw]), dStep);
  855. pR->run_stu.sw_sf = (pSW->tSTz3s10ms.boolTrip && sw_sf[sw] && g_run_stu.jd );
  856. #ifdef GD_AREA_ZHONGSHAN_FTU //中山FTU要求手柄手分的时候退出自动化功能,亮闭锁灯
  857. RunTR(&pSW->tSf3s, (sw_sf[sw]), dStep);
  858. if(pSW->tSf3s.boolTrip&& g_run_stu.jd)
  859. {
  860. if(soe_check(EV_BS_HA+sw*EV_SW_NUM)==false) // 手动分闸,闭锁合闸
  861. {
  862. soe_record_ev(EV_BS_HA+sw*EV_SW_NUM, 1, 0,0,0 );
  863. //fa_s_set_savestatus(sw);
  864. }
  865. prun->bs_bhz = true;
  866. }
  867. else
  868. {
  869. prun->bs_bhz = false;
  870. }
  871. #endif
  872. //CT相序检查
  873. {
  874. bool bok,bCheck;
  875. u32 da,db,dc;
  876. u16 soeno=EV_CTXXYC+sw*EV_SW_NUM;
  877. bCheck=((g_ui[UI_SW_INDEX(sw,SW_AC_IA)].chn_index != INDEX_INVALLID)
  878. &&(g_ui[UI_SW_INDEX(sw,SW_AC_IB)].chn_index != INDEX_INVALLID)
  879. &&(g_ui[UI_SW_INDEX(sw,SW_AC_IC)].chn_index != INDEX_INVALLID));
  880. da = _AbsL(g_ui[UI_SW_INDEX(sw,SW_AC_IA)].p - g_ui[UI_SW_INDEX(sw,SW_AC_IB)].p-120*65536);
  881. db = _AbsL(g_ui[UI_SW_INDEX(sw,SW_AC_IB)].p - g_ui[UI_SW_INDEX(sw,SW_AC_IC)].p+240*65536);
  882. dc = _AbsL(g_ui[UI_SW_INDEX(sw,SW_AC_IA)].p - g_ui[UI_SW_INDEX(sw,SW_AC_IC)].p+120*65536);
  883. bok=pRunSet->bTT_CheckPhase
  884. &&(g_sw[sw].m2_min>pRunSet->dIWL_SQR[sw]) //大于无流定值
  885. &&bCheck
  886. &&((da>15*65536)||(db>15*65536)||(dc>15*65536)); //三相电压角度差30度
  887. RunTR(&pSW->tCTXXYC, bok, dStep);
  888. if(pSW->tCTXXYC.boolTrip)
  889. {
  890. if(soe_check(soeno)==false) //
  891. {
  892. soe_record_ev(soeno, 1, 0,0,0 );
  893. }
  894. }
  895. else
  896. {
  897. if(soe_check(soeno)==true) //
  898. {
  899. soe_record_ev(soeno, 0, 0,0,0 );
  900. }
  901. }
  902. }
  903. // CT 异常判断
  904. {
  905. bool bok,bCheck;
  906. u16 soeno=EV_CTYC+sw*EV_SW_NUM;
  907. bCheck=((g_ui[UI_SW_INDEX(sw,SW_AC_IA)].chn_index != INDEX_INVALLID)
  908. &&(g_ui[UI_SW_INDEX(sw,SW_AC_IC)].chn_index != INDEX_INVALLID));
  909. bok=pRunSet->bTT_CTYC
  910. &&(g_sw[sw].m2_min<pRunSet->dIWL_SQR[sw]) //最小值小于无流定值
  911. &&(g_sw[sw].m2_max>pRunSet->dIWL_SQR[sw])// 最大值大于无流定值
  912. &&bCheck;
  913. RunTR(&pSW->tCTYC, bok, dStep);
  914. if(pSW->tCTYC.boolTrip)
  915. {
  916. if(soe_check(soeno)==false) //
  917. {
  918. soe_record_ev(soeno, 1, 0,0,0 );
  919. }
  920. }
  921. else
  922. {
  923. if(soe_check(soeno)==true) //
  924. {
  925. soe_record_ev(soeno, 0, 0,0,0 );
  926. }
  927. }
  928. }
  929. #ifndef BAT_STATE_LED
  930. { //电池电压低判断:两路直流,任一路大于直流整定值的一半,小于整定值,3秒后报异常,若定值为0 ,退出判断
  931. bool bCheck;
  932. #ifdef DC_TEST_ONE
  933. bCheck=((g_sw_pub.ac_in[PUB_AC_IN_UZ1]>(pRunSet->dwZL/2))&&(g_sw_pub.ac_in[PUB_AC_IN_UZ1]<pRunSet->dwZL)
  934. &&(pRunSet->dwZL>0);
  935. #else
  936. bCheck=(((g_sw_pub.ac_in[PUB_AC_IN_UZ1]>(pRunSet->dwZL/2))&&(g_sw_pub.ac_in[PUB_AC_IN_UZ1]<pRunSet->dwZL))
  937. ||((g_sw_pub.ac_in[PUB_AC_IN_UZ2]>(pRunSet->dwZL/2))&&(g_sw_pub.ac_in[PUB_AC_IN_UZ2]<pRunSet->dwZL)))
  938. &&(pRunSet->dwZL>0);
  939. #endif
  940. RunTR(&pSW->tBatChk, bCheck, dStep);
  941. if(pSW->tBatChk.boolTrip)
  942. {
  943. if(soe_check(EV_BATERR)==false) //
  944. {
  945. soe_record_ev(EV_BATERR, 1, 0,0,0 );
  946. }
  947. }
  948. else
  949. {
  950. if(soe_check(EV_BATERR)==true) //
  951. {
  952. soe_record_ev(EV_BATERR, 0, 0,0,0 );
  953. }
  954. }
  955. }
  956. #else
  957. { //电池电压低判断:两路直流,任一路大于直流整定值的一半,小于整定值0.8倍,3秒后报异常,若定值为0 ,退出判断
  958. bool bCheck,bCheck2,bLowDC;
  959. #ifdef DC_TEST_ONE
  960. bCheck=((g_sw_pub.ac_in[PUB_AC_IN_UZ1]>(pRunSet->dwZL/2))&&(g_sw_pub.ac_in[PUB_AC_IN_UZ1]<pRunSet->dwZL*0.8))
  961. &&(pRunSet->dwZL>0);
  962. bCheck2=(g_sw_pub.ac_in[PUB_AC_IN_UZ1]>(pRunSet->dwZL+pRunSet->dwZL*0.2))
  963. &&pRunSet->dwZL>0; //任一直流电压大于1.2倍->过压
  964. #else
  965. bCheck=((((DWORD)g_sw_pub.ac_in[PUB_AC_IN_UZ1]>(pRunSet->dwZL/2))&&((DWORD)g_sw_pub.ac_in[PUB_AC_IN_UZ1]<pRunSet->dwZL*0.8))
  966. ||(((DWORD)g_sw_pub.ac_in[PUB_AC_IN_UZ2]>(pRunSet->dwZL/2))&&((DWORD)g_sw_pub.ac_in[PUB_AC_IN_UZ2]<pRunSet->dwZL*0.8)))
  967. &&(pRunSet->dwZL>0);
  968. bCheck2=(((DWORD)g_sw_pub.ac_in[PUB_AC_IN_UZ1]>(pRunSet->dwZL+pRunSet->dwZL*0.2))
  969. ||((DWORD)g_sw_pub.ac_in[PUB_AC_IN_UZ2]>(pRunSet->dwZL+pRunSet->dwZL*0.2)))
  970. &&pRunSet->dwZL>0; //任一直流电压大于1.2倍->过压
  971. #endif
  972. RunTR(&pSW->tBatChk, bCheck, dStep);
  973. RunTR(&pSW->tBatOver, bCheck2, dStep);
  974. if ((short)g_sw_pub.di_cfg_index[PUB_DI_DCQY] == INDEX_INVALLID)
  975. {
  976. bLowDC = pSW->tBatChk.boolTrip;
  977. }
  978. else
  979. {
  980. bLowDC = g_run_stu.dcqy;
  981. }
  982. if(pSW->tBatOver.boolTrip)//电池过压
  983. {
  984. if(soe_check(EV_BAT_OVER)==false)
  985. {
  986. soe_record_ev(EV_BAT_OVER, 1, 0,0,0 );
  987. }
  988. }
  989. else if(soe_check(EV_BAT_OVER)==true) //
  990. {
  991. soe_record_ev(EV_BAT_OVER, 0, 0,0,0 );
  992. }
  993. if(bLowDC)
  994. {
  995. if(soe_check(EV_BATERR)==false) //
  996. {
  997. soe_record_ev(EV_BATERR, 1, 0,0,0 );
  998. }
  999. }
  1000. else if(soe_check(EV_BATERR)==true) //
  1001. {
  1002. soe_record_ev(EV_BATERR, 0, 0,0,0 );
  1003. }
  1004. }
  1005. #endif
  1006. #ifdef CUSTOMIZE_BZT //备自投
  1007. //备自投#1线路开关位置
  1008. if ((short)g_sw[sw].di_cfg_index[SW_DI_DL1_HW] != INDEX_INVALLID)
  1009. {
  1010. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_DL1_HW]];
  1011. pSW->uSWST.bFlag.b1DLHW = dido_di_is_on(ecd->slot,ecd->index);
  1012. }
  1013. else
  1014. {
  1015. pSW->uSWST.bFlag.b1DLHW = prun->hw; //合位、进线1合位共用
  1016. }
  1017. if((short)g_sw[sw].di_cfg_index[SW_DI_DL1_TW] != INDEX_INVALLID)
  1018. {
  1019. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_DL1_TW]];
  1020. pSW->uSWST.bFlag.b1DLHW = !dido_di_is_on(ecd->slot,ecd->index);
  1021. }
  1022. else
  1023. {
  1024. pSW->uSWST.bFlag.b1DLHW = !prun->tw;
  1025. }
  1026. //备自投#2线路开关位置
  1027. if ((short)g_sw[sw].di_cfg_index[SW_DI_DL2_HW] != INDEX_INVALLID)
  1028. {
  1029. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_DL2_HW]];
  1030. pSW->uSWST.bFlag.b2DLHW = dido_di_is_on(ecd->slot,ecd->index);
  1031. }
  1032. if ((short)g_sw[sw].di_cfg_index[SW_DI_DL2_TW] != INDEX_INVALLID)
  1033. {
  1034. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_DL2_TW]];
  1035. pSW->uSWST.bFlag.b2DLHW = !dido_di_is_on(ecd->slot,ecd->index);
  1036. }
  1037. //备自投#3线路开关位置
  1038. if ((short)g_sw[sw].di_cfg_index[SW_DI_DL3_HW] != INDEX_INVALLID)
  1039. {
  1040. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_DL3_HW]];
  1041. pSW->uSWST.bFlag.b3DLHW = dido_di_is_on(ecd->slot,ecd->index);
  1042. }
  1043. if ((short)g_sw[sw].di_cfg_index[SW_DI_DL3_TW] != INDEX_INVALLID)
  1044. {
  1045. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_DL3_TW]];
  1046. pSW->uSWST.bFlag.b3DLHW = !dido_di_is_on(ecd->slot,ecd->index);
  1047. }
  1048. //备自投闭锁位置
  1049. if ((short)g_sw[sw].di_cfg_index[SW_DI_BSBZT] != INDEX_INVALLID)
  1050. {
  1051. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_BSBZT]];
  1052. pSW->uSWST.bFlag.bBZTBS = dido_di_is_on(ecd->slot,ecd->index);
  1053. }
  1054. if ((short)g_sw[sw].di_cfg_index[SW_DI_BSBZT] != INDEX_INVALLID)
  1055. {
  1056. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_BSBZT]];
  1057. pSW->uSWST.bFlag.bBZTBS = dido_di_is_on(ecd->slot,ecd->index);
  1058. }
  1059. if ((short)g_sw[sw].di_cfg_index[SW_DI_BZT_SY] != INDEX_INVALLID)
  1060. {
  1061. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_BZT_SY]];
  1062. pSW->uSWST.bFlag.bBZTSY = dido_di_is_on(ecd->slot,ecd->index) || pSW->uSWST.bFlag.bBZTSY;
  1063. }
  1064. if(pRunSet->tSwSet[sw].bZF)
  1065. {
  1066. if((g_sw[sw].do_cfg_index[SW_DO_JX1_SY] < g_equ_config->do_num) && (g_sw[sw].do_cfg_index[SW_DO_JX2_SY] == 0xffff))
  1067. {
  1068. pSW->uSWST.bFlag.b1DLHW = prun->hw; //使用分合位
  1069. if ((short)g_sw[sw].di_cfg_index[SW_DI_DL2_HW] != INDEX_INVALLID)
  1070. {
  1071. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_DL2_HW]];
  1072. pSW->uSWST.bFlag.b2DLHW = dido_di_is_on(ecd->slot,ecd->index);
  1073. }
  1074. }
  1075. else if((g_sw[sw].do_cfg_index[SW_DO_JX2_SY] < g_equ_config->do_num) && (g_sw[sw].do_cfg_index[SW_DO_JX1_SY] == 0xffff))
  1076. {
  1077. if ((short)g_sw[sw].di_cfg_index[SW_DI_DL1_HW] != INDEX_INVALLID)
  1078. {
  1079. ecd = &g_equ_config_di[g_sw[sw].di_cfg_index[SW_DI_DL1_HW]];
  1080. pSW->uSWST.bFlag.b1DLHW = dido_di_is_on(ecd->slot,ecd->index);
  1081. }
  1082. pSW->uSWST.bFlag.b2DLHW = prun->hw; //使用分合位
  1083. }
  1084. }
  1085. #endif
  1086. #ifdef FUNC_LARGECURRENT_BS_CHZ
  1087. //大电流闭锁重合
  1088. {
  1089. //大电流闭锁重合
  1090. bIBSCHZ = OverRelay(g_sw[sw].m2_max, pRunSet->tSwSet[sw].dIBSCHZ, pRunSet->tSwSet[sw].dIBSCHZ, false);
  1091. RunTR(&pSW->tIBSCHZ, bIBSCHZ && pRunSet->tSwSet[sw].bTT_IBSCHZ, dStep);
  1092. pSW->uSWST.bFlag.bIBSCHZ = pSW->tIBSCHZ.boolTrip;
  1093. }
  1094. #endif
  1095. }
  1096. #ifdef YK_ZZDY_KC
  1097. sw_do_pub(PUB_YK_ZZDY_KC,SW_DO_TYPE_ON);
  1098. #endif
  1099. #ifdef IEC_NOLINK_NO_CALLYX
  1100. g_link_comm.link_err = getIecLink101Status();
  1101. RunTR(&g_link_comm.tLinkBreak,g_link_comm.link_err,dStep);
  1102. g_link_comm.link_flag = g_link_comm.tLinkBreak.boolTrip||(!g_link_comm.link_err);
  1103. #endif
  1104. return 0;
  1105. }
  1106. /******************************************************************************
  1107. 函数名称: app_action_result
  1108. 函数版本: 01.01
  1109. 创建作者: xxxxxx
  1110. 创建日期: 2015-10-23
  1111. 函数说明: 应用逻辑运行结果
  1112. 参数说明: 无
  1113. 返回值: 成功返回0.
  1114. 修改记录:
  1115. */
  1116. // 动作灯: 线路故障指示灯为红色,故障状态时闪烁,闭锁合闸时常亮,非故障和非闭锁状态下熄灭
  1117. // LOCK灯,为FA功能使用,过流闭锁不点亮,为自动处理的状态灯,不建议复归时处理
  1118. int app_action_result(void)
  1119. {
  1120. int sw,i;
  1121. u8 exerr, gl, jd,gj, chzdz, bs, gz,bvol,sy,gy,fdl;
  1122. for (sw=0; sw<g_sw_num; sw++)
  1123. {
  1124. TRELAY_T *pR=&g_tRelay[sw];
  1125. RUN_STU_SW *prun=&pR->run_stu;
  1126. // 每个开关都需要重新初始化变量
  1127. exerr=0;
  1128. gl=0;
  1129. jd=0;
  1130. chzdz=0;
  1131. bs=0;
  1132. gz=0;
  1133. sy=0;
  1134. gy=0;
  1135. fdl=0;
  1136. gj = 0;
  1137. // 外部异常
  1138. if (pR->tSWST.uSWST.bFlag.bWCN)
  1139. {
  1140. exerr = 1;
  1141. }
  1142. prun->gj_led =0;
  1143. //告警的时候不亮动作灯
  1144. if(pR->tOC[BH_GL1].sta.bFlag.bGjLed
  1145. || pR->tOC[BH_GL2].sta.bFlag.bGjLed
  1146. || pR->tOC[BH_GL3].sta.bFlag.bGjLed
  1147. || pR->tOC[BH_LX1].sta.bFlag.bGjLed
  1148. || pR->tOC[BH_LX2].sta.bFlag.bGjLed
  1149. #ifdef DISP_SET_LX3
  1150. || pR->tOC[BH_LX3].sta.bFlag.bGjLed
  1151. #endif
  1152. || pR->tOC[FA_GL2].sta.bFlag.bGjLed
  1153. #ifdef SET_GL_GJ2
  1154. || pR->tOC[FA_GL2_II].sta.bFlag.bGjLed
  1155. #endif
  1156. || pR->tOC[FA_LX2].sta.bFlag.bGjLed
  1157. || pR->tOVER_U0TZ.bU0GjLed
  1158. || pR->tU0TZ.bU0GjLed)
  1159. {
  1160. if(pR->tOC[BH_GL1].sta.bFlag.bGjLed
  1161. || pR->tOC[BH_GL2].sta.bFlag.bGjLed
  1162. || pR->tOC[BH_GL3].sta.bFlag.bGjLed
  1163. || pR->tOC[FA_GL2].sta.bFlag.bGjLed
  1164. #ifdef SET_GL_GJ2
  1165. || pR->tOC[FA_GL2_II].sta.bFlag.bGjLed
  1166. #endif
  1167. //|| pR->tOC[FA_GL].sta.bFlag.bGjLed)
  1168. )
  1169. {
  1170. gl = 1;
  1171. }
  1172. #if 0
  1173. else
  1174. #else
  1175. if(pR->tOC[BH_LX1].sta.bFlag.bGjLed
  1176. || pR->tOC[BH_LX2].sta.bFlag.bGjLed
  1177. #ifdef DISP_SET_LX3
  1178. || pR->tOC[BH_LX3].sta.bFlag.bGjLed
  1179. #endif
  1180. || pR->tOC[FA_LX2].sta.bFlag.bGjLed
  1181. || pR->tOVER_U0TZ.bU0GjLed
  1182. || pR->tU0TZ.bU0GjLed)
  1183. #endif
  1184. {
  1185. jd = 1;
  1186. }
  1187. gj = 1;
  1188. prun->gj_led =1;
  1189. prun->dz=RY_DZ_BHGJ;
  1190. }
  1191. // 保护过流
  1192. if (pR->tOC[BH_GL1].sta.bFlag.bDzLed
  1193. || pR->tOC[BH_GL2].sta.bFlag.bDzLed
  1194. || pR->tOC[BH_GL3].sta.bFlag.bDzLed
  1195. || pR->tOC[BH_GLJS].sta.bFlag.bDzLed
  1196. || pR->tOC[FA_GL].sta.bFlag.bDzLed
  1197. || pR->tOC[FA_GL_II].sta.bFlag.bDzLed
  1198. //|| pR->tOC[FA_GL2].sta.bFlag.bGj
  1199. || pR->tgoc.bglTzLed // 智能FA过流
  1200. #ifdef GD_AREA_ZHONGSHAN_2020
  1201. ||pR->tgoc.tOc[FAG_GL1].sta.bFlag.bDzLed
  1202. ||pR->tgoc.tOc[FAG_GL2].sta.bFlag.bDzLed
  1203. #endif
  1204. || pR->uGLFSX.bFlag.bDzLed
  1205. || pR->tOC[FA_DLBS].sta.bFlag.bDzLed) // 过流闭锁,点过流灯
  1206. {
  1207. gl = 1;
  1208. gj = 1;
  1209. prun->dz=RY_DZ_BHT;
  1210. prun->gj_led = 1;
  1211. }
  1212. // 保护接地
  1213. if (pR->tOC[BH_LX1].sta.bFlag.bDzLed
  1214. || pR->tOC[BH_LX2].sta.bFlag.bDzLed
  1215. #ifdef DISP_SET_LX3
  1216. || pR->tOC[BH_LX3].sta.bFlag.bDzLed
  1217. #endif
  1218. || pR->tOC[BH_LXJS].sta.bFlag.bDzLed
  1219. || pR->tOC[FA_LX].sta.bFlag.bDzLed
  1220. //|| pR->tOC[FA_LX2].sta.bFlag.bGj
  1221. #ifdef XDL_ZT
  1222. || xdl_is_dz(sw) // 增加小电流接地
  1223. #endif
  1224. #ifdef FUN_JDXX
  1225. || pR->tJD.sta.bFlag.bTZLed
  1226. || pR->tJD.sta.bFlag.bGJLed
  1227. #endif
  1228. #ifdef GD_AREA_ZHONGSHAN_2020
  1229. ||pR->tgoc.tOc[FAG_LX].sta.bFlag.bDzLed
  1230. #endif
  1231. || pR->tgoc.blxTzLed // 智能FA过流
  1232. || pR->tXXTZ.bU0Led //零序选线跳闸
  1233. || pR->tU0TZ.bU0Led
  1234. || pR->tOVER_U0TZ.bU0Led)
  1235. {
  1236. jd = 1;
  1237. gj = 1;
  1238. prun->dz=RY_DZ_BHT;
  1239. prun->gj_led = 1;
  1240. }
  1241. #ifndef GW_AREA_MAIN_2021
  1242. for(i=0;i<8;i++)
  1243. {
  1244. fdl|=pR->tFdl[i].sta.bFlag.bTz;
  1245. }
  1246. #endif
  1247. //失压跳闸+智能分布式越级跳,首端失压跳,故障隔离跳,通信异常跳,都亮动作灯
  1248. if (pR->tLostVot.bLostVotLed
  1249. || pR->tgoc.bextTzLed
  1250. || pR->tgoc.bsdTzLed
  1251. || pR->tgoc.bgzglTzLed
  1252. || pR->tgoc.berrTzLed )// goose
  1253. {
  1254. prun->dz=RY_DZ_BHT;
  1255. }
  1256. //过压压跳闸
  1257. if (pR->tDYJL.bLed||pR->tPLJL.bLed)
  1258. {
  1259. gy = 1;
  1260. }
  1261. // 重合闸动作
  1262. if (pR->tCHZ.sta.bFlag.bCHZLed)
  1263. {
  1264. chzdz = 1;
  1265. }
  1266. #ifdef GD_AREA_ZHUHAI_V2//珠海要求合闸需亮动作灯
  1267. //合闸动作
  1268. if(pR->uBHDZ.bFlag.bBHH)//合闸动作展宽200ms
  1269. {
  1270. //prun->dz=RY_DZ_BHGJ;//珠海要求重合闸动作后,过流或接地灯一直亮。灯人工干预或定时复归才灭
  1271. prun->dz=RY_DZ_HZ;
  1272. }
  1273. //rt_printf("run_dz = %d, b_BHH = %d\r\n",prun->dz,pR->uBHDZ.bFlag.bBHH);
  1274. #endif
  1275. // 闭锁
  1276. if ( pR->tSDHZ.bL_BSLed
  1277. || pR->tSDHZ.bS_BSLed)
  1278. {
  1279. bs = 1;
  1280. }
  1281. //重合闸充电标志
  1282. prun->chzcd=pR->tCHZ.sta.bFlag.bCDWC;
  1283. if(g_tRelay[sw].tCHZ.wAR_ActTimes>=pRunSet->tSwSet[sw].d_chz_times)
  1284. {
  1285. prun->chzcd=0; //最后一次重合后灭灯,复归后点亮
  1286. }
  1287. prun->exerr = exerr;
  1288. prun->gl = gl;
  1289. prun->jd = jd||pR->tOC[FA_LX2].sta.bFlag.bGj||pR->tU0TZ.bU0GjLed || pR->tU0TZ.bU0Led;
  1290. prun->chzdz = chzdz;
  1291. prun->bs = bs;
  1292. prun->gy=gy;
  1293. /*if(gj)//只告警的时候不亮动作灯
  1294. {
  1295. prun->dz = RY_DZ_NULL;
  1296. prun->gj_led =1;
  1297. }
  1298. else if (gl || jd || chzdz ||sy||gy||fdl) // 故障状态,动作灯闪烁 (过流、接地、重合闸、过载,失压)
  1299. {
  1300. prun->dz = RY_DZ_BHT;
  1301. prun->gj_led =1;
  1302. }
  1303. else */
  1304. if ( bs && pR->tSDHZ.bS_BSLed) // X Y闭锁,动作灯常亮
  1305. {
  1306. prun->dz = RY_DZ_XYBS; // 常亮
  1307. }
  1308. if(prun->dz==RY_DZ_XYBS)
  1309. {
  1310. if(!bs) //闭锁灯自动复归
  1311. {
  1312. prun->dz=RY_DZ_NULL;
  1313. }
  1314. }
  1315. bvol=false;
  1316. for(i=0;i<=VOL_DDY_Uca2;i++)
  1317. {
  1318. bvol|=g_tVol[i].sta.bFlag.bGj;
  1319. }
  1320. }
  1321. // 动作总
  1322. g_run_stu.pubdz= run_status_dz_all();
  1323. return 0;
  1324. }
  1325. u32 rmtpair_dely[2][2]={{0, 0},{0, 0}}; // 用于遥控器配对延时返回
  1326. /*------------------------------ 内部函数 -------------------------------------
  1327. 内部函数以下划线‘_’开头,不需要检查参数的合法性.
  1328. */
  1329. /******************************************************************************
  1330. 函数名称: rmt_key_app
  1331. 函数版本: 01.01
  1332. 创建作者: xxxxxx
  1333. 创建日期: 2015-05-13
  1334. 函数说明: 遥控器按键应用逻辑
  1335. 参数说明: 无
  1336. 返回值: 成功返回0.
  1337. 修改记录:
  1338. */
  1339. int _rmt_key_app(u32 dStep)
  1340. {
  1341. u8 key;
  1342. if (rmtpair_dely[0][0] || rmtpair_dely[1][0])
  1343. {
  1344. return -1;
  1345. }
  1346. for (key=0; key<RMT_KEY_NUM; key++)
  1347. {
  1348. switch(g_rmt_op.step[key])
  1349. {
  1350. case 0:
  1351. // 按键0状态
  1352. g_rmt_op.step[key] = (g_rmt_op.key == (1<<key)) ? 1 : 0;
  1353. break;
  1354. case 1:
  1355. // 按键1->0状态
  1356. g_rmt_op.step[key] = (g_rmt_op.key == (1<<key)) ? 1 : 2;
  1357. break;
  1358. case 2:
  1359. // 按键1->0状态
  1360. g_rmt_op.key_en[key] = 1;
  1361. g_rmt_op.step[key] = 0;
  1362. break;
  1363. }
  1364. }
  1365. switch(g_rmt_op.stu)
  1366. {
  1367. case RMTSTU_NULL:
  1368. // 在空闲态,有解锁按键时,进入解锁状态
  1369. if (g_rmt_op.key_en[RMT_KEY_ULK])
  1370. {
  1371. g_rmt_op.stu = RMTSTU_ULOCK;
  1372. g_rmt_op.key_en[RMT_KEY_ULK] = 0;
  1373. ResetTR(&g_rmt_op.tTULK3STime);
  1374. }
  1375. g_rmt_op.key_en[RMT_KEY_FZ] = 0;
  1376. g_rmt_op.key_en[RMT_KEY_HZ] = 0;
  1377. break;
  1378. case RMTSTU_ULOCK:
  1379. // 在解锁态,打开3秒计时,3秒内有分闸或合闸按键,进入分闸或合闸处理,否则返回空闲态
  1380. RunTR(&g_rmt_op.tTULK3STime, 1, dStep);
  1381. if (g_rmt_op.tTULK3STime.boolTrip)
  1382. {
  1383. g_rmt_op.stu = RMTSTU_NULL;
  1384. }
  1385. else
  1386. {
  1387. if (g_rmt_op.key_en[RMT_KEY_FZ])
  1388. {
  1389. g_rmt_op.stu = RMTSTU_FZ;
  1390. g_rmt_op.key_en[RMT_KEY_FZ] = 0;
  1391. ResetTR(&g_rmt_op.tTULK3STime);
  1392. }
  1393. else if (g_rmt_op.key_en[RMT_KEY_HZ])
  1394. {
  1395. g_rmt_op.stu = RMTSTU_HZ;
  1396. g_rmt_op.key_en[RMT_KEY_HZ] = 0;
  1397. ResetTR(&g_rmt_op.tTULK3STime);
  1398. }
  1399. }
  1400. break;
  1401. case RMTSTU_FZ:
  1402. // 发出分闸指令,返回空闲态
  1403. g_rmt_op.cmd = CMD_FZ;
  1404. g_rmt_op.stu = RMTSTU_NULL;
  1405. break;
  1406. case RMTSTU_HZ:
  1407. // 发出合闸指令,返回空闲态
  1408. g_rmt_op.cmd = CMD_HZ;
  1409. g_rmt_op.stu = RMTSTU_NULL;
  1410. break;
  1411. }
  1412. // 有复归按键,发出复归指令
  1413. if (g_rmt_op.key_en[RMT_KEY_FG])
  1414. {
  1415. g_rmt_op.cmd = CMD_FG;
  1416. g_rmt_op.key_en[RMT_KEY_FG] = 0;
  1417. }
  1418. return 0;
  1419. }
  1420. /******************************************************************************
  1421. 函数名称: _rst_key_app
  1422. 函数版本: 01.01
  1423. 创建作者: xxxxxx
  1424. 创建日期: 2015-05-13
  1425. 函数说明: 复归按键
  1426. 参数说明: 无
  1427. 返回值: 成功返回0.
  1428. 修改记录:
  1429. */
  1430. int _rst_key_app(void)
  1431. {
  1432. static u8 fg_flag=0;
  1433. if(g_run_stu.fg)
  1434. {
  1435. if (!fg_flag)
  1436. {
  1437. ResetHzLed(0);
  1438. SignalReset(0,true);
  1439. fg_flag = 1;
  1440. }
  1441. }
  1442. else
  1443. {
  1444. fg_flag = 0;
  1445. }
  1446. return 0;
  1447. }
  1448. /******************************************************************************
  1449. 函数名称: _create_instu_file
  1450. 函数版本: 01.01
  1451. 创建作者: xxxxxx
  1452. 创建日期: 2015-04-16
  1453. 函数说明: 创建内部状态描述文件
  1454. 参数说明: 无
  1455. 返回值: 成功返回0.
  1456. 修改记录:
  1457. */
  1458. int _create_instu_file(void)
  1459. {
  1460. unsigned int i,file_length;
  1461. u16 crc16;
  1462. char *p;
  1463. loff_t pos;
  1464. struct file * pfile;
  1465. struct instu_file_head_data fh;
  1466. struct instu_desc desc;
  1467. // 写文件头
  1468. // 配置文件头
  1469. memset(&fh,0,sizeof(fh));
  1470. fh.cfh.signature = SIG_INSTU_FILE;
  1471. fh.cfh.version = INSTU_FILE_VERSION;
  1472. //装置类型
  1473. // 公共类三遥资源
  1474. fh.instu_addr = FILE_ADDR_ALGIN(sizeof(fh));
  1475. fh.instu_num = INSTU_NUM;
  1476. // 得到文件长度
  1477. file_length = FILE_ADDR_ALGIN(fh.instu_addr + fh.instu_num * sizeof(struct instu_desc));
  1478. // 分配并初始化空间
  1479. p = rt_malloc(file_length + 2); //加crc长度
  1480. if(!p)
  1481. {
  1482. return -1;
  1483. }
  1484. memset(p,0,file_length);
  1485. // 写入文件头
  1486. memcpy(p,(char *)&fh,sizeof(fh));
  1487. // 写内部状态描述
  1488. for(i=0; i<fh.instu_num; i++)
  1489. {
  1490. memset(&desc,0,sizeof(desc));
  1491. if (i < INSTU_NUM)
  1492. {
  1493. desc.type = g_instu_desc[i].type;
  1494. strncpy(desc.name,g_instu_desc[i].name,20);
  1495. desc.name[20-1] = 0;
  1496. }
  1497. memcpy(p + fh.instu_addr + i*sizeof(desc), (char *)&desc, sizeof(desc));
  1498. }
  1499. // 创建描述文件
  1500. pfile = rt_file_open("/tmp/instu.bin",O_CREAT|O_RDWR|O_TRUNC,0);
  1501. if(IS_ERR(pfile))
  1502. {
  1503. rt_free(p);
  1504. return -1;
  1505. }
  1506. // 计算CRC
  1507. crc16 = CrcStr(p,file_length);
  1508. memcpy(p+file_length,&crc16,2);
  1509. pos = 0;
  1510. rt_file_write(pfile,p,file_length + 2,&pos);
  1511. rt_file_close(pfile,0);
  1512. rt_free(p);
  1513. return 0;
  1514. }
  1515. /*------------------------------ 测试函数 -------------------------------------
  1516. 一个实体文件必须带一个本模块的测试函数来进行单元测试,如果的确不方便在本模块中
  1517. 进行单元测试,必须在此注明实际的测试位置(例如在哪个实体文件中使用哪个测试函数).
  1518. */
  1519. int runstu_printf(void)
  1520. {
  1521. rt_printf("内部状态信息:\r\n");
  1522. rt_printf("yf=%d\r\n",g_run_stu.yf);
  1523. return 0;
  1524. }
  1525. //========================== 本文件结束 =============================