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;
|
}
|
|
}
|