From 96f936755365ee00f88b55400ad307d6bddff28a Mon Sep 17 00:00:00 2001 From: psh Date: Tue, 9 Jan 2024 16:08:41 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E6=A2=AF=E4=BA=A4=E4=BA=92fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basedriver/agv/utils/SocketUtil.java | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/utils/SocketUtil.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/utils/SocketUtil.java index 940de24..3572f7f 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/utils/SocketUtil.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/utils/SocketUtil.java @@ -17,9 +17,9 @@ public class SocketUtil { public static DataOutputStream dos; public static DataInputStream dis; - public static boolean checkConnect(int agvaddr, byte action) { + public synchronized static boolean checkConnect(int agvaddr, byte action) { try { - System.out.println("电梯socket链接开始"); + log.info("电梯socket链接开始"); byte[] b = new byte[1024]; byte[] call = new byte[1024]; byte[] move = new byte[1024]; @@ -27,8 +27,12 @@ public class SocketUtil { // s = new Socket("127.0.0.1", 20002); dos = new DataOutputStream(s.getOutputStream()); dis = new DataInputStream(s.getInputStream()); - System.out.println("电梯socket链接开始"); log.info("电梯socket链接成功"); + b = new byte[]{(byte) 0X1A, (byte) 0X1B, + (byte) 0X02, (byte) 0X01, + (byte) 0X01, (byte) 0X01, + (byte) 0X01, (byte) 0X03, + }; if(agvaddr==2421){ call = new byte[]{(byte) 0X1A, (byte) 0X1B, (byte) 0X02, (byte) 0X01, @@ -67,16 +71,16 @@ public class SocketUtil { } write(b); int[] arr = packageResult(); - if (arr[14] * 256 + arr[15] == 0x00) { - if ((arr[18] * 256 + arr[19] == 0x01 && agvaddr==2421)|| - (arr[18] * 256 + arr[19] == 0x02 && agvaddr==2422)) { + if (arr[7] == 0x00) { + if ((arr[8] == 0x01 && agvaddr==2421)|| + (arr[8] == 0x02 && agvaddr==2422)) { log.info("电梯已就位,下发开门指令"); write(move); packageResult(); - if (arr[22] * 256 + arr[23] == 0x11 && action == 0X10) { + if (arr[10] == 0x11 && action == 0X10) { log.info("电梯已开门就位,反馈NDC允许进入"); return true; - } else if (arr[22] * 256 + arr[23] == 0x21 && action == 0X00) { + } else if (arr[10] == 0x21 && action == 0X00) { log.info("电梯已关门就位,反馈NDC"); return true; } @@ -90,7 +94,6 @@ public class SocketUtil { return false; } } catch (Exception e) { - System.out.println("电梯socket链接异常"); log.info("电梯socket链接异常"); log.error("电梯socket链接出现异常:{}", e); if (ObjectUtil.isNotEmpty(s)) { @@ -110,7 +113,6 @@ public class SocketUtil { public static void write(byte[] b) { try { log.info("下发电梯socket数据:" + Bytes2HexString(b)); - System.out.println("下发电梯socket数据:" + Bytes2HexString(b)); dos.write(b); dos.flush(); } catch (IOException e) { @@ -133,7 +135,7 @@ public class SocketUtil { StringBuffer bs1 = new StringBuffer("0"); bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp)); } - System.out.println("接收电梯socket上报信息:" + bs); + log.info("接收电梯socket上报信息:" + bs); return arr; } }