package com.hdl.sdk.ttl.HDLAppliances.HDLSecurity.Parser; import com.hdl.sdk.ttl.HDLDeviceManger.Bean.AppliancesInfo; /** * Created by JLChen on 2019/7/29 */ public class SecurityParser { public static final int fail = 0; /** * 布防设置 */ //布防类型 6 =撤防 5 = 白天布防 4 = 晚上有客布防 3 = 夜间布防 2 = 离开布防 1 = 假期布防 public static final int ARMING_HOLIDAY = 1; public static final int ARMING_LEAVE = 2; public static final int ARMING_AT_NIGHT = 3; public static final int ARMING_AT_NIGHT_WITH_GUEST = 4; public static final int ARMING_DURING_THE_DAY = 5; public static final int ARMING_DISARMING = 6; public static final int ARMING_FAIL = 7;//布防失败 // public static final int ARMING_UNKNOWM = -1;//未知状态 //获取布防 bytes数据 public static byte[] getArmingByte(AppliancesInfo appliancesInfo, int state) { try { if (state < 0 || state > 6) {//参数错误默认撤防 state = 6; } byte[] addBytes = new byte[2]; addBytes[0] = (byte) appliancesInfo.getChannelNum(); addBytes[1] = (byte) state; return addBytes; } catch (Exception e) { e.printStackTrace(); return new byte[]{fail}; } } // Bit 4 0 = 正常状态 , 1 = 电流报警 // Bit 3 0 =正常状态, 1 = 紧急报警 // Bit 2 0 =正常状态, 1 = 突发报警 // Bit 1 0 =正常状态, 1 =煤气报警 // Bit 0 0 =正常状态, 1 = 火警 3 // // Encode Bit Value // Bit 7 0 =正常状态, 1 = 温度报警 // Bit 6 0 =正常状态, 1 = 功率报警 // Bit 5 0 =正常状态, 1 = 无声报警 //private int CurrentAlarm; //电流报警 // private int EmergencyAlarm; //紧急报警 // private int SuddenAlarm; //突发报警 // private int FireAlarm; //火警 3 // // private int TemperatureAlarm;//温度报警 // private int PowerAlarm; //功率报警 // private int SilentAlarm; //无声报警 /** * 报警设置 ALARM */ public static final int ALARM_CURRENT = 4; //电流报警 public static final int ALARM_EMERGENCY = 3; //紧急报警 public static final int ALARM_SUDDEN = 2; //突发报警 public static final int ALARM_GAS = 1; //煤气报警 public static final int ALARM_FIRE = 0; //火警 3 public static final int ALARM_TEMPERATURE = 7; //温度报警 public static final int ALARM_POWER = 6; //功率报警 public static final int ALARM_SILENT = 5; //无声报警 //获取报警设置 bytes数据 只报警一种情况 public static byte[] getAlarmByte(AppliancesInfo appliancesInfo, int state) { try { byte[] addBytes = new byte[3]; addBytes[0] = (byte) appliancesInfo.getChannelNum(); switch (state) { case ALARM_FIRE: addBytes[1] = 0x01; break; case ALARM_GAS: addBytes[1] = (byte) (1 << 1); break; case ALARM_SUDDEN: addBytes[1] = (byte) (1 << 2); break; case ALARM_EMERGENCY: addBytes[1] = (byte) (1 << 3); break; case ALARM_CURRENT: addBytes[1] = (byte) (1 << 4); break; case ALARM_SILENT: addBytes[2] = (byte) (1 << 5); break; case ALARM_POWER: addBytes[2] = (byte) (1 << 6); break; case ALARM_TEMPERATURE: addBytes[2] = (byte) (1 << 7); break; default: break; } return addBytes; } catch (Exception e) { e.printStackTrace(); return new byte[]{fail}; } } }