|
@@ -7,6 +7,8 @@ import io.netty.buffer.ByteBuf;
|
|
|
import io.netty.channel.Channel;
|
|
import io.netty.channel.Channel;
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
import io.netty.channel.ChannelHandlerContext;
|
|
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
|
import io.netty.channel.ChannelInboundHandlerAdapter;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
import java.awt.*;
|
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
@@ -17,6 +19,7 @@ public class YgslClientHandler extends ChannelInboundHandlerAdapter {
|
|
|
|
|
|
|
|
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
public static byte[] responseByte;
|
|
public static byte[] responseByte;
|
|
|
|
|
+ public static final Logger log = LoggerFactory.getLogger(YgslClientHandler.class);
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
|
public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
|
@@ -45,11 +48,11 @@ public class YgslClientHandler extends ChannelInboundHandlerAdapter {
|
|
|
ByteBuf buf = (ByteBuf) msg;
|
|
ByteBuf buf = (ByteBuf) msg;
|
|
|
// 你的处理逻辑
|
|
// 你的处理逻辑
|
|
|
String content = buf.toString(StandardCharsets.UTF_8);
|
|
String content = buf.toString(StandardCharsets.UTF_8);
|
|
|
-// System.out.println("msg:"+content);
|
|
|
|
|
-// System.out.println("msg-size:"+content.length());
|
|
|
|
|
-
|
|
|
|
|
|
|
+ log.info("msg:"+content);
|
|
|
|
|
+ log.info("msg-size:"+content.length());
|
|
|
String mid = YgslParam.getMid(content);
|
|
String mid = YgslParam.getMid(content);
|
|
|
-// System.out.println("MID:"+mid);
|
|
|
|
|
|
|
+ log.info("MID:"+mid);
|
|
|
|
|
+
|
|
|
switch (mid){
|
|
switch (mid){
|
|
|
case "0002":
|
|
case "0002":
|
|
|
YgslUtil.lastTighteningResultSubscribe(MesClient.ygslClient);
|
|
YgslUtil.lastTighteningResultSubscribe(MesClient.ygslClient);
|
|
@@ -61,7 +64,7 @@ public class YgslClientHandler extends ChannelInboundHandlerAdapter {
|
|
|
YgslUtil.selectJob(MesClient.ygslClient);
|
|
YgslUtil.selectJob(MesClient.ygslClient);
|
|
|
break;
|
|
break;
|
|
|
case "0004": // 错误信息
|
|
case "0004": // 错误信息
|
|
|
- System.out.println("MID1:"+YgslParam.getReplyMid(content)+";ErrorCode:"+YgslParam.getErrCode(content));
|
|
|
|
|
|
|
+ log.error("MID:"+YgslParam.getReplyMid(content)+";ErrorCode:"+YgslParam.getErrCode(content));
|
|
|
if(YgslParam.getReplyMid(content).equals("0063")) {
|
|
if(YgslParam.getReplyMid(content).equals("0063")) {
|
|
|
System.out.println("未订阅");
|
|
System.out.println("未订阅");
|
|
|
MesClient.subBtnA.setText("未订阅");
|
|
MesClient.subBtnA.setText("未订阅");
|
|
@@ -102,7 +105,7 @@ public class YgslClientHandler extends ChannelInboundHandlerAdapter {
|
|
|
// System.out.println("getBatchSize:"+YgslParam.getBatchSize(content));
|
|
// System.out.println("getBatchSize:"+YgslParam.getBatchSize(content));
|
|
|
// System.out.println("getBatchCounter:"+YgslParam.getBatchCounter(content));
|
|
// System.out.println("getBatchCounter:"+YgslParam.getBatchCounter(content));
|
|
|
YgslUtil.lastTighteningResultDataAcknowledge(MesClient.ygslClient);
|
|
YgslUtil.lastTighteningResultDataAcknowledge(MesClient.ygslClient);
|
|
|
- if(MesClient.work_status == 1){
|
|
|
|
|
|
|
+ if(MesClient.work_status == 1 && MesClient.cura < MesClient.maxa){
|
|
|
String tighteningStatus = YgslParam.getTighteningStatus(content);
|
|
String tighteningStatus = YgslParam.getTighteningStatus(content);
|
|
|
String torqueStatus = YgslParam.getTorqueStatus(content);
|
|
String torqueStatus = YgslParam.getTorqueStatus(content);
|
|
|
String angleStatus = YgslParam.getAngleStatus(content);
|
|
String angleStatus = YgslParam.getAngleStatus(content);
|
|
@@ -116,12 +119,16 @@ public class YgslClientHandler extends ChannelInboundHandlerAdapter {
|
|
|
String angle = YgslParam.getAngle(content);
|
|
String angle = YgslParam.getAngle(content);
|
|
|
String jobID = YgslParam.getJobID(content);
|
|
String jobID = YgslParam.getJobID(content);
|
|
|
String tighteningID = YgslParam.getTighteningID(content);
|
|
String tighteningID = YgslParam.getTighteningID(content);
|
|
|
|
|
+ log.info("tighteningID:"+tighteningID);
|
|
|
|
|
+ log.info("pos:A");
|
|
|
|
|
+ log.info("jobID:"+jobID);
|
|
|
|
|
+ log.info("atids:"+MesClient.atids.toString());
|
|
|
if(!tighteningID.isEmpty() && !MesClient.atids.contains(tighteningID)){
|
|
if(!tighteningID.isEmpty() && !MesClient.atids.contains(tighteningID)){
|
|
|
MesClient.atids.add(tighteningID);
|
|
MesClient.atids.add(tighteningID);
|
|
|
-
|
|
|
|
|
String pos = "A";
|
|
String pos = "A";
|
|
|
-
|
|
|
|
|
- Boolean checkRet = JdbcUtils.checkTighteningById(tighteningID,pos,jobID);
|
|
|
|
|
|
|
+// Boolean checkRet = JdbcUtils.checkTighteningById(tighteningID,pos,jobID);
|
|
|
|
|
+// log.info("checkRet:"+checkRet);
|
|
|
|
|
+ Boolean checkRet = false;
|
|
|
if(!checkRet){
|
|
if(!checkRet){
|
|
|
|
|
|
|
|
if(tighteningStatus.equals("0")){ // NG
|
|
if(tighteningStatus.equals("0")){ // NG
|
|
@@ -144,8 +151,10 @@ public class YgslClientHandler extends ChannelInboundHandlerAdapter {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
String serialNumber = String.valueOf(MesClient.cura);
|
|
String serialNumber = String.valueOf(MesClient.cura);
|
|
|
|
|
+ log.info("serialNumber:"+serialNumber);
|
|
|
|
|
+// String serialNumber = String.valueOf(MesClient.cura);
|
|
|
if(!tighteningStatus.equals("1")){
|
|
if(!tighteningStatus.equals("1")){
|
|
|
- serialNumber = String.valueOf(MesClient.cura + 1);
|
|
|
|
|
|
|
+// serialNumber = String.valueOf(MesClient.cura + 1);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
MesClient.torquea.setText(torque);
|
|
MesClient.torquea.setText(torque);
|
|
@@ -166,12 +175,12 @@ public class YgslClientHandler extends ChannelInboundHandlerAdapter {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- YgslUtil.lastTighteningResultDataAcknowledge(MesClient.ygslClient);
|
|
|
|
|
|
|
+// YgslUtil.lastTighteningResultDataAcknowledge(MesClient.ygslClient);
|
|
|
|
|
|
|
|
// 两枪都达到预定数量时才自动提交
|
|
// 两枪都达到预定数量时才自动提交
|
|
|
MesClient.tryAutoSubmitWhenBothGunsDone();
|
|
MesClient.tryAutoSubmitWhenBothGunsDone();
|
|
|
}else{
|
|
}else{
|
|
|
- YgslUtil.lastTighteningResultDataAcknowledge(MesClient.ygslClient);
|
|
|
|
|
|
|
+// YgslUtil.lastTighteningResultDataAcknowledge(MesClient.ygslClient);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
break;
|
|
@@ -182,6 +191,7 @@ public class YgslClientHandler extends ChannelInboundHandlerAdapter {
|
|
|
}
|
|
}
|
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
|
|
+ log.error("error:"+e.getMessage());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|