add:海柔

Signed-off-by: jiaoliming <dawnjiao@foxmail.com>
This commit is contained in:
jiaoliming
2023-09-01 10:30:34 +08:00
parent 10adfb89f5
commit 1a2dcfc24c
8 changed files with 1519 additions and 43 deletions

View File

@@ -0,0 +1,49 @@
package org.nl.acs.device_driver.basedriver.agv.ndcfour;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.DeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
/**
* NDC双工位AGV
*/
@Service
public class AgvNdcFourDefination implements DeviceDriverDefination {
@Override
public String getDriverCode() {
return "agv_ndc_four";
}
@Override
public String getDriverName() {
return "NDC海柔AGV";
}
@Override
public String getDriverDescription() {
return "NDC海柔AGV";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new AgvNdcFourDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return AgvNdcFourDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.agv);
return types;
}
}

View File

@@ -0,0 +1,992 @@
package org.nl.acs.device_driver.basedriver.agv.ndcfour;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.agv.server.impl.NDCAgvServiceImpl;
import org.nl.acs.auto.run.NDCSocketConnectionAutoRun;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_auto_cache_line.HailiangAutoCacheLineDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_machine_storage_station.HailiangCleaningMachineStorageStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_old_special_empty_station.HailiangOldSpecialEmptyStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_old_special_full_station.HailiangOldSpecialFullStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_old_special_pour_station.HailiangOldSpecialPourStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_empty_station.HailiangSpecialEmptyStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_full_station.HailiangSpecialFullStationDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_pour_station.HailiangSpecialPourStationDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.log.service.impl.DeviceExecuteLogServiceImpl;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.acs.task.service.impl.TaskServiceImpl;
import org.nl.modules.wql.util.SpringContextHolder;
import java.util.Collections;
import java.util.List;
/**
* 双工位诺宝AGV
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class AgvNdcFourDeviceDriver extends AbstractDeviceDriver implements DeviceDriver {
private InstructionService instructionService = SpringContextHolder.getBean(InstructionServiceImpl.class);
private NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvServiceImpl.class);
private DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
private DeviceService deviceService = SpringContextHolder.getBean(DeviceService.class);
private DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogServiceImpl.class);
private TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
private int agvaddr = 0;
private int agvaddr_copy = 0;
private int weight = 0;
private String device_code = "";
private int phase = 0;
//x坐标
private int x = 0;
//y坐标
private int y = 0;
//角度
private int angle = 0;
//电量
private int electric_qty = 0;
//三色灯状态
private int status = 0;
//车辆故障
private int error = 0;
private int last_x = 0;
private int last_y = 0;
private int last_angle = 0;
private int last_electric_qty = 0;
private int last_status = 0;
private int last_error = 0;
public synchronized void processSocket(int[] arr) throws Exception {
device_code = this.getDeviceCode();
log.info("AGV驱动接收AGV上报信息,设备号:{},上报信息:{}", device_code, arr);
byte[] data = null;
phase = arr[16] * 256 + arr[17];
// agv任务号
int index = arr[12] * 256 + arr[13];
//任务号
int ikey = arr[26] * 256 + arr[27];
//站点号
agvaddr = arr[18] * 256 + arr[19];
//车号
int carno = arr[20];
List<Instruction> insts = null;
if (ikey != 0) {
insts = instructionService.findByLinkNum(String.valueOf(ikey));
}
log.info("AGV驱动,设备号:{},接收agv上报信息" + "phase--" + phase + " index--" + index + " ikey--" + ikey + " agvaddr--" + agvaddr + " Car--" + carno, device_code);
Device device = null;
String device_code = null;
//海亮专机设备空框位
HailiangSpecialEmptyStationDeviceDriver hailiangSpecialEmptyStationDeviceDriver;
//海亮专机设备满框位
HailiangSpecialFullStationDeviceDriver hailiangSpecialFullStationDeviceDriver;
//海亮smart200专机满料位
HailiangOldSpecialFullStationDeviceDriver hailiangOldSpecialFullStationDeviceDriver;
//海亮smarrt200专机空料位
HailiangOldSpecialEmptyStationDeviceDriver hailiangOldSpecialEmptyStationDeviceDriver;
//海亮smart200专机倒料位
HailiangOldSpecialPourStationDeviceDriver hailiangOldSpecialPourStationDeviceDriver;
//海亮专机设备倒料位
HailiangSpecialPourStationDeviceDriver hailiangSpecialPourStationDeviceDriver;
//自动缓存线
HailiangAutoCacheLineDeviceDriver hailiangAutoCacheLineDeviceDriver;
//清洗倒料
HailiangCleaningMachineStorageStationDeviceDriver hailiangCleaningMachineStorageStationDeviceDriver;
if (phase == 0x02) {
//分配 车id
//(不需要wms反馈)
for (Instruction inst : insts) {
inst.setCarno(String.valueOf(carno));
instructionService.update(inst);
log.info("AGV上报小车id,修改指令中车号为:{},指令号:{}", String.valueOf(carno), inst.getInstruction_code());
}
} else if (phase == 0x03) {
//到达取货点1 || 自动缓存线入库---到达取满框1/点对点任务取货就绪
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//取满箱任务起点 一般是专机满料点和缓存线
if (StrUtil.equals(inst.getStart_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangSpecialFullStationDeviceDriver) {
log.info("开始设置phase值,到达取货点1,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangSpecialFullStationDeviceDriver = (HailiangSpecialFullStationDeviceDriver) device.getDeviceDriver();
hailiangSpecialFullStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangOldSpecialFullStationDeviceDriver) {
log.info("开始设置phase值,到达取货点1,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangOldSpecialFullStationDeviceDriver = (HailiangOldSpecialFullStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialFullStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,到达出缓存线取满框点1,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x05) {
//取货完毕 || 自动缓存线入库---取满框完毕1/点对点取货完毕
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//取满箱任务起点 一般是专机满料点和缓存线
if (StrUtil.equals(inst.getStart_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangSpecialFullStationDeviceDriver) {
log.info("开始设置phase值,取货点1取货完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangSpecialFullStationDeviceDriver = (HailiangSpecialFullStationDeviceDriver) device.getDeviceDriver();
hailiangSpecialFullStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangOldSpecialFullStationDeviceDriver) {
log.info("开始设置phase值,取货点1取货完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangOldSpecialFullStationDeviceDriver = (HailiangOldSpecialFullStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialFullStationDeviceDriver.set(phase, index, inst);
}
//入缓存线任务的起点有专机满料位 出缓存的起点是缓存线
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线取满框点1取货完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x07) {
//到达取货点2 || 自动缓存线入库---到达取满框2
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//双任务-取满箱任务起点2 一般是专机满料点和缓存线
if (StrUtil.equals(inst.getStart_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangSpecialFullStationDeviceDriver) {
log.info("开始设置phase值,到达取货点2,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangSpecialFullStationDeviceDriver = (HailiangSpecialFullStationDeviceDriver) device.getDeviceDriver();
hailiangSpecialFullStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangOldSpecialFullStationDeviceDriver) {
log.info("开始设置phase值,到达取货点2,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangOldSpecialFullStationDeviceDriver = (HailiangOldSpecialFullStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialFullStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,到达出缓存线取满框点2,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x09) {
//取货完毕2 || 自动缓存线入库---取满框完毕2
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//双任务-取满箱任务起点2 一般是专机满料点和缓存线
if (StrUtil.equals(inst.getStart_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangSpecialFullStationDeviceDriver) {
log.info("开始设置phase值,取货点2取货完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangSpecialFullStationDeviceDriver = (HailiangSpecialFullStationDeviceDriver) device.getDeviceDriver();
hailiangSpecialFullStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangOldSpecialFullStationDeviceDriver) {
log.info("开始设置phase值,取货点2取货完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangOldSpecialFullStationDeviceDriver = (HailiangOldSpecialFullStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialFullStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,出缓存线取满框点2取货完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x0A) {
//自动缓存线入库--到达送满框1
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//只有满料位入到缓存线有到达送满框
if (StrUtil.equals(inst.getPut_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线入库到达送满框点1,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
break;
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x0B) {
//到达倒料点1 || 自动缓存线出库
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//只有满料位到倒料位、清洗储料仓,及缓存线到倒料位、清洗储料仓有倒料点 倒料点都是倒料位、清洗储料仓
if (StrUtil.equals(inst.getPut_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangSpecialPourStationDeviceDriver) {
log.info("开始设置phase值,到达倒料点1,设备号:{}", device_code);
hailiangSpecialPourStationDeviceDriver = (HailiangSpecialPourStationDeviceDriver) device.getDeviceDriver();
hailiangSpecialPourStationDeviceDriver.set(phase, index, inst);
break;
}
if (device.getDeviceDriver() instanceof HailiangOldSpecialPourStationDeviceDriver) {
log.info("开始设置phase值,到达倒料点1,设备号:{}", device_code);
hailiangOldSpecialPourStationDeviceDriver = (HailiangOldSpecialPourStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialPourStationDeviceDriver.set(phase, index, inst);
break;
}
if (device.getDeviceDriver() instanceof HailiangCleaningMachineStorageStationDeviceDriver) {
log.info("开始设置phase值,到达倒料点1,设备号:{}", device_code);
hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) device.getDeviceDriver();
hailiangCleaningMachineStorageStationDeviceDriver.set(phase, index, inst);
break;
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x0C) {
//自动缓存线入库---送满框完毕1
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//送满框1 只有满料位到缓存线才有送满框1
if (StrUtil.equals(inst.getPut_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线入库送满框点1完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
break;
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x0D) {
//倒料点1倒料完毕 || 自动缓存线出库
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//只有满料位、缓存线到倒料位、清洗储料仓才有倒料完毕1
if (StrUtil.equals(inst.getPut_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangSpecialPourStationDeviceDriver) {
log.info("开始设置phase值,倒料点1倒料完毕,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangSpecialPourStationDeviceDriver = (HailiangSpecialPourStationDeviceDriver) device.getDeviceDriver();
hailiangSpecialPourStationDeviceDriver.set(phase, index, inst);
break;
}
if (device.getDeviceDriver() instanceof HailiangOldSpecialPourStationDeviceDriver) {
log.info("开始设置phase值,倒料点1倒料完毕,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangOldSpecialPourStationDeviceDriver = (HailiangOldSpecialPourStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialPourStationDeviceDriver.set(phase, index, inst);
break;
}
if (device.getDeviceDriver() instanceof HailiangCleaningMachineStorageStationDeviceDriver) {
log.info("开始设置phase值,倒料点1倒料完毕,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) device.getDeviceDriver();
hailiangCleaningMachineStorageStationDeviceDriver.set(phase, index, inst);
break;
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x0E) {
//自动缓存线入库---到达取空框1
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//只有满料位到缓存线放满完成后才有到达取空框1 取空框是缓存线才有
if (StrUtil.equals(inst.getPut_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线入库,到达取空框1,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
break;
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x0F) {
//到达倒料点2 || 自动缓存线出库
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
Collections.reverse(insts);
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//只有满料位到倒料位、清洗储料仓,及缓存线到倒料位、清洗储料仓有倒料点 倒料点都是倒料位、清洗储料仓
if (StrUtil.equals(inst.getPut_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangSpecialPourStationDeviceDriver) {
log.info("开始设置phase值,到达倒料点2,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangSpecialPourStationDeviceDriver = (HailiangSpecialPourStationDeviceDriver) device.getDeviceDriver();
hailiangSpecialPourStationDeviceDriver.set(phase, index, inst);
break;
}
if (device.getDeviceDriver() instanceof HailiangOldSpecialPourStationDeviceDriver) {
log.info("开始设置phase值,到达倒料点2,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangOldSpecialPourStationDeviceDriver = (HailiangOldSpecialPourStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialPourStationDeviceDriver.set(phase, index, inst);
break;
}
if (device.getDeviceDriver() instanceof HailiangCleaningMachineStorageStationDeviceDriver) {
log.info("开始设置phase值,到达倒料点2,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) device.getDeviceDriver();
hailiangCleaningMachineStorageStationDeviceDriver.set(phase, index, inst);
break;
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x10) {
//自动缓存线入库---取空框完毕1
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//只有满料位到缓存线入库才有取空框1完毕
if (StrUtil.equals(inst.getPut_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线入库,取空框1完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
break;
}
}
}
} else if (phase == 0x21) {
//自动缓存线入库--到达送满框2
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
Collections.reverse(insts);
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//只有满料位到缓存线才有到达送满框2
if (StrUtil.equals(inst.getPut_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线入库,到达送满框点2,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
break;
}
}
}
} else if (phase == 0x23) {
//自动缓存线入库--送满框完毕2
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
Collections.reverse(insts);
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//只有满料位到缓存线才有到送满框完毕
if (StrUtil.equals(inst.getPut_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线入库,送满框点2完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
break;
}
}
}
} else if (phase == 0x25) {
//自动缓存线入库--到达取空框2
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
Collections.reverse(insts);
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
Collections.reverse(insts);
//只有满料位到缓存线才有到达取空框2
if (StrUtil.equals(inst.getPut_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线入库,到达取空框点2,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
break;
}
}
}
} else if (phase == 0x27) {
//自动缓存线入库--取空框完毕2
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
Collections.reverse(insts);
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//只有满料位到缓存线才有到达取空框完毕2
if (StrUtil.equals(inst.getPut_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线入库,取空框点2取货完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
break;
}
}
}
} else if (phase == 0x11) {
//到料完毕2 || 自动缓存线出库
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
Collections.reverse(insts);
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//只有满料位到倒料位、清洗储料仓,及缓存线到倒料位、清洗储料仓有倒料点 倒料点都是倒料位、清洗储料仓
if (StrUtil.equals(inst.getPut_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangSpecialPourStationDeviceDriver) {
log.info("开始设置phase值,倒料点2倒料完毕,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangSpecialPourStationDeviceDriver = (HailiangSpecialPourStationDeviceDriver) device.getDeviceDriver();
hailiangSpecialPourStationDeviceDriver.set(phase, index, inst);
break;
}
if (device.getDeviceDriver() instanceof HailiangOldSpecialPourStationDeviceDriver) {
log.info("开始设置phase值,倒料点2倒料完毕,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangOldSpecialPourStationDeviceDriver = (HailiangOldSpecialPourStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialPourStationDeviceDriver.set(phase, index, inst);
break;
}
if (device.getDeviceDriver() instanceof HailiangCleaningMachineStorageStationDeviceDriver) {
log.info("开始设置phase值,倒料点2倒料完毕,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) device.getDeviceDriver();
hailiangCleaningMachineStorageStationDeviceDriver.set(phase, index, inst);
break;
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x13) {
//到达送箱点1/自动缓存线入库--到达送空框1/点对点送框就绪
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//所有任务都有到达送空框1
if (StrUtil.equals(inst.getNext_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangSpecialEmptyStationDeviceDriver) {
log.info("开始设置phase值,到达还空框1,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangSpecialEmptyStationDeviceDriver = (HailiangSpecialEmptyStationDeviceDriver) device.getDeviceDriver();
hailiangSpecialEmptyStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangOldSpecialEmptyStationDeviceDriver) {
log.info("开始设置phase值,到达还空框1,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangOldSpecialEmptyStationDeviceDriver = (HailiangOldSpecialEmptyStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialEmptyStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线出库,还空框1完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x15) {
//送箱完毕/自动缓存线入库--送空框完毕1/点对点送框完毕
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//所有任务都有到送空框1完毕
if (StrUtil.equals(inst.getNext_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangSpecialEmptyStationDeviceDriver) {
log.info("开始设置phase值,还空框1完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangSpecialEmptyStationDeviceDriver = (HailiangSpecialEmptyStationDeviceDriver) device.getDeviceDriver();
hailiangSpecialEmptyStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangOldSpecialEmptyStationDeviceDriver) {
log.info("开始设置phase值,还空框1完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangOldSpecialEmptyStationDeviceDriver = (HailiangOldSpecialEmptyStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialEmptyStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线出库还空框1完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x17) {
//到达送箱点2/自动缓存线入库 --到达送空框2
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
Collections.reverse(insts);
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//所有双任务都有到达送空框2
if (StrUtil.equals(inst.getNext_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangSpecialEmptyStationDeviceDriver) {
log.info("开始设置phase值,到达还空框2,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangSpecialEmptyStationDeviceDriver = (HailiangSpecialEmptyStationDeviceDriver) device.getDeviceDriver();
hailiangSpecialEmptyStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangOldSpecialEmptyStationDeviceDriver) {
log.info("开始设置phase值,到达还空框2,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangOldSpecialEmptyStationDeviceDriver = (HailiangOldSpecialEmptyStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialEmptyStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线出库到达还空框2,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x19) {
//送箱完毕/自动缓存线入库--送空框完毕2
if (agvaddr == 0) {
agvaddr = agvaddr_copy;
}
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
device = deviceAppService.findDeviceByCode(device_code);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
Collections.reverse(insts);
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
//所有双任务都有送空框完毕2
if (StrUtil.equals(inst.getNext_device_code(), device_code)) {
if (device.getDeviceDriver() instanceof HailiangSpecialEmptyStationDeviceDriver) {
log.info("开始设置phase值,还空框2完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangSpecialEmptyStationDeviceDriver = (HailiangSpecialEmptyStationDeviceDriver) device.getDeviceDriver();
hailiangSpecialEmptyStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangOldSpecialEmptyStationDeviceDriver) {
log.info("开始设置phase值,还空框2完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangOldSpecialEmptyStationDeviceDriver = (HailiangOldSpecialEmptyStationDeviceDriver) device.getDeviceDriver();
hailiangOldSpecialEmptyStationDeviceDriver.set(phase, index, inst);
}
if (device.getDeviceDriver() instanceof HailiangAutoCacheLineDeviceDriver) {
log.info("开始设置phase值,缓存线出库还空框2完成,设备号:{},指令号:{}", device_code, inst.getInstruction_code());
hailiangAutoCacheLineDeviceDriver = (HailiangAutoCacheLineDeviceDriver) device.getDeviceDriver();
hailiangAutoCacheLineDeviceDriver.set(phase, index, inst);
}
}
}
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x64) {//param,agv货位id待定
//1、根据货位id找到对应三工位设备赋给agv属性地址对应的满料位设备
//到达位置点
agvaddr = arr[18] * 256 + arr[19];
agvaddr_copy = agvaddr;
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x65) {//param,重量待定
// if (agvaddr == 0) {
// agvaddr = agvaddr_copy;
// }
if (agvaddr < 1) {
log.info("phase:" + phase + "--agv地址参数有误agvaddr=" + agvaddr);
return;
}
agvaddr = agvaddr_copy;
device_code = deviceService.queryDeviceCodeByAddress(agvaddr);
if (ObjectUtil.isEmpty(device_code)) {
log.info(agvaddr + "对应设备号为空!");
return;
}
//1、得到重量信息
int weight = (arr[18] * 256 + arr[19]) * 10;
if (weight < 0) {
log.info("AGV上报重量小于0不反馈AGV信息,指令号:{}", ikey);
return;
}
for (Instruction inst : insts) {
//校验agv上报站点编号与指令起始点相同
if (ObjectUtil.isEmpty(inst)) {
log.info("未找到关联编号{}对应的指令", ikey);
break;
}
// 4010 待处理
if (StrUtil.equals(inst.getStart_device_code(), device_code)) {
String now = DateUtil.now();
inst.setWeight(String.valueOf(weight));
inst.setUpdate_time(now);
instructionService.update(inst);
TaskDto taskDto = taskService.findByCodeFromCache(inst.getTask_code());
if (taskDto != null) {
taskDto.setWeight(String.valueOf(weight));
taskDto.setUpdate_time(now);
taskService.update(taskDto);
}
}
}
data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0);
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
} else if (phase == 0x71) {
x = ikey;
if (x != last_x) {
logServer.deviceItemValue(this.device_code, "x", String.valueOf(x));
}
} else if (phase == 0x72) {
y = ikey;
if (y != last_y) {
logServer.deviceItemValue(this.device_code, "y", String.valueOf(y));
}
} else if (phase == 0x73) {
angle = last_angle;
if (angle != last_angle) {
logServer.deviceItemValue(this.device_code, "angle", String.valueOf(angle));
}
} else if (phase == 0x74) {
electric_qty = ikey;
if (electric_qty != last_electric_qty) {
logServer.deviceItemValue(this.device_code, "electric_qty", String.valueOf(electric_qty));
}
} else if (phase == 0x75) {
status = ikey;
if (status != last_status) {
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status));
}
} else if (phase == 0x76) {
error = ikey;
if (error != last_error) {
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
}
}
if (!ObjectUtil.isEmpty(data)) {
NDCSocketConnectionAutoRun.write(data);
}
}
}

View File

@@ -0,0 +1,66 @@
package org.nl.acs.device_driver.basedriver.agv.utils;
import org.springframework.stereotype.Service;
@Service
public class FourAgvPhase implements IAgv {
@Override
public String getPhaseName(Integer phase) {
if (phase == 0x01) {
return "开始任务/上报订单号";
} else if (phase == 0x02){
return "分配车id";
} else if (phase == 0x03){
return "到达取货点1";
} else if (phase == 0x05){
return "取货点1取货完毕";
} else if (phase == 0x07){
return "到达取货点2";
} else if (phase == 0x09){
return "取货点2取货完毕";
} else if (phase == 0x0B){
return "到达倒料点1";
} else if (phase == 0x0D){
return "倒料点1倒料完毕";
} else if (phase == 0x0F){
return "到达倒料点2";
} else if (phase == 0x11){
return "倒料点2倒料完毕";
} else if (phase == 0x13){
return "到达放货点1";
} else if (phase == 0x15){
return "放货点1放货完毕";
} else if (phase == 0x17){
return "到达放货点2";
} else if (phase == 0x19){
return "放货点2放货完毕";
} else if (phase == 0x1B){
return "到达取货点3";
} else if (phase == 0x1D){
return "取货点3取货完毕";
} else if (phase == 0x1F){
return "到达取货点4";
} else if (phase == 0x21){
return "取货点4取货完毕";
} else if (phase == 0x23){
return "到达放货点3";
} else if (phase == 0x25){
return "放货点3放货完毕";
}else if (phase == 0x27){
return "到达放货点4";
} else if (phase == 0x29){
return "放货点4放货完毕";
} else if (phase == 0x30){
return "请求删除任务";
} else if (phase == 0xFF){
return "任务删除确认";
} else if (phase == 0x64){
return "到达位置点";
} else if (phase == 0x65){
return "称重就绪";
} else if (phase == 0x2A){
return "任务完毕";
}
return null;
}
}

View File

@@ -1,4 +1,4 @@
package org.nl.acs.device_driver.basedriver.hailiang_hr_ssx;
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_hr_ssx;
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
import org.nl.acs.device_driver.DeviceDriver;

View File

@@ -1,4 +1,4 @@
package org.nl.acs.device_driver.basedriver.hailiang_hr_ssx;
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_hr_ssx;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
@@ -28,6 +28,8 @@ import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.Device;
import org.nl.acs.order.service.dto.EalingOrderDto;
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,7 +38,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
@Slf4j
@Data
@@ -50,6 +51,8 @@ public class HailiangHrSsxDeviceDriver extends AbstractOpcDeviceDriver implement
LiKuToAcsService liKuToAcsService = SpringContextHolder.getBean(LiKuToAcsServiceImpl.class);
@Autowired
AcsToLiKuService acsToLiKuService = SpringContextHolder.getBean(AcsToLiKuServiceImpl.class);
@Autowired
TaskService taskServer = SpringContextHolder.getBean("taskServiceImpl");
int heartbeat = 0;
int mode = 0;
@@ -70,8 +73,8 @@ public class HailiangHrSsxDeviceDriver extends AbstractOpcDeviceDriver implement
Boolean isonline = true;
String message = null;
Boolean iserror = false;
private Date instruction_require_time = new Date();
private int instruction_require_time_out = 3000;
private Date instruction_require_time;
private int instruction_require_time_out = 30000;
boolean requireSucess = false;
private int instruction_finished_time_out;
@@ -97,10 +100,35 @@ public class HailiangHrSsxDeviceDriver extends AbstractOpcDeviceDriver implement
if (mode != last_mode) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode + "复位请求标记");
}
if (move != last_move){
if (move != last_move && barcode != last_barcode){
message = null;
requireSucess =false;
if (move == 1 && barcode.length() > 0){
TaskDto vehicle_dto = taskServer.findByContainer(barcode);
if (vehicle_dto == null) {
instruction_require_time = new Date();
}
}
// if(move ==0 && barcode.length()>0 && !requireSucess ){
// ContainerArrivedRequest containerArrivedRequest = new ContainerArrivedRequest();
// NodeStates nodeStates = new NodeStates();
// containerArrivedRequest.setSlotCode(device_code);
// containerArrivedRequest.setContainerCode(barcode);
// Date date = new Date();
// SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
// nodeStates.setLastHasContainerTime(Long.parseLong(dateFormat.format(date)));
// nodeStates.setLastReadTime(Long.parseLong(dateFormat.format(date)));
// nodeStates.setLastReportTime(Long.parseLong(dateFormat.format(date)));
// Resp<JSONObject> containerArrivedResp=acsToLiKuService.containerArrived(containerArrivedRequest);
// JSONObject response1=JSONObject.parseObject(String.valueOf(containerArrivedResp));
// int code=response1.getInteger("code");
// String msg=response1.getString("msg");
// if(code == 0) {
// log.info("请求成功 请求结果{}", code,msg);
// requireSucess = true;
// }
// }
}
if (error != last_error) {
if (error != 0) {
@@ -127,25 +155,7 @@ public class HailiangHrSsxDeviceDriver extends AbstractOpcDeviceDriver implement
Instruction instruction = null;
List toInstructions;
if(move ==1 && barcode.length()>0 && !requireSucess ){
ContainerArrivedRequest containerArrivedRequest=new ContainerArrivedRequest();
NodeStates nodeStates=new NodeStates();
containerArrivedRequest.setSlotCode(device_code);
containerArrivedRequest.setContainerCode(barcode);
Date date = new Date();
SimpleDateFormat dateFormat= new SimpleDateFormat("yyyy-MM-dd :hh:mm:ss");
nodeStates.setLastHasContainerTime(Long.parseLong(dateFormat.format(date)));
nodeStates.setLastReadTime(Long.parseLong(dateFormat.format(date)));
nodeStates.setLastReportTime(Long.parseLong(dateFormat.format(date)));
Resp<JSONObject> containerArrivedResp=acsToLiKuService.containerArrived(containerArrivedRequest);
JSONObject response1=JSONObject.parseObject(String.valueOf(containerArrivedResp));
int code=response1.getInteger("code");
String msg=response1.getString("msg");
if(code == 0) {
log.info("请求成功 请求结果{}", code,msg);
requireSucess = true;
}
}
}
last_mode = mode;

View File

@@ -1,4 +1,4 @@
package org.nl.acs.device_driver.basedriver.hailiang_hr_ssx;
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_hr_ssx;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@@ -11,16 +11,19 @@ import java.util.List;
@Data
public class ItemProtocol {
public static String item_heartbeat = "heartbeat";
public static String item_mode = "mode";
public static String item_move = "move";
public static String item_action = "action";
public static String item_error = "error";
public static String item_mode = "mode";//0-脱机2-待机3-电机运行
public static String item_move = "move";//0无货 1有货
public static String item_action = "action";//1-允许取货2-允许放货3-收箱完成
public static String item_error = "error";//故障
public static String item_direction = "direction";
public static String item_is_flip = "is_flip";
public static String item_task = "task";
public static String item_barcode = "barcode";
// 1-请求取货与诺宝对接输送滚筒运行
// 2-取货完成
// 3-请求放货 (与诺宝对接输送滚筒运行
// 4-放货完成
public static String item_to_command = "to_command";
public static String item_to_target = "to_target";
public static String item_to_task = "to_task";
@@ -113,24 +116,22 @@ public class ItemProtocol {
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.W0"));
list.add(new ItemDto(item_mode, "工作状态", "DB600.W2", Boolean.valueOf(true)));
list.add(new ItemDto(item_move, "光电开关信号", "DB600.W4"));
list.add(new ItemDto(item_action, "取放信号", "DB600.W6"));
list.add(new ItemDto(item_direction, "电机方向", "DB600.W8"));
list.add(new ItemDto(item_is_flip, "是否翻转", "DB600.W10"));
list.add(new ItemDto(item_error, "报警信", "DB600.W12"));
list.add(new ItemDto(item_task, "任务号", "DB600.D14"));
list.add(new ItemDto(item_heartbeat, "心跳", "DB0.W0"));
list.add(new ItemDto(item_mode, "工作模式", "DB0.W2", Boolean.valueOf(true)));
list.add(new ItemDto(item_move, "光电信号", "DB0.W4"));
list.add(new ItemDto(item_action, "动作信号", "DB600.W6"));
list.add(new ItemDto(item_direction, "是否满料", "DB0.W8"));
list.add(new ItemDto(item_is_flip, "故障", "DB0.W10"));
list.add(new ItemDto(item_task, "任务", "DB0.D12"));
list.add(new ItemDto(item_barcode, "条码", "DB600.STRING18.20"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "下发作业命令", "DB610.W2", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_target, "下发目标站", "DB610.W4"));
list.add(new ItemDto(item_to_is_flip, "下发是否翻转", "DB610.W6"));
list.add(new ItemDto(item_to_task, "下发任务号", "DB610.D8"));
list.add(new ItemDto(item_to_command, "下发命令", "DB1000.W1000", Boolean.valueOf(true)));
list.add(new ItemDto(item_to_target, "下发目标站", "DB1000.W1002"));
list.add(new ItemDto(item_to_task, "下发任务号", "DB1000.D1004"));
list.add(new ItemDto(item_to_barcode, "下发条码", "DB610.STRING12.20"));
return list;
}

View File

@@ -0,0 +1,51 @@
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_with_station;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.DeviceDriverDefination;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceType;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
/**
* 说明:关联站点驱动
*/
@Service
public class WithStationDefination implements DeviceDriverDefination {
@Override
public String getDriverCode() {
return "hailiang_with_station";
}
@Override
public String getDriverName() {
return "关联驱动";
}
@Override
public String getDriverDescription() {
return "关联驱动";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new WithStationDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return WithStationDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.conveyor);
return types;
}
}

