add 输送
This commit is contained in:
@@ -31,8 +31,9 @@ public enum DriverTypeEnum {
|
||||
|
||||
HAOKAI_AUTO_CONVEYOR(11, "haokai_auto_conveyor", "豪恺自动线对接位", "conveyor"),
|
||||
|
||||
PAINT_CONVEYOR(12, "paint_conveyor", "油漆线", "conveyor");
|
||||
PAINT_CONVEYOR(12, "paint_conveyor", "油漆线", "conveyor"),
|
||||
|
||||
SIEMENS_CONVEYOR(13, "siemens_conveyor", "西门子-输送机驱动", "conveyor");
|
||||
|
||||
//驱动索引
|
||||
private int index;
|
||||
|
||||
@@ -163,8 +163,8 @@ public class EmptyVehicleStackingPositionDeviceDriver extends AbstractOpcDeviceD
|
||||
last_mode = mode;
|
||||
last_move = move;
|
||||
last_error = error;
|
||||
last_task = error;
|
||||
last_number = error;
|
||||
last_task = task;
|
||||
last_number = number;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -111,7 +111,6 @@ public class HailiangSmartplcTestDeviceDriver extends AbstractOpcDeviceDriver im
|
||||
number = this.itemProtocol.getItem_number();
|
||||
container_type = this.itemProtocol.getItem_container_type();
|
||||
task = this.itemProtocol.getItem_task();
|
||||
System.out.println("设备:" + device_code + "共挤线mode=" + mode);
|
||||
if (mode != last_mode) {
|
||||
if (mode == 4) {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "请求标记变化前:requireSucess = " + requireSucess);
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
package org.nl.acs.device_driver.basedriver.siemens_conveyor;
|
||||
|
||||
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_container_type = "container_type";
|
||||
|
||||
public static String item_action = "action";
|
||||
//托盘方向
|
||||
public static String item_carrier_direction = "carrier_direction";
|
||||
//报警
|
||||
public static String item_error = "error";
|
||||
//任务号
|
||||
public static String item_task = "task";
|
||||
|
||||
//下发命令
|
||||
public static String item_to_command = "to_command";
|
||||
//下发目标站
|
||||
public static String item_to_target = "to_target";
|
||||
//下发托盘类型
|
||||
public static String item_to_container_type = "to_container_type";
|
||||
//下发任务号
|
||||
public static String item_to_task = "to_task";
|
||||
//困扎次数
|
||||
public static String item_to_strap_times = "to_strap_times";
|
||||
//木箱长度
|
||||
public static String item_to_length = "to_length";
|
||||
//木箱宽度
|
||||
public static String item_to_weight = "to_weight";
|
||||
//木箱高度
|
||||
public static String item_to_height = "to_height";
|
||||
|
||||
|
||||
private SiemensConveyorDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(SiemensConveyorDeviceDriver 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 getContainer_type() {
|
||||
return this.getOpcIntegerValue(item_container_type);
|
||||
}
|
||||
|
||||
public int getCarrier_direction() {
|
||||
return this.getOpcIntegerValue(item_carrier_direction);
|
||||
}
|
||||
|
||||
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_strap_times() {
|
||||
return this.getOpcIntegerValue(item_to_strap_times);
|
||||
}
|
||||
|
||||
public int getTo_length() {
|
||||
return this.getOpcIntegerValue(item_to_length);
|
||||
}
|
||||
|
||||
public int getTo_weight() {
|
||||
return this.getOpcIntegerValue(item_to_weight);
|
||||
}
|
||||
|
||||
public int getTo_height() {
|
||||
return this.getOpcIntegerValue(item_to_height);
|
||||
}
|
||||
|
||||
|
||||
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 static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB101.B0"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB101.B2"));
|
||||
list.add(new ItemDto(item_move, "光电信号", "DB101.B3"));
|
||||
list.add(new ItemDto(item_action, "动作信号", "DB101.B4"));
|
||||
list.add(new ItemDto(item_carrier_direction, "托盘方向", "DB101.B5"));
|
||||
list.add(new ItemDto(item_error, "报警信号", "DB101.B6"));
|
||||
list.add(new ItemDto(item_container_type, "托盘类型", "DB101.B8"));
|
||||
list.add(new ItemDto(item_task, "任务号", "DB101.D10"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "下发命令", "DB102.W0"));
|
||||
list.add(new ItemDto(item_to_target, "下发目标站", "DB102.W2"));
|
||||
list.add(new ItemDto(item_to_container_type, "下发托盘类型", "DB102.W4"));
|
||||
list.add(new ItemDto(item_to_task, "下发任务号", "DB102.D6"));
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.nl.acs.device_driver.basedriver.siemens_conveyor;
|
||||
|
||||
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 SiemensConveyorDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "siemens_conveyor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "西门子-输送机驱动";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "西门子-输送机驱动";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new SiemensConveyorDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return SiemensConveyorDeviceDriver.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,689 @@
|
||||
package org.nl.acs.device_driver.basedriver.siemens_conveyor;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.server.NDCAgvService;
|
||||
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.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.modules.system.service.ParamService;
|
||||
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 SiemensConveyorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
|
||||
protected ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
@Autowired
|
||||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
|
||||
@Autowired
|
||||
DeviceService deviceservice = SpringContextHolder.getBean(DeviceService.class);
|
||||
@Autowired
|
||||
RouteLineService routelineserver = SpringContextHolder.getBean(RouteLineService.class);
|
||||
@Autowired
|
||||
TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
|
||||
@Autowired
|
||||
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
|
||||
@Autowired
|
||||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
|
||||
@Autowired
|
||||
ParamService paramService = SpringContextHolder.getBean(ParamService.class);
|
||||
@Autowired
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
|
||||
@Autowired
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
@Autowired
|
||||
NDCAgvService agvService = SpringContextHolder.getBean(NDCAgvService.class);
|
||||
//当前指令
|
||||
Instruction inst = null;
|
||||
|
||||
private String error_type = "ssx_error_type";
|
||||
|
||||
//工作模式
|
||||
int mode = 0;
|
||||
int last_mode = 0;
|
||||
//光电信号
|
||||
int move = 0;
|
||||
int last_move = 0;
|
||||
//托盘方向
|
||||
int carrier_direction = 0;
|
||||
int last_carrier_direction = 0;
|
||||
//报警信号
|
||||
int error = 0;
|
||||
int last_error = 0;
|
||||
//任务号
|
||||
int task = 0;
|
||||
int last_task = 0;
|
||||
int agvphase = 0;
|
||||
String task_code = null;
|
||||
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_strap_times = 0;
|
||||
int last_to_strap_times = 0;
|
||||
int to_length = 0;
|
||||
int last_to_length = 0;
|
||||
int to_weight = 0;
|
||||
int last_to_weight = 0;
|
||||
int to_height = 0;
|
||||
int last_to_height = 0;
|
||||
|
||||
int phase = 0;
|
||||
int index = 0;
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
Boolean iserror = false;
|
||||
|
||||
String hand_barcode = null;
|
||||
|
||||
Integer heartbeat_tag;
|
||||
private Date instruction_update_time = new Date();
|
||||
private int instruction_update_time_out = 500;
|
||||
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date require_apply_labeling_time = new Date();
|
||||
private Date require_apply_strangulation_time = new Date();
|
||||
private Date require_empty_in_time = new Date();
|
||||
private Date require_empty_out_time = new Date();
|
||||
|
||||
private int instruction_require_time_out = 3000;
|
||||
//行架机械手申请任务成功标识
|
||||
boolean requireSucess = false;
|
||||
boolean requireEmptyInSuccess = false;
|
||||
boolean requiresShipDeviceUpdate = true;
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
int branchProtocol = 0;
|
||||
String inst_message;
|
||||
String last_inst_message;
|
||||
int heartbeat = 0;
|
||||
int last_heartbeat = 0;
|
||||
//当前指令
|
||||
|
||||
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||
int flag;
|
||||
|
||||
String device_code;
|
||||
|
||||
String vehicle_code;
|
||||
String last_vehicle_code;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
move = this.itemProtocol.getMove();
|
||||
carrier_direction = this.itemProtocol.getCarrier_direction();
|
||||
error = this.itemProtocol.getError();
|
||||
task = this.itemProtocol.getTask();
|
||||
to_command = this.itemProtocol.getTo_command();
|
||||
to_target = this.itemProtocol.getTo_target();
|
||||
to_task = this.itemProtocol.getTo_task();
|
||||
heartbeat = this.itemProtocol.getHeartbeat();
|
||||
to_strap_times = this.itemProtocol.getTo_strap_times();
|
||||
to_length = this.itemProtocol.getTo_length();
|
||||
to_weight = this.itemProtocol.getTo_weight();
|
||||
to_height = this.itemProtocol.getTo_height();
|
||||
// if(heartbeat != last_heartbeat){
|
||||
// logServer.deviceExecuteLog(this.device_code, "", "", "heartbeat:" + last_heartbeat + "->" + heartbeat);
|
||||
// }
|
||||
|
||||
if (to_strap_times != last_to_strap_times) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_strap_times:" + last_to_strap_times + "->" + to_strap_times);
|
||||
}
|
||||
if (to_length != last_to_length) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_length:" + last_to_length + "->" + to_length);
|
||||
}
|
||||
if (to_weight != last_to_weight) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_weight:" + last_to_weight + "->" + to_weight);
|
||||
}
|
||||
if (to_height != last_to_height) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_height:" + last_to_height + "->" + to_height);
|
||||
}
|
||||
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.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode + "复位请求标记:" + requireSucess);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + last_mode + "->" + mode);
|
||||
}
|
||||
if (move != last_move) {
|
||||
message = null;
|
||||
if (move == 0) {
|
||||
inst_message = null;
|
||||
this.hand_barcode = null;
|
||||
this.clearWrite();
|
||||
}
|
||||
if (move == 0 && last_move == 1) {
|
||||
last_vehicle_code = vehicle_code;
|
||||
last_inst_message = inst_message;
|
||||
if ("true".equals(this.device.getExtraValue().get("ship_device_update"))) {
|
||||
this.requiresShipDeviceUpdate = false;
|
||||
}
|
||||
}
|
||||
logServer.deviceItemValue(this.device_code, "move", String.valueOf(move));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号move:" + last_move + "->" + move);
|
||||
}
|
||||
if (carrier_direction != last_carrier_direction) {
|
||||
logServer.deviceItemValue(this.device_code, "carrier_direction", String.valueOf(carrier_direction));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号carrier_direction:" + last_carrier_direction + "->" + carrier_direction);
|
||||
}
|
||||
if (error != last_error) {
|
||||
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + last_error + "->" + error);
|
||||
}
|
||||
if (task != last_task) {
|
||||
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号task:" + last_task + "->" + task);
|
||||
}
|
||||
|
||||
if (move != 0 && task > 0) {
|
||||
|
||||
update_instruction_status();
|
||||
}
|
||||
|
||||
} catch (Exception var17) {
|
||||
var17.printStackTrace();
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
|
||||
}
|
||||
|
||||
|
||||
if (mode == 0) {
|
||||
this.setIsonline(false);
|
||||
message = "未联机";
|
||||
//有报警
|
||||
|
||||
} else {
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
if (error != 0) {
|
||||
this.setIserror(true);
|
||||
message = "有报警";
|
||||
}
|
||||
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
|
||||
switch (mode) {
|
||||
case 1:
|
||||
log.debug("设备运转模式:等待工作");
|
||||
break;
|
||||
case 2:
|
||||
//申请任务
|
||||
if (move > 0 && !requireSucess) {
|
||||
instruction_require();
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
//申请任务
|
||||
if (move > 0 && !requireSucess) {
|
||||
apply();
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
last_mode = mode;
|
||||
last_move = move;
|
||||
last_carrier_direction = carrier_direction;
|
||||
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_strap_times = to_strap_times;
|
||||
last_to_length = to_length;
|
||||
last_to_weight = to_weight;
|
||||
last_to_height = to_height;
|
||||
}
|
||||
|
||||
public boolean exe_error() {
|
||||
if (this.error == 0) {
|
||||
return true;
|
||||
} else {
|
||||
log.debug("设备报警");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void clearWrite() {
|
||||
|
||||
List list = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
map.put("code", "to_target");
|
||||
map.put("value", "0");
|
||||
list.add(map);
|
||||
Map map2 = new HashMap();
|
||||
map2.put("code", "to_task");
|
||||
map2.put("value", "0");
|
||||
list.add(map2);
|
||||
Map map3 = new HashMap();
|
||||
map3.put("code", "to_command");
|
||||
map3.put("value", "0");
|
||||
list.add(map3);
|
||||
Map map4 = new HashMap();
|
||||
map4.put("code", "to_strap_times");
|
||||
map4.put("value", "0");
|
||||
list.add(map4);
|
||||
this.writing(0,0,0);
|
||||
message = null;
|
||||
vehicle_code = null;
|
||||
}
|
||||
|
||||
public boolean exe_business() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized boolean finish_instruction() throws Exception {
|
||||
instructionService.finish(inst);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
protected void thingToNothing() throws Exception {
|
||||
requireSucess = false;
|
||||
}
|
||||
|
||||
|
||||
public void writing(int command, int target, int task) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command;
|
||||
String to_target = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_target;
|
||||
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_task;
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
itemMap.put(to_target, target);
|
||||
itemMap.put(to_task, task);
|
||||
ReadUtil.write(itemMap, server);
|
||||
server.disconnect();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
String mode = "";
|
||||
String move = "";
|
||||
String carrier_direction = "";
|
||||
if (this.getMode() == 0) {
|
||||
mode = "脱机";
|
||||
} else if (this.getMode() == 1) {
|
||||
mode = "单机";
|
||||
} else if (this.getMode() == 2) {
|
||||
mode = "待机";
|
||||
} else if (this.getMode() == 3) {
|
||||
mode = "运行中";
|
||||
} else if (this.getMode() == 4) {
|
||||
mode = "申请捆扎中";
|
||||
} else if (this.getMode() == 5) {
|
||||
mode = "申请贴标中";
|
||||
} else if (this.getMode() == 6) {
|
||||
mode = "申请空盘入库中";
|
||||
} else if (this.getMode() == 7) {
|
||||
mode = "申请空盘出库中";
|
||||
} else if (this.getMode() == 8) {
|
||||
mode = "申请AGV任务中";
|
||||
}
|
||||
|
||||
if (this.getMove() == 0) {
|
||||
move = "无货";
|
||||
jo.put("hasGoods", false);
|
||||
} else if (this.getMove() == 1) {
|
||||
move = "有货";
|
||||
jo.put("hasGoods", true);
|
||||
} else if (this.getMove() == 2) {
|
||||
move = "有托盘有货";
|
||||
jo.put("hasGoods", true);
|
||||
}
|
||||
|
||||
if (this.carrier_direction == 1) {
|
||||
carrier_direction = "正转";
|
||||
} else if (this.carrier_direction == 2) {
|
||||
carrier_direction = "反转";
|
||||
}
|
||||
String requireSucess = "0";
|
||||
if (this.requireSucess) {
|
||||
requireSucess = "1";
|
||||
}
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("mode", mode);
|
||||
jo.put("move", move);
|
||||
jo.put("carrier_direction", carrier_direction);
|
||||
jo.put("task", task);
|
||||
jo.put("last_task", last_task);
|
||||
jo.put("task_code", task_code);
|
||||
jo.put("inst_message", this.inst_message);
|
||||
jo.put("last_inst_message", this.last_inst_message);
|
||||
jo.put("isOnline", this.getIsonline());
|
||||
jo.put("error",error);
|
||||
jo.put("isError", this.getIserror());
|
||||
jo.put("message", this.getMessage());
|
||||
jo.put("hand_barcode", hand_barcode);
|
||||
jo.put("barcode", this.getMove() == 0 ? null : instructionService.findByCodeFromCache(String.valueOf(task)) == null ? vehicle_code : instructionService.findByCodeFromCache(String.valueOf(task)).getVehicle_code());
|
||||
jo.put("is_click", true);
|
||||
jo.put("requireSucess", requireSucess);
|
||||
jo.put("driver_type", "siemens_conveyor");
|
||||
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;
|
||||
}
|
||||
|
||||
String hand_barcode = data.getString("hand_barcode");
|
||||
this.setHand_barcode(hand_barcode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 请求指令
|
||||
*/
|
||||
public synchronized boolean instruction_require() {
|
||||
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;
|
||||
//判断是否存在起点相同 任务状态就绪的任务
|
||||
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
|
||||
if (!ObjectUtil.isEmpty(taskdto)) {
|
||||
//需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建
|
||||
Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code());
|
||||
if (ObjectUtil.isNotEmpty(inst)) {
|
||||
Device next_device = deviceAppservice.findDeviceByCode(inst.getNext_device_code());
|
||||
String next_addr = next_device.getExtraValue().get("address").toString();
|
||||
this.writing(1,Integer.parseInt(inst.getInstruction_code()),Integer.parseInt(next_addr));
|
||||
requireSucess = true;
|
||||
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
|
||||
, inst.getInstruction_code())) {
|
||||
this.writing(1,Integer.parseInt(inst.getInstruction_code()),Integer.parseInt(next_addr));
|
||||
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发信号");
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(ObjectUtil.isEmpty(instructionService.findByTaskcodeAndStatus(taskdto.getTask_code()))){
|
||||
requireSucess = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
message = "下发电气任务号成功";
|
||||
requireSucess = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
String taskid = taskdto.getTask_id();
|
||||
String taskcode = taskdto.getTask_code();
|
||||
String vehiclecode = taskdto.getVehicle_code();
|
||||
String priority = taskdto.getPriority();
|
||||
String start_point_code = taskdto.getStart_point_code();
|
||||
String start_device_code = taskdto.getStart_device_code();
|
||||
String route_plan_code = taskdto.getRoute_plan_code();
|
||||
String next_device_code = "";
|
||||
|
||||
/**
|
||||
* 开始平均分配
|
||||
*/
|
||||
String this_coevice_code = taskserver.queryAssignedByDevice(device_code, taskdto.getNext_device_code());
|
||||
if (StrUtil.isEmpty(this_coevice_code)) {
|
||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, taskdto.getNext_device_code(), route_plan_code);
|
||||
RouteLineDto routeLineDto = shortPathsList.get(0);
|
||||
|
||||
String path = routeLineDto.getPath();
|
||||
String type = routeLineDto.getType();
|
||||
String[] str = path.split("->");
|
||||
|
||||
List<String> pathlist = Arrays.asList(str);
|
||||
int index = 0;
|
||||
for (int m = 0; m < pathlist.size(); m++) {
|
||||
if (pathlist.get(m).equals(start_device_code)) {
|
||||
index = m + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
next_device_code = pathlist.get(index);
|
||||
} else {
|
||||
next_device_code = this_coevice_code;
|
||||
}
|
||||
//校验路由关系
|
||||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
|
||||
if (ObjectUtils.isEmpty(shortPathsList)) {
|
||||
throw new RuntimeException("路由不通!");
|
||||
}
|
||||
|
||||
Device startdevice = deviceAppservice.findDeviceByCode(start_device_code);
|
||||
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code);
|
||||
String next_point_code;
|
||||
if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) {
|
||||
next_point_code = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.getTo_z();
|
||||
} else {
|
||||
next_point_code = next_device_code;
|
||||
}
|
||||
Instruction instdto = new Instruction();
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(route_plan_code);
|
||||
instdto.setRemark(taskdto.getRemark());
|
||||
instdto.setMaterial(taskdto.getMaterial());
|
||||
instdto.setQuantity(taskdto.getQuantity());
|
||||
instdto.setTask_id(taskid);
|
||||
instdto.setTask_code(taskcode);
|
||||
instdto.setVehicle_code(vehiclecode);
|
||||
String now = DateUtil.now();
|
||||
instdto.setCreate_time(now);
|
||||
instdto.setCreate_by("auto");
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
instdto.setPriority(priority);
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(start_point_code);
|
||||
try {
|
||||
instructionService.create(instdto);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("指令创建失败!", e.getMessage());
|
||||
return false;
|
||||
}
|
||||
//创建指令后修改任务状态
|
||||
taskdto.setTask_status("1");
|
||||
taskserver.update(taskdto);
|
||||
requireSucess = true;
|
||||
Device next_device = deviceAppservice.findDeviceByCode(inst.getNext_device_code());
|
||||
String next_addr = next_device.getExtraValue().get("address").toString();
|
||||
this.writing(1,Integer.parseInt(inst.getInstruction_code()),Integer.parseInt(next_addr));
|
||||
requireSucess = true;
|
||||
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
|
||||
, instdto.getInstruction_code())) {
|
||||
this.writing(1,Integer.parseInt(inst.getInstruction_code()),Integer.parseInt(next_addr));
|
||||
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(ObjectUtil.isEmpty(taskserver.findByCode(taskdto.getTask_code()))){
|
||||
requireSucess = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
//如果不存在则直接找对应指令
|
||||
Instruction inst = instructionService.findByDeviceCodeFromCache(this.device_code);
|
||||
if (ObjectUtil.isEmpty(inst)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Device nextdevice = deviceAppservice.findDeviceByCode(inst.getNext_device_code());
|
||||
String next_addr = nextdevice.getExtraValue().get("address").toString();
|
||||
|
||||
this.writing(1,Integer.parseInt(inst.getInstruction_code()),Integer.parseInt(next_addr));
|
||||
requireSucess = true;
|
||||
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
|
||||
, inst.getInstruction_code())) {
|
||||
this.writing(1,Integer.parseInt(inst.getInstruction_code()),Integer.parseInt(next_addr));
|
||||
logServer.deviceExecuteLog(device_code, "", "", inst.getInstruction_code() + "再次下发电气信号");
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(ObjectUtil.isEmpty(instructionService.findByDeviceCodeFromCache(this.device_code))){
|
||||
requireSucess = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指令状态
|
||||
*/
|
||||
public synchronized void update_instruction_status() throws Exception {
|
||||
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;
|
||||
inst = instructionService.findByCodeFromCache(String.valueOf(task));
|
||||
if (inst != null) {
|
||||
inst_message = "当前指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code() + " 载具号:" + inst.getVehicle_code();
|
||||
vehicle_code = inst.getVehicle_code();
|
||||
task_code = inst.getTask_code();
|
||||
if (StrUtil.equals(inst.getInstruction_status(), "0") && StrUtil.equals(this.getDeviceCode(), inst.getStart_device_code())) {
|
||||
inst.setInstruction_status("1");
|
||||
inst.setExecute_device_code(this.device_code);
|
||||
instructionService.update(inst);
|
||||
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈执行中状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code());
|
||||
}
|
||||
if (StrUtil.equals(inst.getInstruction_status(), "1") || StrUtil.equals(inst.getInstruction_status(), "0") ) {
|
||||
if (StrUtil.equals(this.getDeviceCode(), inst.getNext_device_code())) {
|
||||
vehicle_code = inst.getVehicle_code();
|
||||
inst.setExecute_device_code(this.device_code);
|
||||
finish_instruction();
|
||||
logServer.deviceExecuteLog(device_code, "", "", "入库输送线任务开始反馈完成状态,反馈成功,指令号:" + task + ",载具号:"+ inst.getVehicle_code());
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
inst_message = null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求指令
|
||||
*/
|
||||
public synchronized boolean apply() {
|
||||
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;
|
||||
if(task>0){
|
||||
Instruction instruction = instructionService.findByCode(String.valueOf(task));
|
||||
if(ObjectUtil.isEmpty(instruction)){
|
||||
logServer.deviceExecuteLog(device_code, "", "", "未找到对应指令,task:"+task);
|
||||
return false;
|
||||
}
|
||||
TaskDto taskDto = taskserver.findByCode(instruction.getTask_code());
|
||||
if(ObjectUtil.isEmpty(taskDto)){
|
||||
logServer.deviceExecuteLog(device_code, "", "", "未找到对应任务,task:"+task);
|
||||
return false;
|
||||
}
|
||||
JSONObject apply = new JSONObject();
|
||||
apply.put("device_code", device_code);
|
||||
apply.put("task_id", taskDto.getExt_task_id());
|
||||
apply.put("type", "12");
|
||||
String str = acsToWmsService.applyTaskToWms(apply);
|
||||
JSONObject jo = JSON.parseObject(str);
|
||||
if (ObjectUtil.isEmpty(jo)) {
|
||||
message = "申请AGV任务失败 null";
|
||||
} else {
|
||||
if (jo.getInteger("status") == 200) {
|
||||
requireSucess = true;
|
||||
} else {
|
||||
message = "申请AGV任务失败," + jo.get("message").toString();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
logServer.deviceExecuteLog(device_code, "", "", "未申请agv任务,task:"+task);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -184,13 +184,15 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
AddressDto addressDto = addressService.findByCode("requestTaskAgain");
|
||||
String methods_url = addressDto.getMethods_url();
|
||||
String url = wmsurl + methods_url;
|
||||
logServer.acsToLms("acsToLms", url, String.valueOf(jo), "开始请求~");
|
||||
logServer.acsToLms("acsToLms", url, String.valueOf(jo), "requestTaskAgain 开始请求~");
|
||||
try {
|
||||
result = HttpRequest.post(url)
|
||||
.body(String.valueOf(jo))
|
||||
.execute().body();
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
logServer.acsToLms("acsToLms", url, String.valueOf(jo), jsonObject.getString("status"), jsonObject.getString("message"));
|
||||
logServer.acsToLms("acsToLms", url, String.valueOf(jo), "requestTaskAgain 返回参数~"+jsonObject.toString());
|
||||
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
logServer.acsToLms("acsToLms", url, String.valueOf(jo), "400", e.getMessage());
|
||||
@@ -216,7 +218,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
AddressDto addressDto = addressService.findByCode("apply_InEmpty");
|
||||
String methods_url = addressDto.getMethods_url();
|
||||
String url = wmsurl + methods_url;
|
||||
log.info("requestTaskAgain----请求参数{}", jo);
|
||||
log.info("apply_InEmpty----请求参数{}", jo);
|
||||
|
||||
try {
|
||||
result2 = HttpRequest.post(url)
|
||||
@@ -224,7 +226,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
.body(String.valueOf(jo))
|
||||
.execute().body();
|
||||
System.out.println(result2);
|
||||
log.info("requestTaskAgain----返回参数{}", result2);
|
||||
log.info("apply_InEmpty----返回参数{}", result2);
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
//网络不通
|
||||
|
||||
@@ -88,6 +88,9 @@ public interface InstructionService {
|
||||
|
||||
Instruction findByCacheTaskcode(String code);
|
||||
|
||||
Instruction findByTaskcodeAndStatus(String code);
|
||||
|
||||
|
||||
/**
|
||||
* 根据任务id查询
|
||||
*
|
||||
|
||||
@@ -243,6 +243,19 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction findByTaskcodeAndStatus(String code) {
|
||||
Iterator var3 = instructions.iterator();
|
||||
while (var3.hasNext()) {
|
||||
Instruction instruction = (Instruction) var3.next();
|
||||
if (StrUtil.equals(instruction.getTask_code(), code)
|
||||
&& StrUtil.equals(instruction.getInstruction_status(), "0")) {
|
||||
return instruction;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Instruction findByTaskid(String id, String wherecaluse) {
|
||||
if (!StrUtil.isEmpty(wherecaluse)) {
|
||||
|
||||
@@ -67,6 +67,15 @@ public interface TaskService {
|
||||
*/
|
||||
List<TaskDto> queryAll(Map whereJson);
|
||||
|
||||
/**
|
||||
* 根据起点设备编号查询当前是否有就绪任务
|
||||
*
|
||||
* @param device_code
|
||||
* @return
|
||||
*/
|
||||
TaskDto findByStartCodeAndReady(String device_code);
|
||||
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
*
|
||||
|
||||
@@ -228,6 +228,20 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TaskDto findByStartCodeAndReady(String device_code) {
|
||||
Iterator var3 = tasks.iterator();
|
||||
|
||||
while (var3.hasNext()) {
|
||||
TaskDto task = (TaskDto) var3.next();
|
||||
if (StrUtil.equals(task.getStart_device_code(), device_code)
|
||||
&& StrUtil.equals(task.getTask_status(), "0")) {
|
||||
return task;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryAll(Map whereJson) {
|
||||
WQLObject wo = WQLObject.getWQLObject("acs_task");
|
||||
|
||||
@@ -80,8 +80,8 @@ public class LogAspect {
|
||||
// 方法路径
|
||||
String methodName = joinPoint.getTarget().getClass().getName() + "." + signature.getName() + "()";
|
||||
String params=getParameter(method, joinPoint.getArgs());
|
||||
log.info("请求方法:{}",methodName);
|
||||
log.info("请求方法参数:{}",params);
|
||||
// log.info("请求方法:{}",methodName);
|
||||
// log.info("请求方法参数:{}",params);
|
||||
|
||||
Object result;
|
||||
currentTime.set(System.currentTimeMillis());
|
||||
|
||||
@@ -62,7 +62,7 @@ public class QueryOneZDAgvTaskStatus {
|
||||
// UNROUTABLE:无法规划该业务订单的执行路线
|
||||
|
||||
//执行中
|
||||
if ("BEING_PROCESSED".equals(status) || "ACTIVE".equals(status)) {
|
||||
if ("BEING_PdROCESSED".equals(status) || "ACTIVE".equals(status)) {
|
||||
if (inst != null) {
|
||||
inst.setInstruction_status("1");
|
||||
instructionService.update(inst);
|
||||
|
||||
Reference in New Issue
Block a user