@@ -52,6 +52,10 @@ public enum StatusEnum {
|
||||
BZ_EMPTY_REQ("6", "送空框请求(包装)", ""),
|
||||
QX_LACK_REQ("7", "清洗机缺料请求", ""),
|
||||
QX_FULL_REQ("8", "清洗机满料请求", ""),
|
||||
QXXL_FULL_REQ("9", "取满框请求(清洗下料)", ""),
|
||||
QXXL_EMPTY_REQ("10", "叫空框请求(清洗下料)", ""),
|
||||
QXXL_COMPEL_REQ("11", "强制搬出请求(清洗下料)", ""),
|
||||
KZSL_EMPTY_REQ("12","取空框请求(刻字上料)",""),
|
||||
|
||||
//指令状态
|
||||
INST_READY("0", "就绪", ""),
|
||||
|
||||
@@ -146,6 +146,7 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
|
||||
} else {
|
||||
System.out.println("agv上报不是0073类型动作,不处理");
|
||||
log.info("agv上报不是0073类型动作,不处理");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -101,9 +101,12 @@ public enum DriverTypeEnum {
|
||||
|
||||
HAILIANG_OLD_UNBOXING_MACHINE_DRIVER(46, "hailiang_old_unboxing_machine", "海亮-老车间-开箱机", "conveyor"),
|
||||
|
||||
HAILIANG_OLD_PACKAGE_RECVIEING_DRIVER(47, "hailiang_old_package_receiving_machine", "海亮-老车间-包装接料位", "conveyor");
|
||||
HAILIANG_OLD_PACKAGE_RECVIEING_DRIVER(47, "hailiang_old_package_receiving_machine", "海亮-老车间-包装接料位", "conveyor"),
|
||||
|
||||
HAILIANG_CLEANING_PUT_LINE(48, "hailiang_cleaning_put_line", "海亮-清洗下料", "conveyor"),
|
||||
|
||||
HAILIANG_ENGRAVING_IN(49, "hailiang_engraving_in", "海亮-刻字上料线体", "conveyor"),
|
||||
HAILIANG_FRAME_WEIGHING(50, "hailiang_frame_weighing", "海亮-合框称重", "conveyor");
|
||||
//驱动索引
|
||||
private int index;
|
||||
//驱动编码
|
||||
|
||||
@@ -633,7 +633,8 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
||||
celldto.setZ(formatNum(j));
|
||||
//celldto.setAddress(Integer.parseInt(CodeUtil.getNewCode("NDCADDRESS_NO")));
|
||||
celldto.setCreate_by("init");
|
||||
celldto.setCreate_time(SecurityUtils.getCurrentUsername());
|
||||
// celldto.setCreate_time(SecurityUtils.getCurrentUsername());
|
||||
celldto.setCreate_time(DateUtil.now());
|
||||
wo.insert((JSONObject) JSONObject.toJSON(celldto));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,10 @@ import org.nl.acs.agv.server.impl.NDCAgvServiceImpl;
|
||||
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.basedriver.hailiang_one.RemoveDevicePhase;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_put_line.HailiangCleaningPutLineDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_cache.HailiangEngravingCacheDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_in.HailiangEngravingInDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_machine.HailiangEngravingMachineDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_packer_station.HailiangPackerStationDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_ordinary_site.StandardOrdinarySiteDeviceDriver;
|
||||
@@ -119,6 +122,10 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
StandardOrdinarySiteDeviceDriver standardOrdinarySiteDeviceDriver;
|
||||
//货架
|
||||
StandardStorageDeviceDriver standardStorageDeviceDriver;
|
||||
//刻字上料线体
|
||||
HailiangEngravingInDeviceDriver hailiangEngravingInDeviceDriver;
|
||||
//清洗下料
|
||||
HailiangCleaningPutLineDeviceDriver hailiangCleaningPutLineDeviceDriver;
|
||||
|
||||
//开始任务/上报订单号
|
||||
if (phase == 0x02) {
|
||||
@@ -167,6 +174,12 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
}
|
||||
|
||||
if (StrUtil.equals(inst.getStart_device_code(), device_code)) {
|
||||
|
||||
// if (device.getDeviceDriver() instanceof RemoveDevicePhase) {
|
||||
// RemoveDevicePhase removeDevicePhase = (RemoveDevicePhase) device.getDeviceDriver();
|
||||
// removeDevicePhase.set(phase, index, inst);
|
||||
// }
|
||||
|
||||
if (device.getDeviceDriver() instanceof HailiangEngravingMachineDeviceDriver) {
|
||||
hailiangEngravingMachineDeviceDriver = (HailiangEngravingMachineDeviceDriver) device.getDeviceDriver();
|
||||
hailiangEngravingMachineDeviceDriver.set(phase, index, inst);
|
||||
@@ -187,6 +200,17 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
hailiangPackerStationDeviceDriver.set(phase, index, inst);
|
||||
}
|
||||
|
||||
if (device.getDeviceDriver() instanceof HailiangEngravingInDeviceDriver) {
|
||||
hailiangEngravingInDeviceDriver = (HailiangEngravingInDeviceDriver) device.getDeviceDriver();
|
||||
hailiangEngravingInDeviceDriver.set(phase, index, inst);
|
||||
}
|
||||
|
||||
if (device.getDeviceDriver() instanceof HailiangCleaningPutLineDeviceDriver) {
|
||||
hailiangCleaningPutLineDeviceDriver = (HailiangCleaningPutLineDeviceDriver) device.getDeviceDriver();
|
||||
hailiangCleaningPutLineDeviceDriver.set(phase, index, inst);
|
||||
}
|
||||
|
||||
|
||||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
}
|
||||
@@ -281,6 +305,14 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver();
|
||||
hailiangPackerStationDeviceDriver.set(phase, index, inst);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof HailiangEngravingInDeviceDriver) {
|
||||
hailiangEngravingInDeviceDriver = (HailiangEngravingInDeviceDriver) device.getDeviceDriver();
|
||||
hailiangEngravingInDeviceDriver.set(phase, index, inst);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof HailiangCleaningPutLineDeviceDriver) {
|
||||
hailiangCleaningPutLineDeviceDriver = (HailiangCleaningPutLineDeviceDriver) device.getDeviceDriver();
|
||||
hailiangCleaningPutLineDeviceDriver.set(phase, index, inst);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver();
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
@@ -340,6 +372,14 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
hailiangPackerStationDeviceDriver = (HailiangPackerStationDeviceDriver) device.getDeviceDriver();
|
||||
hailiangPackerStationDeviceDriver.set(phase, index, inst);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof HailiangEngravingInDeviceDriver) {
|
||||
hailiangEngravingInDeviceDriver = (HailiangEngravingInDeviceDriver) device.getDeviceDriver();
|
||||
hailiangEngravingInDeviceDriver.set(phase, index, inst);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof HailiangCleaningPutLineDeviceDriver) {
|
||||
hailiangCleaningPutLineDeviceDriver = (HailiangCleaningPutLineDeviceDriver) device.getDeviceDriver();
|
||||
hailiangCleaningPutLineDeviceDriver.set(phase, index, inst);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver();
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
@@ -401,6 +441,14 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver();
|
||||
standardOrdinarySiteDeviceDriver.set(phase, index, inst);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof HailiangEngravingInDeviceDriver) {
|
||||
hailiangEngravingInDeviceDriver = (HailiangEngravingInDeviceDriver) device.getDeviceDriver();
|
||||
hailiangEngravingInDeviceDriver.set(phase, index, inst);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof HailiangCleaningPutLineDeviceDriver) {
|
||||
hailiangCleaningPutLineDeviceDriver = (HailiangCleaningPutLineDeviceDriver) device.getDeviceDriver();
|
||||
hailiangCleaningPutLineDeviceDriver.set(phase, index, inst);
|
||||
}
|
||||
if (device.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
|
||||
standardStorageDeviceDriver = (StandardStorageDeviceDriver) device.getDeviceDriver();
|
||||
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_feeding_line;
|
||||
|
||||
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;
|
||||
@@ -200,7 +201,7 @@ public class HailiangCleaningFeedingLineDriver extends AbstractOpcDeviceDriver i
|
||||
|
||||
//反馈mes清洗上料完成
|
||||
if (mode == 1 && task_finish == 1 && !requireSucess) {
|
||||
boolean flag = feedMesTaskClear();
|
||||
boolean flag = feedMesTaskClear(in_pcsn);
|
||||
this.noFeedMessage = null;
|
||||
if (flag) {
|
||||
this.message = "反馈清洗上料完成成功";
|
||||
@@ -231,13 +232,17 @@ public class HailiangCleaningFeedingLineDriver extends AbstractOpcDeviceDriver i
|
||||
/**
|
||||
* 上料完成以后反馈mes 上料设备号
|
||||
*/
|
||||
private boolean feedMesTaskClear() {
|
||||
private boolean feedMesTaskClear(int in_pcsn) {
|
||||
if (redisUtils.hasKey(this.device_code)) {
|
||||
return false;
|
||||
} else {
|
||||
this.writing("to_confirm_finished", "1");
|
||||
|
||||
ProduceshiftorderDto dto = produceshiftorderService.findOrderByDeviceCode(this.getDevice_code());
|
||||
if (dto != null) {
|
||||
if (!StrUtil.equals(dto.getOrder_id(),String.valueOf(in_pcsn))){
|
||||
return false;
|
||||
}
|
||||
this.writing("to_confirm_finished", "1");
|
||||
String[] in_devices = dto.getIn_devices().split(",");
|
||||
//上料完成清除储料仓内存中的物料信息
|
||||
Arrays.stream(in_devices).forEach(device_code -> {
|
||||
@@ -245,6 +250,10 @@ public class HailiangCleaningFeedingLineDriver extends AbstractOpcDeviceDriver i
|
||||
if (device.getDeviceDriver() instanceof HailiangCleaningMachineStorageStationDeviceDriver) {
|
||||
HailiangCleaningMachineStorageStationDeviceDriver hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) device.getDeviceDriver();
|
||||
hailiangCleaningMachineStorageStationDeviceDriver.setMaterial_code(null);
|
||||
//下发储料仓去皮
|
||||
hailiangCleaningMachineStorageStationDeviceDriver.writing("to_peel","1");
|
||||
//下发称重
|
||||
hailiangCleaningMachineStorageStationDeviceDriver.writing("to_open_weight","1");
|
||||
}
|
||||
});
|
||||
//修改工单状态为执行中
|
||||
@@ -403,6 +412,7 @@ public class HailiangCleaningFeedingLineDriver extends AbstractOpcDeviceDriver i
|
||||
}
|
||||
//下发电气信号
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_pcsn",dto.getOrder_id());//下发批次号,暂时用工单号
|
||||
map.put("to_all_num", String.valueOf(qtySum));
|
||||
map.put("to_all_weight", String.valueOf(weightSum));
|
||||
map.put("to_in_confirm_finish", "1");
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_put_line;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
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 HailiangCleaningPutLineDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "hailiang_cleaning_put_line";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "海亮-清洗机下料";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "海亮-清洗机下料";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new HailiangCleaningPutLineDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return HailiangCleaningPutLineDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.conveyor);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,488 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_put_line;
|
||||
|
||||
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.agv.server.impl.NDCAgvServiceImpl;
|
||||
import org.nl.acs.auto.run.NDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.ApplyTaskTime;
|
||||
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.ErrorUtil;
|
||||
import org.nl.acs.history.service.DeviceErrorLogService;
|
||||
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
|
||||
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.order.service.dto.ProduceshiftorderDto;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 海亮清洗机下料
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class HailiangCleaningPutLineDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
@Autowired
|
||||
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
@Autowired
|
||||
RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
@Autowired
|
||||
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvServiceImpl.class);
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
|
||||
//工作模式
|
||||
int mode = 0;
|
||||
//开机状态
|
||||
int is_open = 0;
|
||||
//收料就绪
|
||||
int put_line_ready = 0;
|
||||
//所有设备就绪
|
||||
int all_ready = 0;
|
||||
//清洗机入料线体就绪
|
||||
int in_line_ready = 0;
|
||||
//收料位有货
|
||||
int move = 0;
|
||||
//空框请求
|
||||
int empty_req = 0;
|
||||
//满框请求
|
||||
int full_req = 0;
|
||||
//人工满框请求
|
||||
int compel_full_req = 0;
|
||||
//收料位1上升到位
|
||||
int is_up = 0;
|
||||
//报警信号
|
||||
int error = 0;
|
||||
//收料位1实时重量
|
||||
int now_weight = 0;
|
||||
//收料位1满料框重量
|
||||
int full_weight = 0;
|
||||
//上料批次号
|
||||
int in_pcsn = 0;
|
||||
//收料位1条码
|
||||
int barcode = 0;
|
||||
//收料位1批次入料总数量
|
||||
int all_num = 0;
|
||||
//收料位1批次入料总重量
|
||||
int all_weight = 0;
|
||||
//开机准备时间(S)
|
||||
int open_ready_time = 0;
|
||||
//设备运转时间(S)
|
||||
int device_running_time = 0;
|
||||
//待机时间(S)
|
||||
int await_time = 0;
|
||||
|
||||
|
||||
//工作模式
|
||||
int last_mode = 0;
|
||||
//开机状态
|
||||
int last_is_open = 0;
|
||||
//收料就绪
|
||||
int last_put_line_ready = 0;
|
||||
//所有设备就绪
|
||||
int last_all_ready = 0;
|
||||
//清洗机入料线体就绪
|
||||
int last_in_line_ready = 0;
|
||||
//收料位有货
|
||||
int last_move = 0;
|
||||
//空框请求
|
||||
int last_empty_req = 0;
|
||||
//满框请求
|
||||
int last_full_req = 0;
|
||||
//人工满框请求
|
||||
int last_compel_full_req = 0;
|
||||
//收料位1上升到位
|
||||
int last_is_up = 0;
|
||||
//报警信号
|
||||
int last_error = 0;
|
||||
//收料位1实时重量
|
||||
int last_now_weight = 0;
|
||||
//收料位1满料框重量
|
||||
int last_full_weight = 0;
|
||||
//上料批次号
|
||||
int last_in_pcsn = 0;
|
||||
int last_barcode = 0;
|
||||
//收料位1批次入料总数量
|
||||
int last_all_num = 0;
|
||||
//收料位1批次入料总重量
|
||||
int last_all_weight = 0;
|
||||
int last_open_ready_time = 0;
|
||||
int last_device_running_time = 0;
|
||||
int last_await_time = 0;
|
||||
|
||||
|
||||
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
|
||||
|
||||
//请求成功标记
|
||||
Boolean requireSucess = false;
|
||||
//当前指令
|
||||
Instruction inst = null;
|
||||
String noFeedAgvMessage;
|
||||
String noApplyTaskMessage = null;
|
||||
|
||||
//agv请求当前信息
|
||||
private int agvphase = 0;
|
||||
private int index = 0;
|
||||
|
||||
String device_code;
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getItem_mode();
|
||||
move = this.itemProtocol.getItem_move();
|
||||
is_open = this.itemProtocol.getItem_is_open();
|
||||
put_line_ready = this.itemProtocol.getItem_put_line_ready();
|
||||
all_ready = this.itemProtocol.getItem_all_ready();
|
||||
error = this.itemProtocol.getItem_error();
|
||||
in_line_ready = this.itemProtocol.getItem_in_line_ready();
|
||||
empty_req = this.itemProtocol.getItme_empty_req();
|
||||
full_req = this.itemProtocol.getItem_full_req();
|
||||
compel_full_req = this.itemProtocol.getItem_compel_full_req();
|
||||
is_up = this.itemProtocol.getItem_is_up();
|
||||
now_weight = this.itemProtocol.getItem_now_weight();
|
||||
full_weight = this.itemProtocol.getItem_full_weight();
|
||||
in_pcsn = this.itemProtocol.getItem_in_pcsn();
|
||||
barcode = this.itemProtocol.getItem_barcode();
|
||||
all_num = this.itemProtocol.getItem_all_num();
|
||||
all_weight = this.itemProtocol.getItem_all_weight();
|
||||
device_running_time = this.itemProtocol.getItem_device_running_time();
|
||||
await_time = this.itemProtocol.getItem_await_time();
|
||||
if (mode != last_mode) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
||||
}
|
||||
if (move != last_move) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move);
|
||||
}
|
||||
if (is_open != last_is_open) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号is_open:" + last_is_open + "->" + is_open);
|
||||
}
|
||||
if (put_line_ready != last_put_line_ready) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号put_line_ready:" + last_put_line_ready + "->" + put_line_ready);
|
||||
}
|
||||
if (open_ready_time != last_open_ready_time) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号open_ready_time:" + last_open_ready_time + "->" + open_ready_time);
|
||||
}
|
||||
if (all_ready != last_all_ready) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号all_ready:" + last_all_ready + "->" + all_ready);
|
||||
}
|
||||
if (in_line_ready != last_in_line_ready) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号order_real_time:" + last_in_line_ready + "->" + in_line_ready);
|
||||
}
|
||||
if (empty_req != last_empty_req) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号empty_req:" + last_empty_req + "->" + empty_req);
|
||||
}
|
||||
if (full_req != last_full_req) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号full_req:" + last_full_req + "->" + full_req);
|
||||
}
|
||||
if (compel_full_req != last_compel_full_req) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号compel_full_req:" + last_compel_full_req + "->" + compel_full_req);
|
||||
}
|
||||
if (is_up != last_is_up) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号is_up:" + last_is_up + "->" + is_up);
|
||||
}
|
||||
if (now_weight != last_now_weight) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号now_weight:" + last_now_weight + "->" + now_weight);
|
||||
}
|
||||
if (full_weight != last_full_weight) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号full_weight:" + last_full_weight + "->" + full_weight);
|
||||
}
|
||||
if (in_pcsn != last_in_pcsn) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号in_pcsn:" + last_in_pcsn + "->" + in_pcsn);
|
||||
}
|
||||
if (all_num != last_all_num) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号all_num:" + last_all_num + "->" + all_num);
|
||||
}
|
||||
if (all_weight != last_all_weight) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号all_weight:" + last_all_weight + "->" + all_weight);
|
||||
}
|
||||
if (device_running_time != last_device_running_time) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号device_running_time:" + last_device_running_time + "->" + device_running_time);
|
||||
}
|
||||
if (await_time != last_await_time) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号await_time:" + last_await_time + "->" + await_time);
|
||||
}
|
||||
|
||||
if (error != last_error) {
|
||||
if (error != 0) {
|
||||
DeviceErrorLogDto dto = new DeviceErrorLogDto();
|
||||
dto.setDevice_code(device_code);
|
||||
dto.setError_code(String.valueOf(error));
|
||||
dto.setError_info(ErrorUtil.getDictDetail("clean_error_type", String.valueOf(error)));
|
||||
deviceErrorLogService.create(dto);
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
var17.printStackTrace();
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17 + ",inst == null :" + ObjectUtil.isEmpty(inst));
|
||||
}
|
||||
|
||||
if (!this.itemProtocol.getIsonline()) {
|
||||
//this.setIsonline(false);
|
||||
//this.setIserror(true);
|
||||
message = "信号量同步异常";
|
||||
//未联机
|
||||
}else if (mode == 0) {
|
||||
message = "未联机";
|
||||
//有报警
|
||||
} else {
|
||||
this.setIserror(false);
|
||||
message = "";
|
||||
//工作模式联机、满框请求 就申请agv任务
|
||||
if (mode == 1 && full_req == 1 && put_line_ready ==0 && !requireSucess) {
|
||||
boolean flag = apply_task(StatusEnum.QXXL_FULL_REQ.getCode());
|
||||
this.noApplyTaskMessage = null;
|
||||
if (flag) {
|
||||
this.message = "申请满框请求任务成功";
|
||||
}
|
||||
}
|
||||
//工作模式联机、强制搬出请求 就申请agv任务
|
||||
if (mode == 1 && empty_req == 1 && put_line_ready ==0 && !requireSucess) {
|
||||
boolean flag = apply_task(StatusEnum.QXXL_COMPEL_REQ.getCode());
|
||||
this.noApplyTaskMessage = null;
|
||||
if (flag) {
|
||||
this.message = "申请强制搬出请求任务成功";
|
||||
}
|
||||
}
|
||||
//工作模式联机、空框请求 就申请agv任务
|
||||
if (mode == 1 && empty_req == 1 && put_line_ready ==0 && !requireSucess) {
|
||||
boolean flag = apply_task(StatusEnum.QXXL_EMPTY_REQ.getCode());
|
||||
this.noApplyTaskMessage = null;
|
||||
if (flag) {
|
||||
this.message = "申请空框请求任务成功";
|
||||
}
|
||||
}
|
||||
//agv到达取货位
|
||||
if (agvphase == 0x03) {
|
||||
if (ObjectUtil.isNotEmpty(inst) && mode == 1 && move == 1 && is_up== 1) {
|
||||
inst.setExecute_status(InstActionEnum.EXECUTE_TO_GET.getCode());
|
||||
instructionService.update(inst);
|
||||
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
|
||||
NDCSocketConnectionAutoRun.write(data);
|
||||
this.set(0, 0, null);
|
||||
noFeedAgvMessage = null;
|
||||
message = this.messageInfo(agvphase);
|
||||
logServer.deviceExecuteLog(device_code, "", "", this.messageInfo(agvphase));
|
||||
} else {
|
||||
String notFeedAgvMessage = "";
|
||||
if (mode != 1) {
|
||||
notFeedAgvMessage += "工作模式未联机,";
|
||||
}
|
||||
if (move == 0) {
|
||||
notFeedAgvMessage += "光电信号无货,";
|
||||
}
|
||||
if (inst == null) {
|
||||
notFeedAgvMessage += "AGV指令为空,";
|
||||
}
|
||||
this.noFeedAgvMessage = this.replace(notFeedAgvMessage);
|
||||
}
|
||||
}
|
||||
|
||||
//agv取货完成
|
||||
if (agvphase == 0x05) {
|
||||
if (ObjectUtil.isNotEmpty(inst) && mode == 1 && move == 0) {
|
||||
inst.setExecute_status(InstActionEnum.EXECUTE_GET_FINISH.getCode());
|
||||
instructionService.update(inst);
|
||||
//下发取货位AGV取货完成
|
||||
writing("to_agv_take_finish", "1");
|
||||
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
|
||||
NDCSocketConnectionAutoRun.write(data);
|
||||
this.set(0, 0, null);
|
||||
noFeedAgvMessage = null;
|
||||
message = this.messageInfo(agvphase);
|
||||
logServer.deviceExecuteLog(device_code, "", "", this.messageInfo(agvphase));
|
||||
} else {
|
||||
String notFeedAgvMessage = "";
|
||||
if (mode != 1) {
|
||||
notFeedAgvMessage += "工作模式未联机,";
|
||||
}
|
||||
if (move != 0) {
|
||||
notFeedAgvMessage += "光电信号有货,";
|
||||
}
|
||||
if (inst == null) {
|
||||
notFeedAgvMessage += "AGV指令为空,";
|
||||
}
|
||||
this.noFeedAgvMessage = this.replace(notFeedAgvMessage);
|
||||
}
|
||||
}
|
||||
//agv到达放框位
|
||||
if (agvphase == 0x07) {
|
||||
if (ObjectUtil.isNotEmpty(inst) && mode == 1 && move == 0 && is_up== 1) {
|
||||
inst.setExecute_status(InstActionEnum.EXECUTE_TO_PUT_FALL_SEND_FULL.getCode());
|
||||
instructionService.update(inst);
|
||||
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
|
||||
NDCSocketConnectionAutoRun.write(data);
|
||||
this.set(0, 0, null);
|
||||
noFeedAgvMessage = null;
|
||||
message = this.messageInfo(agvphase);
|
||||
logServer.deviceExecuteLog(device_code, "", "", this.messageInfo(agvphase));
|
||||
} else {
|
||||
String notFeedAgvMessage = "";
|
||||
if (mode != 1) {
|
||||
notFeedAgvMessage += "工作模式未联机,";
|
||||
}
|
||||
if (move == 0) {
|
||||
notFeedAgvMessage += "光电信号无货,";
|
||||
}
|
||||
if (inst == null) {
|
||||
notFeedAgvMessage += "AGV指令为空,";
|
||||
}
|
||||
this.noFeedAgvMessage = this.replace(notFeedAgvMessage);
|
||||
}
|
||||
}
|
||||
|
||||
//agv放框完成
|
||||
if (agvphase == 0x09) {
|
||||
if (ObjectUtil.isNotEmpty(inst) && mode == 1 && move == 1 && is_up == 0) {
|
||||
inst.setExecute_status(InstActionEnum.EXECUTE_PUT_FALL_SEND_FULL_FINISH.getCode());
|
||||
instructionService.update(inst);
|
||||
//下发AGV放框完成
|
||||
writing("to_agv_release_finish", "1");
|
||||
byte[] data = agvService.sendAgvOneModeInst(agvphase, index, 0);
|
||||
NDCSocketConnectionAutoRun.write(data);
|
||||
this.set(0, 0, null);
|
||||
noFeedAgvMessage = null;
|
||||
message = this.messageInfo(agvphase);
|
||||
logServer.deviceExecuteLog(device_code, "", "", this.messageInfo(agvphase));
|
||||
} else {
|
||||
String notFeedAgvMessage = "";
|
||||
if (mode != 1) {
|
||||
notFeedAgvMessage += "工作模式未联机,";
|
||||
}
|
||||
if (move != 0) {
|
||||
notFeedAgvMessage += "光电信号有货,";
|
||||
}
|
||||
if (inst == null) {
|
||||
notFeedAgvMessage += "AGV指令为空,";
|
||||
}
|
||||
this.noFeedAgvMessage = this.replace(notFeedAgvMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_is_open = is_open;
|
||||
last_put_line_ready = put_line_ready;
|
||||
last_all_ready = all_ready;
|
||||
last_in_line_ready = in_line_ready;
|
||||
last_move = move;
|
||||
last_empty_req = empty_req;
|
||||
last_full_req = full_req;
|
||||
last_compel_full_req = compel_full_req;
|
||||
last_is_up = is_up;
|
||||
last_error = error;
|
||||
last_now_weight = now_weight;
|
||||
last_full_weight = full_weight;
|
||||
last_in_pcsn = in_pcsn;
|
||||
last_all_num = all_num;
|
||||
last_all_weight = all_weight;
|
||||
last_open_ready_time = open_ready_time;
|
||||
last_device_running_time = device_running_time;
|
||||
last_await_time = await_time;
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请任务
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public synchronized boolean apply_task(String code) {
|
||||
if (redisUtils.hasKey("apply:" + this.device_code)) {
|
||||
return false;
|
||||
} else {
|
||||
redisUtils.setExpire(this.device_code, null, ApplyTaskTime.APPLY_TIME, TimeUnit.SECONDS);
|
||||
JSONObject reqParam = new JSONObject();
|
||||
reqParam.put("type", code);
|
||||
reqParam.put("device_code", this.getDevice_code());
|
||||
reqParam.put("in_pcsn", this.getIn_pcsn());
|
||||
reqParam.put("barcode", this.getBarcode());
|
||||
reqParam.put("full_weight", this.getFull_weight());
|
||||
reqParam.put("all_num",this.getAll_num());
|
||||
HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam);
|
||||
if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
|
||||
JSONObject resp = JSONObject.parseObject(httpResponse.body());
|
||||
if (resp.getInteger("status") == 200) {
|
||||
requireSucess = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备监控信息
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("isOnline", this.itemProtocol.getIsonline());
|
||||
jo.put("error", ErrorUtil.getDictDetail("clean_error_type", String.valueOf(this.getError())));
|
||||
jo.put("driver_type", "hailiang_cleaning_put_line");
|
||||
return jo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改设备信息
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_put_line;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_feeding_line.HailiangCleaningFeedingLineDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_machine.HailiangCleaningMachineDeviceDriver;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class ItemProtocol {
|
||||
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
public static String item_mode = "mode"; //工作模式
|
||||
public static String item_line_status = "line_status";//线体状态
|
||||
public static String item_is_open = "is_open";//线体开机状态
|
||||
public static String item_put_line_ready = "put_line_ready";//收料线体就绪
|
||||
public static String item_all_ready = "all_ready"; //所有设备就绪
|
||||
public static String item_in_line_ready = "in_line_ready"; //清洗机入料线体就绪
|
||||
public static String item_move = "move";//收料位1有货
|
||||
public static String itme_empty_req = "empty_req";//收料位1缺空料框(空框请求)
|
||||
public static String item_full_req = "full_req";//收料位1满料框,请求AGV(满框请求)
|
||||
public static String item_compel_full_req = "compel_full_req";//人工触发(满框请求)
|
||||
public static String item_is_up = "is_up";//收料位1上升到位
|
||||
public static String item_error = "error"; //报警信号
|
||||
public static String item_now_weight = "now_weight";//收料位1实时重量
|
||||
public static String item_full_weight = "full_weight";//收料位1满料框重量
|
||||
public static String item_barcode = "barcode";//收料位1条码
|
||||
public static String item_in_pcsn = "in_pcsn";//收料位1批次号(上料批次号)
|
||||
public static String item_all_num = "all_num";//收料位1批次入料总数量
|
||||
public static String item_all_weight = "all_weight";//收料位1批次入料总重量
|
||||
public static String item_open_ready_time = "open_ready_time"; //开机准备时间(S)
|
||||
public static String item_device_running_time = "device_running_time"; //设备运转时间(S)
|
||||
public static String item_await_time = "await_time"; //待机时间(S)
|
||||
|
||||
//AGV放货完成
|
||||
public static String item_to_agv_release_finish = "to_agv_release_finish";
|
||||
//AGV取货完成
|
||||
public static String item_to_agv_take_finish = "to_agv_take_finish";
|
||||
//收料位1去皮
|
||||
public static String item_to_peel = "to_peel";
|
||||
//称重禁用
|
||||
public static String item_to_dis_weight = "to_dis_weight";
|
||||
//满框标准重量
|
||||
public static String item_to_full_weight = "to_full_weight";
|
||||
//铁料框自重
|
||||
public static String item_to_dead_weight = "to_dead_weight";
|
||||
|
||||
|
||||
|
||||
private HailiangCleaningPutLineDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(HailiangCleaningPutLineDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getItem_heartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getItem_line_status() {
|
||||
return this.getOpcIntegerValue(item_line_status);
|
||||
}
|
||||
|
||||
public int getItem_is_open() {
|
||||
return this.getOpcIntegerValue(item_is_open);
|
||||
}
|
||||
|
||||
public int getItem_put_line_ready() {
|
||||
return this.getOpcIntegerValue(item_put_line_ready);
|
||||
}
|
||||
|
||||
public int getItem_all_ready() {
|
||||
return this.getOpcIntegerValue(item_all_ready);
|
||||
}
|
||||
|
||||
public int getItem_in_line_ready() {
|
||||
return this.getOpcIntegerValue(item_in_line_ready);
|
||||
}
|
||||
|
||||
public int getItem_move() {
|
||||
return this.getOpcIntegerValue(item_move);
|
||||
}
|
||||
|
||||
public int getItme_empty_req() {
|
||||
return this.getOpcIntegerValue(itme_empty_req);
|
||||
}
|
||||
|
||||
public int getItem_full_req() {
|
||||
return this.getOpcIntegerValue(item_full_req);
|
||||
}
|
||||
|
||||
public int getItem_compel_full_req() {
|
||||
return this.getOpcIntegerValue(item_compel_full_req);
|
||||
}
|
||||
|
||||
public int getItem_is_up() {
|
||||
return this.getOpcIntegerValue(item_is_up);
|
||||
}
|
||||
|
||||
public int getItem_error() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getItem_now_weight() {
|
||||
return this.getOpcIntegerValue(item_now_weight);
|
||||
}
|
||||
|
||||
public int getItem_full_weight() {
|
||||
return this.getOpcIntegerValue(item_full_weight);
|
||||
}
|
||||
|
||||
public int getItem_in_pcsn() {
|
||||
return this.getOpcIntegerValue(item_in_pcsn);
|
||||
}
|
||||
public int getItem_barcode() {
|
||||
return this.getOpcIntegerValue(item_barcode);
|
||||
}
|
||||
public int getItem_all_num() {
|
||||
return this.getOpcIntegerValue(item_all_num);
|
||||
}
|
||||
|
||||
public int getItem_all_weight() {
|
||||
return this.getOpcIntegerValue(item_all_weight);
|
||||
}
|
||||
|
||||
public int getItem_open_ready_time() {
|
||||
return this.getOpcIntegerValue(item_open_ready_time);
|
||||
}
|
||||
|
||||
public int getItem_device_running_time() {
|
||||
return this.getOpcIntegerValue(item_device_running_time);
|
||||
}
|
||||
|
||||
public int getItem_await_time() {
|
||||
return this.getOpcIntegerValue(item_await_time);
|
||||
}
|
||||
|
||||
public int getItem_mode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB1.W82"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB1.B0.0"));
|
||||
list.add(new ItemDto(item_line_status, "线体状态", "DB1.B0.0"));
|
||||
list.add(new ItemDto(item_is_open, "线体开机状态", "DB1.B0.1"));
|
||||
list.add(new ItemDto(item_put_line_ready, "收料线体就绪", "DB1.B0.2"));
|
||||
list.add(new ItemDto(item_all_ready, "所有设备就绪", "DB1.B0.3"));
|
||||
list.add(new ItemDto(item_in_line_ready, "清洗机入料线体就绪", "DB1.B0.4"));
|
||||
list.add(new ItemDto(item_move, "收料位1有货", "DB1.B0.6"));
|
||||
list.add(new ItemDto(itme_empty_req, "空框请求", "DB1.B1.0"));
|
||||
list.add(new ItemDto(item_full_req, "满框请求", "DB1.B1.2"));
|
||||
list.add(new ItemDto(item_compel_full_req, "强制搬出1", "DB1.B1.4"));
|
||||
list.add(new ItemDto(item_is_up, "收料位1上升到位", "DB1.B1.6"));
|
||||
list.add(new ItemDto(item_error, "故障信息", "DB1.W4"));
|
||||
list.add(new ItemDto(item_now_weight, "收料位1实时重量", "DB1.D84"));
|
||||
list.add(new ItemDto(item_full_weight, "收料位1满料框重量", "DB1.D88"));
|
||||
list.add(new ItemDto(item_barcode, "收料位1条码", "DB1.D100"));
|
||||
list.add(new ItemDto(item_in_pcsn, "收料位1批次号", "DB1.D116"));
|
||||
list.add(new ItemDto(item_all_num, "收料位1批次入料总数量", "DB1.D120"));
|
||||
list.add(new ItemDto(item_all_weight, "收料位1批次入料总重量", "DB1.D124"));
|
||||
list.add(new ItemDto(item_open_ready_time, "开机准备时间(S)", "DB1.D144"));
|
||||
list.add(new ItemDto(item_device_running_time, "设备运转时间(S)", "DB1.D148"));
|
||||
list.add(new ItemDto(item_await_time, "待机时间(S)", "DB1.D152"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_agv_release_finish, "AGV放货完成","DB2.W4"));
|
||||
list.add(new ItemDto(item_to_agv_take_finish,"AGV取货完成","DB2.W8"));
|
||||
list.add(new ItemDto(item_to_peel,"收料位1去皮","DB2.W12"));
|
||||
list.add(new ItemDto(item_to_dis_weight, "称重禁用", "DB2.W16"));
|
||||
list.add(new ItemDto(item_to_full_weight,"满框标准重量","DB2.D84"));
|
||||
list.add(new ItemDto(item_to_dead_weight,"铁料框自重","DB2.D88"));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -272,10 +272,11 @@ public class EalingMachineDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
map.put("to_order_box_num", ealingOrderDto.getOrder_box_num());
|
||||
map.put("to_order_bag_num", ealingOrderDto.getOrder_bag_num());
|
||||
map.put("to_template_no", ealingOrderDto.getTemplate_no());
|
||||
map.put("to_x" + x, x);
|
||||
map.put("to_y" + y, y);
|
||||
|
||||
//模板号大于100 再下发这些信息
|
||||
if (StrUtil.isNotEmpty(ealingOrderDto.getTemplate_no()) && Integer.parseInt(ealingOrderDto.getTemplate_no()) > 100) {
|
||||
map.put("to_x" + x, x);
|
||||
map.put("to_y" + y, y);
|
||||
map.put("to_bag_length", ealingOrderDto.getBag_length());
|
||||
map.put("to_bag_width", ealingOrderDto.getBag_width());
|
||||
map.put("to_bag_num_of_one_floor_box", ealingOrderDto.getBag_num_of_one_floor_box());
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_in;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
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 HailiangEngravingInDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "hailiang_engraving_in";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "海亮-刻字机上料位";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "海亮-刻字机上料位";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new HailiangEngravingInDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return HailiangEngravingInDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.conveyor);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,815 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_in;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
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.acsEnum.WorkerOrderEnum;
|
||||
import org.nl.acs.agv.server.impl.NDCAgvServiceImpl;
|
||||
import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.ApplyTaskTime;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.IssuedDeviceOrderInfo;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.MonitoringLargeScreenData;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.RemoveDevicePhase;
|
||||
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.ErrorUtil;
|
||||
import org.nl.acs.history.service.DeviceErrorLogService;
|
||||
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
|
||||
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.order.service.ProduceshiftorderService;
|
||||
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.acs.task.service.impl.TaskServiceImpl;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 海亮刻字机上料
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class HailiangEngravingInDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, IssuedDeviceOrderInfo, RemoveDevicePhase {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
@Autowired
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
@Autowired
|
||||
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class);
|
||||
@Autowired
|
||||
NDCAgvServiceImpl agvService = SpringContextHolder.getBean(NDCAgvServiceImpl.class);
|
||||
@Autowired
|
||||
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
@Autowired
|
||||
TaskService taskService = SpringContextHolder.getBean(TaskServiceImpl.class);
|
||||
@Autowired
|
||||
RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
|
||||
|
||||
//线体状态
|
||||
int status = 0;
|
||||
//线体开机状态
|
||||
int is_open = 0;
|
||||
//刻字机运行状态
|
||||
int is_running = 0;
|
||||
//线体就绪
|
||||
int line_ready = 0;
|
||||
//回流满框请求
|
||||
int fl_full_req = 0;
|
||||
//空框请求
|
||||
int empty_req = 0;
|
||||
//任务完成
|
||||
int task_finish = 0;
|
||||
//回流在席光电(有货)
|
||||
int fl_move = 0;
|
||||
//在席光电状态
|
||||
int gd_move = 0;
|
||||
//允许放料斗
|
||||
int allow_put = 0;
|
||||
//料斗空
|
||||
int empty = 0;
|
||||
//回流报警
|
||||
int fl_error = 0;
|
||||
//任务号
|
||||
int task = 0;
|
||||
//模式 所有设备就绪
|
||||
int mode = 0;
|
||||
//报警信号
|
||||
int error = 0;
|
||||
//刻字上料重量
|
||||
int engraving_weight = 0;
|
||||
//剩余实时重量
|
||||
int engraving_storage_now_weight = 0;
|
||||
//上料总重量实际值
|
||||
int engraving_all_weight = 0;
|
||||
//回流实时重量
|
||||
int fl_now_weight = 0;
|
||||
//回流满框重量
|
||||
int fl_full_weight = 0;
|
||||
//料框条码
|
||||
int barcode = 0;
|
||||
//开机准备时间(S)
|
||||
int open_ready_time = 0;
|
||||
//设备运转时间(S)
|
||||
int device_running_time = 0;
|
||||
//待机时间(S)
|
||||
int await_time = 0;
|
||||
|
||||
//线体状态
|
||||
int last_status = 0;
|
||||
//线体开机状态
|
||||
int last_is_open = 0;
|
||||
//刻字机运行状态
|
||||
int last_is_running = 0;
|
||||
//线体就绪
|
||||
int last_line_ready = 0;
|
||||
//回流满框请求
|
||||
int last_fl_full_req = 0;
|
||||
//空框请求
|
||||
int last_empty_req = 0;
|
||||
//任务完成
|
||||
int last_task_finish = 0;
|
||||
//回流在席光电(有货)
|
||||
int last_fl_move = 0;
|
||||
//在席光电状态
|
||||
int last_gd_move = 0;
|
||||
//允许放料斗
|
||||
int last_allow_put = 0;
|
||||
//料斗空
|
||||
int last_empty = 0;
|
||||
//回流报警
|
||||
int last_fl_error = 0;
|
||||
//任务号
|
||||
int last_task = 0;
|
||||
//模式 所有设备就绪
|
||||
int last_mode = 0;
|
||||
//报警信号
|
||||
int last_error = 0;
|
||||
//刻字上料重量
|
||||
int last_engraving_weight = 0;
|
||||
//剩余实时重量
|
||||
int last_engraving_storage_now_weight = 0;
|
||||
//上料总重量实际值
|
||||
int last_engraving_all_weight = 0;
|
||||
//回流实时重量
|
||||
int last_fl_now_weight = 0;
|
||||
//回流满框重量
|
||||
int last_fl_full_weight = 0;
|
||||
//料框条码
|
||||
int last_barcode = 0;
|
||||
//开机准备时间(S)
|
||||
int last_open_ready_time = 0;
|
||||
//设备运转时间(S)
|
||||
int last_device_running_time = 0;
|
||||
//待机时间(S)
|
||||
int last_await_time = 0;
|
||||
|
||||
//设备在线状态
|
||||
Boolean isonline = true;
|
||||
Boolean last_isonline = true;
|
||||
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
|
||||
|
||||
//申请任务请求时间
|
||||
private Date instruction_apply_time = new Date();
|
||||
private int instruction_require_time_out = 3000;
|
||||
|
||||
String noFeedAgvMessage;
|
||||
String noApplyTaskMessage = null;
|
||||
String noFeedMessage = null;
|
||||
|
||||
//申请任务请求成功标记
|
||||
Boolean requireSucess = false;
|
||||
//反馈设备状态请求标记
|
||||
Boolean feedDeviceStatusFlag = false;
|
||||
|
||||
//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()));
|
||||
|
||||
}
|
||||
|
||||
String device_code;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized void execute() {
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getItem_mode();//模式 所有设备就绪
|
||||
status = this.itemProtocol.getItem_status();//线体状态
|
||||
is_open = this.itemProtocol.getItem_is_open();//线体开机状态
|
||||
is_running = this.itemProtocol.getItem_is_running();//刻字机运行状态
|
||||
empty_req = this.itemProtocol.getItem_empty_req();//空箱请求
|
||||
fl_move = this.itemProtocol.getItem_fl_move();//回流在席光电(有货)
|
||||
allow_put = this.itemProtocol.getItem_allow_put();//允许放料斗
|
||||
line_ready = this.itemProtocol.getItem_line_ready();//线体就绪
|
||||
fl_full_req = this.itemProtocol.getItem_fl_full_req();//回流满框请求
|
||||
task_finish = this.itemProtocol.getItem_task_finish();//任务完成
|
||||
gd_move = this.itemProtocol.getItem_gd_move();//在席光电状态
|
||||
allow_put = this.itemProtocol.getItem_allow_put();//允许放料斗
|
||||
empty = this.itemProtocol.getItem_empty();//料斗空
|
||||
fl_error = this.itemProtocol.getItem_fl_error();//回流报警
|
||||
task = this.itemProtocol.getItem_task();//任务号
|
||||
error = this.itemProtocol.getItem_error();//报警信号
|
||||
engraving_weight = this.itemProtocol.getItem_engraving_weight();//刻字上料重量
|
||||
engraving_storage_now_weight = this.itemProtocol.getItem_engraving_storage_now_weight();//剩余实时重量
|
||||
engraving_all_weight = this.itemProtocol.getItem_engraving_all_weight();//上料总重量实际值
|
||||
fl_now_weight = this.itemProtocol.getItem_fl_now_weight();//回流实时重量
|
||||
fl_full_weight = this.itemProtocol.getItem_fl_full_weight();//回流满框重量
|
||||
barcode = this.itemProtocol.getItem_barcode();//料框条码
|
||||
open_ready_time = this.itemProtocol.getItem_open_ready_time();//开机准备时间(S)
|
||||
device_running_time = this.itemProtocol.getItem_device_running_time();//设备运转时间(S)
|
||||
await_time = this.itemProtocol.getItem_await_time(); //待机时间(S)
|
||||
|
||||
isonline = this.itemProtocol.getIsonline();
|
||||
|
||||
if (mode != last_mode) {
|
||||
feedDeviceStatusFlag = false;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
||||
}
|
||||
if (gd_move != last_gd_move) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_gd_move + "->" + gd_move);
|
||||
}
|
||||
if (status != last_status) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status);
|
||||
}
|
||||
if (is_open != last_is_open) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号is_open:" + last_is_open + "->" + is_open);
|
||||
}
|
||||
if (is_running != last_is_running) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号is_running:" + last_is_running + "->" + is_running);
|
||||
}
|
||||
if (empty_req != last_empty_req) {
|
||||
if (empty_req == 1) {
|
||||
requireSucess = false;
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号empty_req:" + last_empty_req + "->" + empty_req);
|
||||
}
|
||||
|
||||
if (fl_move != last_fl_move) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号fl_move:" + last_fl_move + "->" + fl_move);
|
||||
}
|
||||
if (allow_put != last_allow_put) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号allow_put:" + last_allow_put + "->" + allow_put);
|
||||
}
|
||||
if (line_ready != last_line_ready) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号line_ready:" + last_line_ready + "->" + line_ready);
|
||||
}
|
||||
if (fl_full_req != last_fl_full_req) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号fl_full_req:" + last_fl_full_req + "->" + fl_full_req);
|
||||
}
|
||||
if (line_ready != last_line_ready) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号line_ready:" + last_line_ready + "->" + line_ready);
|
||||
}
|
||||
if (error != last_error) {
|
||||
if (error != 0) {
|
||||
DeviceErrorLogDto dto = new DeviceErrorLogDto();
|
||||
dto.setDevice_code(device_code);
|
||||
dto.setError_code(String.valueOf(error));
|
||||
dto.setError_info(ErrorUtil.getDictDetail("eng_mach_error_type", String.valueOf(error)));
|
||||
deviceErrorLogService.create(dto);
|
||||
}
|
||||
if (error == 1 || error == 51) {
|
||||
feedDeviceStatusFlag = false;
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
||||
}
|
||||
if (fl_error != last_fl_error) {
|
||||
if (fl_error != 0) {
|
||||
DeviceErrorLogDto dto = new DeviceErrorLogDto();
|
||||
dto.setDevice_code(device_code);
|
||||
dto.setError_code(String.valueOf(fl_error));
|
||||
dto.setError_info(ErrorUtil.getDictDetail("eng_mach_error_type", String.valueOf(fl_error)));
|
||||
deviceErrorLogService.create(dto);
|
||||
}
|
||||
if (fl_error == 1 || fl_error == 51) {
|
||||
feedDeviceStatusFlag = false;
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
||||
}
|
||||
|
||||
if (task != last_task) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task);
|
||||
}
|
||||
if (mode != last_mode) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
||||
}
|
||||
if (engraving_weight != last_engraving_weight) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号engraving_weight:" + last_engraving_weight + "->" + engraving_weight);
|
||||
}
|
||||
if (engraving_storage_now_weight != last_engraving_storage_now_weight) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号engraving_storage_now_weight:" + last_engraving_storage_now_weight + "->" + engraving_storage_now_weight);
|
||||
}
|
||||
if (engraving_all_weight != last_engraving_all_weight) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号engraving_all_weight:" + last_engraving_all_weight + "->" + engraving_all_weight);
|
||||
}
|
||||
if (fl_now_weight != last_fl_now_weight) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号fl_now_weight:" + last_fl_now_weight + "->" + fl_now_weight);
|
||||
}
|
||||
if (fl_full_weight != last_fl_full_weight) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号fl_full_weight:" + last_fl_full_weight + "->" + fl_full_weight);
|
||||
}
|
||||
if (barcode != last_barcode) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号barcode:" + last_barcode + "->" + barcode);
|
||||
}
|
||||
if (open_ready_time != last_open_ready_time) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号open_ready_time:" + last_open_ready_time + "->" + open_ready_time);
|
||||
}
|
||||
if (device_running_time != last_device_running_time) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号device_running_time:" + last_device_running_time + "->" + device_running_time);
|
||||
}
|
||||
if (await_time != last_await_time) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号await_time:" + last_await_time + "->" + await_time);
|
||||
}
|
||||
if (isonline != last_isonline) {
|
||||
feedDeviceStatusFlag = false;
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号isonline:" + last_isonline + "->" + isonline);
|
||||
}
|
||||
|
||||
if (!this.itemProtocol.getIsonline() && !feedDeviceStatusFlag) {
|
||||
JSONObject chm = new JSONObject();
|
||||
chm.put("device_code", this.getDevice_code());
|
||||
//设备关机
|
||||
chm.put("status_type", StatusEnum.DEVICE_STATUS_CLOSE.getCode());
|
||||
chm.put("start_time", DateUtil.now());
|
||||
chm.put("error_code", "0");
|
||||
acsToWmsService.feedDeviceStatusType(chm);
|
||||
feedDeviceStatusFlag = true;
|
||||
} else if (this.itemProtocol.getIsonline() && (error == 1 || error == 51) && !feedDeviceStatusFlag) {
|
||||
JSONObject chm = new JSONObject();
|
||||
chm.put("device_code", this.getDevice_code());
|
||||
//设备报警
|
||||
chm.put("status_type", StatusEnum.DEVICE_STATUS_ERROR.getCode());
|
||||
chm.put("start_time", DateUtil.now());
|
||||
chm.put("error_code", String.valueOf(error));
|
||||
acsToWmsService.feedDeviceStatusType(chm);
|
||||
feedDeviceStatusFlag = true;
|
||||
} else if (this.itemProtocol.getIsonline() && mode == 1 && task > 0 && !feedDeviceStatusFlag) {
|
||||
JSONObject chm = new JSONObject();
|
||||
chm.put("device_code", this.getDevice_code());
|
||||
//设备生产中
|
||||
chm.put("status_type", StatusEnum.DEVICE_STATUS_PRODUCING.getCode());
|
||||
chm.put("start_time", DateUtil.now());
|
||||
chm.put("error_code", "0");
|
||||
acsToWmsService.feedDeviceStatusType(chm);
|
||||
feedDeviceStatusFlag = true;
|
||||
} else if (this.itemProtocol.getIsonline() && mode == 0 && task > 0 && !feedDeviceStatusFlag) {
|
||||
JSONObject chm = new JSONObject();
|
||||
chm.put("device_code", this.getDevice_code());
|
||||
//设备待生产
|
||||
chm.put("status_type", StatusEnum.DEVICE_STATUS_WAIT_PRODUCE.getCode());
|
||||
chm.put("start_time", DateUtil.now());
|
||||
chm.put("error_code", "0");
|
||||
acsToWmsService.feedDeviceStatusType(chm);
|
||||
feedDeviceStatusFlag = true;
|
||||
} else if (this.itemProtocol.getIsonline() && !feedDeviceStatusFlag) {
|
||||
JSONObject chm = new JSONObject();
|
||||
chm.put("device_code", this.getDevice_code());
|
||||
//设备开机
|
||||
chm.put("status_type", StatusEnum.DEVICE_STATUS_OPEN.getCode());
|
||||
chm.put("start_time", DateUtil.now());
|
||||
chm.put("error_code", "0");
|
||||
acsToWmsService.feedDeviceStatusType(chm);
|
||||
feedDeviceStatusFlag = true;
|
||||
}
|
||||
|
||||
// // 修改工单状态为生产中
|
||||
// if (mode == 1 && order > 0) {
|
||||
// ProduceshiftorderDto pdto = produceshiftorderService.findByCodeFromCache(String.valueOf(order));
|
||||
// if (pdto != null) {
|
||||
// if (pdto.getOrder_status().equals(WorkerOrderEnum.READY.getCode())) {
|
||||
// pdto.setOrder_status(WorkerOrderEnum.PRODUCTING.getCode());
|
||||
// produceshiftorderService.update(pdto);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//修改工单状态为自动完成
|
||||
// if (mode == 1 && order_finish != last_order_finish && order_finish == 1 && order > 0) {
|
||||
// ProduceshiftorderDto pdto = produceshiftorderService.findByCodeFromCache(String.valueOf(order));
|
||||
// if (pdto != null) {
|
||||
// if (pdto.getOrder_status().equals(WorkerOrderEnum.PRODUCTING.getCode())) {
|
||||
// produceshiftorderService.finished(pdto);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
} catch (Exception var17) {
|
||||
var17.printStackTrace();
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17 + ",inst == null :" + ObjectUtil.isEmpty(inst));
|
||||
}
|
||||
|
||||
if (!this.itemProtocol.getIsonline()) {
|
||||
//this.setIsonline(false);
|
||||
//this.setIserror(true);
|
||||
message = "信号量同步异常";
|
||||
//未联机
|
||||
} else if (mode == 0) {
|
||||
//this.setIsonline(false);
|
||||
//this.setIserror(true);
|
||||
message = "未联机";
|
||||
//有报警
|
||||
} else {
|
||||
//this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
message = "";
|
||||
//有货、联机、满料请求申请AGV搬运任务
|
||||
// if (gd_move == 1 && mode == 1 && empty_req == 1 && !requireSucess) {
|
||||
// boolean flag = apply_task();
|
||||
// this.noApplyTaskMessage = null;
|
||||
// if (flag) {
|
||||
// this.message = "申请满料任务成功";
|
||||
// }
|
||||
// } else {
|
||||
// if (empty_req == 1) {
|
||||
// String notApplyTaskMessage = "";
|
||||
// if (mode != 1) {
|
||||
// notApplyTaskMessage += "工作模式未联机,";
|
||||
// }
|
||||
// if (gd_move != 1) {
|
||||
// notApplyTaskMessage += "光电信号无货,";
|
||||
// }
|
||||
// if (requireSucess) {
|
||||
// notApplyTaskMessage += "请求标记未复位,";
|
||||
// }
|
||||
// this.noApplyTaskMessage = this.replace(notApplyTaskMessage);
|
||||
// }
|
||||
// }
|
||||
|
||||
//无货、联机、空箱请求申请AGV搬运任务
|
||||
if (gd_move == 0 && mode == 1 && empty_req == 1 && !requireSucess) {
|
||||
boolean flag = apply_empty_task();
|
||||
this.noApplyTaskMessage = null;
|
||||
if (flag) {
|
||||
this.message = "申请空箱任务成功";
|
||||
}
|
||||
} else {
|
||||
if (empty_req == 1) {
|
||||
String notApplyTaskMessage = "";
|
||||
if (mode != 1) {
|
||||
notApplyTaskMessage += "工作模式未联机,";
|
||||
}
|
||||
if (gd_move != 0) {
|
||||
notApplyTaskMessage += "光电信号有货,";
|
||||
}
|
||||
if (requireSucess) {
|
||||
notApplyTaskMessage += "请求标记未复位,";
|
||||
}
|
||||
this.noApplyTaskMessage = this.replace(notApplyTaskMessage);
|
||||
}
|
||||
}
|
||||
|
||||
//到达取货点
|
||||
if (agvphase == 0x03) {
|
||||
if (ObjectUtil.isNotEmpty(inst) && gd_move == 1) {
|
||||
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);
|
||||
noFeedAgvMessage = null;
|
||||
message = this.messageInfo(agvphase);
|
||||
logServer.deviceExecuteLog(device_code, "", "", this.messageInfo(agvphase));
|
||||
} else {
|
||||
String notFeedAgvMessage = "";
|
||||
if (gd_move == 0) {
|
||||
notFeedAgvMessage += "光电信号无货,";
|
||||
}
|
||||
if (inst == null) {
|
||||
notFeedAgvMessage += "AGV指令为空,";
|
||||
}
|
||||
this.noFeedAgvMessage = this.replace(notFeedAgvMessage);
|
||||
}
|
||||
}
|
||||
|
||||
//取货完成
|
||||
if (agvphase == 0x05) {
|
||||
if (ObjectUtil.isNotEmpty(inst) && gd_move == 0) {
|
||||
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);
|
||||
noFeedAgvMessage = null;
|
||||
message = this.messageInfo(agvphase);
|
||||
logServer.deviceExecuteLog(device_code, "", "", this.messageInfo(agvphase));
|
||||
} else {
|
||||
String notFeedAgvMessage = "";
|
||||
if (gd_move != 0) {
|
||||
notFeedAgvMessage += "光电信号有货,";
|
||||
}
|
||||
if (inst == null) {
|
||||
notFeedAgvMessage += "AGV指令为空,";
|
||||
}
|
||||
this.noFeedAgvMessage = this.replace(notFeedAgvMessage);
|
||||
}
|
||||
}
|
||||
|
||||
if (agvphase == 0x07) {
|
||||
if (ObjectUtil.isNotEmpty(inst) && gd_move == 0) {
|
||||
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);
|
||||
noFeedAgvMessage = null;
|
||||
message = this.messageInfo(agvphase);
|
||||
logServer.deviceExecuteLog(device_code, "", "", this.messageInfo(agvphase));
|
||||
} else {
|
||||
String notFeedAgvMessage = "";
|
||||
if (gd_move != 0) {
|
||||
notFeedAgvMessage += "光电信号有货,";
|
||||
}
|
||||
if (inst == null) {
|
||||
notFeedAgvMessage += "AGV指令为空,";
|
||||
}
|
||||
this.noFeedAgvMessage = this.replace(notFeedAgvMessage);
|
||||
}
|
||||
}
|
||||
|
||||
if (agvphase == 0x09) {
|
||||
if (ObjectUtil.isNotEmpty(inst) && mode == 1 && allow_put == 1) {
|
||||
//放框完成
|
||||
writing("to_agv_put_finish", "1");
|
||||
if (empty_req == 1){
|
||||
//判断电气上报的【剩余实时重量】>10kg 将【上料总重量】写给电气
|
||||
if (engraving_storage_now_weight > 10){
|
||||
writing("to_all_weight", String.valueOf(engraving_all_weight));
|
||||
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);
|
||||
noFeedAgvMessage = null;
|
||||
message = this.messageInfo(agvphase);
|
||||
logServer.deviceExecuteLog(device_code, "", "", this.messageInfo(agvphase));
|
||||
}else {
|
||||
writing("to_agv_put_finish", "1");
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
String notFeedAgvMessage = "";
|
||||
if (gd_move != 1) {
|
||||
notFeedAgvMessage += "光电信号无货,";
|
||||
}
|
||||
if (inst == null) {
|
||||
notFeedAgvMessage += "AGV指令为空,";
|
||||
}
|
||||
this.noFeedAgvMessage = this.replace(notFeedAgvMessage);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
last_status = status;
|
||||
last_is_open = is_open;
|
||||
last_is_running = is_running;
|
||||
last_line_ready = line_ready;
|
||||
last_fl_full_req = fl_full_req;
|
||||
last_empty_req = empty_req;
|
||||
last_task_finish = task_finish;
|
||||
last_fl_move = fl_move;
|
||||
last_gd_move = gd_move;
|
||||
last_allow_put = allow_put;
|
||||
last_empty = empty;
|
||||
last_fl_error = fl_error;
|
||||
last_task = task;
|
||||
last_mode = mode;
|
||||
last_error = error;
|
||||
last_engraving_weight = engraving_weight;
|
||||
last_engraving_storage_now_weight = engraving_storage_now_weight;
|
||||
last_engraving_all_weight = engraving_all_weight;
|
||||
last_fl_now_weight = fl_now_weight;
|
||||
last_fl_full_weight = fl_full_weight;
|
||||
last_barcode = barcode;
|
||||
last_open_ready_time = open_ready_time;
|
||||
last_device_running_time = device_running_time;
|
||||
last_await_time = await_time;
|
||||
last_isonline = isonline;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请取空框
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public synchronized boolean apply_empty_task() {
|
||||
if (redisUtils.hasKey("apply:" + this.device_code)) {
|
||||
return false;
|
||||
} else {
|
||||
redisUtils.setExpire(this.device_code, null, ApplyTaskTime.APPLY_TIME, TimeUnit.SECONDS);
|
||||
// ProduceshiftorderDto produceshiftorderDto = produceshiftorderService.findByCodeFromCache(String.valueOf(order));
|
||||
TaskDto taskDto = taskService.findByNextCode(device_code);
|
||||
if (taskDto == null) {
|
||||
JSONObject reqParam = new JSONObject();
|
||||
reqParam.put("type", StatusEnum.KZSL_EMPTY_REQ.getCode());
|
||||
reqParam.put("device_code", this.getDevice_code());
|
||||
reqParam.put("workorder_code", this.getTask());
|
||||
HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam);
|
||||
if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
|
||||
requireSucess = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Date date = new Date();
|
||||
// if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
// log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
// return false;
|
||||
// } else {
|
||||
// ProduceshiftorderDto produceshiftorderDto = produceshiftorderService.findByCodeFromCache(String.valueOf(order));
|
||||
// TaskDto taskDto = taskService.findByNextCode(device_code);
|
||||
// if (produceshiftorderDto != null && StrUtil.equals(produceshiftorderDto.getIs_needmove(), StatusEnum.NEED_MOVE.getCode()) && taskDto == null) {
|
||||
// JSONObject reqParam = new JSONObject();
|
||||
// reqParam.put("type", StatusEnum.KZ_EMPTY_REQ.getCode());
|
||||
// reqParam.put("device_code", this.getDevice_code());
|
||||
// reqParam.put("workorder_code", this.getOrder());
|
||||
// HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam);
|
||||
// if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
|
||||
// requireSucess = true;
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请满料任务
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
// public synchronized boolean apply_task() {
|
||||
// if (redisUtils.hasKey("apply:" + this.device_code)) {
|
||||
// return false;
|
||||
// } else {
|
||||
// redisUtils.setExpire(this.device_code, null, ApplyTaskTime.APPLY_TIME, TimeUnit.SECONDS);
|
||||
// ProduceshiftorderDto produceshiftorderDto = produceshiftorderService.findByCodeFromCache(String.valueOf(order));
|
||||
// TaskDto taskDto = taskService.findByStartCode(device_code);
|
||||
// if (produceshiftorderDto != null && StrUtil.equals(produceshiftorderDto.getIs_needmove(), StatusEnum.NEED_MOVE.getCode()) && taskDto == null) {
|
||||
// JSONObject reqParam = new JSONObject();
|
||||
// reqParam.put("device_code", this.getDevice_code());
|
||||
// reqParam.put("type", StatusEnum.KZ_FULL_REQ.getCode());
|
||||
//// reqParam.put("quantity", this.getPort_full_num());
|
||||
//// reqParam.put("workorder_code", this.getOrder());
|
||||
// HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam);
|
||||
// if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
|
||||
// JSONObject resp = JSONObject.parseObject(httpResponse.body());
|
||||
// if (resp.getInteger("status") == 200) {
|
||||
// requireSucess = true;
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// Date date = new Date();
|
||||
// if (date.getTime() - this.instruction_apply_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
// log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
// return false;
|
||||
// } else {
|
||||
// ProduceshiftorderDto produceshiftorderDto = produceshiftorderService.findByCodeFromCache(String.valueOf(order));
|
||||
// TaskDto taskDto = taskService.findByStartCode(device_code);
|
||||
// if (produceshiftorderDto != null && StrUtil.equals(produceshiftorderDto.getIs_needmove(), StatusEnum.NEED_MOVE.getCode()) && taskDto == null) {
|
||||
// JSONObject reqParam = new JSONObject();
|
||||
// reqParam.put("device_code", this.getDevice_code());
|
||||
// reqParam.put("type", StatusEnum.KZ_FULL_REQ.getCode());
|
||||
// reqParam.put("quantity", this.getPort_full_num());
|
||||
// reqParam.put("workorder_code", this.getOrder());
|
||||
// HttpResponse httpResponse = acsToWmsService.applyTaskToWms(reqParam);
|
||||
// if (ObjectUtil.isNotEmpty(httpResponse) && httpResponse.getStatus() == 200) {
|
||||
// JSONObject resp = JSONObject.parseObject(httpResponse.body());
|
||||
// if (resp.getInteger("status") == 200) {
|
||||
// requireSucess = true;
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 下发工单信息
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void issuedOrderInfo(ProduceshiftorderDto dto) {
|
||||
// if (!this.getItemProtocol().getIsonline()) {
|
||||
// throw new BadRequestException("设备未开机,工单下发失败!");
|
||||
// }
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_clear", "1");
|
||||
map.put("to_order", dto.getOrder_code());
|
||||
map.put("to_one_box_num", String.valueOf(dto.getOne_qty()));
|
||||
map.put("to_order_prod_num", String.valueOf(dto.getQty()));
|
||||
this.writing(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发工单完成信息
|
||||
*/
|
||||
@Override
|
||||
public void issuedOrderFinish(String autoFinish) {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
if (StrUtil.equals(autoFinish, WorkerOrderEnum.FORCEFINISH.getCode())) {
|
||||
map.put("to_order_compel_finished", "1");
|
||||
map.put("to_confirm_finished", "1");
|
||||
} else {
|
||||
map.put("to_confirm_finished", "1");
|
||||
}
|
||||
//map.put("to_order", "0");
|
||||
map.put("to_clear", "1");
|
||||
this.writing(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备暂停
|
||||
*/
|
||||
@Override
|
||||
public void toStop() {
|
||||
this.writing("to_pause", "1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备恢复
|
||||
*/
|
||||
@Override
|
||||
public void toStart() {
|
||||
this.writing("to_pause", "0");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备信息
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("mode", mode == 1 ? "联机" : "单机");
|
||||
jo.put("move", gd_move == 1 ? "有货" : "无货");
|
||||
jo.put("empty_req", empty_req == 1 ? "是" : "否");
|
||||
jo.put("full_req", empty_req == 1 ? "是" : "否");
|
||||
jo.put("full_finish", task_finish == 1 ? "是" : "否");
|
||||
// jo.put("order_finish", order_finish == 1 ? "是" : "否");
|
||||
jo.put("requireSucess", requireSucess.toString());
|
||||
// jo.put("order_now", order_now);
|
||||
// jo.put("one_now", one_now);
|
||||
jo.put("task", task);
|
||||
// jo.put("lettering_silo_number", lettering_silo_number);
|
||||
jo.put("error", ErrorUtil.getDictDetail("eng_mach_error_type", String.valueOf(this.getError())));
|
||||
jo.put("order", task);
|
||||
jo.put("isOnline", this.itemProtocol.getIsonline());
|
||||
jo.put("isError", this.getIserror());
|
||||
jo.put("message", this.getMessage());
|
||||
jo.put("noFeedAgvMessage", this.getNoFeedAgvMessage());
|
||||
jo.put("noApplyTaskMessage", this.getNoApplyTaskMessage());
|
||||
jo.put("is_click", true);
|
||||
jo.put("driver_type", "hailiang_engraving_machine");
|
||||
return jo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改设备状态
|
||||
* 复位请求标记
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
Boolean requireSucess = data.getBoolean("requireSucess");
|
||||
if (ObjectUtil.isNotEmpty(requireSucess))
|
||||
this.requireSucess = requireSucess;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_in;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class ItemProtocol {
|
||||
|
||||
public static String item_heartbeat = "heartbeat";
|
||||
public static String item_status = "status";//线体状态
|
||||
public static String item_is_open = "is_open";//线体开机状态
|
||||
public static String item_is_running = "is_running";//刻字机运行状态
|
||||
public static String item_line_ready = "line_ready";//线体就绪
|
||||
public static String item_mode = "mode";//模式 所有设备就绪
|
||||
public static String item_task_finish = "task_finish";//任务完成
|
||||
public static String item_fl_move = "fl_move";//回流在席光电(有货)
|
||||
public static String item_fl_full_req = "fl_full_req";//回流满框请求
|
||||
public static String item_gd_move = "gd_move";//在席光电状态
|
||||
public static String item_valve_open = "valve_open";//阀门开定位
|
||||
public static String item_valve_close = "valve_close";//阀门关定位
|
||||
public static String item_empty = "empty";//料斗空
|
||||
public static String item_empty_req = "empty_req";//请求取空料斗(空框请求)
|
||||
public static String item_allow_put = "allow_put"; //允许放料斗
|
||||
public static String item_error = "error"; //刻字报警信号(上料线体)
|
||||
public static String item_fl_error = "fl_error"; //回流报警信号
|
||||
public static String item_task = "task"; //任务号
|
||||
public static String item_open_ready_time = "open_ready_time"; //开机准备时间(S)
|
||||
public static String item_device_running_time = "device_running_time"; //设备运转时间(S)
|
||||
public static String item_await_time = "await_time"; //待机时间(S)
|
||||
public static String item_engraving_weight = "engraving_weight"; //刻字上料重量
|
||||
public static String item_engraving_storage_now_weight = "engraving_storage_now_weight"; //剩余实时重量
|
||||
public static String item_engraving_all_weight = "engraving_all_weight"; //上料总重量实际值
|
||||
public static String item_fl_now_weight = "fl_now_weight"; //回流实时重量
|
||||
public static String item_fl_full_weight = "fl_full_weight"; //回流满框重量
|
||||
public static String item_barcode = "barcode"; //料框条码
|
||||
|
||||
//开机
|
||||
public static String item_to_open = "to_open";
|
||||
//刻字机编号
|
||||
public static String item_to_engraving_sn = "to_engraving_sn";
|
||||
//清洗机开关
|
||||
public static String item_to_clean_open = "to_clean_open";
|
||||
//产量清零
|
||||
public static String item_to_clear = "to_clear";
|
||||
//确认完成(订单完成状态置零)
|
||||
public static String item_to_confirm_finished = "to_confirm_finished";
|
||||
//称重校验是否禁用
|
||||
public static String item_to_dis_weight = "to_dis_weight";
|
||||
//AGV放货完成
|
||||
public static String item_to_agv_put_finish = "to_agv_put_finish";
|
||||
//AGV取货完成
|
||||
public static String item_to_agv_take_finish = "to_agv_take_finish";
|
||||
//是否禁用条码
|
||||
public static String item_to_dis_barcode = "to_dis_barcode";
|
||||
//秤去皮
|
||||
public static String item_to_peel = "to_peel";
|
||||
//任务号
|
||||
public static String item_to_task = "to_task";
|
||||
//刻字上料重量
|
||||
public static String item_to_in_weight = "to_in_weight";
|
||||
//回流满框重量标准值
|
||||
public static String item_to_fl_full_weight = "to_fl_full_weight";
|
||||
//上料总重量
|
||||
public static String item_to_all_weight = "to_all_weight";
|
||||
//回流塑料框自重
|
||||
public static String item_to_fl_self_weight = "to_fl_self_weight";
|
||||
|
||||
private HailiangEngravingInDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(HailiangEngravingInDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
|
||||
public int getItem_heartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getItem_status() {
|
||||
return this.getOpcIntegerValue(item_status);
|
||||
}
|
||||
|
||||
public int getItem_is_open() {
|
||||
return this.getOpcIntegerValue(item_is_open);
|
||||
}
|
||||
|
||||
public int getItem_is_running() {
|
||||
return this.getOpcIntegerValue(item_is_running);
|
||||
}
|
||||
|
||||
public int getItem_line_ready() {
|
||||
return this.getOpcIntegerValue(item_line_ready);
|
||||
}
|
||||
|
||||
public int getItem_mode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getItem_task_finish() {
|
||||
return this.getOpcIntegerValue(item_task_finish);
|
||||
}
|
||||
|
||||
public int getItem_fl_move() {
|
||||
return this.getOpcIntegerValue(item_fl_move);
|
||||
}
|
||||
|
||||
public int getItem_fl_full_req() {
|
||||
return this.getOpcIntegerValue(item_fl_full_req);
|
||||
}
|
||||
|
||||
public int getItem_gd_move() {
|
||||
return this.getOpcIntegerValue(item_gd_move);
|
||||
}
|
||||
|
||||
public int getItem_valve_open() {
|
||||
return this.getOpcIntegerValue(item_valve_open);
|
||||
}
|
||||
|
||||
public int getItem_valve_close() {
|
||||
return this.getOpcIntegerValue(item_valve_close);
|
||||
}
|
||||
|
||||
public int getItem_empty() {
|
||||
return this.getOpcIntegerValue(item_empty);
|
||||
}
|
||||
|
||||
public int getItem_empty_req() {
|
||||
return this.getOpcIntegerValue(item_empty_req);
|
||||
}
|
||||
|
||||
public int getItem_allow_put() {
|
||||
return this.getOpcIntegerValue(item_allow_put);
|
||||
}
|
||||
|
||||
public int getItem_error() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getItem_fl_error() {
|
||||
return this.getOpcIntegerValue(item_fl_error);
|
||||
}
|
||||
|
||||
public int getItem_task() {
|
||||
return this.getOpcIntegerValue(item_task);
|
||||
}
|
||||
|
||||
public int getItem_open_ready_time() {
|
||||
return this.getOpcIntegerValue(item_open_ready_time);
|
||||
}
|
||||
|
||||
public int getItem_device_running_time() {
|
||||
return this.getOpcIntegerValue(item_device_running_time);
|
||||
}
|
||||
|
||||
public int getItem_await_time() {
|
||||
return this.getOpcIntegerValue(item_await_time);
|
||||
}
|
||||
|
||||
public int getItem_engraving_weight() {
|
||||
return this.getOpcIntegerValue(item_engraving_weight);
|
||||
}
|
||||
|
||||
public int getItem_engraving_storage_now_weight() {
|
||||
return this.getOpcIntegerValue(item_engraving_storage_now_weight);
|
||||
}
|
||||
|
||||
public int getItem_engraving_all_weight() {
|
||||
return this.getOpcIntegerValue(item_engraving_all_weight);
|
||||
}
|
||||
|
||||
public int getItem_fl_now_weight() {
|
||||
return this.getOpcIntegerValue(item_fl_now_weight);
|
||||
}
|
||||
|
||||
public int getItem_fl_full_weight() {
|
||||
return this.getOpcIntegerValue(item_fl_full_weight);
|
||||
}
|
||||
|
||||
public int getItem_barcode() {
|
||||
return this.getOpcIntegerValue(item_barcode);
|
||||
}
|
||||
|
||||
//是否有货
|
||||
public int hasGoods(int move) {
|
||||
return move;
|
||||
}
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB1.W82"));
|
||||
list.add(new ItemDto(item_status, "线体状态", "DB1.B0.0"));
|
||||
list.add(new ItemDto(item_is_open, "线体开机状态", "DB1.B0.1"));
|
||||
list.add(new ItemDto(item_is_running, "清洗机运行状态", "DB1.B0.3"));
|
||||
list.add(new ItemDto(item_line_ready, "线体就绪", "DB1.B0.7"));
|
||||
list.add(new ItemDto(item_mode, "模式", "DB1.B1.0"));
|
||||
list.add(new ItemDto(item_task_finish, "任务完成", "DB1.B1.3"));
|
||||
list.add(new ItemDto(item_fl_move, "回流在席光电(有货)", "DB1.B1.5"));
|
||||
list.add(new ItemDto(item_fl_full_req, "回流满框请求", "DB1.B1.7"));
|
||||
list.add(new ItemDto(item_gd_move, "在席光电状态", "DB1.B2.0"));
|
||||
list.add(new ItemDto(item_valve_open, "阀门开定位", "DB1.B2.1"));
|
||||
list.add(new ItemDto(item_valve_close, "阀门关定位", "DB1.B2.2"));
|
||||
list.add(new ItemDto(item_empty, "料斗空", "DB1.B2.3"));
|
||||
list.add(new ItemDto(item_empty_req, "请求取空料斗(空框请求)", "DB1.B2.4"));
|
||||
list.add(new ItemDto(item_allow_put, "允许放料斗", "DB1.B2.5"));
|
||||
list.add(new ItemDto(item_error, "刻字报警信号", "DB1.W4"));
|
||||
list.add(new ItemDto(item_fl_error, "回流报警信号", "DB1.W6"));
|
||||
list.add(new ItemDto(item_task, "任务号", "DB1.D92"));
|
||||
list.add(new ItemDto(item_open_ready_time, "开机准备时间", "DB1.D108"));
|
||||
list.add(new ItemDto(item_device_running_time, "设备运转时间", "DB1.D112"));
|
||||
list.add(new ItemDto(item_await_time, "待机时间", "DB1.D116"));
|
||||
list.add(new ItemDto(item_engraving_weight, "刻字上料重量", "DB1.D120"));
|
||||
list.add(new ItemDto(item_engraving_storage_now_weight, "剩余实时重量", "DB1.D124"));
|
||||
list.add(new ItemDto(item_engraving_all_weight, "上料总重量实际值", "DB1.D128"));
|
||||
list.add(new ItemDto(item_fl_now_weight, "回流实时重量", "DB1.D132"));
|
||||
list.add(new ItemDto(item_fl_full_weight, "回流满框重量", "DB1.D136"));
|
||||
list.add(new ItemDto(item_barcode, "料框条码", "DB1.D140"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_open, "设备开关", "DB2.W4", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_to_engraving_sn, "刻字机编号", "DB2.W6"));
|
||||
list.add(new ItemDto(item_to_clean_open, "清洗机开关", "DB2.W8"));
|
||||
list.add(new ItemDto(item_to_clear, "当前产量清零", "DB2.W12"));
|
||||
list.add(new ItemDto(item_to_confirm_finished, "确认完成", "DB2.W14"));
|
||||
list.add(new ItemDto(item_to_dis_weight, "称重校验是否禁用", "DB2.W16"));
|
||||
list.add(new ItemDto(item_to_confirm_finished, "任务确认完成", "DB2.W20"));
|
||||
list.add(new ItemDto(item_to_agv_put_finish, "AGV放货完成", "DB2.W24"));
|
||||
list.add(new ItemDto(item_to_agv_take_finish, "AGV取货完成", "DB2.W26"));
|
||||
list.add(new ItemDto(item_to_dis_barcode, "是否禁用条码", "DB2.W28"));
|
||||
list.add(new ItemDto(item_to_peel, "秤去皮", "DB2.W30"));
|
||||
list.add(new ItemDto(item_to_task, "任务号", "DB2.D92"));
|
||||
list.add(new ItemDto(item_to_in_weight, "刻字上料重量", "DB2.D96"));
|
||||
list.add(new ItemDto(item_to_fl_full_weight, "回流满框重量标准值", "DB2.D100"));
|
||||
list.add(new ItemDto(item_to_all_weight, "上料总重量", "DB2.D104"));
|
||||
list.add(new ItemDto(item_to_fl_self_weight, "回流塑料框自重", "DB2.D108"));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_frame_weighing;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
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 HailiangFrameWeighingDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "hailiang_frame_weighing";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "海亮-合框称重";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "海亮-合框称重";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new HailiangFrameWeighingDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return HailiangFrameWeighingDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.conveyor);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_frame_weighing;
|
||||
|
||||
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.StatusEnum;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.ApplyTaskTime;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.IssuedDeviceOrderInfo;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_cleaning_machine_storage_station.HailiangCleaningMachineStorageStationDeviceDriver;
|
||||
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.ErrorUtil;
|
||||
import org.nl.acs.history.service.DeviceErrorLogService;
|
||||
import org.nl.acs.history.service.dto.DeviceErrorLogDto;
|
||||
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
|
||||
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.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.order.service.ProduceshiftorderService;
|
||||
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
|
||||
import org.nl.acs.order.service.impl.ProduceshiftorderServiceImpl;
|
||||
import org.nl.modules.common.utils.RedisUtils;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 海亮-清洗上料线体
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class HailiangFrameWeighingDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, IssuedDeviceOrderInfo {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
@Autowired
|
||||
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
@Autowired
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
@Autowired
|
||||
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderServiceImpl.class);
|
||||
@Autowired
|
||||
RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
|
||||
//工作模式
|
||||
int mode = 0;
|
||||
//称就绪
|
||||
int weigh_ready = 0;
|
||||
//所有设备就绪
|
||||
int all_ready = 0;
|
||||
//人工称重作业中
|
||||
int hand_weigh = 0;
|
||||
//合框称重位1有料框
|
||||
int frame_weighing_one = 0;
|
||||
//合框称重位2有料框
|
||||
int frame_weighing_two = 0;
|
||||
//入库暂存位1有料框
|
||||
int in_one = 0;
|
||||
//入库暂存位2有料框
|
||||
int in_two = 0;
|
||||
//入库暂存位3有料框
|
||||
int in_three = 0;
|
||||
//入库暂存位4有料框
|
||||
int in_four = 0;
|
||||
//报警信号
|
||||
int error = 0;
|
||||
//AGV作业中
|
||||
int agv_working = 0;
|
||||
//心跳
|
||||
int heartbeat = 0;
|
||||
//称实时值
|
||||
int now_weigh = 0;
|
||||
//wcs获取称重值
|
||||
int acs_get_now_weigh = 0;
|
||||
|
||||
|
||||
int last_mode = 0;
|
||||
int last_weigh_ready = 0;
|
||||
int last_all_ready = 0;
|
||||
int last_hand_weigh = 0;
|
||||
int last_frame_weighing_one = 0;
|
||||
int last_frame_weighing_two = 0;
|
||||
int last_in_one = 0;
|
||||
int last_in_two = 0;
|
||||
int last_in_three = 0;
|
||||
int last_in_four = 0;
|
||||
int last_error = 0;
|
||||
int last_agv_working = 0;
|
||||
int last_heartbeat = 0;
|
||||
int last_now_weigh = 0;
|
||||
int last_acs_get_now_weigh = 0;
|
||||
|
||||
Boolean isonline = true;
|
||||
String message = null;
|
||||
String noApplyTaskMessage = null;
|
||||
String noFeedMessage = null;
|
||||
Boolean iserror = false;
|
||||
|
||||
//请求成功标记
|
||||
Boolean requireSucess = false;
|
||||
|
||||
private Date instruction_apply_time = new Date();
|
||||
private int instruction_require_time_out = 3000;
|
||||
|
||||
//当前指令
|
||||
Instruction inst = null;
|
||||
|
||||
String device_code;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getItem_mode();
|
||||
weigh_ready = this.itemProtocol.getItem_weigh_ready();
|
||||
all_ready = this.itemProtocol.getItem_all_ready();
|
||||
hand_weigh = this.itemProtocol.getItem_hand_weigh();
|
||||
frame_weighing_one = this.itemProtocol.getItem_frame_weighing_one();
|
||||
frame_weighing_two = this.itemProtocol.getItem_frame_weighing_two();
|
||||
in_one = this.itemProtocol.getItem_in_one();
|
||||
in_two = this.itemProtocol.getItem_in_two();
|
||||
in_three = this.itemProtocol.getItem_in_three();
|
||||
in_four = this.itemProtocol.getItem_in_four();
|
||||
error = this.itemProtocol.getItem_error();
|
||||
agv_working = this.itemProtocol.getItem_agv_working();
|
||||
heartbeat = this.itemProtocol.getItem_heartbeat();
|
||||
now_weigh = this.itemProtocol.getItem_now_weigh();
|
||||
acs_get_now_weigh = this.itemProtocol.getItem_acs_get_now_weigh();
|
||||
|
||||
if (mode != last_mode) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
||||
}
|
||||
if (weigh_ready != last_weigh_ready) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号weigh_ready:" + last_weigh_ready + "->" + weigh_ready);
|
||||
}
|
||||
if (all_ready != last_all_ready) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号all_ready:" + last_all_ready + "->" + all_ready);
|
||||
}
|
||||
if (hand_weigh != last_hand_weigh) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号hand_weigh:" + last_hand_weigh + "->" + hand_weigh);
|
||||
}
|
||||
if (frame_weighing_one != last_frame_weighing_one) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号frame_weighing_one:" + last_frame_weighing_one + "->" + frame_weighing_one);
|
||||
}
|
||||
if (frame_weighing_two != last_frame_weighing_two) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号frame_weighing_two:" + last_frame_weighing_two + "->" + frame_weighing_two);
|
||||
}
|
||||
if (in_one != last_in_one) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号in_one:" + last_in_one + "->" + in_one);
|
||||
}
|
||||
if (in_two != last_in_two) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号in_two:" + last_in_two + "->" + in_two);
|
||||
}
|
||||
if (in_three != last_in_three) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号in_three:" + last_in_three + "->" + in_three);
|
||||
}
|
||||
if (in_four != last_in_four) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号in_four:" + last_in_four + "->" + in_four);
|
||||
}
|
||||
if (agv_working != last_agv_working) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号agv_working:" + last_agv_working + "->" + agv_working);
|
||||
}
|
||||
if (heartbeat != last_heartbeat) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号heartbeat:" + last_heartbeat + "->" + heartbeat);
|
||||
}
|
||||
if (now_weigh != last_now_weigh) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号now_weigh:" + last_now_weigh + "->" + now_weigh);
|
||||
}
|
||||
if (acs_get_now_weigh != last_acs_get_now_weigh) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号acs_get_now_weigh:" + last_acs_get_now_weigh + "->" + acs_get_now_weigh);
|
||||
}
|
||||
if (error != last_error) {
|
||||
if (error != 0) {
|
||||
DeviceErrorLogDto dto = new DeviceErrorLogDto();
|
||||
dto.setDevice_code(device_code);
|
||||
dto.setError_code(String.valueOf(error));
|
||||
dto.setError_info(ErrorUtil.getDictDetail("clean_up_error_type", String.valueOf(error)));
|
||||
deviceErrorLogService.create(dto);
|
||||
}
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
||||
}
|
||||
|
||||
|
||||
} catch (Exception var17) {
|
||||
var17.printStackTrace();
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17 + ",inst == null :" + ObjectUtil.isEmpty(inst));
|
||||
}
|
||||
|
||||
if (!this.itemProtocol.getIsonline()) {
|
||||
//this.setIsonline(false);
|
||||
//this.setIserror(true);
|
||||
message = "信号量同步异常";
|
||||
//未联机
|
||||
} else if (mode == 0) {
|
||||
//this.setIsonline(false);
|
||||
//this.setIserror(true);
|
||||
message = "未联机";
|
||||
//有报警
|
||||
} else {
|
||||
// this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_weigh_ready = weigh_ready;
|
||||
last_all_ready = all_ready;
|
||||
last_hand_weigh = hand_weigh;
|
||||
last_frame_weighing_one = frame_weighing_one;
|
||||
last_frame_weighing_two = frame_weighing_two;
|
||||
last_in_one = in_one;
|
||||
last_in_two = in_two;
|
||||
last_in_three = in_three;
|
||||
last_in_four = in_four;
|
||||
last_error = error;
|
||||
last_agv_working = agv_working;
|
||||
last_heartbeat = heartbeat;
|
||||
last_now_weigh = now_weigh;
|
||||
last_acs_get_now_weigh = acs_get_now_weigh;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取设备监控信息
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("mode", mode == 1 ? "联机" : "单机");
|
||||
jo.put("all_ready", all_ready == 1 ? "是" : "否");
|
||||
jo.put("hand_weigh", hand_weigh == 1 ? "是" : "否");
|
||||
jo.put("frame_weighing_one", frame_weighing_one == 1 ? "是" : "否");
|
||||
jo.put("frame_weighing_two", frame_weighing_two == 1 ? "是" : "否");
|
||||
jo.put("in_one", in_one == 1 ? "是" : "否");
|
||||
jo.put("in_two", in_two == 1 ? "是" : "否");
|
||||
jo.put("in_three", in_three == 1 ? "是" : "否");
|
||||
jo.put("in_four", in_four == 1 ? "是" : "否");
|
||||
jo.put("isOnline", this.itemProtocol.getIsonline());
|
||||
jo.put("error", ErrorUtil.getDictDetail("clean_up_error_type", String.valueOf(this.getError())));
|
||||
jo.put("isError", this.getIserror());
|
||||
jo.put("agv_working", agv_working == 1 ? "是" : "否");
|
||||
jo.put("heartbeat", this.itemProtocol.getItem_heartbeat());
|
||||
jo.put("now_weigh", this.itemProtocol.getItem_now_weigh());
|
||||
jo.put("acs_get_now_weigh", this.itemProtocol.getItem_acs_get_now_weigh());
|
||||
jo.put("driver_type", "hailiang_frame_weighing");
|
||||
jo.put("is_click", true);
|
||||
return jo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改设备信息
|
||||
* 复位请求标记
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
Boolean requireSucess = data.getBoolean("requireSucess");
|
||||
if (ObjectUtil.isNotEmpty(requireSucess))
|
||||
this.requireSucess = requireSucess;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发工单信息
|
||||
* 清洗上料设备特殊 mes中无工单 acs主要是为了记录信息 反馈给mes
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void issuedOrderInfo(ProduceshiftorderDto dto) {
|
||||
HailiangCleaningMachineStorageStationDeviceDriver hailiangCleaningMachineStorageStationDeviceDriver;
|
||||
String[] in_devices = dto.getIn_devices().split(",");
|
||||
//上料储料仓总重量
|
||||
int weightSum = 0;
|
||||
//上料储料仓总数量
|
||||
int qtySum = 0;
|
||||
//遍历上料储料仓设备 求重量和数量和下发给清洗上料位
|
||||
for (int i = 0; i < in_devices.length; i++) {
|
||||
String in_device = in_devices[i];
|
||||
Device device = deviceAppService.findDeviceByCode(in_device);
|
||||
if (device != null) {
|
||||
hailiangCleaningMachineStorageStationDeviceDriver = (HailiangCleaningMachineStorageStationDeviceDriver) device.getDeviceDriver();
|
||||
weightSum += hailiangCleaningMachineStorageStationDeviceDriver.getSilo_weight();
|
||||
qtySum += hailiangCleaningMachineStorageStationDeviceDriver.getFull_number();
|
||||
hailiangCleaningMachineStorageStationDeviceDriver.writing("to_feeding", "1");
|
||||
}
|
||||
}
|
||||
//下发电气信号
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_pcsn",dto.getOrder_id());//下发批次号,暂时用工单号
|
||||
map.put("to_all_num", String.valueOf(qtySum));
|
||||
map.put("to_all_weight", String.valueOf(weightSum));
|
||||
map.put("to_in_confirm_finish", "1");
|
||||
this.writing(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发工单完成信息
|
||||
*/
|
||||
@Override
|
||||
public void issuedOrderFinish(String autoFinish) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备暂停调用方法
|
||||
*/
|
||||
@Override
|
||||
public void toStop() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设备启动调用方法
|
||||
*/
|
||||
@Override
|
||||
public void toStart() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_frame_weighing;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Data
|
||||
public class ItemProtocol {
|
||||
|
||||
public static String item_mode = "mode"; //工作模式
|
||||
public static String item_weigh_ready = "weigh_ready"; //称就绪
|
||||
public static String item_all_ready = "all_ready"; //所有设备就绪
|
||||
public static String item_hand_weigh = "hand_weigh";//人工称重作业中
|
||||
public static String item_frame_weighing_one = "frame_weighing_one"; //合框称重位1有料框
|
||||
public static String item_frame_weighing_two = "frame_weighing_two"; //合框称重位2有料框
|
||||
public static String item_in_one = "in_one"; //入库暂存位1有料框
|
||||
public static String item_in_two = "in_two"; //入库暂存位2有料框
|
||||
public static String item_in_three = "in_three"; //入库暂存位3有料框
|
||||
public static String item_in_four = "in_four"; //入库暂存位4有料框
|
||||
public static String item_error = "error"; //报警信号
|
||||
public static String item_agv_working = "agv_working";//AGV作业中
|
||||
public static String item_heartbeat = "heartbeat";//心跳
|
||||
public static String item_now_weigh = "now_weigh";//称实时值
|
||||
public static String item_acs_get_now_weigh = "acs_get_now_weigh";//wcs获取称重值
|
||||
|
||||
|
||||
//AGV作业中
|
||||
public static String item_to_agv_working = "to_agv_working";
|
||||
//获取称重值
|
||||
public static String item_to_get_now_weigh = "to_get_now_weigh";
|
||||
|
||||
|
||||
private HailiangFrameWeighingDriver driver;
|
||||
|
||||
public ItemProtocol(HailiangFrameWeighingDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getItem_mode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getItem_weigh_ready() {
|
||||
return this.getOpcIntegerValue(item_weigh_ready);
|
||||
}
|
||||
|
||||
public int getItem_all_ready() {
|
||||
return this.getOpcIntegerValue(item_all_ready);
|
||||
}
|
||||
|
||||
public int getItem_hand_weigh() {
|
||||
return this.getOpcIntegerValue(item_hand_weigh);
|
||||
}
|
||||
|
||||
public int getItem_frame_weighing_one() {
|
||||
return this.getOpcIntegerValue(item_frame_weighing_one);
|
||||
}
|
||||
|
||||
public int getItem_frame_weighing_two() {
|
||||
return this.getOpcIntegerValue(item_frame_weighing_two);
|
||||
}
|
||||
|
||||
public int getItem_in_one() {
|
||||
return this.getOpcIntegerValue(item_in_one);
|
||||
}
|
||||
|
||||
public int getItem_in_two() {
|
||||
return this.getOpcIntegerValue(item_in_two);
|
||||
}
|
||||
|
||||
public int getItem_in_three() {
|
||||
return this.getOpcIntegerValue(item_in_three);
|
||||
}
|
||||
|
||||
public int getItem_in_four() {
|
||||
return this.getOpcIntegerValue(item_in_four);
|
||||
}
|
||||
|
||||
public int getItem_error() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getItem_agv_working() {
|
||||
return this.getOpcIntegerValue(item_agv_working);
|
||||
}
|
||||
|
||||
public int getItem_heartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getItem_now_weigh() {
|
||||
return this.getOpcIntegerValue(item_now_weigh);
|
||||
}
|
||||
|
||||
public int getItem_acs_get_now_weigh() {
|
||||
return this.getOpcIntegerValue(item_acs_get_now_weigh);
|
||||
}
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB1.B0.0"));
|
||||
list.add(new ItemDto(item_weigh_ready, "称就绪", "DB1.B0.5"));
|
||||
list.add(new ItemDto(item_all_ready, "所有设备就绪", "DB1.B0.6"));
|
||||
list.add(new ItemDto(item_hand_weigh, "人工称重作业中", "DB1.B0.7"));
|
||||
list.add(new ItemDto(item_frame_weighing_one, "合框称重位1有料框", "DB1.B1.0"));
|
||||
list.add(new ItemDto(item_frame_weighing_two, "合框称重位2有料框", "DB1.B1.1"));
|
||||
list.add(new ItemDto(item_in_one, "入库暂存位1有料框", "DB1.B1.2"));
|
||||
list.add(new ItemDto(item_in_two, "入库暂存位2有料框", "DB1.B1.3"));
|
||||
list.add(new ItemDto(item_in_three, "入库暂存位3有料框", "DB1.B1.4"));
|
||||
list.add(new ItemDto(item_in_four, "入库暂存位4有料框", "DB1.B1.5"));
|
||||
list.add(new ItemDto(item_error, "故障信息", "DB1.W4"));
|
||||
list.add(new ItemDto(item_agv_working, "AGV作业中", "DB1.W18"));
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB1.W82"));
|
||||
list.add(new ItemDto(item_now_weigh, "称实时值", "DB1.D108"));
|
||||
list.add(new ItemDto(item_acs_get_now_weigh, "wcs获取称重值", "DB1.D112"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_agv_working, "AGV作业中", "DB2.W18"));
|
||||
list.add(new ItemDto(item_to_get_now_weigh, "获取称重值", "DB2.W20"));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ public class ItemProtocol {
|
||||
list.add(new ItemDto(item_now_bag_num_of_box, "当前装箱机箱实时袋数量", "DB1.D128"));
|
||||
list.add(new ItemDto(item_now_bag_num, "当前装箱机袋装的总数量", "DB1.D132"));
|
||||
list.add(new ItemDto(item_now_seal_box_num, "当前封箱数量", "DB1.D136"));
|
||||
list.add(new ItemDto(item_to_order, "工单号", "DB1.D160"));
|
||||
list.add(new ItemDto(item_order, "工单号", "DB1.D160"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.nl.acs.opc.DeviceExtraManageDto;
|
||||
import org.nl.acs.order.service.ProduceshiftorderService;
|
||||
import org.nl.acs.order.service.dto.EalingOrderDto;
|
||||
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
|
||||
import org.nl.acs.order.service.dto.UnboxingOrderDto;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
@@ -259,6 +260,28 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
String tray_num = param.getString("tray_num");
|
||||
|
||||
Map<String, Object> extra_map = param.getJSONObject("extra_map");
|
||||
|
||||
Map<String, Object> package_ext = param.getJSONObject("package_ext");
|
||||
|
||||
EalingOrderDto ealingOrderDto = new EalingOrderDto();
|
||||
// UnboxingOrderDto unboxingOrderDto = null;
|
||||
if (ObjectUtil.isNotEmpty(package_ext)) {
|
||||
//是否启用封箱线
|
||||
is_used_fxx = ObjectUtil.isEmpty(package_ext.get("is_used_fxx")) ? null : package_ext.get("is_used_fxx").toString();
|
||||
//拆箱数量
|
||||
// unboxingOrderDto.setOrder_box_num(ObjectUtil.isEmpty(package_ext.get("demol_num")) ? null : package_ext.get("demol_num").toString());
|
||||
ealingOrderDto.setOrder_box_num(ObjectUtil.isEmpty(package_ext.get("demol_num")) ? null : package_ext.get("demol_num").toString());
|
||||
//装箱模版
|
||||
ealingOrderDto.setTemplate_no(ObjectUtil.isEmpty(package_ext.get("package_model")) ? null : package_ext.get("package_model").toString());
|
||||
//码盘模版
|
||||
lane_tray_template= ObjectUtil.isEmpty(package_ext.get("stack_model")) ? null : package_ext.get("stack_model").toString();
|
||||
//是否正反转
|
||||
ealingOrderDto.setIs_foreward(ObjectUtil.isEmpty(package_ext.get("is_foreward")) ? null : package_ext.get("is_foreward").toString());
|
||||
//袋数
|
||||
ealingOrderDto.setOrder_bag_num(ObjectUtil.isEmpty(package_ext.get("order_bag_num")) ? null : package_ext.get("order_bag_num").toString());
|
||||
}
|
||||
ealingOrderDto.setOrder_code(workorder_code);
|
||||
|
||||
String one_box_package_qty = "";
|
||||
String package_qty = "";
|
||||
String one_package_qty = "";
|
||||
@@ -291,7 +314,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
|
||||
}
|
||||
|
||||
Map<String, Object> params = param.getJSONObject("params");
|
||||
EalingOrderDto ealingOrderDto = null;
|
||||
|
||||
if (ObjectUtil.isNotEmpty(params)) {
|
||||
ealingOrderDto = JSONObject.toJavaObject(JSON.parseObject(JSON.toJSONString(params)), EalingOrderDto.class);
|
||||
ealingOrderDto.setOrder_code(workorder_code);
|
||||
|
||||
Reference in New Issue
Block a user