1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity;
 
 
import com.hdl.sdk.hdl_core.HDLAppliances.HDLSecurity.Parser.SecurityParser;
import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo;
import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.SecurityStateBean;
 
/**
 * Created by JLChen on 2019/7/29
 * 安防模块
 */
public class SecurityBackInfo {
 
    private AppliancesInfo appliancesInfo;
    private String remarks;
    private int channelNum;  //回路号
    private SecurityStateBean mSecurityStateBean;
 
    private byte[] curState;    //返回信息
 
    public SecurityBackInfo() {
 
    }
 
    public SecurityBackInfo(AppliancesInfo mAppliancesInfo) {
        this.appliancesInfo = mAppliancesInfo;
        this.remarks = mAppliancesInfo.getRemarks();
        this.curState = mAppliancesInfo.getArrCurState();
        this.mSecurityStateBean = new SecurityStateBean();
 
        if (this.curState == null) return;
 
        if (this.curState.length >= 3) {
            this.channelNum = this.curState[0] & 0xFF;
            this.mSecurityStateBean.alarmCurrent = this.curState[1] & 0x10;
            this.mSecurityStateBean.alarmEmergency = this.curState[1] & 0x08;
            this.mSecurityStateBean.alarmSudden = this.curState[1] & 0x04;
            this.mSecurityStateBean.alarmGas = this.curState[1] & 0x02;
            this.mSecurityStateBean.alarmFire = this.curState[1] & 0x01;
            this.mSecurityStateBean.alarmTemperature = this.curState[2] & 0x80;
            this.mSecurityStateBean.alarmPower = this.curState[2] & 0x40;
            this.mSecurityStateBean.alarmSilent = this.curState[2] & 0x20;
            int mCurState = this.curState[2] & 0x1F;
 
            switch (mCurState) {
                case 0:
                    this.mSecurityStateBean.armingState = SecurityParser.ARMING_DISARMING;//撤防状态
                    break;
                case 1:
                    this.mSecurityStateBean.armingState = SecurityParser.ARMING_HOLIDAY;//假期布防
                    break;
                case 2:
                    this.mSecurityStateBean.armingState = SecurityParser.ARMING_LEAVE;//离开布防
                    break;
                case 4:
                    this.mSecurityStateBean.armingState = SecurityParser.ARMING_AT_NIGHT;//夜间布防
                    break;
                case 8:
                    this.mSecurityStateBean.armingState = SecurityParser.ARMING_AT_NIGHT_WITH_GUEST;//晚上有客布防
                    break;
                case 10:
                    this.mSecurityStateBean.armingState = SecurityParser.ARMING_DURING_THE_DAY;//白天布防
                    break;
                default:
//                    this.armingState = SecurityParser.ARMING_DISARMING;//撤防状态
                    this.mSecurityStateBean.armingState = -1;  //未知状态
                    break;
            }
 
 
        }
 
    }
 
 
    public AppliancesInfo getAppliancesInfo() {
        return appliancesInfo;
    }
 
    public void setAppliancesInfo(AppliancesInfo appliancesInfo) {
        this.appliancesInfo = appliancesInfo;
    }
 
    public String getRemarks() {
        return remarks;
    }
 
    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }
 
    public int getChannelNum() {
        return channelNum;
    }
 
    public void setChannelNum(int channelNum) {
        this.channelNum = channelNum;
    }
 
    public SecurityStateBean getSecurityStateBean() {
        return mSecurityStateBean;
    }
 
    public void setSecurityStateBean(SecurityStateBean securityStateBean) {
        mSecurityStateBean = securityStateBean;
    }
 
    public byte[] getCurState() {
        return curState;
    }
 
    public void setCurState(byte[] curState) {
        this.curState = curState;
    }
}
 
 
//        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 = 无声报警
//        Bit 4 0 =正常状态, 1 = 白天布防状态
//        Bit 3 0 =正常状态, 1 = 晚上有客布防
//        Bit 2 0 =正常状态, 1 = 夜间布防
//        Bit 1 0 =正常状态, 1 = 离开布防
//        Bit 0 0 =正常状态, 1 = 假期布防