Browse Source

电梯交互fix

master
psh 1 year ago
parent
commit
96f9367553
  1. 24
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/utils/SocketUtil.java

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

Loading…
Cancel
Save