vince
2024-07-03 69e8acc5dd1f760eb60e914472c151bfa8126a52
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
package com.fzzy.protocol.zldz.analysis;
 
import com.fzzy.api.Constant;
import com.fzzy.api.data.ApiCommonDevice;
import com.fzzy.api.utils.BytesUtil;
import com.fzzy.gateway.entity.GatewayDevice;
import com.fzzy.gateway.service.GatewayDeviceService;
import com.fzzy.protocol.zldz.data.ReMessage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
 
import javax.annotation.Resource;
 
/**
 * @author vince
 */
@Slf4j
@Component(AnalysisConf.BEAN_ID)
public class AnalysisConf {
 
    public static final String BEAN_ID = "zldz.analysisConf";
 
    @Resource
    private GatewayDeviceService gatewayDeviceService;
 
    /**
     * 解析分机配置信息
     *
     * @param message
     * @param device
     */
    public void analysis8816(ReMessage message, GatewayDevice device, ApiCommonDevice commonDevice) {
 
        log.debug("分机---->>>平台:消息类型=8816-----{}", device.getDeviceName());
 
        String content = message.getBody().getContent();
 
        // 读写标志
        int start = 0, len = 1;
        String temp = content.substring(start * 2, start * 2 + len * 2);
        int readTag = BytesUtil.hexToInt(temp);
 
        // 设备ID,全局唯一
        start = 1;
        len = 2;
        temp = content.substring(start * 2, start * 2 + len * 2);
 
        // 网络ID
        start = 3;
        len = 1;
        temp = content.substring(start * 2, start * 2 + len * 2);
 
        // 信道
        start = 4;
        len = 1;
        temp = content.substring(start * 2, start * 2 + len * 2);
 
        // 速率
        start = 5;
        len = 1;
        temp = content.substring(start * 2, start * 2 + len * 2);
 
        //层 -行 -列
        String cable = "";
        // 层数
        start = 6;
        len = 1;
        temp = content.substring(start * 2, start * 2 + len * 2);
        cable += BytesUtil.hexToInt(temp);
 
        // 行数
        start = 7;
        len = 1;
        temp = content.substring(start * 2, start * 2 + len * 2);
        cable += "-" + BytesUtil.hexToInt(temp);
 
        // 列数
        start = 8;
        len = 1;
        temp = content.substring(start * 2, start * 2 + len * 2);
        cable += "-" + BytesUtil.hexToInt(temp);
 
 
        // 电缆制式
        start = 9;
        len = 1;
        temp = content.substring(start * 2, start * 2 + len * 2);
        device.setCableFormat("0" + BytesUtil.hexToInt(temp));
 
        // 电缆类型
        start = 10;
        len = 1;
        temp = content.substring(start * 2, start * 2 + len * 2);
        device.setCableType("0" + BytesUtil.hexToInt(temp));
 
        // 供电模式
        start = 11;
        len = 1;
        temp = content.substring(start * 2, start * 2 + len * 2);
        //ser.setPowerModel("0" + BytesUtil.hexToInt(temp));
 
 
        // 组织编码
        start = 12;
        temp = content.substring(start * 2);
        if (readTag != 1) {// 表示写的成功返回
            device.setOrgId(BytesUtil.hexToInt(BytesUtil.tran_LH(temp)) + "");
        }
 
        device.setIp(message.getIp());
        device.setPort(message.getPort());
 
        // 开始列默认=1
        if (null == device.getCableStart()) {
            device.setCableStart("1");
        }
 
        log.info("分机---->>>平台:分机配置解析完成---{},更新到服服务器",
                device.getDeviceName());
 
        //更新设备信息
        gatewayDeviceService.updateData(device);
 
        //更新连接设备信息
        commonDevice.setSn(device.getDeviceSn());
        commonDevice.setCable(cable);
        commonDevice.setOrgId(device.getOrgId());
        Constant.updateCache(commonDevice);
    }
 
    /**
     * 电缆初始化成功
     *
     * @param reMessage
     * @param ser
     */
    public void analysis8822(ReMessage reMessage, GatewayDevice ser) {
        log.info("--------电缆初始化成功------------{}", ser.getDeviceName());
    }
 
    /**
     * 电缆修改返回,
     *
     * @param reMessage
     * @param ser
     */
    public void analysis8826(ReMessage reMessage, GatewayDevice ser) {
        log.info("--------修改电缆信息返回------------{}", ser.getDeviceName());
    }
 
    /**
     * 通道电缆获取返回,分机返回收到命令信息,实际返回值在8829中说明
     *
     * @param reMessage
     * @param ser
     */
    public void analysis8825(ReMessage reMessage, GatewayDevice ser) {
        log.info("--------通道电缆获取返回------------{}", ser.getDeviceName());
    }
 
    /**
     * 终端发送通道电缆数据给后台,分机主动推送
     *
     * @param reMessage
     * @param ser
     */
    @SuppressWarnings("unchecked")
    public void analysis1129(ReMessage reMessage, GatewayDevice ser) {
        log.info("--------终端发送通道电缆数据给后台------------{}", ser.getDeviceName());
    }
 
    /**
     * 电缆汇总应答
     *
     * @param reMessage
     * @param ser
     */
    public void analysis8823(ReMessage reMessage, GatewayDevice ser) {
        // 开始解析
        String content = reMessage.getBody().getContent();
 
        //DO NOTHING
    }
}