add:新增标准版行架机械手驱动
This commit is contained in:
@@ -43,7 +43,10 @@ public enum DriverTypeEnum {
|
||||
DOUBLE_STATION_STACKER(16, "double_station_stacker", "标准版-双工位堆垛机", "double_station_stacker"),
|
||||
|
||||
DOUBLE_BELT_CONVEYOR(17, "double_belt_conveyor", "双工位输送线", "conveyor"),
|
||||
WITH_STATION_DEVICE_DRIVER(18, "with_station_device_driver", "输送线关联站点", "conveyor");
|
||||
|
||||
WITH_STATION_DEVICE_DRIVER(18, "with_station_device_driver", "输送线关联站点", "conveyor"),
|
||||
|
||||
STANDARD_MANIPULATOR(19, "standard_manipulator", "标准版-行架机械手", "station");
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -402,14 +402,13 @@ public class DoubleBeltConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
return false;
|
||||
}
|
||||
Map map = new HashMap();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("to_target", next_addr);
|
||||
map.put("to_task", inst.getInstruction_code());
|
||||
map.put("to_command", "1");
|
||||
map.put("to_container_type", "1");
|
||||
map.put("to_container_no", "1");
|
||||
list.add(map);
|
||||
this.writing(list);
|
||||
this.writing(map);
|
||||
led_message = getLedMessage(inst);
|
||||
requireSucess = true;
|
||||
return true;
|
||||
@@ -498,15 +497,14 @@ public class DoubleBeltConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
taskdto.setTask_status("1");
|
||||
taskserver.update(taskdto);
|
||||
requireSucess = true;
|
||||
Map map = new HashMap();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
||||
map.put("to_target", next_addr);
|
||||
map.put("to_task", instdto.getInstruction_code());
|
||||
map.put("to_command", "1");
|
||||
map.put("to_container_type", "1");
|
||||
map.put("to_container_no", "1");
|
||||
list.add(map);
|
||||
this.writing(list);
|
||||
this.writing(map);
|
||||
led_message = getLedMessage(instdto);
|
||||
requireSucess = true;
|
||||
return true;
|
||||
@@ -525,6 +523,21 @@ public class DoubleBeltConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
|
||||
}
|
||||
|
||||
|
||||
public void writing(Map<String, Object> map) {
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||
map.forEach((key, value) -> {
|
||||
if (ObjectUtil.isNotEmpty(value)) {
|
||||
itemMap.put(getToParam() + key, value);
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void writing(String key, String param) {
|
||||
|
||||
|
||||
@@ -263,8 +263,7 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im
|
||||
} else if (frontZerror != 0 || backZerror != 0) {
|
||||
message = "有报警";
|
||||
} else {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
List<Object> list = new ArrayList<>();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
if (CommandEnum.STANDY.getStatus().equals(frontCommand) || backCommand.equals(CommandEnum.STANDY.getStatus())){
|
||||
applyTask();
|
||||
requireSucess = true;
|
||||
@@ -350,8 +349,7 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im
|
||||
requireSucess = true;
|
||||
}
|
||||
if (ObjectUtil.isNotNull(map)) {
|
||||
list.add(map);
|
||||
this.writing(list);
|
||||
this.writing(map);
|
||||
}
|
||||
}
|
||||
lastHeartbeat = heartbeat;
|
||||
@@ -809,6 +807,20 @@ public class DoubleStationStackerDeviceDriver extends AbstractOpcDeviceDriver im
|
||||
}
|
||||
}
|
||||
|
||||
public void writing(Map<String, Object> map) {
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||
map.forEach((key, value) -> {
|
||||
if (ObjectUtil.isNotEmpty(value)) {
|
||||
itemMap.put(getToParam() + key, value);
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将扩展表中的字符串数据转换成集合
|
||||
|
||||
@@ -0,0 +1,167 @@
|
||||
package org.nl.acs.device_driver.manipulator.standard_manipulator;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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_walk_y = "walk_y";
|
||||
//任务号
|
||||
public static String item_task = "task";
|
||||
//报警
|
||||
public static String item_error = "error";
|
||||
//x轴坐标
|
||||
public static String item_x_position = "x_position";
|
||||
//y轴坐标
|
||||
public static String item_y_position = "y_position";
|
||||
|
||||
//下发命令
|
||||
public static String item_to_command = "to_command";
|
||||
//下发起始站
|
||||
public static String item_to_onset = "to_onset";
|
||||
//下发目标站
|
||||
public static String item_to_target = "to_target";
|
||||
//下发任务号
|
||||
public static String item_to_task = "to_task";
|
||||
|
||||
|
||||
private StandardManipulatorDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(StandardManipulatorDeviceDriver 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 getWalk_y() {
|
||||
return this.getOpcIntegerValue(item_walk_y);
|
||||
}
|
||||
|
||||
public int getError() {
|
||||
return this.getOpcIntegerValue(item_error);
|
||||
}
|
||||
|
||||
public int getTask() {
|
||||
return this.getOpcIntegerValue(item_task);
|
||||
}
|
||||
|
||||
public int getTo_command() {
|
||||
return this.getOpcIntegerValue(item_to_command);
|
||||
}
|
||||
|
||||
public int getTo_target() {
|
||||
return this.getOpcIntegerValue(item_to_target);
|
||||
}
|
||||
|
||||
public int getTo_task() {
|
||||
return this.getOpcIntegerValue(item_to_task);
|
||||
}
|
||||
|
||||
public int getTo_onset() {
|
||||
return this.getOpcIntegerValue(item_to_onset);
|
||||
}
|
||||
|
||||
public float getX_position() {
|
||||
return this.getOpcFloatValue(item_x_position);
|
||||
}
|
||||
|
||||
public float getY_position() {
|
||||
return this.getOpcFloatValue(item_y_position);
|
||||
}
|
||||
|
||||
|
||||
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 String getOpcStringValue(String protocol) {
|
||||
String value = this.driver.getStringValue(protocol);
|
||||
if (StrUtil.isEmpty(value)) {
|
||||
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
public float getOpcFloatValue(String protocol) {
|
||||
Float value = this.driver.getDoubleValue(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<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB1.B1"));
|
||||
list.add(new ItemDto(item_move, "光电信号", "DB1.B2"));
|
||||
list.add(new ItemDto(item_action, "动作信号", "DB1.B3"));
|
||||
list.add(new ItemDto(item_walk_y, "行走列", "DB1.B4"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB1.B5"));
|
||||
list.add(new ItemDto(item_task, "任务号", "DB1.D6"));
|
||||
list.add(new ItemDto(item_x_position, "x坐标", "DB1.REAL10"));
|
||||
list.add(new ItemDto(item_y_position, "y坐标", "DB1.REAL14"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_to_command, "下发命令", "DB2.W0"));
|
||||
list.add(new ItemDto(item_to_onset, "下发起始站", "DB2.W2"));
|
||||
list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W4"));
|
||||
list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D6"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.nl.acs.device_driver.manipulator.standard_manipulator;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.enums.DeviceType;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
import org.nl.acs.device_driver.stacker.standard_stacker.StandardStackerDeviceDriver;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class StandardManipulatorDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "standard_manipulator";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "标准版-行架机械手";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "标准版-行架机械手";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new StandardStackerDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return StandardManipulatorDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.station);
|
||||
return types;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,396 @@
|
||||
package org.nl.acs.device_driver.manipulator.standard_manipulator;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.common.base.CommonFinalParam;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceExtraService;
|
||||
import org.nl.acs.device.service.impl.DeviceExtraServiceImpl;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.FeedLmsRealFailed;
|
||||
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.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.domain.Instruction;
|
||||
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.DeviceAppService;
|
||||
import org.nl.acs.opc.DeviceAppServiceImpl;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 标准版-行架机械手
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class StandardManipulatorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
|
||||
@Autowired
|
||||
DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||
@Autowired
|
||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineServiceImpl.class);
|
||||
@Autowired
|
||||
DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
|
||||
@Autowired
|
||||
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||
|
||||
//工作模式
|
||||
int mode = 0;
|
||||
int last_mode = 0;
|
||||
//光电信号
|
||||
int move = 0;
|
||||
int last_move = 0;
|
||||
//动作信号
|
||||
int action = 0;
|
||||
int last_action = 0;
|
||||
//行走列
|
||||
int walk_y = 0;
|
||||
int last_walk_y = 0;
|
||||
//报警信号
|
||||
int error = 0;
|
||||
int last_error = 0;
|
||||
//任务号
|
||||
int task = 0;
|
||||
int last_task = 0;
|
||||
// x坐标
|
||||
float x_position = 0;
|
||||
float last_x_position = 0;
|
||||
// y坐标
|
||||
float y_position = 0;
|
||||
float last_y_position = 0;
|
||||
|
||||
int heartbeat = 0;
|
||||
int last_heartbeat = 0;
|
||||
int to_command = 0;
|
||||
int last_to_command = 0;
|
||||
|
||||
int to_target = 0;
|
||||
int last_to_target = 0;
|
||||
|
||||
int to_task = 0;
|
||||
int last_to_task = 0;
|
||||
|
||||
int to_onset = 0;
|
||||
int last_to_onset = 0;
|
||||
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
private Date instruction_update_time = new Date();
|
||||
private int instruction_update_time_out = 1000;
|
||||
Integer heartbeat_tag;
|
||||
private Date instruction_require_time = new Date();
|
||||
|
||||
private int instruction_require_time_out = 3000;
|
||||
//行架机械手申请任务成功标识
|
||||
boolean requireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
int branchProtocol = 0;
|
||||
private String error_type = "hxhj_error_type";
|
||||
|
||||
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||
int flag;
|
||||
|
||||
String device_code;
|
||||
|
||||
//当前指令
|
||||
Instruction inst = null;
|
||||
|
||||
//0 无任务执行 1更新指令状态 2下发电气信号 3允许取货 允许放货 5放货完成
|
||||
int now_steps_type = 0;
|
||||
String notCreateTaskMessage = "";
|
||||
String notCreateInstMessage = "";
|
||||
String feedMessage = "";
|
||||
|
||||
|
||||
List<String> getDeviceCodeList = null;
|
||||
|
||||
List<String> putDeviceCodeList = null;
|
||||
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
move = this.itemProtocol.getMove();
|
||||
action = this.itemProtocol.getAction();
|
||||
walk_y = this.itemProtocol.getWalk_y();
|
||||
error = this.itemProtocol.getError();
|
||||
task = this.itemProtocol.getTask();
|
||||
heartbeat = this.itemProtocol.getHeartbeat();
|
||||
to_command = this.itemProtocol.getTo_command();
|
||||
to_target = this.itemProtocol.getTo_target();
|
||||
to_task = this.itemProtocol.getTo_task();
|
||||
to_onset = this.itemProtocol.getTo_onset();
|
||||
x_position = this.itemProtocol.getX_position();
|
||||
y_position = this.itemProtocol.getY_position();
|
||||
|
||||
if (to_onset != last_to_onset) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset:" + last_to_onset + "->" + to_onset);
|
||||
}
|
||||
if (to_command != last_to_command) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_command:" + last_to_command + "->" + to_command);
|
||||
}
|
||||
if (to_target != last_to_target) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_target:" + last_to_target + "->" + to_target);
|
||||
}
|
||||
if (to_task != last_to_task) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task:" + last_to_task + "->" + to_task);
|
||||
}
|
||||
if (mode != last_mode) {
|
||||
requireSucess = false;
|
||||
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 (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 (walk_y != last_walk_y) {
|
||||
logServer.deviceItemValue(this.device_code, "walk_y", String.valueOf(walk_y));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号walk_y:" + last_walk_y + "->" + walk_y);
|
||||
}
|
||||
if (task != last_task) {
|
||||
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task);
|
||||
}
|
||||
if (x_position != last_x_position) {
|
||||
logServer.deviceItemValue(this.device_code, "x_position", String.valueOf(x_position));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号x_position:" + last_x_position + "->" + x_position);
|
||||
}
|
||||
if (y_position != last_y_position) {
|
||||
logServer.deviceItemValue(this.device_code, "y_position", String.valueOf(y_position));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号y_position:" + last_y_position + "->" + y_position);
|
||||
}
|
||||
|
||||
// 更新指令状态
|
||||
if (mode == 3 && task > 0) {
|
||||
Date date = new Date();
|
||||
if (date.getTime() - this.instruction_update_time.getTime() < (long) this.instruction_update_time_out) {
|
||||
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_update_time_out);
|
||||
|
||||
} else {
|
||||
this.instruction_update_time = date;
|
||||
//更改指令状态
|
||||
if (task > 0) {
|
||||
Instruction inst = checkInst();
|
||||
if (inst != null) {
|
||||
if (StrUtil.equals(inst.getInstruction_status(), "0")) {
|
||||
inst.setInstruction_status(CommonFinalParam.ONE);
|
||||
inst.setExecute_device_code(this.device_code);
|
||||
instructionService.update(inst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
var17.printStackTrace();
|
||||
feedMessage = var17.getMessage();
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
|
||||
|
||||
}
|
||||
|
||||
if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
message = "未联机";
|
||||
//有报警
|
||||
} else if (error != 0) {
|
||||
this.setIserror(true);
|
||||
message = "有报警";
|
||||
//无报警
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
|
||||
//行架机械手申请任务
|
||||
if (mode == 2 && move == 0 && task == 0 && !requireSucess) {
|
||||
// boolean res = applyTask();
|
||||
// if (res) {
|
||||
// notCreateInstMessage = "";
|
||||
// notCreateTaskMessage = "";
|
||||
// feedMessage = "";
|
||||
// }
|
||||
} else {
|
||||
if (mode == 2) {
|
||||
//if (!requireSucess) {
|
||||
String remark = "未查找任务原因为:";
|
||||
if (mode != 2) {
|
||||
remark = remark + "工作模式(mode)不是待机状态,";
|
||||
}
|
||||
if (move != 0) {
|
||||
remark = remark + "光电信号(move)为有货状态,";
|
||||
}
|
||||
if (task != 0) {
|
||||
remark = remark + "当前上报任务号(task)应该为0,";
|
||||
if (ObjectUtil.isNotEmpty(this.inst)) {
|
||||
this.inst = null;
|
||||
}
|
||||
}
|
||||
if (requireSucess) {
|
||||
remark = remark + "请右击该图标,将请求任务复位标记(requireSucess)改为否。";
|
||||
}
|
||||
this.setNotCreateTaskMessage(remark);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
last_mode = mode;
|
||||
last_move = move;
|
||||
last_action = action;
|
||||
last_walk_y = walk_y;
|
||||
last_error = error;
|
||||
last_task = task;
|
||||
last_heartbeat = heartbeat;
|
||||
last_to_task = to_task;
|
||||
last_to_command = to_command;
|
||||
last_to_target = to_target;
|
||||
last_to_onset = to_onset;
|
||||
last_x_position = x_position;
|
||||
last_y_position = y_position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
String mode = "";
|
||||
String move = "";
|
||||
String action = "";
|
||||
String walk_y = "";
|
||||
if (this.getMode() == 0) {
|
||||
mode = "脱机";
|
||||
} else if (this.getMode() == 1) {
|
||||
mode = "单机";
|
||||
} else if (this.getMode() == 2) {
|
||||
mode = "待机";
|
||||
} else if (this.getMode() == 3) {
|
||||
mode = "运行中";
|
||||
}
|
||||
|
||||
if (this.getMove() == 0) {
|
||||
move = "无货";
|
||||
} else if (this.getMove() == 1) {
|
||||
move = "有货";
|
||||
}
|
||||
|
||||
String requireSucess = "0";
|
||||
if (this.requireSucess) {
|
||||
requireSucess = "1";
|
||||
}
|
||||
jo.put("requireSucess", requireSucess);
|
||||
if (this.getAction() == 1) {
|
||||
action = "取货中";
|
||||
} else if (this.getAction() == 2) {
|
||||
action = "取货完成";
|
||||
} else if (this.getAction() == 3) {
|
||||
action = "放货中";
|
||||
} else if (this.getAction() == 4) {
|
||||
action = "放货完成";
|
||||
}
|
||||
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("mode", mode);
|
||||
jo.put("move", move);
|
||||
jo.put("action", action);
|
||||
jo.put("task", task);
|
||||
jo.put("walk_y", walk_y);
|
||||
jo.put("isOnline", this.getIsonline());
|
||||
jo.put("error", ErrorUtil.getDictDetail("hxhj_error_type", String.valueOf(this.getError())));
|
||||
jo.put("isError", this.getIserror());
|
||||
jo.put("message", this.getMessage());
|
||||
jo.put("notCreateTaskMessage", notCreateTaskMessage);
|
||||
jo.put("notCreateInstMessage", notCreateInstMessage);
|
||||
jo.put("feedMessage", feedMessage);
|
||||
jo.put("driver_type", "siemens_conveyor");
|
||||
jo.put("is_click", true);
|
||||
jo.put("x", x_position);
|
||||
jo.put("y", y_position);
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
String requestSucess = data.getString("requireSucess");
|
||||
if (StrUtil.equals(requestSucess, "0")) {
|
||||
this.requireSucess = false;
|
||||
} else if (StrUtil.equals(requestSucess, "1")) {
|
||||
this.requireSucess = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject feedLmsRealFailedInfo() {
|
||||
JSONObject jo = new JSONObject();
|
||||
jo.put("device_code", this.getDevice().getDevice_code());
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("fault_code", String.valueOf(error));
|
||||
jo.put("fault_info", ErrorUtil.getDictDetail(error_type, String.valueOf(this.getError())));
|
||||
jo.put("fault_type", error_type);
|
||||
return jo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Instruction checkInst() {
|
||||
if (ObjectUtil.isNotEmpty(this.inst)) {
|
||||
if (this.task > 0) {
|
||||
if (this.inst.getInstruction_code().equals(String.valueOf(this.task))) {
|
||||
return this.inst;
|
||||
} else {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
return inst;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
return inst;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user