add 老车间驱动
This commit is contained in:
@@ -97,7 +97,11 @@ public enum DriverTypeEnum {
|
||||
|
||||
HAILIANG_OLD_LETTERING_PACKAGE_DRIVER(44, "hailiang_old_lettering_package_device", "老车间-刻字包装机", "conveyor"),
|
||||
|
||||
HAILIANG_OLD_PACKAGE_SSX_DRIVER(45, "hailiang_old_package_ssx_station", "老车间-刻字包装输送线", "conveyor");
|
||||
HAILIANG_OLD_PACKAGE_SSX_DRIVER(45, "hailiang_old_package_ssx_station", "老车间-刻字包装输送线", "conveyor"),
|
||||
|
||||
HAILIANG_OLD_UNBOXING_MACHINE_DRIVER(46, "hailiang_old_unboxing_machine", "海亮-老车间-开箱机", "conveyor"),
|
||||
|
||||
HAILIANG_OLD_PACKAGE_RECVIEING_DRIVER(47, "hailiang_old_package_receiving_machine", "海亮-老车间-包装接料位", "conveyor");
|
||||
|
||||
|
||||
//驱动索引
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_package_receiving_station;
|
||||
|
||||
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 HailiangOldPackageReceivingStationDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "hailiang_old_package_receiving_machine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "海亮-老车间-包装接料位";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "海亮-老车间-包装接料位";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new HailiangOldPackageReceivingStationDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return HailiangOldPackageReceivingStationDeviceDriver.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,197 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_package_receiving_station;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.acsEnum.WorkerOrderEnum;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.IssuedDeviceOrderInfo;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.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.order.service.dto.EalingOrderDto;
|
||||
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 包装接料位
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class HailiangOldPackageReceivingStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, IssuedDeviceOrderInfo {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
@Autowired
|
||||
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
|
||||
|
||||
int heartbeat = 0;
|
||||
int mode = 0;
|
||||
int unboxing_error = 0;
|
||||
int unboxing_running = 0;
|
||||
int unboxing_ready = 0;
|
||||
int order_finish = 0;
|
||||
int order_compel_finish = 0;
|
||||
int error = 0;
|
||||
int now_order_num = 0;
|
||||
int task = 0;
|
||||
int open_ready_time = 0;
|
||||
int device_running_time = 0;
|
||||
int await_time = 0;
|
||||
int order = 0;
|
||||
|
||||
int last_heartbeat = 0;
|
||||
int last_mode = 0;
|
||||
int last_unboxing_error = 0;
|
||||
int last_unboxing_running = 0;
|
||||
int last_unboxing_ready = 0;
|
||||
int last_order_finish = 0;
|
||||
int last_order_compel_finish = 0;
|
||||
int last_error = 0;
|
||||
int last_now_order_num = 0;
|
||||
int last_task = 0;
|
||||
int last_open_ready_time = 0;
|
||||
int last_device_running_time = 0;
|
||||
int last_await_time = 0;
|
||||
int last_order = 0;
|
||||
|
||||
|
||||
Boolean isonline = true;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
|
||||
private int instruction_require_time_out;
|
||||
boolean requireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
String device_code = null;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
error = this.itemProtocol.getError();
|
||||
|
||||
|
||||
|
||||
if (mode != last_mode) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记");
|
||||
}
|
||||
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("unbox_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);
|
||||
}
|
||||
|
||||
if (!this.itemProtocol.getIsonline()) {
|
||||
//this.setIsonline(false);
|
||||
//this.setIserror(true);
|
||||
message = "信号量同步异常";
|
||||
//未联机
|
||||
} else if (mode == 0) {
|
||||
message = "未联机";
|
||||
} else {
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
}
|
||||
last_mode = mode;
|
||||
last_unboxing_error = unboxing_error;
|
||||
last_unboxing_running = unboxing_running;
|
||||
last_unboxing_ready = unboxing_ready;
|
||||
last_order_finish = order_finish;
|
||||
last_order_compel_finish = order_compel_finish;
|
||||
last_error = error;
|
||||
last_now_order_num = now_order_num;
|
||||
last_task = task;
|
||||
last_order = order;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("mode", mode == 1 ? "联机" : "未联机");
|
||||
jo.put("order_finish", order_finish == 1 ? "是" : "否");
|
||||
jo.put("order_compel_finish", order_compel_finish == 1 ? "是" : "否");
|
||||
jo.put("error", ErrorUtil.getDictDetail("unbox_error_type", String.valueOf(error)));
|
||||
jo.put("now_order_num", now_order_num);
|
||||
jo.put("task", task);
|
||||
jo.put("order", order);
|
||||
jo.put("isOnline", this.itemProtocol.getIsonline());
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void issuedOrderInfo(ProduceshiftorderDto dto) {
|
||||
EalingOrderDto ealingOrderDto = dto.getEalingOrderDto();
|
||||
if (ealingOrderDto != null) {
|
||||
String is_foreward = ealingOrderDto.getIs_foreward();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("to_clear", "1");
|
||||
map.put("to_is_foreward", is_foreward);
|
||||
map.put("to_order_box_num", ealingOrderDto.getOrder_box_num());
|
||||
map.put("to_order", ealingOrderDto.getOrder_code());
|
||||
this.writing(map);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void issuedOrderFinish(String autoFinish) {
|
||||
if (StrUtil.equals(autoFinish, WorkerOrderEnum.FORCEFINISH.getCode())) {
|
||||
this.writing("to_order_compel_finished", "1");
|
||||
} else {
|
||||
this.writing("to_confirm_finished", "1");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toStop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toStart() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_package_receiving_station;
|
||||
|
||||
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_old.hailiang_old_package_ssx.HailiangLetteringPackageSsxDeviceDriver;
|
||||
|
||||
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_move = "move";
|
||||
public static String item_action = "action";
|
||||
public static String item_error = "error";
|
||||
public static String item_is_full = "is_full";
|
||||
public static String item_task = "task";
|
||||
|
||||
|
||||
public static String item_to_command = "to_command";
|
||||
public static String item_to_target = "to_target";
|
||||
public static String item_to_task = "to_task";
|
||||
|
||||
|
||||
|
||||
private HailiangOldPackageReceivingStationDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(HailiangOldPackageReceivingStationDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getMove() {
|
||||
return this.getOpcIntegerValue(item_move);
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
}
|
||||
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getIs_full() {
|
||||
return this.getOpcIntegerValue(item_is_full);
|
||||
}
|
||||
|
||||
public int getTask() {
|
||||
return this.getOpcIntegerValue(item_task);
|
||||
}
|
||||
|
||||
public int getToCommand() {
|
||||
return this.getOpcIntegerValue(item_to_command);
|
||||
}
|
||||
|
||||
public int getToTarget() {
|
||||
return this.getOpcIntegerValue(item_to_target);
|
||||
}
|
||||
|
||||
public int getToTask() {
|
||||
return this.getOpcIntegerValue(item_to_task);
|
||||
}
|
||||
|
||||
//是否有货
|
||||
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 String getOpcStringValue(String protocol) {
|
||||
String value = this.driver.getStringValue(protocol);
|
||||
if (value == null) {
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.W0"));
|
||||
list.add(new ItemDto(item_mode, "工作状态", "DB600.W2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_move, "光电开关信号", "DB600.W4"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "DB600.W6"));
|
||||
list.add(new ItemDto(item_is_full, "是否满料", "DB600.W8"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB600.W10"));
|
||||
list.add(new ItemDto(item_task, "任务号", "DB600.D12"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "下发作业命令", "DB601.W2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W4"));
|
||||
list.add(new ItemDto(item_to_task, "任务号", "DB601.D6"));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@ import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 包装输送线
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
public class ItemProtocol {
|
||||
@@ -116,24 +118,24 @@ public class ItemProtocol {
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "VW0"));
|
||||
list.add(new ItemDto(item_mode, "工作状态", "VW2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_move, "光电开关信号", "VW4"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "VW6"));
|
||||
list.add(new ItemDto(item_direction, "电机方向", "VW8"));
|
||||
list.add(new ItemDto(item_vehicle_type, "托盘类型", "VW10"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "VW12"));
|
||||
list.add(new ItemDto(item_task, "任务号", "VD14"));
|
||||
list.add(new ItemDto(item_barcode, "条码", "WB18.20"));
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.W0"));
|
||||
list.add(new ItemDto(item_mode, "工作状态", "DB600.W2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_move, "光电开关信号", "DB600.W4"));
|
||||
list.add(new ItemDto(item_action, "取放信号", "DB600.W6"));
|
||||
list.add(new ItemDto(item_direction, "电机方向", "DB600.W8"));
|
||||
list.add(new ItemDto(item_vehicle_type, "托盘类型", "DB600.W10"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB600.W12"));
|
||||
list.add(new ItemDto(item_task, "任务号", "DB600.D14"));
|
||||
list.add(new ItemDto(item_barcode, "条码", "DB600.STRING18.20"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "下发作业命令", "VW2", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_to_target, "下发目标站", "VW4"));
|
||||
list.add(new ItemDto(item_to_vehicle_type, "下发托盘类型", "VW6"));
|
||||
list.add(new ItemDto(item_to_task, "任务号", "VD8"));
|
||||
list.add(new ItemDto(item_to_command, "下发作业命令", "DB601.W0", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_to_target, "下发目标站", "DB601.W2"));
|
||||
list.add(new ItemDto(item_to_vehicle_type, "下发托盘类型", "DB601.W4"));
|
||||
list.add(new ItemDto(item_to_task, "任务号", "DB601.D6"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@ import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 海亮老车间码垛机械手
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
public class ItemProtocol {
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_unboxing_machine;
|
||||
|
||||
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 HailiangOldUnboxingMachineDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "hailiang_old_unboxing_machine";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "海亮-老车间-开箱机";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "海亮-老车间-开箱机";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new HailiangOldUnboxingMachineDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return HailiangOldUnboxingMachineDeviceDriver.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,189 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_unboxing_machine;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.acsEnum.WorkerOrderEnum;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.IssuedDeviceOrderInfo;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.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.order.service.dto.EalingOrderDto;
|
||||
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 开箱机
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class HailiangOldUnboxingMachineDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, IssuedDeviceOrderInfo {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
@Autowired
|
||||
DeviceErrorLogService deviceErrorLogService = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
|
||||
|
||||
int heartbeat = 0;
|
||||
int mode = 0;
|
||||
int unboxing_error = 0;
|
||||
int unboxing_running = 0;
|
||||
int unboxing_ready = 0;
|
||||
int order_finish = 0;
|
||||
int order_compel_finish = 0;
|
||||
int error = 0;
|
||||
int now_order_num = 0;
|
||||
int task = 0;
|
||||
int open_ready_time = 0;
|
||||
int device_running_time = 0;
|
||||
int await_time = 0;
|
||||
int order = 0;
|
||||
|
||||
int last_heartbeat = 0;
|
||||
int last_mode = 0;
|
||||
int last_unboxing_error = 0;
|
||||
int last_unboxing_running = 0;
|
||||
int last_unboxing_ready = 0;
|
||||
int last_order_finish = 0;
|
||||
int last_order_compel_finish = 0;
|
||||
int last_error = 0;
|
||||
int last_now_order_num = 0;
|
||||
int last_task = 0;
|
||||
int last_open_ready_time = 0;
|
||||
int last_device_running_time = 0;
|
||||
int last_await_time = 0;
|
||||
int last_order = 0;
|
||||
|
||||
|
||||
Boolean isonline = true;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
|
||||
private int instruction_require_time_out;
|
||||
boolean requireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
String device_code = null;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
error = this.itemProtocol.getError();
|
||||
|
||||
if (mode != last_mode) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记");
|
||||
}
|
||||
|
||||
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("unbox_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);
|
||||
}
|
||||
|
||||
if (!this.itemProtocol.getIsonline()) {
|
||||
//this.setIsonline(false);
|
||||
//this.setIserror(true);
|
||||
message = "信号量同步异常";
|
||||
//未联机
|
||||
} else if (mode == 0) {
|
||||
message = "未联机";
|
||||
} else {
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
}
|
||||
|
||||
|
||||
last_mode = mode;
|
||||
last_error = error;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("mode", mode == 1 ? "联机" : "未联机");
|
||||
jo.put("error", ErrorUtil.getDictDetail("unbox_error_type", String.valueOf(error)));
|
||||
jo.put("now_order_num", now_order_num);
|
||||
jo.put("task", task);
|
||||
jo.put("order", order);
|
||||
jo.put("isOnline", this.itemProtocol.getIsonline());
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void issuedOrderInfo(ProduceshiftorderDto dto) {
|
||||
EalingOrderDto ealingOrderDto = dto.getEalingOrderDto();
|
||||
if (ealingOrderDto != null) {
|
||||
String is_foreward = ealingOrderDto.getIs_foreward();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("to_clear", "1");
|
||||
map.put("to_is_foreward", is_foreward);
|
||||
map.put("to_order_box_num", ealingOrderDto.getOrder_box_num());
|
||||
map.put("to_order", ealingOrderDto.getOrder_code());
|
||||
this.writing(map);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void issuedOrderFinish(String autoFinish) {
|
||||
if (StrUtil.equals(autoFinish, WorkerOrderEnum.FORCEFINISH.getCode())) {
|
||||
this.writing("to_order_compel_finished", "1");
|
||||
} else {
|
||||
this.writing("to_confirm_finished", "1");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toStop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toStart() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_unboxing_machine;
|
||||
|
||||
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_mode = "mode";
|
||||
//开箱机故障
|
||||
public static String item_error = "error";
|
||||
//开箱机运行状态
|
||||
public static String item_status = "status";
|
||||
//开箱数量
|
||||
public static String item_qty = "qty";
|
||||
//前往1巷道数量
|
||||
public static String item_one_qty = "one_qty";
|
||||
//前往1巷道数量
|
||||
public static String item_two_qty = "two_qty";
|
||||
//前往1巷道数量
|
||||
public static String item_three_qty = "three_qty";
|
||||
//前往1巷道数量
|
||||
public static String item_four_qty = "four_qty";
|
||||
//前往1巷道数量
|
||||
public static String item_five_qty = "five_qty";
|
||||
//前往1巷道状态
|
||||
public static String item_one_status = "one_status";
|
||||
//前往2巷道状态
|
||||
public static String item_two_status = "two_status";
|
||||
//前往3巷道状态
|
||||
public static String item_three_status = "three_status";
|
||||
//前往4巷道状态
|
||||
public static String item_four_status = "four_status";
|
||||
//前往5巷道状态
|
||||
public static String item_five_status = "five_status";
|
||||
|
||||
|
||||
//前往1巷道状态
|
||||
public static String item_to_one_status = "to_one_status";
|
||||
//前往2巷道状态
|
||||
public static String item_to_two_status = "to_two_status";
|
||||
//前往3巷道状态
|
||||
public static String item_to_three_status = "to_three_status";
|
||||
//前往4巷道状态
|
||||
public static String item_to_four_status = "to_four_status";
|
||||
//前往5巷道状态
|
||||
public static String item_to_five_status = "to_five_status";
|
||||
//清零
|
||||
public static String item_to_clear = "to_clear";
|
||||
|
||||
private HailiangOldUnboxingMachineDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(HailiangOldUnboxingMachineDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
};
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
};
|
||||
|
||||
public int getStatus() {
|
||||
return this.getOpcIntegerValue(item_status);
|
||||
};
|
||||
|
||||
public int getQty() {
|
||||
return this.getOpcIntegerValue(item_qty);
|
||||
};
|
||||
|
||||
public int getOne_qty() {
|
||||
return this.getOpcIntegerValue(item_one_qty);
|
||||
};
|
||||
|
||||
public int getTwo_qty() {
|
||||
return this.getOpcIntegerValue(item_two_qty);
|
||||
};
|
||||
|
||||
public int getThree_qty() {
|
||||
return this.getOpcIntegerValue(item_three_qty);
|
||||
};
|
||||
|
||||
public int getFour_qty() {
|
||||
return this.getOpcIntegerValue(item_four_qty);
|
||||
};
|
||||
|
||||
public int getFive_qty() {
|
||||
return this.getOpcIntegerValue(item_five_qty);
|
||||
};
|
||||
|
||||
public int getOne_status() {
|
||||
return this.getOpcIntegerValue(item_one_status);
|
||||
};
|
||||
|
||||
public int getTwo_status() {
|
||||
return this.getOpcIntegerValue(item_two_status);
|
||||
};
|
||||
|
||||
public int getThree_status() {
|
||||
return this.getOpcIntegerValue(item_three_status);
|
||||
};
|
||||
|
||||
public int getFour_status() {
|
||||
return this.getOpcIntegerValue(item_four_status);
|
||||
};
|
||||
|
||||
public int getFive_status() {
|
||||
return this.getOpcIntegerValue(item_five_status);
|
||||
};
|
||||
|
||||
|
||||
Boolean isonline;
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||
setIsonline(false);
|
||||
} else {
|
||||
setIsonline(true);
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB600.W0"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB600.W2"));
|
||||
list.add(new ItemDto(item_status, "状态", "DB600.W4"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB600.W6"));
|
||||
list.add(new ItemDto(item_qty, "订单实时", "DB600.W8"));
|
||||
list.add(new ItemDto(item_one_qty, "1号巷道数量", "DB600.W10"));
|
||||
list.add(new ItemDto(item_two_qty, "2号巷道数量", "DB600.W12"));
|
||||
list.add(new ItemDto(item_three_qty, "3号巷道数量", "DB600.W14"));
|
||||
list.add(new ItemDto(item_four_qty, "4号巷道数量", "DB600.W16"));
|
||||
list.add(new ItemDto(item_five_qty, "5号巷道数量", "DB600.W18"));
|
||||
list.add(new ItemDto(item_one_status, "1号巷道状态", "DB600.W20"));
|
||||
list.add(new ItemDto(item_two_status, "2号巷道状态", "DB600.W22"));
|
||||
list.add(new ItemDto(item_three_status, "3号巷道状态", "DB600.W24"));
|
||||
list.add(new ItemDto(item_four_status, "4号巷道状态", "DB600.W26"));
|
||||
list.add(new ItemDto(item_five_status, "5号巷道状态", "DB600.W28"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_one_status, "禁用1号巷道状态", "DB601.W2"));
|
||||
list.add(new ItemDto(item_to_two_status, "禁用2号巷道状态", "DB600.W4"));
|
||||
list.add(new ItemDto(item_to_three_status, "禁用3号巷道状态", "DB600.W6"));
|
||||
list.add(new ItemDto(item_to_four_status, "禁用4号巷道状态", "DB600.W8"));
|
||||
list.add(new ItemDto(item_to_five_status, "禁用5号巷道状态", "DB600.W10"));
|
||||
list.add(new ItemDto(item_to_clear, "清零", "DB600.W12"));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user