电梯交互fix
This commit is contained in:
@@ -17,9 +17,9 @@ public class SocketUtil {
|
|||||||
public static DataOutputStream dos;
|
public static DataOutputStream dos;
|
||||||
public static DataInputStream dis;
|
public static DataInputStream dis;
|
||||||
|
|
||||||
public static boolean checkConnect(int agvaddr, byte action) {
|
public synchronized static boolean checkConnect(int agvaddr, byte action) {
|
||||||
try {
|
try {
|
||||||
System.out.println("电梯socket链接开始");
|
log.info("电梯socket链接开始");
|
||||||
byte[] b = new byte[1024];
|
byte[] b = new byte[1024];
|
||||||
byte[] call = new byte[1024];
|
byte[] call = new byte[1024];
|
||||||
byte[] move = new byte[1024];
|
byte[] move = new byte[1024];
|
||||||
@@ -27,8 +27,12 @@ public class SocketUtil {
|
|||||||
// s = new Socket("127.0.0.1", 20002);
|
// s = new Socket("127.0.0.1", 20002);
|
||||||
dos = new DataOutputStream(s.getOutputStream());
|
dos = new DataOutputStream(s.getOutputStream());
|
||||||
dis = new DataInputStream(s.getInputStream());
|
dis = new DataInputStream(s.getInputStream());
|
||||||
System.out.println("电梯socket链接开始");
|
|
||||||
log.info("电梯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){
|
if(agvaddr==2421){
|
||||||
call = new byte[]{(byte) 0X1A, (byte) 0X1B,
|
call = new byte[]{(byte) 0X1A, (byte) 0X1B,
|
||||||
(byte) 0X02, (byte) 0X01,
|
(byte) 0X02, (byte) 0X01,
|
||||||
@@ -67,16 +71,16 @@ public class SocketUtil {
|
|||||||
}
|
}
|
||||||
write(b);
|
write(b);
|
||||||
int[] arr = packageResult();
|
int[] arr = packageResult();
|
||||||
if (arr[14] * 256 + arr[15] == 0x00) {
|
if (arr[7] == 0x00) {
|
||||||
if ((arr[18] * 256 + arr[19] == 0x01 && agvaddr==2421)||
|
if ((arr[8] == 0x01 && agvaddr==2421)||
|
||||||
(arr[18] * 256 + arr[19] == 0x02 && agvaddr==2422)) {
|
(arr[8] == 0x02 && agvaddr==2422)) {
|
||||||
log.info("电梯已就位,下发开门指令");
|
log.info("电梯已就位,下发开门指令");
|
||||||
write(move);
|
write(move);
|
||||||
packageResult();
|
packageResult();
|
||||||
if (arr[22] * 256 + arr[23] == 0x11 && action == 0X10) {
|
if (arr[10] == 0x11 && action == 0X10) {
|
||||||
log.info("电梯已开门就位,反馈NDC允许进入");
|
log.info("电梯已开门就位,反馈NDC允许进入");
|
||||||
return true;
|
return true;
|
||||||
} else if (arr[22] * 256 + arr[23] == 0x21 && action == 0X00) {
|
} else if (arr[10] == 0x21 && action == 0X00) {
|
||||||
log.info("电梯已关门就位,反馈NDC");
|
log.info("电梯已关门就位,反馈NDC");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -90,7 +94,6 @@ public class SocketUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("电梯socket链接异常");
|
|
||||||
log.info("电梯socket链接异常");
|
log.info("电梯socket链接异常");
|
||||||
log.error("电梯socket链接出现异常:{}", e);
|
log.error("电梯socket链接出现异常:{}", e);
|
||||||
if (ObjectUtil.isNotEmpty(s)) {
|
if (ObjectUtil.isNotEmpty(s)) {
|
||||||
@@ -110,7 +113,6 @@ public class SocketUtil {
|
|||||||
public static void write(byte[] b) {
|
public static void write(byte[] b) {
|
||||||
try {
|
try {
|
||||||
log.info("下发电梯socket数据:" + Bytes2HexString(b));
|
log.info("下发电梯socket数据:" + Bytes2HexString(b));
|
||||||
System.out.println("下发电梯socket数据:" + Bytes2HexString(b));
|
|
||||||
dos.write(b);
|
dos.write(b);
|
||||||
dos.flush();
|
dos.flush();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -133,7 +135,7 @@ public class SocketUtil {
|
|||||||
StringBuffer bs1 = new StringBuffer("0");
|
StringBuffer bs1 = new StringBuffer("0");
|
||||||
bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
|
bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
|
||||||
}
|
}
|
||||||
System.out.println("接收电梯socket上报信息:" + bs);
|
log.info("接收电梯socket上报信息:" + bs);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user