浏览代码

[BT-6703-RT]fix detect alarm VACin

balbekova 4 年之前
父节点
当前提交
a8fe2f4901
共有 1 个文件被更改,包括 22 次插入21 次删除
  1. 22 21
      modules/monitor/ups_monitor.c

+ 22 - 21
modules/monitor/ups_monitor.c

@@ -433,49 +433,50 @@ void UPS_TestFinishMonitor(void)
 #endif
 }
 
-bool UPS_VACinputRangeAlarm(void)
+uint8_t UPS_VACinputRangeAlarm(void)
 {
-  bool flag = false;
-  static uint8_t stateCurrentVACinput = HYST_IDLE;
+  uint8_t flag = 0;
+  static uint8_t stateCurrentVACinput_low = HYST_IDLE;
+  static uint8_t stateCurrentVACinput_high = HYST_IDLE;
   float VACinputCurrent = UPS.VAC_in;
 
   /* Отслеживается переход через нижнию границу */
   if (VACinputCurrent < sSettings.sAlarmManager.ac_input_range.low)
   {
-      if (stateCurrentVACinput == HYST_IDLE || stateCurrentVACinput == HYST_DOWN) {
-        stateCurrentVACinput = HYST_DOWN;
-        flag = true;
+      if (stateCurrentVACinput_low == HYST_IDLE || stateCurrentVACinput_low == HYST_DOWN) {
+        stateCurrentVACinput_low = HYST_DOWN;
+        flag |= (1 << 1);
       }
   } else  if (VACinputCurrent > (sSettings.sAlarmManager.ac_input_range.low + sSettings.sAlarmManager.ac_input_range.hyst))
   {
-      if (stateCurrentVACinput == HYST_DOWN)
+      if (stateCurrentVACinput_low == HYST_DOWN)
 	    {
-        stateCurrentVACinput = HYST_IDLE;
-        flag = false;
+        stateCurrentVACinput_low = HYST_IDLE;
+        flag &= 0xfd;
       }
   } else {
-    if (stateCurrentVACinput == HYST_DOWN) {
-      flag = true;
+    if (stateCurrentVACinput_low == HYST_DOWN) {
+      flag |= (1 << 1);
     }
   }
 
   /* Отслеживается переход через верхнюю границу */
   if (VACinputCurrent > sSettings.sAlarmManager.ac_input_range.high)
   {
-      if (stateCurrentVACinput == HYST_IDLE || stateCurrentVACinput == HYST_UP) {
-        stateCurrentVACinput = HYST_UP;
-        flag = true;
+      if (stateCurrentVACinput_high == HYST_IDLE || stateCurrentVACinput_high == HYST_UP) {
+        stateCurrentVACinput_high = HYST_UP;
+        flag |= (1 << 2);
       }
   } else  if (VACinputCurrent < (sSettings.sAlarmManager.ac_input_range.high - sSettings.sAlarmManager.ac_input_range.hyst))
   {
-      if (stateCurrentVACinput == HYST_UP)
+      if (stateCurrentVACinput_high == HYST_UP)
 	    {
-        stateCurrentVACinput = HYST_IDLE;
-        flag = false;
+        stateCurrentVACinput_high = HYST_IDLE;
+        flag &= 0xfb;
       }
   } else {
-    if (stateCurrentVACinput == HYST_UP) {
-      flag = true;
+    if (stateCurrentVACinput_high == HYST_UP) {
+      flag |= (1 << 2);
     }
   }
   return flag;
@@ -502,8 +503,8 @@ void UPS_LineFailMonitor(void)
 	  CurrROtype_Sourse[i] = sSettings.sRelays[i].ro_type_source;
 #endif
 #ifdef HARDWARE_BT6703_RT
-  lineFailCurrent = (((UPS.Status >> 7) & 0x01);
-  lineFailCurrent |= UPS_VACinputRangeAlarm()) ? 2 : 0;
+  lineFailCurrent = ((UPS.Status >> 7) & 0x01);
+  lineFailCurrent |= UPS_VACinputRangeAlarm();
 #else 
   lineFailCurrent = (UPS.Status >> 7) & 0x01;
 #endif