|
@ -1,6 +1,7 @@ |
|
|
package org.nl.acs.device_driver.basedriver.agv.ndcone; |
|
|
package org.nl.acs.device_driver.basedriver.agv.ndcone; |
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
@ -23,6 +24,7 @@ import org.nl.acs.instruction.service.impl.InstructionServiceImpl; |
|
|
import org.nl.acs.log.LokiLog; |
|
|
import org.nl.acs.log.LokiLog; |
|
|
import org.nl.acs.log.LokiLogType; |
|
|
import org.nl.acs.log.LokiLogType; |
|
|
import org.nl.acs.log.service.DeviceExecuteLogService; |
|
|
import org.nl.acs.log.service.DeviceExecuteLogService; |
|
|
|
|
|
import org.nl.acs.monitor.DeviceStageMonitor; |
|
|
import org.nl.acs.opc.Device; |
|
|
import org.nl.acs.opc.Device; |
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
import org.nl.acs.task.service.TaskService; |
|
|
import org.nl.acs.task.service.TaskService; |
|
@ -43,7 +45,7 @@ import java.util.Map; |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@Data |
|
|
@Data |
|
|
@RequiredArgsConstructor |
|
|
@RequiredArgsConstructor |
|
|
public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver { |
|
|
public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, DeviceStageMonitor { |
|
|
|
|
|
|
|
|
ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); |
|
|
ParamService paramService = SpringContextHolder.getBean(ParamServiceImpl.class); |
|
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); |
|
|
InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class); |
|
@ -72,6 +74,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
int last_status = 0; |
|
|
int last_status = 0; |
|
|
int last_error = 0; |
|
|
int last_error = 0; |
|
|
|
|
|
|
|
|
|
|
|
private Instruction instruction; |
|
|
|
|
|
|
|
|
@LokiLog(type = LokiLogType.ACS_TO_LMS) |
|
|
@LokiLog(type = LokiLogType.ACS_TO_LMS) |
|
|
public synchronized void processSocket(int[] arr) throws Exception { |
|
|
public synchronized void processSocket(int[] arr) throws Exception { |
|
|
device_code = this.getDeviceCode(); |
|
|
device_code = this.getDeviceCode(); |
|
@ -94,10 +98,14 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); |
|
|
agv_device = deviceAppService.findDeviceByCode(String.valueOf(carno)); |
|
|
} |
|
|
} |
|
|
if (ikey != 0) { |
|
|
if (ikey != 0) { |
|
|
|
|
|
if (phase != 0x67 && phase != 0x71 && phase != 0x72 && phase != 0x73 && phase != 0x74 && phase != 0x75) { |
|
|
inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); |
|
|
inst = instructionService.findByCodeFromCache(String.valueOf(ikey)); |
|
|
if (ObjectUtil.isEmpty(inst)){ |
|
|
this.instruction = inst; |
|
|
inst = instructionService.findByCode(String.valueOf(ikey)); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
// inst = instructionService.findByCodeFromCache(String.valueOf(ikey));
|
|
|
|
|
|
// if (ObjectUtil.isEmpty(inst)){
|
|
|
|
|
|
// inst = instructionService.findByCode(String.valueOf(ikey));
|
|
|
|
|
|
// }
|
|
|
} |
|
|
} |
|
|
if (!ObjectUtil.isEmpty(link_inst)) { |
|
|
if (!ObjectUtil.isEmpty(link_inst)) { |
|
|
link_flag = true; |
|
|
link_flag = true; |
|
@ -108,13 +116,13 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
String emptyNum = null; |
|
|
String emptyNum = null; |
|
|
String device_code = null; |
|
|
String device_code = null; |
|
|
|
|
|
|
|
|
if (phase == 0x67) { |
|
|
// if (phase == 0x67) {
|
|
|
//故障信息
|
|
|
// //故障信息
|
|
|
if (arr[18] * 256 + arr[19] == 0) { |
|
|
// if (arr[18] * 256 + arr[19] == 0) {
|
|
|
|
|
|
//
|
|
|
} |
|
|
// }
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
|
|
|
} |
|
|
// }
|
|
|
|
|
|
|
|
|
//普通站点
|
|
|
//普通站点
|
|
|
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; |
|
|
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver; |
|
@ -142,9 +150,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
request.put("METHOD", "1"); |
|
|
request.put("METHOD", "1"); |
|
|
request.put("AGVCODE", this.device_code); |
|
|
request.put("AGVCODE", this.device_code); |
|
|
request.put("REQTIME", DateUtil.now()); |
|
|
request.put("REQTIME", DateUtil.now()); |
|
|
log.info("atrAgvCallback 请求参数:"+request.toJSONString()); |
|
|
log.info("atrAgvCallback 请求参数:" + request.toJSONString()); |
|
|
String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); |
|
|
String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); |
|
|
log.info("atrAgvCallback 返回参数:"+str); |
|
|
log.info("atrAgvCallback 返回参数:" + str); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
//到达取货点
|
|
|
//到达取货点
|
|
@ -218,9 +226,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
request.put("METHOD", "2"); |
|
|
request.put("METHOD", "2"); |
|
|
request.put("AGVCODE", this.device_code); |
|
|
request.put("AGVCODE", this.device_code); |
|
|
request.put("REQTIME", DateUtil.now()); |
|
|
request.put("REQTIME", DateUtil.now()); |
|
|
log.info("atrAgvCallback 请求参数:"+request.toJSONString()); |
|
|
log.info("atrAgvCallback 请求参数:" + request.toJSONString()); |
|
|
String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); |
|
|
String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); |
|
|
log.info("atrAgvCallback 返回参数:"+str); |
|
|
log.info("atrAgvCallback 返回参数:" + str); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -307,9 +315,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
request.put("METHOD", "3"); |
|
|
request.put("METHOD", "3"); |
|
|
request.put("AGVCODE", this.device_code); |
|
|
request.put("AGVCODE", this.device_code); |
|
|
request.put("REQTIME", DateUtil.now()); |
|
|
request.put("REQTIME", DateUtil.now()); |
|
|
log.info("atrAgvCallback 请求参数:"+request.toJSONString()); |
|
|
log.info("atrAgvCallback 请求参数:" + request.toJSONString()); |
|
|
String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); |
|
|
String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); |
|
|
log.info("atrAgvCallback 返回参数:"+str); |
|
|
log.info("atrAgvCallback 返回参数:" + str); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -371,9 +379,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
request.put("METHOD", "4"); |
|
|
request.put("METHOD", "4"); |
|
|
request.put("AGVCODE", this.device_code); |
|
|
request.put("AGVCODE", this.device_code); |
|
|
request.put("REQTIME", DateUtil.now()); |
|
|
request.put("REQTIME", DateUtil.now()); |
|
|
log.info("atrAgvCallback 请求参数:"+request.toJSONString()); |
|
|
log.info("atrAgvCallback 请求参数:" + request.toJSONString()); |
|
|
String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); |
|
|
String str = new RTMSAGVSERVICE().getBasicHttpBindingIRTMSAGVSERVICE().atrAgvCallback(request.toJSONString()); |
|
|
log.info("atrAgvCallback 返回参数:"+str); |
|
|
log.info("atrAgvCallback 返回参数:" + str); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -444,6 +452,24 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
} else if (phase == 0x51) {//离开交通灯区域
|
|
|
} else if (phase == 0x51) {//离开交通灯区域
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); |
|
|
|
|
|
} else if (phase == 0x67) {//agv异常
|
|
|
|
|
|
error = ikey; |
|
|
|
|
|
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0); |
|
|
|
|
|
} else if (phase == 0x71) { |
|
|
|
|
|
//x坐标
|
|
|
|
|
|
x = ikey; |
|
|
|
|
|
} else if (phase == 0x72) { |
|
|
|
|
|
//y坐标
|
|
|
|
|
|
y = ikey; |
|
|
|
|
|
} else if (phase == 0x73) { |
|
|
|
|
|
//车辆角度
|
|
|
|
|
|
angle = ikey; |
|
|
|
|
|
} else if (phase == 0x74) { |
|
|
|
|
|
//agv电量
|
|
|
|
|
|
electric_qty = ikey; |
|
|
|
|
|
} else if (phase == 0x75) { |
|
|
|
|
|
//三色灯状态
|
|
|
|
|
|
status = ikey; |
|
|
} |
|
|
} |
|
|
if (!ObjectUtil.isEmpty(data)) { |
|
|
if (!ObjectUtil.isEmpty(data)) { |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); |
|
|
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data); |
|
@ -451,4 +477,32 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public JSONObject getDeviceStatusName() throws Exception { |
|
|
|
|
|
JSONObject jo = new JSONObject(); |
|
|
|
|
|
jo.put("REQCODE", IdUtil.getSnowflake().nextId()); |
|
|
|
|
|
|
|
|
|
|
|
jo.put("REQTIME", DateUtil.now()); |
|
|
|
|
|
//agv编码
|
|
|
|
|
|
jo.put("AGVCODE", this.getDevice().getDevice_code()); |
|
|
|
|
|
//角度
|
|
|
|
|
|
jo.put("AGVDIR", this.getAngle()); |
|
|
|
|
|
//IP
|
|
|
|
|
|
jo.put("AGVIP", ObjectUtil.isEmpty(this.getDevice().getExtraValue()) ? "" : this.getDevice().getExtraValue().get("ip_address")); |
|
|
|
|
|
//电量
|
|
|
|
|
|
jo.put("AGVBATTERY", this.getElectric_qty()); |
|
|
|
|
|
//x坐标
|
|
|
|
|
|
jo.put("POSX", this.getX()); |
|
|
|
|
|
//y坐标
|
|
|
|
|
|
jo.put("POSY", this.getY()); |
|
|
|
|
|
String status_name = this.status == 1 ? "关机" : this.status == 2 ? "工作中" : this.status == 3 ? "交通管制" : this.status == 4 ? "任务等待" : this.status == 5 ? "充电中" : this.status == 6 ? "故障中" : this.status == 7 ? "电量低" : "正常"; |
|
|
|
|
|
//agv状态
|
|
|
|
|
|
jo.put("STATUS", status_name); |
|
|
|
|
|
return jo; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void setDeviceStatus(JSONObject data) { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|