add 老车间设备驱动
This commit is contained in:
@@ -89,7 +89,15 @@ public enum DriverTypeEnum {
|
||||
|
||||
HAILIANG_SEALING_MACHINE_DRIVER(40, "hailiang_sealing_machine", "海亮-封箱机", "conveyor"),
|
||||
|
||||
HAILIANG_UNBOXING_MACHINE_DRIVER(41, "hailiang_unboxing_machine", "海亮-开箱机", "conveyor");
|
||||
HAILIANG_UNBOXING_MACHINE_DRIVER(41, "hailiang_unboxing_machine", "海亮-开箱机", "conveyor"),
|
||||
|
||||
HAILIANG_OLD_STACKING_MANIPULATOR_DRIVER(42, "hailiang_old_stacking_manipulator", "老车间-码垛机械手", "station"),
|
||||
|
||||
HAILIANG_OLD_PALLETIZING_STATION_DRIVER(43, "hailiang_old_palletizing_station", "老车间-码垛工位", "station"),
|
||||
|
||||
HAILIANG_OLD_LETTERING_PACKAGE_DRIVER(44, "hailiang_old_lettering_package_device", "老车间-刻字包装机", "conveyor"),
|
||||
|
||||
HAILIANG_OLD_PACKAGE_SSX_DRIVER(45, "hailiang_old_package_ssx_station", "老车间-刻字包装输送线", "conveyor");
|
||||
|
||||
|
||||
//驱动索引
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_lettering_package_device;
|
||||
|
||||
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 HailiangOldLetteringPackageDeviceDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "hailiang_old_lettering_package_device";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "海亮-老车间-刻字包装机";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "海亮-老车间-刻字包装机";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new HailiangOldLetteringPackageDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return HailiangOldLetteringPackageDeviceDriver.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,185 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_lettering_package_device;
|
||||
|
||||
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 HailiangOldLetteringPackageDeviceDriver 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 error = 0;
|
||||
int task = 0;
|
||||
int move = 0;
|
||||
String barcode,last_barcode;
|
||||
|
||||
int last_heartbeat = 0;
|
||||
int last_mode = 0;
|
||||
int last_error = 0;
|
||||
int last_task = 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();
|
||||
move = this.itemProtocol.getMove();
|
||||
error = this.itemProtocol.getError();
|
||||
task = this.itemProtocol.getTask();
|
||||
barcode = this.itemProtocol.getBarcode();
|
||||
|
||||
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 + "复位请求标记");
|
||||
}
|
||||
|
||||
if (task != last_task) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task + "复位请求标记");
|
||||
}
|
||||
|
||||
} 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;
|
||||
|
||||
if(move == 1 && error == 0 && barcode.length() > 0){
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_error = error;
|
||||
last_task = task;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("mode", mode == 1 ? "联机" : "未联机");
|
||||
jo.put("move", move == 1 ? "有货" : "无货");
|
||||
jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(error)));
|
||||
jo.put("task", task);
|
||||
jo.put("barcode", barcode);
|
||||
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,141 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_lettering_package_device;
|
||||
|
||||
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_move = "move";
|
||||
public static String item_action = "action";
|
||||
public static String item_error = "error";
|
||||
public static String item_direction = "direction";
|
||||
public static String item_vehicle_type = "vehicle_type";
|
||||
public static String item_task = "task";
|
||||
public static String item_barcode = "barcode";
|
||||
|
||||
|
||||
public static String item_to_command = "to_command";
|
||||
public static String item_to_target = "to_target";
|
||||
public static String item_to_vehicle_type = "to_vehicle_type";
|
||||
public static String item_to_task = "to_task";
|
||||
|
||||
|
||||
|
||||
private HailiangOldLetteringPackageDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(HailiangOldLetteringPackageDeviceDriver 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 String getBarcode() {
|
||||
return this.getOpcStringValue(item_barcode);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getVehicle_type() {
|
||||
return this.getOpcIntegerValue(item_vehicle_type);
|
||||
}
|
||||
|
||||
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 getToVehicle_type() {
|
||||
return this.getOpcIntegerValue(item_to_vehicle_type);
|
||||
}
|
||||
|
||||
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, "心跳", "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, "条码", "VB18.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"));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_package_ssx;
|
||||
|
||||
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 HailiangLetteringPackageSsxDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "hailiang_old_package_ssx_station";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "海亮-老车间-包装输送线";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "海亮-老车间-包装输送线";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new HailiangLetteringPackageSsxDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return HailiangLetteringPackageSsxDeviceDriver.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,227 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_package_ssx;
|
||||
|
||||
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;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 老车间-刻字包装输送线
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class HailiangLetteringPackageSsxDeviceDriver 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 error = 0;
|
||||
int task = 0;
|
||||
int move = 0;
|
||||
int to_command = 0;
|
||||
String barcode,last_barcode;
|
||||
|
||||
int last_heartbeat = 0;
|
||||
int last_mode = 0;
|
||||
int last_error = 0;
|
||||
int last_task = 0;
|
||||
int last_move = 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();
|
||||
move = this.itemProtocol.getMove();
|
||||
error = this.itemProtocol.getError();
|
||||
task = this.itemProtocol.getTask();
|
||||
barcode = this.itemProtocol.getBarcode();
|
||||
to_command = this.itemProtocol.getToCommand();
|
||||
if (mode != last_mode) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记");
|
||||
}
|
||||
if (move != last_move){
|
||||
if(to_command != 0){
|
||||
this.writing("to_command", "0");
|
||||
this.writing("to_target", "0");
|
||||
}
|
||||
}
|
||||
|
||||
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 + "复位请求标记");
|
||||
}
|
||||
|
||||
if (task != last_task) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task + "复位请求标记");
|
||||
}
|
||||
|
||||
} 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;
|
||||
|
||||
if(move == 1 && error == 0 && barcode.length() > 0){
|
||||
//2305281100001
|
||||
if(barcode.trim().length() == 16){
|
||||
if(isNumeric(barcode.trim())){
|
||||
/**
|
||||
* 工单为前9位
|
||||
* 第10位是否翻转
|
||||
* 第11位为前往巷道
|
||||
* 后5位为流水号
|
||||
*/
|
||||
String order = barcode.trim().substring(0,9);
|
||||
int isFlip = Integer.parseInt(barcode.trim().substring(9,10));
|
||||
int target = Integer.parseInt(barcode.trim().substring(10,11));
|
||||
if(isFlip>0 && target>0){
|
||||
this.writing("to_command", String.valueOf(isFlip));
|
||||
this.writing("to_target", String.valueOf(target));
|
||||
|
||||
} else {
|
||||
message = "条码:"+ barcode + ",是否翻转:"+isFlip + "目标巷道:"+target;
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
message = "条码不为数字,无法解析";
|
||||
}
|
||||
} else {
|
||||
message = "条码长度不等于16,无法下发目标位置";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_move = move;
|
||||
last_error = error;
|
||||
last_task = task;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("mode", mode == 1 ? "联机" : "未联机");
|
||||
jo.put("move", move == 1 ? "有货" : "无货");
|
||||
jo.put("error", ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(error)));
|
||||
jo.put("task", task);
|
||||
jo.put("barcode", barcode);
|
||||
jo.put("isOnline", this.itemProtocol.getIsonline());
|
||||
jo.put("message", message);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isNumeric(String str){
|
||||
Pattern pattern = Pattern.compile("[0-9]*");
|
||||
return pattern.matcher(str).matches();
|
||||
}
|
||||
|
||||
@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,141 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_package_ssx;
|
||||
|
||||
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_move = "move";
|
||||
public static String item_action = "action";
|
||||
public static String item_error = "error";
|
||||
public static String item_direction = "direction";
|
||||
public static String item_vehicle_type = "vehicle_type";
|
||||
public static String item_task = "task";
|
||||
public static String item_barcode = "barcode";
|
||||
|
||||
|
||||
public static String item_to_command = "to_command";
|
||||
public static String item_to_target = "to_target";
|
||||
public static String item_to_vehicle_type = "to_vehicle_type";
|
||||
public static String item_to_task = "to_task";
|
||||
|
||||
|
||||
|
||||
private HailiangLetteringPackageSsxDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(HailiangLetteringPackageSsxDeviceDriver 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 String getBarcode() {
|
||||
return this.getOpcStringValue(item_barcode);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getVehicle_type() {
|
||||
return this.getOpcIntegerValue(item_vehicle_type);
|
||||
}
|
||||
|
||||
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 getToVehicle_type() {
|
||||
return this.getOpcIntegerValue(item_to_vehicle_type);
|
||||
}
|
||||
|
||||
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, "心跳", "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"));
|
||||
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"));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_palletizing_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 HailiangOldPalletizingStationDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "hailiang_old_palletizing_station";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "海亮老车间-码垛工位";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "海亮老车间-码垛工位";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new HailiangOldPalletizingStationDriver()).setDevice(device).setDriverDefination(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return HailiangOldPalletizingStationDriver.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,199 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_palletizing_station;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.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.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.order.service.ProduceshiftorderService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 海亮老车间码垛工位
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class HailiangOldPalletizingStationDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@Autowired
|
||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||
@Autowired
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@Autowired
|
||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
@Autowired
|
||||
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class);
|
||||
@Autowired
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
|
||||
private long last_feedDeviceStatusTime = 0;
|
||||
int status_type = 0;
|
||||
int last_status_type = 0;
|
||||
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_finished_time = new Date();
|
||||
private Date instruction_apply_time = new Date();
|
||||
private int instruction_require_time_out = 3000;
|
||||
//请求成功标记
|
||||
Boolean requireSucess = false;
|
||||
|
||||
String device_code;
|
||||
|
||||
//心跳
|
||||
int heartbert = 0;
|
||||
int last_heartbert = 0;
|
||||
//模式
|
||||
int mode = 0;
|
||||
int last_mode = 0;
|
||||
//光电信号
|
||||
int move = 0;
|
||||
int last_move = 0;
|
||||
//数量
|
||||
int number = 0;
|
||||
int last_number = 0;
|
||||
//故障
|
||||
int error = 0;
|
||||
int last_error = 0;
|
||||
//箱型
|
||||
int boxtype = 0;
|
||||
int last_boxtype = 0;
|
||||
|
||||
@Override
|
||||
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
move = this.itemProtocol.getMove();
|
||||
number = this.itemProtocol.getNumber();
|
||||
error = this.itemProtocol.getError();
|
||||
boxtype = this.itemProtocol.getBoxtype();
|
||||
if (mode != last_mode) {
|
||||
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
||||
}
|
||||
if (move != last_move) {
|
||||
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move);
|
||||
}
|
||||
if (number != last_number) {
|
||||
logServer.deviceItemValue(this.device_code, "number", String.valueOf(number));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号number:" + last_number + "->" + number);
|
||||
}
|
||||
if (error != last_error) {
|
||||
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
||||
}
|
||||
if (boxtype != last_boxtype) {
|
||||
logServer.deviceItemValue(this.device_code, "boxtype", String.valueOf(boxtype));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号boxtype:" + last_boxtype + "->" + boxtype);
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号出现异常:" + var17.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!this.itemProtocol.getIsonline()) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "信号量同步异常";
|
||||
//未联机
|
||||
} else if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "未联机";
|
||||
//有报警
|
||||
} else if (error != 0) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "有报警";
|
||||
//无报警
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected void executing(Instruction instruction) {
|
||||
this.executing(1, instruction, "");
|
||||
}
|
||||
|
||||
public void executing(int command, Instruction instruction, String appendMessage) {
|
||||
|
||||
}
|
||||
|
||||
public void executing(Server server, Map<String, Object> itemMap) {
|
||||
ReadUtil.write(itemMap, server);
|
||||
}
|
||||
|
||||
|
||||
public void writing(String param, String value) {
|
||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + param;
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
ReadUtil.write(itemMap, server);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_palletizing_station;
|
||||
|
||||
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_move = "move";
|
||||
//数量
|
||||
public static String item_number = "number";
|
||||
//故障
|
||||
public static String item_error = "error";
|
||||
//箱型
|
||||
public static String item_boxtype = "boxtype";
|
||||
|
||||
//下发命令
|
||||
public static String item_to_command = "to_command";
|
||||
|
||||
|
||||
private HailiangOldPalletizingStationDriver driver;
|
||||
|
||||
public ItemProtocol(HailiangOldPalletizingStationDriver 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 getNumber() {
|
||||
return this.getOpcIntegerValue(item_number);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getBoxtype() {
|
||||
return this.getOpcIntegerValue(item_boxtype);
|
||||
}
|
||||
|
||||
|
||||
//是否有货
|
||||
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 String getField_desc(String item) {
|
||||
String field_desc = "";
|
||||
List<ItemDto> readlist = getReadableItemDtos();
|
||||
List<ItemDto> writelist = getWriteableItemDtos();
|
||||
for (int i = 0; i < readlist.size(); i++) {
|
||||
ItemDto dto = readlist.get(i);
|
||||
// if(){
|
||||
//
|
||||
// }
|
||||
}
|
||||
return field_desc;
|
||||
}
|
||||
|
||||
|
||||
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_move, "光电信号", "DB600.W4"));
|
||||
list.add(new ItemDto(item_number, "数量", "DB600.W6"));
|
||||
list.add(new ItemDto(item_error, "故障", "DB600.W8"));
|
||||
list.add(new ItemDto(item_boxtype, "箱型", "DB600.W10"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "下发命令", "DB601.W2"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemProtocol{}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_stacking_manipulator;
|
||||
|
||||
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 HailiangOldStackingManipulatorDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "hailiang_old_stacking_manipulator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "海亮老车间-码垛机械手";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "海亮老车间-码垛机械手";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new HailiangOldStackingManipulatorDriver()).setDevice(device).setDriverDefination(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return HailiangOldStackingManipulatorDriver.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,355 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_stacking_manipulator;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.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.instruction.service.InstructionService;
|
||||
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.order.service.ProduceshiftorderService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 海亮老车间码垛机械手
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class HailiangOldStackingManipulatorDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@Autowired
|
||||
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
|
||||
@Autowired
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@Autowired
|
||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||
@Autowired
|
||||
ProduceshiftorderService produceshiftorderService = SpringContextHolder.getBean(ProduceshiftorderService.class);
|
||||
@Autowired
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
|
||||
//心跳
|
||||
int heartbeat = 0;
|
||||
int last_heartbeat = 0;
|
||||
//模式
|
||||
int mode = 0;
|
||||
int last_mode = 0;
|
||||
//状态
|
||||
int status = 0;
|
||||
int last_status = 0;
|
||||
//动作
|
||||
int action = 0;
|
||||
int last_action = 0;
|
||||
//故障
|
||||
int error = 0;
|
||||
int last_error = 0;
|
||||
//当前抓取工位
|
||||
int getStation = 0;
|
||||
int last_getStation = 0;
|
||||
//当前码盘工位
|
||||
int putStation = 0;
|
||||
int last_putStation = 0;
|
||||
//码盘位当前码盘数量
|
||||
int encoder_qty = 0;
|
||||
int last_encoder_qty = 0;
|
||||
//箱型
|
||||
int boxtype = 0;
|
||||
int last_boxtype = 0;
|
||||
|
||||
//请求托盘信息成功标志
|
||||
Boolean vehicleInfoRequireSuccess = false;
|
||||
//请求单次放置完成成功标志
|
||||
Boolean singlePlacementRequireSuccess = false;
|
||||
//请求码垛完成标志
|
||||
Boolean stackingRequireSuccess = false;
|
||||
|
||||
|
||||
//当前设备状态 01代表 关机, 02代表 开机, 03代表 生产中, 04代表 待机, 05代表 异常
|
||||
int status_type = 0;
|
||||
//上次设备状态
|
||||
int last_status_type = 0;
|
||||
|
||||
//获取托盘信息请求时间
|
||||
private Date instruction_require_time = new Date();
|
||||
//单次放置请求完成时间
|
||||
private Date singlePlacementRequireTime = new Date();
|
||||
//码垛完成请求时间
|
||||
private Date stackingRequireTime = new Date();
|
||||
//请求超时时间
|
||||
private int instruction_require_time_out = 3000;
|
||||
|
||||
//设备是否在线
|
||||
Boolean isonline = true;
|
||||
//设备是否异常
|
||||
Boolean iserror = false;
|
||||
//异常消息
|
||||
String message = null;
|
||||
|
||||
String device_code;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public synchronized void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.getItemProtocol().getMode();
|
||||
status = this.getItemProtocol().getStatus();
|
||||
action = this.getItemProtocol().getAction();
|
||||
error = this.getItemProtocol().getError();
|
||||
getStation = this.getItemProtocol().getGetStation();
|
||||
putStation = this.getItemProtocol().getPutStation();
|
||||
encoder_qty = this.getItemProtocol().getEncoder_qty();
|
||||
boxtype = this.getItemProtocol().getBoxtype();
|
||||
if (mode != last_mode) {
|
||||
logServer.deviceItemValue(this.device_code, "mode", String.valueOf(mode));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
||||
}
|
||||
if (status != last_status) {
|
||||
logServer.deviceItemValue(this.device_code, "status", String.valueOf(status));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号status:" + last_status + "->" + status);
|
||||
}
|
||||
if (action != last_action) {
|
||||
logServer.deviceItemValue(this.device_code, "action", String.valueOf(action));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + last_action + "->" + action);
|
||||
}
|
||||
if (error != last_error) {
|
||||
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
||||
}
|
||||
if (getStation != last_getStation) {
|
||||
logServer.deviceItemValue(this.device_code, "getStation", String.valueOf(getStation));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号getStation:" + last_getStation + "->" + getStation);
|
||||
}
|
||||
if (putStation != last_putStation) {
|
||||
logServer.deviceItemValue(this.device_code, "putStation", String.valueOf(putStation));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号putStation:" + last_putStation + "->" + putStation);
|
||||
}
|
||||
if (encoder_qty != last_encoder_qty) {
|
||||
logServer.deviceItemValue(this.device_code, "encoder_qty", String.valueOf(encoder_qty));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号encoder_qty:" + last_encoder_qty + "->" + encoder_qty);
|
||||
}
|
||||
if (boxtype != last_boxtype) {
|
||||
logServer.deviceItemValue(this.device_code, "boxtype", String.valueOf(boxtype));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号boxtype:" + last_boxtype + "->" + boxtype);
|
||||
}
|
||||
} catch (Exception var17) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号出现异常:" + var17.getMessage());
|
||||
return;
|
||||
}
|
||||
if (!this.itemProtocol.getIsonline()) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "信号量同步异常";
|
||||
//未联机
|
||||
} else if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "未联机";
|
||||
//有报警
|
||||
} else if (error != 0) {
|
||||
this.setIsonline(false);
|
||||
this.setIserror(true);
|
||||
message = "有报警";
|
||||
//无报警
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
switch (action) {
|
||||
case 1:
|
||||
if (!vehicleInfoRequireSuccess) {
|
||||
getVehicleInfo();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (!singlePlacementRequireSuccess) {
|
||||
singlePlacementCompleted();
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (!stackingRequireSuccess) {
|
||||
stackingCompleted();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//获取托盘信息
|
||||
public synchronized boolean getVehicleInfo() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
return false;
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
//获取机械手关联抓取工位/放货工位的设备信息 将读取kep抓取工位的值-1 作为对应设备编码所在的索引位置
|
||||
//抓取工位
|
||||
List<String> getDeviceCodeList = this.getExtraDeviceCodes("link_get_device_code");
|
||||
//放货工位
|
||||
List<String> putDeviceCodeList = this.getExtraDeviceCodes("link_put_device_code");
|
||||
//根据kep读取到的抓取工位的值 - 1 得到对应设备的下标,再根据下标获得对应设备的编码
|
||||
String getDeviceCode = getDeviceCodeList.get(getGetStation() - 1).replace("\"", "");
|
||||
//根据抓取工位获取托盘信息
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("getStation", getDeviceCode);
|
||||
JSONObject resp = acsToWmsService.getVehicle(map);
|
||||
int code = Integer.parseInt(resp.getString("code"));
|
||||
String message = resp.getString("message");
|
||||
String getStation = resp.getString("getStation");
|
||||
String putStation = resp.getString("putStation");
|
||||
String encoder_qty = resp.getString("encoder_qty");
|
||||
String boxtype = resp.getString("boxtype");
|
||||
if (code == 200) {
|
||||
//根据获取托盘信息返回的结果 得到对应抓取工位/放货工位设备编码所在的索引位置
|
||||
int getIndex = getDeviceCodeList.indexOf(getStation);
|
||||
int putIndex = putDeviceCodeList.indexOf(putStation);
|
||||
//将的到的索引 + 1 写入kep中
|
||||
this.writing("to_getStation", String.valueOf(getIndex + 1));
|
||||
this.writing("to_putStation", String.valueOf(putIndex + 1));
|
||||
this.writing("to_boxtype", boxtype);
|
||||
this.writing("to_feedback", "1");
|
||||
//获取托盘信息成功后 设为true 防止多次请求 等单次防止完成时设为false
|
||||
this.setVehicleInfoRequireSuccess(true);
|
||||
} else {
|
||||
log.warn("获取托盘信息失败!设备号:{},原因{}", device_code, message);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//单次放置完成
|
||||
public synchronized boolean singlePlacementCompleted() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.singlePlacementRequireTime.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
return false;
|
||||
} else {
|
||||
this.singlePlacementRequireTime = date;
|
||||
//获取机械手关联抓取工位/放货工位的设备信息 将读取kep抓取工位的值-1 作为对应设备编码所在的索引位置
|
||||
//抓取工位
|
||||
List<String> getDeviceCodeList = this.getExtraDeviceCodes("link_get_device_code");
|
||||
//放货工位
|
||||
List<String> putDeviceCodeList = this.getExtraDeviceCodes("link_put_device_code");
|
||||
//根据kep读取到的抓取工位的值 - 1 得到对应设备的下标,再根据下标获得对应设备的编码
|
||||
String getDeviceCode = getDeviceCodeList.get(getGetStation() - 1).replace("\"", "");
|
||||
//根据kep读取到的放货工位的值 - 1 得到对应设备的下标,再根据下标获得对应设备的编码
|
||||
String putDeviceCode = putDeviceCodeList.get(getPutStation() - 1).replace("\"", "");
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("getStation", getDeviceCode);
|
||||
map.put("putStation", putDeviceCode);
|
||||
map.put("encoder_qty", getEncoder_qty());
|
||||
map.put("boxtype", getBoxtype());
|
||||
JSONObject resp = acsToWmsService.singlePlacementCompleted(map);
|
||||
int code = Integer.parseInt(resp.getString("code"));
|
||||
String message = resp.getString("message");
|
||||
JSONObject data = resp.getJSONObject("data");
|
||||
if (code == 200) {
|
||||
this.writing("to_feedback", "2");
|
||||
this.setSinglePlacementRequireSuccess(true);
|
||||
} else {
|
||||
log.warn("单次放置完成反馈失败!设备号:{},原因{}", device_code, message);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//码垛完成
|
||||
public synchronized boolean stackingCompleted() {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.stackingRequireTime.getTime() < (long) this.instruction_require_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
|
||||
return false;
|
||||
} else {
|
||||
this.stackingRequireTime = date;
|
||||
//获取机械手关联放货工位的设备信息 将读取kep抓取工位的值-1 作为对应设备编码所在的索引位置
|
||||
//放货工位
|
||||
List<String> putDeviceCodeList = this.getExtraDeviceCodes("link_put_device_code");
|
||||
//根据kep读取到的放货工位的值 - 1 得到对应设备的下标,再根据下标获得对应设备的编码
|
||||
String putDeviceCode = putDeviceCodeList.get(getPutStation() - 1).replace("\"", "");
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("putStation", putDeviceCode);
|
||||
map.put("encoder_qty", getEncoder_qty());
|
||||
map.put("boxtype", getBoxtype());
|
||||
JSONObject resp = acsToWmsService.stackingCompleted(map);
|
||||
int code = Integer.parseInt(resp.getString("code"));
|
||||
String message = resp.getString("message");
|
||||
JSONObject data = resp.getJSONObject("data");
|
||||
if (code == 200) {
|
||||
this.writing("to_feedback", "3");
|
||||
this.setStackingRequireSuccess(true);
|
||||
} else {
|
||||
log.warn("码垛完成反馈失败!设备号:{},原因{}", device_code, message);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//将扩展表中的字符串数据转换成集合
|
||||
public List<String> getExtraDeviceCodes(String extraName) {
|
||||
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
|
||||
String devices1 = extraValue.substring(1, extraValue.length() - 1);
|
||||
List<String> devicesList = new ArrayList<>();
|
||||
String[] devices = devices1.split(",");
|
||||
for (int i = 0; i < devices.length; i++) {
|
||||
String s = devices[i].replace("\"", "").replace("\"", "");
|
||||
devicesList.add(s);
|
||||
}
|
||||
return devicesList;
|
||||
}
|
||||
|
||||
//写入kep点位值
|
||||
public void writing(String param, String value) {
|
||||
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + param;
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
ReadUtil.write(itemMap, server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
package org.nl.acs.device_driver.basedriver.hailiang_old.hailiang_old_stacking_manipulator;
|
||||
|
||||
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_status = "status";
|
||||
//动作
|
||||
public static String item_action = "action";
|
||||
//故障
|
||||
public static String item_error = "error";
|
||||
//当前抓取工位
|
||||
public static String item_getStation = "getStation";
|
||||
//当前码盘工位
|
||||
public static String item_putStation = "putStation";
|
||||
//码盘位当前码盘数量
|
||||
public static String item_encoder_qty= "encoder_qty";
|
||||
//箱型
|
||||
public static String item_boxtype= "boxtype";
|
||||
|
||||
//机器人动作反馈
|
||||
public static String item_to_feedback = "to_feedback";
|
||||
//故障
|
||||
public static String item_to_error = "to_error";
|
||||
//当前抓取工位
|
||||
public static String item_to_getStation = "to_getStation";
|
||||
//当前码盘
|
||||
public static String item_to_putStation = "to_putStation";
|
||||
//箱型
|
||||
public static String item_to_boxtype = "to_boxtype";
|
||||
|
||||
|
||||
|
||||
private HailiangOldStackingManipulatorDriver driver;
|
||||
|
||||
public ItemProtocol(HailiangOldStackingManipulatorDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getHeartbeat() {
|
||||
return this.getOpcIntegerValue(item_heartbeat);
|
||||
}
|
||||
|
||||
public int getMode() {
|
||||
return this.getOpcIntegerValue(item_mode);
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return this.getOpcIntegerValue(item_status);
|
||||
}
|
||||
|
||||
public int getAction() {
|
||||
return this.getOpcIntegerValue(item_action);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getGetStation() {
|
||||
return this.getOpcIntegerValue(item_getStation);
|
||||
}
|
||||
|
||||
public int getPutStation() {
|
||||
return this.getOpcIntegerValue(item_putStation);
|
||||
}
|
||||
|
||||
public int getEncoder_qty() {
|
||||
return this.getOpcIntegerValue(item_encoder_qty);
|
||||
}
|
||||
|
||||
public int getBoxtype() {
|
||||
return this.getOpcIntegerValue(item_boxtype);
|
||||
}
|
||||
|
||||
//是否有货
|
||||
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 String getField_desc(String item) {
|
||||
String field_desc = "";
|
||||
List<ItemDto> readlist = getReadableItemDtos();
|
||||
List<ItemDto> writelist = getWriteableItemDtos();
|
||||
for (int i = 0; i < readlist.size(); i++) {
|
||||
ItemDto dto = readlist.get(i);
|
||||
// if(){
|
||||
//
|
||||
// }
|
||||
}
|
||||
return field_desc;
|
||||
}
|
||||
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB602.W0"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB602.W2"));
|
||||
list.add(new ItemDto(item_status, "设备状态", "DB602.W4"));
|
||||
list.add(new ItemDto(item_action, "动作", "DB602.W6"));
|
||||
list.add(new ItemDto(item_error, "故障", "DB602.W8"));
|
||||
list.add(new ItemDto(item_getStation, "当前抓取工位", "DB602.W10"));
|
||||
list.add(new ItemDto(item_putStation, "当前码盘工位", "DB602.W12"));
|
||||
list.add(new ItemDto(item_encoder_qty, "码盘位当前码盘数量", "DB602.W14"));
|
||||
list.add(new ItemDto(item_boxtype, "箱型", "DB602.W16"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_feedback, "机器人动作反馈", "DB603.W2"));
|
||||
list.add(new ItemDto(item_to_error, "故障", "DB603.W4"));
|
||||
list.add(new ItemDto(item_to_getStation, "当前抓取工位", "DB603.W6"));
|
||||
list.add(new ItemDto(item_to_putStation, "当前码盘工位", "DB603.W8"));
|
||||
list.add(new ItemDto(item_to_boxtype, "箱型", "DB603.W10"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemProtocol{}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,6 +150,7 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(getToParam() + key, value);
|
||||
ReadUtil.write(itemMap, server);
|
||||
server.disconnect();
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发单个电气信号:" + key + ",下发电气信号值:" + value);
|
||||
}
|
||||
|
||||
|
||||
@@ -127,4 +127,29 @@ public interface AcsToWmsService {
|
||||
* @returna
|
||||
*/
|
||||
HttpResponse queryDoorsStatus();
|
||||
|
||||
/**
|
||||
* 获取托盘信息
|
||||
*/
|
||||
JSONObject getVehicle(JSONObject json);
|
||||
|
||||
/**
|
||||
* 单次放置完成
|
||||
*
|
||||
* @param
|
||||
* @returna
|
||||
*/
|
||||
JSONObject singlePlacementCompleted(JSONObject param);
|
||||
|
||||
/**
|
||||
* 码垛完成
|
||||
*
|
||||
* @param
|
||||
* @returna
|
||||
*/
|
||||
JSONObject stackingCompleted(JSONObject param);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Map;
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
int a;
|
||||
private final ParamService paramService;
|
||||
private final DeviceService deviceService;
|
||||
private final AddressService addressService;
|
||||
@@ -452,6 +453,64 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getVehicle(JSONObject json) {
|
||||
// String getStation = json.getString("getStation");
|
||||
// JSONObject map = new JSONObject();
|
||||
// Random r = new Random();
|
||||
// int i = 1;
|
||||
// if (a == 20){
|
||||
// i = 2;
|
||||
// }
|
||||
// String a = "";
|
||||
// if (i == 1) {
|
||||
// a = "L001";
|
||||
// } else if (i == 2){
|
||||
// a = "L002";
|
||||
// } else if (i == 3){
|
||||
// a = "L003";
|
||||
// } else if (i == 4){
|
||||
// a = "L004";
|
||||
// }else if (i == 5){
|
||||
// a = "L005";
|
||||
// }else if (i == 6){
|
||||
// a = "L006";
|
||||
// }else {
|
||||
// a = "L002";
|
||||
// }
|
||||
// map.put("code",200);
|
||||
// map.put("message","成功");
|
||||
// map.put("getStation",getStation);
|
||||
// map.put("putStation",a);
|
||||
// map.put("encoder_qty","1");
|
||||
// map.put("boxtype","1");
|
||||
// return map;
|
||||
try {
|
||||
MDC.put(log_file_type, log_type);
|
||||
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
|
||||
AddressDto addressDto = addressService.findByCode("getVehicle");
|
||||
String methods_url = addressDto.getMethods_url();
|
||||
String url = wmsurl + methods_url;
|
||||
log.info("getVehicle----获取托盘信息请求参数{}", json.toString());
|
||||
HttpResponse result = null;
|
||||
try {
|
||||
result = HttpRequest.post(url)
|
||||
.header("Authorization", token)
|
||||
.body(String.valueOf(json))
|
||||
.execute();
|
||||
System.out.println(result);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
log.info("getVehicle----获取托盘信息返回参数{}", result.body());
|
||||
JSONObject jo = JSONObject.parseObject(result.body());
|
||||
return jo;
|
||||
} finally {
|
||||
MDC.remove(log_file_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public HttpResponse queryDoorsStatus() {
|
||||
try {
|
||||
@@ -480,5 +539,67 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject singlePlacementCompleted(JSONObject param) {
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("code", 200);
|
||||
map.put("message", "成功");
|
||||
map.put("data", null);
|
||||
return map;
|
||||
// try {
|
||||
// MDC.put(log_file_type, log_type);
|
||||
// String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
|
||||
// HttpResponse result = null;
|
||||
// log.info("singlePlacementCompleted-----单次放置完成请求");
|
||||
// AddressDto addressDto = addressService.findByCode("singlePlacementCompleted");
|
||||
// String methods_url = addressDto.getMethods_url();
|
||||
// try {
|
||||
// result = HttpRequest.get(wmsurl + methods_url)
|
||||
// .body("")
|
||||
// .execute();
|
||||
// log.info("singlePlacementCompleted-----单次放置完成输出参数{}", result.body().toString());
|
||||
// } catch (Exception e) {
|
||||
// String msg = e.getMessage();
|
||||
// //网络不通
|
||||
// System.out.println(msg);
|
||||
// }
|
||||
// JSONObject jo = JSONObject.parseObject(result.body());
|
||||
// return jo;
|
||||
// } finally {
|
||||
// MDC.remove(log_file_type);
|
||||
// }
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject stackingCompleted(JSONObject param) {
|
||||
a = 20;
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("code", 200);
|
||||
map.put("message", "成功");
|
||||
map.put("data", null);
|
||||
return map;
|
||||
// try {
|
||||
// MDC.put(log_file_type, log_type);
|
||||
// String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
|
||||
// HttpResponse result = null;
|
||||
// log.info("stackingCompleted-----码垛完成请求");
|
||||
// AddressDto addressDto = addressService.findByCode("stackingCompleted");
|
||||
// String methods_url = addressDto.getMethods_url();
|
||||
// try {
|
||||
// result = HttpRequest.get(wmsurl + methods_url)
|
||||
// .body("")
|
||||
// .execute();
|
||||
// log.info("stackingCompleted-----码垛完成输出参数{}", result.body().toString());
|
||||
// } catch (Exception e) {
|
||||
// String msg = e.getMessage();
|
||||
// //网络不通
|
||||
// System.out.println(msg);
|
||||
// }
|
||||
// JSONObject jo = JSONObject.parseObject(result.body());
|
||||
// return jo;
|
||||
// } finally {
|
||||
// MDC.remove(log_file_type);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ delete from sys_log;
|
||||
delete from acs_log;
|
||||
delete from acs_task_feedback;
|
||||
delete from sys_quartz_log;
|
||||
delete from acs_produceshiftorder;
|
||||
delete from acs_storage_cell;
|
||||
update acs_stage_actor set device_code='',image_name ='1';
|
||||
update sys_code_rule_detail set current_value=0;
|
||||
update sys_code_rule_detail set current_value=0;
|
||||
update stage set stage_data = null
|
||||
Reference in New Issue
Block a user