This commit is contained in:
USER-20220102CG\noblelift
2023-02-19 17:24:01 +08:00
parent de9d46d66b
commit 47df45110b
11 changed files with 292 additions and 40 deletions

View File

@@ -82,7 +82,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
ip = paramService.findByCode(AcsConfig.AGVURL2).getValue();
port = Integer.parseInt(paramService.findByCode(AcsConfig.AGVPORT2).getValue());
byte[] b = new byte[1028];
byte[] b = new byte[1024];
s = new Socket(ip, port);
System.out.println("2楼1区域Agv链接成功");
dos = new DataOutputStream(s.getOutputStream());
@@ -164,19 +164,15 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
else if (phase == 0x14) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
break;
} else {
inst.setInstruction_status("2");
instructionService.finish(inst);
}
inst.setInstruction_status("2");
instructionService.finish(inst);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
//请求删除任务
//(需要WCS反馈)
else if (phase == 0x30) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
break;
}
data = ndcAgvService.sendAgvTwoModeInst(0x8F, index, 0);
}
//任务删除确认
@@ -184,9 +180,12 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
else if (phase == 0xFF) {
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到指令号{}对应的指令", ikey);
break;
} else {
inst.setInstruction_status("2");
instructionService.finish(inst);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
instructionService.cancelNOSendAgv(inst.getInstruction_id());
}
instructionService.cancelNOSendAgv(inst.getInstruction_id());
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else {
//上报异常信息
@@ -212,6 +211,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
} catch (Exception e) {
System.out.println("TwoAgv链接异常");
log.info("TwoAgv链接异常");
log.error("agv连接出现异常:{}", e);

View File

@@ -2,6 +2,7 @@ package org.nl.acs.device_driver.basedriver.agv.ndcone;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -22,6 +23,7 @@ import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
import org.nl.acs.log.LokiLog;
import org.nl.acs.log.LokiLogType;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.modules.system.service.ParamService;
@@ -39,7 +41,7 @@ import java.util.Map;
@Slf4j
@Data
@RequiredArgsConstructor
public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver {
public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, DeviceStageMonitor {
ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
@@ -68,6 +70,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
int last_status = 0;
int last_error = 0;
int mode = 2;
@LokiLog(type = LokiLogType.AGV)
public synchronized void processSocket(int[] arr) throws Exception {
device_code = this.getDeviceCode();
@@ -418,4 +422,29 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
return ret;
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
String mode = "";
String action = "";
String move = "";
if (this.getMode() == 0) {
mode = "未联机";
} else if (this.getMode() == 1) {
mode = "联机";
} else if (this.getMode() == 2) {
mode = "联机";
}
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);
jo.put("move", move);
jo.put("error", this.getError());
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
}

View File

@@ -2,6 +2,7 @@ package org.nl.acs.device_driver.basedriver.agv.ndctwo;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -10,6 +11,7 @@ import org.nl.acs.auto.run.TwoNDC2SocketConnectionAutoRun;
import org.nl.acs.auto.run.TwoNDCSocketConnectionAutoRun;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.basedriver.photoelectric_inspection_site.PhotoelectricInspectionSiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_storage.StandardStorageDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
@@ -21,6 +23,7 @@ import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
import org.nl.acs.log.LokiLog;
import org.nl.acs.log.LokiLogType;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.modules.system.service.ParamService;
@@ -33,7 +36,7 @@ import org.nl.modules.wql.util.SpringContextHolder;
@Slf4j
@Data
@RequiredArgsConstructor
public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements DeviceDriver {
public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, DeviceStageMonitor {
ParamService ParamService = SpringContextHolder.getBean(ParamService.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
@@ -49,6 +52,11 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
String device_code = "";
int phase = 0;
int region = 0;
int error = 0;
String message = null;
Boolean isonline = true;
Boolean iserror = false;
int mode = 2;
@LokiLog(type = LokiLogType.AGV)
public synchronized void processSocket(int[] arr) throws Exception {
@@ -98,6 +106,8 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
//货架
StandardStorageDeviceDriver standardStorageDeviceDriver;
//普通-光电检测
PhotoelectricInspectionSiteDeviceDriver photoelectricInspectionSiteDeviceDriver;
if (phase == 0x02) {
if (ObjectUtil.isEmpty(inst)) {
@@ -155,16 +165,22 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
} else {
log.info("等待LMS系统进行确认允许取货设备号{}", device_code);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst);
} else if (device.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver){
photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) device.getDeviceDriver();
if(photoelectricInspectionSiteDeviceDriver.getMove() == 1)
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
// 取货完毕
//(Itype=1/2/3,需要WCS反馈Phase)
@@ -200,7 +216,25 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
log.info("未找到指令号{}对应的指令", ikey);
return;
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if(ObjectUtil.isNotEmpty(this.device.getExtraValue().get("wait"))
&& StrUtil.equals("true",this.device.getExtraValue().get("wait").toString())){
//
standardOrdinarySiteDeviceDriver.setOption(0);
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
}
//到达取货点(Itype=1、3需要WCS反馈)
else if (phase == 0x08) {
@@ -233,10 +267,28 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
log.info("未找到指令号{}对应的指令", ikey);
return;
}
String agv_inst_type = inst.getAgv_inst_type();
if (StrUtil.equals(agv_inst_type, "1") || StrUtil.equals(agv_inst_type, "3")) {
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if(ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
&& StrUtil.equals("true",standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())){
//
if(standardOrdinarySiteDeviceDriver.getOption() == 1 ){
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
} else {
log.info("等待LMS系统进行确认允许取货设备号{}", device_code);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
}
// 取货完毕
//(Itype=1、3,需要WCS反馈)
@@ -271,8 +323,20 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
log.info("未找到指令号{}对应的指令", ikey);
return;
}
String agv_inst_type = inst.getAgv_inst_type();
if (StrUtil.equals(agv_inst_type, "1") || StrUtil.equals(agv_inst_type, "3")) {
//生箔取满完成请求离开 不需要判断
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if(ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
&& StrUtil.equals("true",standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())){
standardOrdinarySiteDeviceDriver.setOption(0);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
@@ -325,7 +389,35 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
log.info("未找到指令号{}对应的指令", ikey);
return;
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
//请求放空 可以直接走
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
// if(ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
// && StrUtil.equals("true",standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())){
// //
// if(standardOrdinarySiteDeviceDriver.getOption() == 1 ){
// data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
// standardOrdinarySiteDeviceDriver.setOption(0);
// } else {
// log.info("等待LMS系统进行确认离开设备号{}", device_code);
// }
// } else {
// data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
// }
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst);
} else if (device.getDeviceDriver() instanceof PhotoelectricInspectionSiteDeviceDriver){
photoelectricInspectionSiteDeviceDriver = (PhotoelectricInspectionSiteDeviceDriver) device.getDeviceDriver();
if(photoelectricInspectionSiteDeviceDriver.getMove() == 0)
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
}
//放货完成
//(Itype=1/2/3,需要WCS反馈)
@@ -360,7 +452,27 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
log.info("未找到指令号{}对应的指令", ikey);
return;
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if(ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
&& StrUtil.equals("true",standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())){
//
if(standardOrdinarySiteDeviceDriver.getOption() == 2 ){
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
standardOrdinarySiteDeviceDriver.setOption(0);
} else {
log.info("等待LMS系统进行确认离开设备号{}", device_code);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
}
//到达放货点
//Itype=1、3,需要WCS反馈
@@ -395,10 +507,29 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
log.info("未找到指令号{}对应的指令", ikey);
return;
}
String agv_inst_type = inst.getAgv_inst_type();
if (StrUtil.equals(agv_inst_type, "1") || StrUtil.equals(agv_inst_type, "3")) {
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if(ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
&& StrUtil.equals("true",standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())){
//
if(standardOrdinarySiteDeviceDriver.getOption() == 2 ){
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
standardOrdinarySiteDeviceDriver.setOption(0);
} else {
log.info("等待LMS系统进行确认离开设备号{}", device_code);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
}
//放货完成
//Itype=1、3,需要WCS反馈
@@ -433,8 +564,25 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
log.info("未找到指令号{}对应的指令", ikey);
return;
}
String agv_inst_type = inst.getAgv_inst_type();
if (StrUtil.equals(agv_inst_type, "1") || StrUtil.equals(agv_inst_type, "3")) {
if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) {
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
if(ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait"))
&& StrUtil.equals("true",standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())){
//
if(standardOrdinarySiteDeviceDriver.getOption() == 2 ){
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
standardOrdinarySiteDeviceDriver.setOption(0);
} else {
log.info("等待LMS系统进行确认离开设备号{}", device_code);
}
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
standardOrdinarySiteDeviceDriver.setAgvphase(phase);
standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst);
} else {
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
}
}
@@ -497,4 +645,60 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
return ret;
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
String mode = "";
String action = "";
String phase = "";
if (this.getMode() == 0) {
mode = "未联机";
} else if (this.getMode() == 1) {
mode = "联机";
} else if (this.getMode() == 2) {
mode = "联机";
}
if(this.getPhase() ==0 ){
phase = "无任务";
} else if (this.getPhase() == 1) {
phase = "1 开始任务";
} else if (this.getPhase() == 2) {
phase = "2 分配车号";
} else if (this.getPhase() == 3) {
phase = "3 到达取货点1";
} else if (this.getPhase() == 5) {
phase = "5 取货点1取货完毕";
} else if (this.getPhase() == 8) {
phase = "8 到达取货点2";
} else if (this.getPhase() == 10) {
phase = "开始任务";
} else if (this.getPhase() == 3) {
phase = "开始任务";
} else if (this.getPhase() == 3) {
phase = "开始任务";
} else if (this.getPhase() == 3) {
phase = "开始任务";
} else if (this.getPhase() == 3) {
phase = "开始任务";
} else if (this.getPhase() == 3) {
phase = "开始任务";
}
jo.put("isOnline", this.getIsonline());
jo.put("error", this.getError());
jo.put("isError", this.getIserror());
jo.put("message", this.getMessage());
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);
jo.put("action", action);
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
}

View File

@@ -192,6 +192,15 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
String mode = "";
String action = "";
String move = "";
String option = "";
if(this.getOption() == 0){
option ="禁止进出";
} else if(this.getOption() == 1){
option ="允许进入";
} else if(this.getOption() == 2){
option ="允许离开";
}
if (this.getMode() == 0) {
mode = "未联机";
} else if (this.getMode() == 1) {
@@ -219,6 +228,7 @@ public class StandardOrdinarySiteDeviceDriver extends AbstractDeviceDriver imple
jo.put("isOnline", true);
jo.put("error", this.getError());
jo.put("isError", this.getIserror());
jo.put("option", option);
return jo;
}

View File

@@ -211,7 +211,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
// Thread.currentThread().interrupt();不会真正停止线程
}
++this.error_num;
if (this.error_num > 3 && !StrUtil.equals(this.message, error_message)) {

View File

@@ -226,11 +226,12 @@ public class OpcUtl {
return server;
} catch (Exception e) {
errNum++;
// e.printStackTrace();
System.out.println("server error:"+e.getMessage());
throw new WDKException(e.getMessage());
}finally{
System.out.println("successNum:"+successNum);
System.out.println("errNum:"+errNum);
System.out.println(11);
}
}

View File

@@ -862,7 +862,7 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
feefbackdto.setVehicle_code(entity.getVehicle_code());
feefbackdto.setError_code(String.valueOf(body.getStatus()));
feefbackdto.setStart_device_code(entity.getStart_device_code());
feefbackdto.setStart_point_code(entity.getNext_point_code());
feefbackdto.setStart_point_code(entity.getStart_point_code());
feefbackdto.setNext_device_code(entity.getNext_device_code());
feefbackdto.setNext_point_code(entity.getNext_point_code());
if (status == 200) {