jiazx0107@163.com
2023-08-28 664bb4d0b7799328667ffc47e39da711a77ddbfa
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
package com.ld.igds.protocol.modbus;
 
import com.ld.igds.constant.Constant;
import com.ld.igds.util.ContextUtil;
 
import java.util.HashMap;
import java.util.Map;
 
/**
 *
 */
public class ServerUtil {
 
 
 
    /**
     * 设备状态返回的结果 KEY= companyId + serId + deviceCode value = 结果状态
     */
    private static Map<String, String> contextStatusMap = new HashMap<>();
 
 
    /**
     * 设备解析后的装法存放
     *
     * @param serId
     * @param deviceCode 设备通道ID
     * @param status     不考虑设备类型,只在通道上标记是OPEN或者CLOSE即可
     */
    public static void add2StatusMap(String companyId, String serId, String deviceCode, String status) {
        contextStatusMap.put(ContextUtil.buildDeviceStatusKey(companyId, serId, deviceCode), status);
    }
 
    public static Map<String, String> getStatusMap() {
        return contextStatusMap;
    }
 
 
 
 
 
 
    public static int getAddrExe(String temp) {
        if (Constant.YN_N.equals(temp)) return 65535;
        if (temp.length() > 4) {
            temp = temp.substring(temp.length() - 4);
        }
        return Integer.valueOf(temp) - 1;
    }
 
}