fix: 修改设备故障码记录相关逻辑。
This commit is contained in:
@@ -4,125 +4,198 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 设备故障码常量定义
|
||||
* 设备故障码常量定义(与 C# DefineDeviceErrorCode 对齐)
|
||||
* 所有的恢复码都 +200
|
||||
*
|
||||
* @author intc
|
||||
*/
|
||||
public class DefineDeviceErrorCode {
|
||||
/**
|
||||
* 电源关闭
|
||||
*/
|
||||
public static final int PowerOff = 1;
|
||||
|
||||
// 三相电压告警 (2-7)
|
||||
/**
|
||||
* 三相A相过压
|
||||
*/
|
||||
public static final int Three_PhaseA_OverVoltage = 2;
|
||||
/**
|
||||
* 三相B相过压
|
||||
*/
|
||||
public static final int Three_PhaseB_OverVoltage = 3;
|
||||
/**
|
||||
* 三相C相过压
|
||||
*/
|
||||
public static final int Three_PhaseC_OverVoltage = 4;
|
||||
/**
|
||||
* 三相A相欠压
|
||||
*/
|
||||
public static final int Three_PhaseA_UnderVoltage = 5;
|
||||
/**
|
||||
* 三相B相欠压
|
||||
*/
|
||||
public static final int Three_PhaseB_UnderVoltage = 6;
|
||||
/**
|
||||
* 三相C相欠压
|
||||
*/
|
||||
public static final int Three_PhaseC_UnderVoltage = 7;
|
||||
// 三相输入缺相 (1001-1003)。一旦缺相会强制4路开关断开
|
||||
public static final int Three_InputLosePhaseA = 1001;
|
||||
public static final int Three_InputLosePhaseB = 1002;
|
||||
public static final int Three_InputLosePhaseC = 1003;
|
||||
|
||||
// 三相电流告警 (8-23)
|
||||
/**
|
||||
* 三相开关1路A相过流
|
||||
*/
|
||||
public static final int Three_Switch1OverElectricA = 8;
|
||||
public static final int Three_Switch1OverElectricB = 9;
|
||||
public static final int Three_Switch1OverElectricC = 10;
|
||||
public static final int Three_Switch2OverElectricA = 11;
|
||||
public static final int Three_Switch2OverElectricB = 12;
|
||||
public static final int Three_Switch2OverElectricC = 13;
|
||||
public static final int Three_Switch3OverElectricA = 14;
|
||||
public static final int Three_Switch3OverElectricB = 15;
|
||||
public static final int Three_Switch3OverElectricC = 16;
|
||||
public static final int Three_Switch4OverElectricA = 17;
|
||||
public static final int Three_Switch4OverElectricB = 18;
|
||||
public static final int Three_Switch4OverElectricC = 19;
|
||||
/**
|
||||
* 三相开关1路缺相
|
||||
*/
|
||||
public static final int Three_Switch1ElectricEmpty = 20;
|
||||
public static final int Three_Switch2ElectricEmpty = 21;
|
||||
public static final int Three_Switch3ElectricEmpty = 22;
|
||||
public static final int Three_Switch4ElectricEmpty = 23;
|
||||
// 三相过压欠压 (1004-1009)。过压欠压不会强制开关关闭,触发机制高于120%/低于80%
|
||||
public static final int Three_PhaseA_OverVoltage = 1004;
|
||||
public static final int Three_PhaseA_UnderVoltage = 1005;
|
||||
public static final int Three_PhaseB_OverVoltage = 1006;
|
||||
public static final int Three_PhaseB_UnderVoltage = 1007;
|
||||
public static final int Three_PhaseC_OverVoltage = 1008;
|
||||
public static final int Three_PhaseC_UnderVoltage = 1009;
|
||||
|
||||
// 单相电流告警 (24-31)
|
||||
/**
|
||||
* 单相开关1路过流
|
||||
*/
|
||||
public static final int One_Switch1OverElectric = 24;
|
||||
public static final int One_Switch2OverElectric = 25;
|
||||
public static final int One_Switch3OverElectric = 26;
|
||||
public static final int One_Switch4OverElectric = 27;
|
||||
/**
|
||||
* 单相开关1路缺相
|
||||
*/
|
||||
public static final int One_Switch1ElectricEmpty = 28;
|
||||
public static final int One_Switch2ElectricEmpty = 29;
|
||||
public static final int One_Switch3ElectricEmpty = 30;
|
||||
public static final int One_Switch4ElectricEmpty = 31;
|
||||
// 三相端口缺相 (1010-1021)。一旦缺相对应开关强制断开
|
||||
public static final int Three_Switch1LosePhaseA = 1010;
|
||||
public static final int Three_Switch1LosePhaseB = 1011;
|
||||
public static final int Three_Switch1LosePhaseC = 1012;
|
||||
public static final int Three_Switch2LosePhaseA = 1013;
|
||||
public static final int Three_Switch2LosePhaseB = 1014;
|
||||
public static final int Three_Switch2LosePhaseC = 1015;
|
||||
public static final int Three_Switch3LosePhaseA = 1016;
|
||||
public static final int Three_Switch3LosePhaseB = 1017;
|
||||
public static final int Three_Switch3LosePhaseC = 1018;
|
||||
public static final int Three_Switch4LosePhaseA = 1019;
|
||||
public static final int Three_Switch4LosePhaseB = 1020;
|
||||
public static final int Three_Switch4LosePhaseC = 1021;
|
||||
|
||||
// 三相过流 (1022-1033)
|
||||
public static final int Three_Switch1OverElectricA = 1022;
|
||||
public static final int Three_Switch1OverElectricB = 1023;
|
||||
public static final int Three_Switch1OverElectricC = 1024;
|
||||
public static final int Three_Switch2OverElectricA = 1025;
|
||||
public static final int Three_Switch2OverElectricB = 1026;
|
||||
public static final int Three_Switch2OverElectricC = 1027;
|
||||
public static final int Three_Switch3OverElectricA = 1028;
|
||||
public static final int Three_Switch3OverElectricB = 1029;
|
||||
public static final int Three_Switch3OverElectricC = 1030;
|
||||
public static final int Three_Switch4OverElectricA = 1031;
|
||||
public static final int Three_Switch4OverElectricB = 1032;
|
||||
public static final int Three_Switch4OverElectricC = 1033;
|
||||
|
||||
// 三相欠流 (1034-1045)
|
||||
public static final int Three_Switch1UnderElectricA = 1034;
|
||||
public static final int Three_Switch1UnderElectricB = 1035;
|
||||
public static final int Three_Switch1UnderElectricC = 1036;
|
||||
public static final int Three_Switch2UnderElectricA = 1037;
|
||||
public static final int Three_Switch2UnderElectricB = 1038;
|
||||
public static final int Three_Switch2UnderElectricC = 1039;
|
||||
public static final int Three_Switch3UnderElectricA = 1040;
|
||||
public static final int Three_Switch3UnderElectricB = 1041;
|
||||
public static final int Three_Switch3UnderElectricC = 1042;
|
||||
public static final int Three_Switch4UnderElectricA = 1043;
|
||||
public static final int Three_Switch4UnderElectricB = 1044;
|
||||
public static final int Three_Switch4UnderElectricC = 1045;
|
||||
|
||||
// 三相空载 (1046-1049)
|
||||
public static final int Three_Switch1ElectricEmpty = 1046;
|
||||
public static final int Three_Switch2ElectricEmpty = 1047;
|
||||
public static final int Three_Switch3ElectricEmpty = 1048;
|
||||
public static final int Three_Switch4ElectricEmpty = 1049;
|
||||
|
||||
// 单相过流 (2009-2012)
|
||||
public static final int One_Switch1OverElectric = 2009;
|
||||
public static final int One_Switch2OverElectric = 2010;
|
||||
public static final int One_Switch3OverElectric = 2011;
|
||||
public static final int One_Switch4OverElectric = 2012;
|
||||
|
||||
// 单相欠流 (2013-2016)
|
||||
public static final int One_Switch1UnderElectric = 2013;
|
||||
public static final int One_Switch2UnderElectric = 2014;
|
||||
public static final int One_Switch3UnderElectric = 2015;
|
||||
public static final int One_Switch4UnderElectric = 2016;
|
||||
|
||||
// 单相空载 (2017-2020)
|
||||
public static final int One_Switch1ElectricEmpty = 2017;
|
||||
public static final int One_Switch2ElectricEmpty = 2018;
|
||||
public static final int One_Switch3ElectricEmpty = 2019;
|
||||
public static final int One_Switch4ElectricEmpty = 2020;
|
||||
|
||||
// 其他故障
|
||||
/** 断电告警。设备断电后蓄电池续航约1分钟,确保断电故障上报 */
|
||||
public static final int PowerOff = 8001;
|
||||
/** 控制板通信故障(后台监控使用) */
|
||||
public static final int ControllerWarn = 8002;
|
||||
/** 计量芯片故障(后台监控使用) */
|
||||
public static final int MeterShipWarn = 8003;
|
||||
|
||||
private static final Map<Integer, String> ERROR_CODE_MESSAGES = new HashMap<>();
|
||||
|
||||
static {
|
||||
ERROR_CODE_MESSAGES.put(PowerOff, "电源关闭");
|
||||
ERROR_CODE_MESSAGES.put(Three_PhaseA_OverVoltage, "A相过压");
|
||||
ERROR_CODE_MESSAGES.put(Three_PhaseB_OverVoltage, "B相过压");
|
||||
ERROR_CODE_MESSAGES.put(Three_PhaseC_OverVoltage, "C相过压");
|
||||
// 三相输入缺相
|
||||
ERROR_CODE_MESSAGES.put(Three_InputLosePhaseA, "输入缺A相");
|
||||
ERROR_CODE_MESSAGES.put(Three_InputLosePhaseB, "输入缺B相");
|
||||
ERROR_CODE_MESSAGES.put(Three_InputLosePhaseC, "输入缺C相");
|
||||
// 三相过压欠压
|
||||
ERROR_CODE_MESSAGES.put(Three_PhaseA_OverVoltage, "A相过压");
|
||||
ERROR_CODE_MESSAGES.put(Three_PhaseA_UnderVoltage, "A相欠压");
|
||||
ERROR_CODE_MESSAGES.put(Three_PhaseB_OverVoltage, "B相过压");
|
||||
ERROR_CODE_MESSAGES.put(Three_PhaseB_UnderVoltage, "B相欠压");
|
||||
ERROR_CODE_MESSAGES.put(Three_PhaseC_OverVoltage, "C相过压");
|
||||
ERROR_CODE_MESSAGES.put(Three_PhaseC_UnderVoltage, "C相欠压");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1OverElectricA, "1路A相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1OverElectricB, "1路B相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1OverElectricC, "1路C相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2OverElectricA, "2路A相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2OverElectricB, "2路B相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2OverElectricC, "2路C相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3OverElectricA, "3路A相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3OverElectricB, "3路B相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3OverElectricC, "3路C相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4OverElectricA, "4路A相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4OverElectricB, "4路B相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4OverElectricC, "4路C相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1ElectricEmpty, "1路缺相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2ElectricEmpty, "2路缺相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3ElectricEmpty, "3路缺相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4ElectricEmpty, "4路缺相");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch1OverElectric, "1路过流");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch2OverElectric, "2路过流");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch3OverElectric, "3路过流");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch4OverElectric, "4路过流");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch1ElectricEmpty, "1路缺相");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch2ElectricEmpty, "2路缺相");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch3ElectricEmpty, "3路缺相");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch4ElectricEmpty, "4路缺相");
|
||||
// 三相端口缺相
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1LosePhaseA, "端口1输出缺A相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1LosePhaseB, "端口1输出缺B相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1LosePhaseC, "端口1输出缺C相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2LosePhaseA, "端口2输出缺A相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2LosePhaseB, "端口2输出缺B相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2LosePhaseC, "端口2输出缺C相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3LosePhaseA, "端口3输出缺A相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3LosePhaseB, "端口3输出缺B相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3LosePhaseC, "端口3输出缺C相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4LosePhaseA, "端口4输出缺A相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4LosePhaseB, "端口4输出缺B相");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4LosePhaseC, "端口4输出缺C相");
|
||||
// 三相过流
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1OverElectricA, "端口1输出A相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1OverElectricB, "端口1输出B相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1OverElectricC, "端口1输出C相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2OverElectricA, "端口2输出A相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2OverElectricB, "端口2输出B相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2OverElectricC, "端口2输出C相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3OverElectricA, "端口3输出A相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3OverElectricB, "端口3输出B相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3OverElectricC, "端口3输出C相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4OverElectricA, "端口4输出A相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4OverElectricB, "端口4输出B相过流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4OverElectricC, "端口4输出C相过流");
|
||||
// 三相欠流
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1UnderElectricA, "端口1输出A相欠流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1UnderElectricB, "端口1输出B相欠流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1UnderElectricC, "端口1输出C相欠流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2UnderElectricA, "端口2输出A相欠流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2UnderElectricB, "端口2输出B相欠流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2UnderElectricC, "端口2输出C相欠流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3UnderElectricA, "端口3输出A相欠流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3UnderElectricB, "端口3输出B相欠流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3UnderElectricC, "端口3输出C相欠流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4UnderElectricA, "端口4输出A相欠流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4UnderElectricB, "端口4输出B相欠流");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4UnderElectricC, "端口4输出C相欠流");
|
||||
// 三相空载
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch1ElectricEmpty, "端口1输出空载");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch2ElectricEmpty, "端口2输出空载");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch3ElectricEmpty, "端口3输出空载");
|
||||
ERROR_CODE_MESSAGES.put(Three_Switch4ElectricEmpty, "端口4输出空载");
|
||||
// 单相过流
|
||||
ERROR_CODE_MESSAGES.put(One_Switch1OverElectric, "端口1输出过流");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch2OverElectric, "端口2输出过流");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch3OverElectric, "端口3输出过流");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch4OverElectric, "端口4输出过流");
|
||||
// 单相欠流
|
||||
ERROR_CODE_MESSAGES.put(One_Switch1UnderElectric, "端口1输出欠流");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch2UnderElectric, "端口2输出欠流");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch3UnderElectric, "端口3输出欠流");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch4UnderElectric, "端口4输出欠流");
|
||||
// 单相空载
|
||||
ERROR_CODE_MESSAGES.put(One_Switch1ElectricEmpty, "端口1输出空载");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch2ElectricEmpty, "端口2输出空载");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch3ElectricEmpty, "端口3输出空载");
|
||||
ERROR_CODE_MESSAGES.put(One_Switch4ElectricEmpty, "端口4输出空载");
|
||||
// 其他
|
||||
ERROR_CODE_MESSAGES.put(PowerOff, "断电告警");
|
||||
ERROR_CODE_MESSAGES.put(ControllerWarn, "控制板通信故障");
|
||||
ERROR_CODE_MESSAGES.put(MeterShipWarn, "计量芯片故障");
|
||||
}
|
||||
|
||||
private DefineDeviceErrorCode() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取故障码对应的错误信息
|
||||
* 获取故障码对应的错误描述
|
||||
*/
|
||||
public static String getErrorMessage(int errorCode) {
|
||||
return ERROR_CODE_MESSAGES.getOrDefault(errorCode, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据相序索引获取相名称(0=A, 1=B, 2=C)
|
||||
*/
|
||||
public static String getPhaseName(int phaseIndex) {
|
||||
switch (phaseIndex) {
|
||||
case 0: return "A";
|
||||
case 1: return "B";
|
||||
case 2: return "C";
|
||||
default: return "无";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.intc.fishery.constant;
|
||||
|
||||
/**
|
||||
* 设备告警码常量定义
|
||||
* 设备告警码常量定义(与 C# DefineDeviceWarnCode 保持一致)
|
||||
*
|
||||
* @author intc
|
||||
*/
|
||||
@@ -12,90 +12,112 @@ public class DefineDeviceWarnCode {
|
||||
public static final int None = 0;
|
||||
|
||||
/**
|
||||
* 用户自定义告警最大码
|
||||
* 溶解氧探头离线(检测仪 或 控制器) 1 << 0 = 1
|
||||
*/
|
||||
public static final int UserMaxCode = 65536;
|
||||
public static final int DetectorOxyOffline = 1 << 0;
|
||||
|
||||
/**
|
||||
* 低溶氧告警
|
||||
* PH探头离线(检测仪) 1 << 1 = 2
|
||||
*/
|
||||
public static final int LowOxygen = 1;
|
||||
public static final int DetectorPHOffline = 1 << 1;
|
||||
|
||||
/**
|
||||
* 高温告警
|
||||
* 盐度探头离线(检测仪) 1 << 2 = 4
|
||||
*/
|
||||
public static final int HighTemperature = 2;
|
||||
public static final int DetectorSalinityOffline = 1 << 2;
|
||||
|
||||
/**
|
||||
* 低温告警
|
||||
* 浊度探头离线(检测仪) 1 << 3 = 8
|
||||
*/
|
||||
public static final int LowTemperature = 4;
|
||||
public static final int DetectorTurbidityOffline = 1 << 3;
|
||||
|
||||
/**
|
||||
* PH值告警
|
||||
* 水位探头离线(检测仪) 1 << 4 = 16
|
||||
*/
|
||||
public static final int PHAlarm = 8;
|
||||
public static final int DetectorWaterLevelOffline = 1 << 4;
|
||||
|
||||
/**
|
||||
* 盐度告警
|
||||
* 氨氮探头离线(检测仪) 1 << 5 = 32
|
||||
*/
|
||||
public static final int SalinityAlarm = 16;
|
||||
public static final int DetectorNH3NOffline = 1 << 5;
|
||||
|
||||
/**
|
||||
* 设备离线
|
||||
* 设备离线(检测仪 或 控制器) 1 << 6 = 64
|
||||
*/
|
||||
public static final int DeviceOffline = 32;
|
||||
public static final int DeviceOffline = 1 << 6;
|
||||
|
||||
/**
|
||||
* 设备失联
|
||||
* 溶解氧低于告警値(检测仪 或 控制器) 1 << 7 = 128
|
||||
*/
|
||||
public static final int DeviceDead = 64;
|
||||
public static final int DissolvedOxyLow = 1 << 7;
|
||||
|
||||
/**
|
||||
* 溶解氧探头未校准
|
||||
* 温度低于告警値(检测仪 或 控制器) 1 << 8 = 256
|
||||
*/
|
||||
public static final int OxyDetectorNoCorrect = 1;
|
||||
public static final int TempLow = 1 << 8;
|
||||
|
||||
/**
|
||||
* 温度高于告警値(检测仪 或 控制器) 1 << 9 = 512
|
||||
*/
|
||||
public static final int TempHigh = 1 << 9;
|
||||
|
||||
/**
|
||||
* 饱和度过高(检测仪 或 控制器) 1 << 10 = 1024
|
||||
*/
|
||||
public static final int SaturaHigh = 1 << 10;
|
||||
|
||||
/**
|
||||
* 设备断电(控制器) 1 << 15 = 32768
|
||||
*/
|
||||
public static final int ErrorPowerOff = 1 << 15;
|
||||
|
||||
/**
|
||||
* 溶解氧探头未校准 1 << 16 = 65536
|
||||
*/
|
||||
public static final int OxyDetectorNoCorrect = 1 << 16;
|
||||
|
||||
/**
|
||||
* 设备过期(服务到期) 1 << 17 = 131072
|
||||
*/
|
||||
public static final int DeviceTimeDead = 1 << 17;
|
||||
|
||||
/**
|
||||
* 用户自定义告警最大码 1 << 18 = 262144
|
||||
*/
|
||||
public static final int UserMaxCode = 1 << 18;
|
||||
|
||||
private DefineDeviceWarnCode() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换告警码为告警描述
|
||||
* 转换告警码为告警描述(与 C# ToWarnDescription 保持一致)
|
||||
* 优先级:设备过期 > 设备离线 > 设备断电 > 溶解氧离线 > 溶解氧告警 > 温度告警 > 饱和度过高
|
||||
*/
|
||||
public static String toWarnDescription(int warnCode) {
|
||||
if (warnCode == None) {
|
||||
return "";
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if ((warnCode & LowOxygen) != 0) {
|
||||
sb.append("低溶氧告警,");
|
||||
}
|
||||
if ((warnCode & HighTemperature) != 0) {
|
||||
sb.append("高温告警,");
|
||||
}
|
||||
if ((warnCode & LowTemperature) != 0) {
|
||||
sb.append("低温告警,");
|
||||
}
|
||||
if ((warnCode & PHAlarm) != 0) {
|
||||
sb.append("PH值告警,");
|
||||
}
|
||||
if ((warnCode & SalinityAlarm) != 0) {
|
||||
sb.append("盐度告警,");
|
||||
if ((warnCode & DeviceTimeDead) != 0) {
|
||||
return "设备过期";
|
||||
}
|
||||
if ((warnCode & DeviceOffline) != 0) {
|
||||
sb.append("设备离线,");
|
||||
return "设备离线";
|
||||
}
|
||||
if ((warnCode & DeviceDead) != 0) {
|
||||
sb.append("设备失联,");
|
||||
if ((warnCode & ErrorPowerOff) != 0) {
|
||||
return "设备断电";
|
||||
}
|
||||
|
||||
// 移除最后的逗号
|
||||
if (sb.length() > 0) {
|
||||
sb.setLength(sb.length() - 1);
|
||||
if ((warnCode & DetectorOxyOffline) != 0) {
|
||||
return "溶解氧离线";
|
||||
}
|
||||
|
||||
return sb.toString();
|
||||
if ((warnCode & DissolvedOxyLow) != 0) {
|
||||
return "溶解氧告警";
|
||||
}
|
||||
if ((warnCode & TempLow) != 0 || (warnCode & TempHigh) != 0) {
|
||||
return "温度告警";
|
||||
}
|
||||
if ((warnCode & SaturaHigh) != 0) {
|
||||
return "饱和度过高";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -805,8 +805,8 @@ public class PondController extends BaseController {
|
||||
|
||||
// 判断设备是否在线(简化判断,实际应根据业务逻辑)
|
||||
if (device.getWarnCode() == null
|
||||
|| (device.getWarnCode() != DefineDeviceWarnCode.DeviceDead
|
||||
&& device.getWarnCode() != DefineDeviceWarnCode.DeviceOffline)) {
|
||||
|| ((device.getWarnCode() & DefineDeviceWarnCode.DeviceTimeDead) == 0
|
||||
&& (device.getWarnCode() & DefineDeviceWarnCode.DeviceOffline) == 0)) {
|
||||
data.setIsAllDead(false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user