|
|
@ -83,170 +83,53 @@ public class NDCAgvServiceImpl implements NDCAgvService { |
|
|
|
@Override |
|
|
|
public void sendAgvInstToNDC(String agv_system_type, Instruction inst) { |
|
|
|
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { |
|
|
|
if (!StrUtil.equals(agv_system_type, "1")) { |
|
|
|
String instcode = inst.getInstruction_code(); |
|
|
|
int type = Integer.parseInt(inst.getAgv_inst_type()); |
|
|
|
int priority = Integer.parseInt(inst.getPriority()) + 128; |
|
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
|
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); |
|
|
|
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); |
|
|
|
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); |
|
|
|
int startAddress2 = deviceService.queryAddressBydeviceCode(inst.getStart_point_code2()); |
|
|
|
int nextAddress2 = deviceService.queryAddressBydeviceCode(inst.getNext_point_code2()); |
|
|
|
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); |
|
|
|
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); |
|
|
|
byte typehigh = (byte) IntToHexHigh(type); |
|
|
|
byte typelow = (byte) IntToHexLow(type); |
|
|
|
byte qhdhigh = (byte) IntToHexHigh(startAddress); |
|
|
|
byte qhdlow = (byte) IntToHexLow(startAddress); |
|
|
|
byte qhdhigh2 = (byte) IntToHexHigh(startAddress2); |
|
|
|
byte qhdlow2 = (byte) IntToHexLow(startAddress2); |
|
|
|
byte fhdhigh = (byte) IntToHexHigh(nextAddress); |
|
|
|
byte fhdlow = (byte) IntToHexLow(nextAddress); |
|
|
|
byte fhdhigh2 = (byte) IntToHexHigh(nextAddress2); |
|
|
|
byte fhdlow2 = (byte) IntToHexLow(nextAddress2); |
|
|
|
byte prioritylow = (byte) IntToHexLow(priority); |
|
|
|
|
|
|
|
String str = "十进制下发:"; |
|
|
|
String str1 = "十六进制下发:"; |
|
|
|
str += "ikey:" + (Integer.parseInt(instcode)); |
|
|
|
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); |
|
|
|
|
|
|
|
str += "/type:" + (type); |
|
|
|
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); |
|
|
|
|
|
|
|
str += "/qhd:" + (startAddress); |
|
|
|
str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); |
|
|
|
str += "/fhd:" + (nextAddress); |
|
|
|
str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); |
|
|
|
|
|
|
|
str += "/qhd2:" + (startAddress2); |
|
|
|
str1 += "/qhd2:" + hexToString(qhdhigh2 & 0xFF) + hexToString(qhdlow2 & 0xFF); |
|
|
|
str += "/fhd2:" + (nextAddress2); |
|
|
|
str1 += "/fhd2:" + hexToString(fhdhigh2 & 0xFF) + hexToString(fhdlow2 & 0xFF); |
|
|
|
|
|
|
|
str += "/priority:" + (priority); |
|
|
|
str1 += "/priority:" + hexToString(prioritylow & 0xFF); |
|
|
|
|
|
|
|
System.out.println(str); |
|
|
|
System.out.println(str1); |
|
|
|
byte[] b = new byte[]{}; |
|
|
|
if (type == 1) { |
|
|
|
b = new byte[]{(byte) 0X87, (byte) 0XCD, |
|
|
|
(byte) 0X00, (byte) 0X08, |
|
|
|
(byte) 0X00, (byte) 0X16, |
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
(byte) 0X00, (byte) 0X71, |
|
|
|
(byte) 0X00, (byte) 0X12, |
|
|
|
(byte) 0X01, prioritylow, |
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
(byte) ikeyhigh, (byte) ikeylow, |
|
|
|
(byte) ikeyhigh, (byte) ikeylow, |
|
|
|
(byte) typehigh, (byte) typelow, |
|
|
|
(byte) qhdhigh, (byte) qhdlow, |
|
|
|
(byte) qhdhigh2, (byte) qhdlow2, |
|
|
|
(byte) fhdhigh, (byte) fhdlow, |
|
|
|
(byte) fhdhigh2, (byte) fhdlow2 |
|
|
|
}; |
|
|
|
} else if (type == 2) { |
|
|
|
b = new byte[]{(byte) 0X87, (byte) 0XCD, |
|
|
|
(byte) 0X00, (byte) 0X08, |
|
|
|
(byte) 0X00, (byte) 0X16, |
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
(byte) 0X00, (byte) 0X71, |
|
|
|
(byte) 0X00, (byte) 0X12, |
|
|
|
(byte) 0X01, prioritylow, |
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
(byte) ikeyhigh, (byte) ikeylow, |
|
|
|
(byte) ikeyhigh, (byte) ikeylow, |
|
|
|
(byte) typehigh, (byte) typelow, |
|
|
|
(byte) qhdhigh, (byte) qhdlow, |
|
|
|
(byte) 0X00, (byte) 0X00, |
|
|
|
(byte) fhdhigh, (byte) fhdlow, |
|
|
|
(byte) 0X00, (byte) 0X00 |
|
|
|
}; |
|
|
|
} else if (type == 3) { |
|
|
|
b = new byte[]{(byte) 0X87, (byte) 0XCD, |
|
|
|
(byte) 0X00, (byte) 0X08, |
|
|
|
(byte) 0X00, (byte) 0X16, |
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
(byte) 0X00, (byte) 0X71, |
|
|
|
(byte) 0X00, (byte) 0X12, |
|
|
|
(byte) 0X01, prioritylow, |
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
(byte) ikeyhigh, (byte) ikeylow, |
|
|
|
(byte) ikeyhigh, (byte) ikeylow, |
|
|
|
(byte) typehigh, (byte) typelow, |
|
|
|
(byte) qhdhigh, (byte) qhdlow, |
|
|
|
(byte) qhdhigh2, (byte) qhdlow2, |
|
|
|
(byte) fhdhigh, (byte) fhdlow, |
|
|
|
(byte) fhdhigh2, (byte) fhdlow2 |
|
|
|
}; |
|
|
|
} |
|
|
|
log.info("下发AGV作业指令--{}", str1); |
|
|
|
if (StrUtil.equals(agv_system_type,"2")){ |
|
|
|
TwoNDCSocketConnectionAutoRun.write(b); |
|
|
|
} else if (StrUtil.equals(agv_system_type,"3")){ |
|
|
|
TwoNDC2SocketConnectionAutoRun.write(b); |
|
|
|
} |
|
|
|
System.out.println("下发agv指令数据:" + Bytes2HexString(b)); |
|
|
|
} else { |
|
|
|
|
|
|
|
String instcode = inst.getInstruction_code(); |
|
|
|
int type = Integer.parseInt(inst.getInstruction_type()); |
|
|
|
int priority = Integer.parseInt(inst.getPriority()) + 128; |
|
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
|
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); |
|
|
|
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); |
|
|
|
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); |
|
|
|
|
|
|
|
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); |
|
|
|
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); |
|
|
|
byte typehigh = (byte) IntToHexHigh(type); |
|
|
|
byte typelow = (byte) IntToHexLow(type); |
|
|
|
byte qhdhigh = (byte) IntToHexHigh(startAddress); |
|
|
|
byte qhdlow = (byte) IntToHexLow(startAddress); |
|
|
|
byte fhdhigh = (byte) IntToHexHigh(nextAddress); |
|
|
|
byte fhdlow = (byte) IntToHexLow(nextAddress); |
|
|
|
byte prioritylow = (byte) IntToHexLow(priority); |
|
|
|
|
|
|
|
String str = "十进制下发:"; |
|
|
|
String str1 = "十六进制下发:"; |
|
|
|
str += "ikey:" + (Integer.parseInt(instcode)); |
|
|
|
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); |
|
|
|
|
|
|
|
str += "/type:" + (type); |
|
|
|
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); |
|
|
|
|
|
|
|
str += "/qhd:" + (startAddress); |
|
|
|
str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); |
|
|
|
str += "/fhd:" + (nextAddress); |
|
|
|
str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); |
|
|
|
|
|
|
|
str += "/priority:" + (priority); |
|
|
|
str1 += "/priority:" + hexToString(prioritylow & 0xFF); |
|
|
|
|
|
|
|
System.out.println(str); |
|
|
|
System.out.println(str1); |
|
|
|
|
|
|
|
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, |
|
|
|
(byte) 0X00, (byte) 0X08, |
|
|
|
(byte) 0X00, (byte) 0X12, |
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
(byte) 0X00, (byte) 0X71, |
|
|
|
(byte) 0X00, (byte) 0X0E, |
|
|
|
(byte) 0X01, prioritylow, |
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
(byte) ikeyhigh, (byte) ikeylow, |
|
|
|
(byte) ikeyhigh, (byte) ikeylow, |
|
|
|
(byte) typehigh, (byte) typelow, |
|
|
|
(byte) qhdhigh, (byte) qhdlow, |
|
|
|
(byte) fhdhigh, (byte) fhdlow |
|
|
|
}; |
|
|
|
log.info("下发AGV作业指令--{}", str1); |
|
|
|
OneNDCSocketConnectionAutoRun.write(b); |
|
|
|
System.out.println("下发agv指令数据:" + Bytes2HexString(b)); |
|
|
|
} |
|
|
|
String instcode = inst.getInstruction_code(); |
|
|
|
int type = Integer.parseInt(inst.getAgv_inst_type()); |
|
|
|
int priority = Integer.parseInt(inst.getPriority()) + 128; |
|
|
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|
|
|
DeviceService deviceService = SpringContextHolder.getBean(DeviceServiceImpl.class); |
|
|
|
int startAddress = deviceService.queryAddressBydeviceCode(inst.getStart_point_code()); |
|
|
|
int nextAddress = deviceService.queryAddressBydeviceCode(inst.getNext_point_code()); |
|
|
|
byte ikeyhigh = (byte) IntToHexHigh(Integer.parseInt(instcode)); |
|
|
|
byte ikeylow = (byte) IntToHexLow(Integer.parseInt(instcode)); |
|
|
|
byte typehigh = (byte) IntToHexHigh(type); |
|
|
|
byte typelow = (byte) IntToHexLow(type); |
|
|
|
byte qhdhigh = (byte) IntToHexHigh(startAddress); |
|
|
|
byte qhdlow = (byte) IntToHexLow(startAddress); |
|
|
|
byte fhdhigh = (byte) IntToHexHigh(nextAddress); |
|
|
|
byte fhdlow = (byte) IntToHexLow(nextAddress); |
|
|
|
byte prioritylow = (byte) IntToHexLow(priority); |
|
|
|
String str = "十进制下发:"; |
|
|
|
String str1 = "十六进制下发:"; |
|
|
|
str += "ikey:" + (Integer.parseInt(instcode)); |
|
|
|
str1 += "ikey:" + hexToString(ikeyhigh & 0xFF) + hexToString(ikeylow & 0xFF); |
|
|
|
str += "/type:" + (type); |
|
|
|
str1 += "/type:" + hexToString(typehigh & 0xFF) + hexToString(typelow & 0xFF); |
|
|
|
str += "/qhd:" + (startAddress); |
|
|
|
str1 += "/qhd:" + hexToString(qhdhigh & 0xFF) + hexToString(qhdlow & 0xFF); |
|
|
|
str += "/fhd:" + (nextAddress); |
|
|
|
str1 += "/fhd:" + hexToString(fhdhigh & 0xFF) + hexToString(fhdlow & 0xFF); |
|
|
|
str += "/priority:" + (priority); |
|
|
|
str1 += "/priority:" + hexToString(prioritylow & 0xFF); |
|
|
|
System.out.println(str); |
|
|
|
System.out.println(str1); |
|
|
|
byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, |
|
|
|
(byte) 0X00, (byte) 0X08, |
|
|
|
(byte) 0X00, (byte) 0X12, |
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
(byte) 0X00, (byte) 0X71, |
|
|
|
(byte) 0X00, (byte) 0X0E, |
|
|
|
(byte) 0X01, prioritylow, |
|
|
|
(byte) 0X00, (byte) 0X01, |
|
|
|
(byte) ikeyhigh, (byte) ikeylow, |
|
|
|
(byte) ikeyhigh, (byte) ikeylow, |
|
|
|
(byte) typehigh, (byte) typelow, |
|
|
|
(byte) qhdhigh, (byte) qhdlow, |
|
|
|
(byte) fhdhigh, (byte) fhdlow |
|
|
|
}; |
|
|
|
log.info("下发AGV作业指令--{}", str1); |
|
|
|
OneNDCSocketConnectionAutoRun.write(b); |
|
|
|
System.out.println("下发agv指令数据:" + Bytes2HexString(b)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|