package com.fzzy.protocol.zldz.analysis;
|
|
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 ser
|
*/
|
public void analysis8816(ReMessage message, GatewayDevice ser) {
|
|
log.debug("分机---->>>平台:消息类型=8816-----{}", ser.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);
|
|
//层 - 行 - 列 配置
|
ser.setCableRule(cable);
|
|
// 电缆制式
|
start = 9;
|
len = 1;
|
temp = content.substring(start * 2, start * 2 + len * 2);
|
ser.setCableFormat("0" + BytesUtil.hexToInt(temp));
|
|
// 电缆类型
|
start = 10;
|
len = 1;
|
temp = content.substring(start * 2, start * 2 + len * 2);
|
ser.setCableType("0" + BytesUtil.hexToInt(temp));
|
|
// 供电模式
|
start = 11;
|
len = 1;
|
temp = content.substring(start * 2, start * 2 + len * 2);
|
//ser.setPowerModel("0" + BytesUtil.hexToInt(temp));
|
|
String msg = ser.getDeviceName() + " 远程获取配置成功,请刷新数据查看!";
|
|
// 组织编码
|
start = 12;
|
temp = content.substring(start * 2);
|
if (readTag == 1) {// 表示写的成功返回
|
ser.setOrgId(ser.getOrgId());
|
msg = ser.getDeviceName() + " 远程写入成功,请刷新数据查看!";
|
} else {
|
ser.setOrgId(BytesUtil.hexToInt(BytesUtil.tran_LH(temp)) + "");
|
}
|
|
if (null == ser.getDeviceSn()) {
|
ser.setDeviceSn(ser.getId());
|
}
|
ser.setIp(message.getIp());
|
ser.setPort(message.getPort());
|
|
// 开始列默认=1
|
if (ser.getCableStart() == 0) {
|
ser.setCableStart(1);
|
}
|
|
log.info("分机---->>>平台:分机配置解析完成---{},更新到服服务器",
|
ser.getDeviceName());
|
|
//更新设备信息
|
gatewayDeviceService.updateData(ser);
|
}
|
|
/**
|
* 电缆初始化成功
|
*
|
* @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
|
}
|
}
|