ndc交互更新

This commit is contained in:
loujf
2022-12-07 14:09:33 +08:00
parent 629c7bca1b
commit a5828449c7
3 changed files with 78 additions and 27 deletions

View File

@@ -22,6 +22,7 @@ import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.opc.DeviceType;
import org.nl.exception.BadRequestException;
import org.nl.start.auto.run.NDCSocketConnectionAutoRun;
import org.nl.utils.SpringContextHolder;
import org.slf4j.MDC;
import org.springframework.stereotype.Service;
@@ -73,7 +74,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
};
log.info("下发删除AGV指令--{}", Bytes2HexString(b));
// NDCSocketConnectionAutoRun.write(b);
NDCSocketConnectionAutoRun.write(b);
System.out.println("下发删除agv指令数据:" + Bytes2HexString(b));
}
} finally {
@@ -182,7 +183,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
};
log.info("下发AGV作业指令--{}", str1);
// NDCSocketConnectionAutoRun.write(b);
NDCSocketConnectionAutoRun.write(b);
System.out.println("下发agv指令数据:" + Bytes2HexString(b));
}
} finally {

View File

@@ -430,7 +430,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Transactional(rollbackFor = Exception.class)
public void update(Instruction dto) {
Instruction entity = this.findById(dto.getInstruction_id());
//if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
if (entity == null) throw new BadRequestException("被删除或无权限,操作失败!");
String currentUsername = SecurityUtils.getCurrentUsername();
String now = DateUtil.now();

View File

@@ -195,7 +195,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
// 到达取货点请求取货
else if (phase == 0x03) {
if (ObjectUtil.isEmpty(inst)) {
logServer.deviceExecuteLog("未找到指令号对应的指令:", "","",String.valueOf(ikey));
logServer.deviceExecuteLog("ndc", "","","未找到指令号对应的指令:" + ikey);
break;
}
//检测站点
@@ -207,7 +207,19 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","", "AGV请求取货设备{}无货,无法反馈");
logServer.deviceExecuteLog("ndc","","", "AGV请求取货设备{}无货,无法反馈");
}
}
//嘉耐缓存货架
if (device.getDeviceDriver() instanceof LnshLaminatingMachineDeviceDriver) {
lnshLaminatingMachineDeviceDriver = (LnshLaminatingMachineDeviceDriver) device.getDeviceDriver();
if (lnshLaminatingMachineDeviceDriver.getMove() != 0) {
inst.setExecute_status("1");
instructionService.update(inst);
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog("ndc","","", "AGV请求取货设备{}无货,无法反馈");
}
}
//嘉耐工位模板
@@ -221,7 +233,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV请求取货设备{}无货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV请求取货设备{}无货,无法反馈");
}
}
//嘉耐码垛机械手工位
@@ -235,7 +247,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV请求取货设备{}无货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV请求取货设备{}无货,无法反馈");
}
}
//嘉耐音来码垛机械手工位
@@ -249,7 +261,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV请求取货设备{}无货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV请求取货设备{}无货,无法反馈");
}
}
//普通站点
@@ -267,7 +279,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV请求取货设备{}无货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV请求取货设备{}无货,无法反馈");
}
}
}
@@ -275,7 +287,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
// 取货完成请求离开
else if (phase == 0x05) {
if (ObjectUtil.isEmpty(inst)) {
logServer.deviceExecuteLog("未找到指令号对应的指令:", "","",String.valueOf(ikey));
logServer.deviceExecuteLog("ndc", "","","未找到指令号对应的指令:" + ikey);
break;
}
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
@@ -286,7 +298,19 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV取货完成请求离开设备{}有货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV取货完成请求离开设备{}有货,无法反馈");
}
}
//嘉耐缓存货架
if (device.getDeviceDriver() instanceof LnshLaminatingMachineDeviceDriver) {
lnshLaminatingMachineDeviceDriver = (LnshLaminatingMachineDeviceDriver) device.getDeviceDriver();
if (lnshLaminatingMachineDeviceDriver.getMove() == 0) {
inst.setExecute_status("5");
instructionService.update(inst);
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog("ndc","","","AGV取货完成请求离开设备{}有货,无法反馈");
}
}
//嘉耐工位模板
@@ -299,7 +323,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV取货完成请求离开设备{}有货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV取货完成请求离开设备{}有货,无法反馈");
}
}
//嘉耐码垛机械手工位
@@ -312,7 +336,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV取货完成请求离开设备{}有货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV取货完成请求离开设备{}有货,无法反馈");
}
}
@@ -326,7 +350,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV取货完成请求离开设备{}有货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV取货完成请求离开设备{}有货,无法反馈");
}
}
@@ -348,9 +372,10 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
// 到达扫码点
else if (phase == 0x06) {
if (ObjectUtil.isEmpty(inst)) {
logServer.deviceExecuteLog("未找到指令号对应的指令:", "","",String.valueOf(ikey));
logServer.deviceExecuteLog("ndc", "","","未找到指令号对应的指令:" + ikey);
break;
}
logServer.deviceExecuteLog("ndc","","","phase==0x06," + "指令号:" + ikey + ",address" + device_code);
//检测站点
if (device.getDeviceDriver() instanceof LnshLaminatingMachineDeviceDriver) {
lnshLaminatingMachineDeviceDriver = (LnshLaminatingMachineDeviceDriver) device.getDeviceDriver();
@@ -375,7 +400,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
//请求放货
else if (phase == 0x07) {
if (ObjectUtil.isEmpty(inst)) {
logServer.deviceExecuteLog("未找到指令号对应的指令:", "","",String.valueOf(ikey));
logServer.deviceExecuteLog("ndc", "","","未找到指令号对应的指令:" + ikey);
break;
}
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
@@ -386,7 +411,19 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV请求放货设备{}有货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV请求放货设备{}有货,无法反馈");
}
}
//嘉耐缓存货架
if (device.getDeviceDriver() instanceof LnshLaminatingMachineDeviceDriver) {
lnshLaminatingMachineDeviceDriver = (LnshLaminatingMachineDeviceDriver) device.getDeviceDriver();
if (lnshLaminatingMachineDeviceDriver.getMove() == 0) {
inst.setExecute_status("3");
instructionService.update(inst);
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog("ndc","","","AGV请求放货设备{}有货,无法反馈");
}
}
//嘉耐工位模板
@@ -401,7 +438,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV请求放货设备{}有货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV请求放货设备{}有货,无法反馈");
}
}
//嘉耐码垛机械手工位
@@ -415,7 +452,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV请求放货设备{}有货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV请求放货设备{}有货,无法反馈");
}
}
//嘉耐音来码垛机械手工位
@@ -429,14 +466,14 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV请求放货设备{}有货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV请求放货设备{}有货,无法反馈");
}
}
}
// 放货完成请求离开
else if (phase == 0x09) {
if (ObjectUtil.isEmpty(inst)) {
logServer.deviceExecuteLog("未找到指令号对应的指令:", "","",String.valueOf(ikey));
logServer.deviceExecuteLog("ndc", "","","未找到指令号对应的指令:" + ikey);
break;
}
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
@@ -447,7 +484,19 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV放货完成请求离开设备{}无货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV放货完成请求离开设备{}无货,无法反馈");
}
}
//嘉耐缓存货架
if (device.getDeviceDriver() instanceof LnshLaminatingMachineDeviceDriver) {
lnshLaminatingMachineDeviceDriver = (LnshLaminatingMachineDeviceDriver) device.getDeviceDriver();
if (lnshLaminatingMachineDeviceDriver.getMove() != 0) {
inst.setExecute_status("6");
instructionService.update(inst);
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog("ndc","","","AGV放货完成请求离开设备{}无货,无法反馈");
}
}
//嘉耐工位模板
@@ -461,7 +510,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV放货完成请求离开设备{}无货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV放货完成请求离开设备{}无货,无法反馈");
}
}
@@ -476,7 +525,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV放货完成请求离开设备{}无货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV放货完成请求离开设备{}无货,无法反馈");
}
}
@@ -491,7 +540,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
data = AgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
} else {
logServer.deviceExecuteLog(device_code,"","","AGV放货完成请求离开设备{}无货,无法反馈");
logServer.deviceExecuteLog("ndc","","","AGV放货完成请求离开设备{}无货,无法反馈");
}
}
@@ -575,7 +624,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dto.setName(String.valueOf(carno));
if (arr[18] * 256 + arr[19] == 0) {
dto.setState("IDLE");
acsToWmsService.feedbackAgvStatus(String.valueOf(carno), "0", "");
// acsToWmsService.feedbackAgvStatus(String.valueOf(carno), "0", "");
} else {
StringBuffer errbs = new StringBuffer();
for (int i = 0; i < ERROR.length; i++) {
@@ -584,7 +633,8 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
//反馈故障
}
dto.setState("ERROR");
acsToWmsService.feedbackAgvStatus(String.valueOf(carno), "1", "error");
// logServer.deviceExecuteLog("ndc","","",String.valueOf(errbs));
// acsToWmsService.feedbackAgvStatus(String.valueOf(carno), "1", "error");
}
}
//X坐标