|
|
|
|
@ -19,6 +19,11 @@ public class MyProtocolDecoder extends FixedLengthFrameDecoder {
|
|
|
|
|
this.plcService = plcService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static String HEART = "0A";
|
|
|
|
|
private static String ORDER = "0B";
|
|
|
|
|
private static String ACTION = "0C";
|
|
|
|
|
private static String WARN = "0D";
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 解析TCP数据包
|
|
|
|
|
*
|
|
|
|
|
@ -73,11 +78,10 @@ public class MyProtocolDecoder extends FixedLengthFrameDecoder {
|
|
|
|
|
byte[] bytes = new byte[]{b1, b2, b3, b4, b5, b6, b7, b8};
|
|
|
|
|
String signal = "pl43"+plcId+type+String.valueOf(taskId)+short1+short2+short3+short4+short5+short6+short7+short8+":"+code+b1+b2+b3+b4+b5+b6+b7+b8;
|
|
|
|
|
log.info("plcId:{},原始信号:{}", plcId, signal);
|
|
|
|
|
if (type.equals("0A")) {
|
|
|
|
|
if (type.equals(HEART)) {
|
|
|
|
|
//心跳
|
|
|
|
|
log.debug("receive heart plcId:{}", plcId);
|
|
|
|
|
} else if (type.equals("0B")) {
|
|
|
|
|
|
|
|
|
|
} else if (type.equals(ORDER)) {
|
|
|
|
|
if ("B1".equals(code)) {
|
|
|
|
|
log.info("order start ,plcId:{},orderInfo:{}", plcId, plcOrderInfo.toString());
|
|
|
|
|
plcService.orderStart(plcOrderInfo, plcId);
|
|
|
|
|
@ -85,10 +89,8 @@ public class MyProtocolDecoder extends FixedLengthFrameDecoder {
|
|
|
|
|
log.info("order end, plcId:{},orderInfo:{}", plcId, plcOrderInfo.toString());
|
|
|
|
|
plcService.orderStop(plcId, plcOrderInfo.getOrderNum());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else if (type.equals("0C")) {
|
|
|
|
|
} else if (type.equals(ACTION)) {
|
|
|
|
|
log.info("action code,{} plcId:{},orderInfo:{}", code, plcId, plcOrderInfo.toString());
|
|
|
|
|
|
|
|
|
|
if(!code.equals("C6")){
|
|
|
|
|
Integer times = OrderAction.put(plcOrderInfo.getOrderNum());
|
|
|
|
|
//执行动作
|
|
|
|
|
@ -96,7 +98,7 @@ public class MyProtocolDecoder extends FixedLengthFrameDecoder {
|
|
|
|
|
}else {
|
|
|
|
|
plcService.action(plcOrderInfo, plcId, 1, code);
|
|
|
|
|
}
|
|
|
|
|
} else if (type.equals("0D")) {
|
|
|
|
|
} else if (type.equals(WARN)) {
|
|
|
|
|
log.info(" warn code:{}", code);
|
|
|
|
|
if ("D0".equals(code)) {
|
|
|
|
|
log.info("warn start ,plcId:{},warnInfo:b1:{},b2:{},b3:{},b4:{},b5:{},b6:{},b7:{},b8:{}", plcId, b1, b2, b3, b4, b5, b6, b7, b8);
|
|
|
|
|
|