View File

@@ -0,0 +1,307 @@
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_with_station;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.acsEnum.InstActionEnum;
import org.nl.acs.acsEnum.StatusEnum;
import org.nl.acs.agv.server.NDCAgvService;
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.ScannerDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_hr_ssx.HailiangHrSsxDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_package_ssx.HailiangLetteringPackageSsxDeviceDriver;
import org.nl.acs.device_driver.basedriver.hailiang_one.IssuedDeviceOrderInfo;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.history.service.DeviceErrorLogService;
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction;
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.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.wql.util.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.*;
/**
* 关联驱动
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
@Autowired
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
@Autowired
TaskService taskServer = SpringContextHolder.getBean("taskServiceImpl");
@Autowired
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
@Autowired
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
@Autowired
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
Integer hasGoods = 0;
int error = 0;
Boolean iserror = false;
Boolean islock = false;
int branchProtocol = 0;
int last_branchProtocol = 0;
//是否需要输入物料
String input_material = "0";
//备注
String remark = "";
//数量
String qty = "";
//批次
String batch = "";
//物料
String material = "";
//目标点位
String purpose = "";
//上次指令
Instruction last_inst = null;
boolean requireSucess = false;
//触摸屏手动触发任务
private Boolean is_has_task = false;
//申请搬运任务
private Boolean apply_handling = false;
//申请物料
private Boolean apply_material = false;
// 1取货完成 2放货完成 3进入区域 4离开区域
private int flag;
//人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0
private int manua_confirm = 0;
String device_code = null;
String container;
String container_type_desc;
String last_container_type_desc;
String last_container;
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private int instruction_require_time_out = 30000;
String message;
// 1 上位系统允许进入 2 上位系统允许离开
int option = 0;
//agv请求当前信息
private int agvphase = 0;
private int index = 0;
private Instruction inst = null;
public synchronized void set(int agvphase, int index, Instruction inst) {
this.agvphase = agvphase;
this.index = index;
this.inst = inst;
logServer.deviceExecuteLog(device_code, "", "", "设置phase值--->" + agvphase + ",index值--->" + index + ",指令信息关联编号--->" + (inst == null ? "" : inst.getLink_num()));
}
int mode = 2;
int move;
@Override
public void execute() {
hasGoods = this.getDevice().getHas_goods();
batch = this.getDevice().getBatch();
device_code = this.getDeviceCode();
if (agvphase == 0x03) {
if (ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status(InstActionEnum.EXECUTE_TO_GET.getCode());
instructionService.update(inst);
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
OneNDCSocketConnectionAutoRun.write(data);
this.set(0, 0, null);
}
}
if (agvphase == 0x05) {
if (ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status(InstActionEnum.EXECUTE_GET_FINISH.getCode());
instructionService.update(inst);
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
OneNDCSocketConnectionAutoRun.write(data);
this.set(0, 0, null);
}
}
if (agvphase == 0x07) {
if (ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status(InstActionEnum.EXECUTE_TO_PUT_FALL_SEND_FULL.getCode());
instructionService.update(inst);
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
OneNDCSocketConnectionAutoRun.write(data);
this.set(0, 0, null);
}
}
if (agvphase == 0x09) {
if (ObjectUtil.isNotEmpty(inst)) {
inst.setExecute_status(InstActionEnum.EXECUTE_PUT_FALL_SEND_FULL_FINISH.getCode());
instructionService.update(inst);
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
OneNDCSocketConnectionAutoRun.write(data);
this.set(0, 0, null);
}
}
//取关联设备 list
//遍历
List<String> hiaRouDeviceCodeList = this.getExtraDeviceCodes("link_device_code");
for(int i=0;i<hiaRouDeviceCodeList.size();i++){
Device haiRouDevice = deviceAppservice.findDeviceByCode(hiaRouDeviceCodeList.get(i));
HailiangHrSsxDeviceDriver hailiangHrSsxDeviceDriver;
HailiangHrSsxDeviceDriver hailiangHrSsxDeviceDriver_wait;
if(haiRouDevice.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) {
hailiangHrSsxDeviceDriver = (HailiangHrSsxDeviceDriver) haiRouDevice.getDeviceDriver();
//判断对接位当前条码是否有任务,有任务就不合并等待位。
TaskDto vehicle_dto = taskServer.findByContainer(hailiangHrSsxDeviceDriver.getBarcode());
if (vehicle_dto == null) {
//获取关联设备(等待位)
String wait_device_code = ObjectUtil.isNotEmpty(haiRouDevice.getExtraValue().get("link_device_code")) ? haiRouDevice.getExtraValue().get("link_device_code").toString() : "";
if (StrUtil.isNotEmpty(wait_device_code)) {
Device wait_device = deviceAppservice.findDeviceByCode(wait_device_code);
if (wait_device != null && wait_device.getDeviceDriver() instanceof HailiangHrSsxDeviceDriver) {
hailiangHrSsxDeviceDriver_wait = (HailiangHrSsxDeviceDriver) haiRouDevice.getDeviceDriver();
//对接位有货有码后30秒内等待位也有货有码的话就一起申请lms任务。否则单独申请任务
if (hailiangHrSsxDeviceDriver_wait.getInstruction_require_time().getTime() - hailiangHrSsxDeviceDriver.getInstruction_require_time().getTime() < (long)this.instruction_require_time_out){
JSONObject reqParam = new JSONObject();
reqParam.put("type", StatusEnum.HAIROU_LIKU_REQ.getCode());
reqParam.put("device_code_one", hailiangHrSsxDeviceDriver.getDevice_code());
reqParam.put("vehicle_code_one", hailiangHrSsxDeviceDriver.getBarcode());
reqParam.put("device_code_two", hailiangHrSsxDeviceDriver_wait.getDevice_code());
reqParam.put("vehicle_code_two", hailiangHrSsxDeviceDriver_wait.getBarcode());
//向lms请求任务
HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam);
if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
requireSucess = true;
}
}else {
//否则对接位单独申请任务
JSONObject reqParam = new JSONObject();
reqParam.put("type", StatusEnum.HAIROU_IN_REQ.getCode());
reqParam.put("device_code1", hailiangHrSsxDeviceDriver.getDevice_code());
reqParam.put("barcode1", hailiangHrSsxDeviceDriver.getBarcode());
HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam);
if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
requireSucess = true;
}
}
}
}
}
}
}
}
//将扩展表中的字符串数据转换成集合
public List<String> getExtraDeviceCodes(String extraName) {
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
String devices1 = extraValue.substring(1, extraValue.length() - 1);
List<String> devicesList = new ArrayList<>();
String[] devices = devices1.split(",");
for (int i = 0; i < devices.length; i++) {
String s = devices[i].replace("\"", "").replace("\"", "");
devicesList.add(s);
}
return devicesList;
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
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) {
mode = "单机";
} else if (this.getMode() == 2) {
mode = "联机";
} else if (this.getMode() == 3) {
mode = "运行中";
}
if (this.getMove() == 0) {
move = "无货";
jo.put("hasGoods", false);
} else if (this.getMove() == 1) {
move = "有货";
jo.put("hasGoods", true);
} else if (this.getMove() == 2) {
move = "有托盘有货";
jo.put("hasGoods", true);
}
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("mode", mode);
jo.put("move", move);
jo.put("action", action);
jo.put("isOnline", true);
jo.put("error", this.getError());
jo.put("isError", this.getIserror());
jo.put("option", option);
jo.put("is_click", true);
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
String flag = data.getString("option");
if (StrUtil.isNotEmpty(flag)) {
option = Integer.parseInt(flag);
}
}
}