更新
This commit is contained in:
@@ -103,7 +103,7 @@ public enum DriverTypeEnum {
|
|||||||
|
|
||||||
LNSH_SPLIT_MANIPULATOR(47, "lnsh_split_manipulator", "晟华-拆垛机械手", "station"),
|
LNSH_SPLIT_MANIPULATOR(47, "lnsh_split_manipulator", "晟华-拆垛机械手", "station"),
|
||||||
|
|
||||||
LNSH_RGV(48, "lnsh_rgv", "晟华-RGV", "station"),
|
LNSH_RGV(48, "lnsh_rgv", "晟华-RGV", "rgv"),
|
||||||
|
|
||||||
LNSH_PACKAGE_LINE(49, "lnsh_package_line", "晟华-包装机", "station"),
|
LNSH_PACKAGE_LINE(49, "lnsh_package_line", "晟华-包装机", "station"),
|
||||||
|
|
||||||
|
|||||||
@@ -1192,6 +1192,18 @@ public class DeviceServiceImpl implements DeviceService, ApplicationAutoInitial
|
|||||||
}
|
}
|
||||||
|
|
||||||
extraObj.put("address", dto.getAddress());
|
extraObj.put("address", dto.getAddress());
|
||||||
|
JSONArray get_device_code = extraObj.getJSONArray("get_device_code");
|
||||||
|
JSONArray load_device_code = extraObj.getJSONArray("load_device_code");
|
||||||
|
JSONArray put_device_code = extraObj.getJSONArray("put_device_code");
|
||||||
|
if (ObjectUtil.isNotEmpty(get_device_code)) {
|
||||||
|
extraObj.put("get_device_code",get_device_code);
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(load_device_code)) {
|
||||||
|
extraObj.put("load_device_code",load_device_code);
|
||||||
|
}
|
||||||
|
if (ObjectUtil.isNotEmpty(put_device_code)) {
|
||||||
|
extraObj.put("put_device_code",put_device_code);
|
||||||
|
}
|
||||||
result.put("form", extraObj);
|
result.put("form", extraObj);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -252,6 +252,65 @@ public class LnshPalletizingManipulatorDeviceDriver extends AbstractOpcDeviceDri
|
|||||||
production_time = this.itemProtocol.getProduction_time();
|
production_time = this.itemProtocol.getProduction_time();
|
||||||
error_time = this.itemProtocol.getError_time();
|
error_time = this.itemProtocol.getError_time();
|
||||||
encoder_qty = this.itemProtocol.getEncoder_qty();
|
encoder_qty = this.itemProtocol.getEncoder_qty();
|
||||||
|
|
||||||
|
product_code = this.itemProtocol.getProduct_code();
|
||||||
|
AlongSide = this.itemProtocol.getAlongSide();
|
||||||
|
BshortSide = this.itemProtocol.getBshortSide();
|
||||||
|
Htrapezoidal = this.itemProtocol.getHtrapezoidal();
|
||||||
|
Wthickness = this.itemProtocol.getWthickness();
|
||||||
|
tray_qty = this.itemProtocol.getTray_qty();
|
||||||
|
tray_high = this.itemProtocol.getTray_high();
|
||||||
|
crib_category = this.itemProtocol.getCrib_category();
|
||||||
|
palletX1_line = this.itemProtocol.getPalletX1_line();
|
||||||
|
palletY1_row = this.itemProtocol.getPalletY1_row();
|
||||||
|
palletA1_angle = this.itemProtocol.getPalletA1_angle();
|
||||||
|
palletX2_line = this.itemProtocol.getPalletX2_line();
|
||||||
|
palletY2_row = this.itemProtocol.getPalletY2_row();
|
||||||
|
palletA2_angle = this.itemProtocol.getPalletA2_angle();
|
||||||
|
palletX3_line = this.itemProtocol.getPalletX3_line();
|
||||||
|
palletY3_row = this.itemProtocol.getPalletY3_row();
|
||||||
|
palletA3_angle = this.itemProtocol.getPalletA3_angle();
|
||||||
|
pressCribX1_line = this.itemProtocol.getPressCribX1_line();
|
||||||
|
pressCribY1_row = this.itemProtocol.getPressCribY1_row();
|
||||||
|
pressCribA1_angle = this.itemProtocol.getPressCribA1_angle();
|
||||||
|
pressCribX2_line = this.itemProtocol.getPressCribX2_line();
|
||||||
|
pressCribY2_row = this.itemProtocol.getPressCribY2_row();
|
||||||
|
pressCribA2_angle = this.itemProtocol.getPressCribA2_angle();
|
||||||
|
pressCribX3_line = this.itemProtocol.getPressCribX3_line();
|
||||||
|
pressCribY3_row = this.itemProtocol.getPressCribY3_row();
|
||||||
|
pressCribA3_angle = this.itemProtocol.getPressCribA3_angle();
|
||||||
|
Zoffset = this.itemProtocol.getZoffset();
|
||||||
|
pallet_layerQty = this.itemProtocol.getPallet_layerQty();
|
||||||
|
pressCrib_layerQty = this.itemProtocol.getPressCrib_layerQty();
|
||||||
|
codeLayerX1_interval = this.itemProtocol.getCodeLayerX1_interval();
|
||||||
|
codeLayerY1_interval = this.itemProtocol.getCodeLayerY1_interval();
|
||||||
|
codeLayerX2_interval = this.itemProtocol.getCodeLayerX2_interval();
|
||||||
|
codeLayerY2_interval = this.itemProtocol.getCodeLayerY2_interval();
|
||||||
|
codeLayerX3_interval = this.itemProtocol.getCodeLayerX3_interval();
|
||||||
|
codeLayerY3_interval = this.itemProtocol.getcodeLayerY3_interval();
|
||||||
|
codeLayerX1_offset = this.itemProtocol.getCodeLayerX1_offset();
|
||||||
|
codeLayerY1_offset = this.itemProtocol.getCodeLayerY1_offset();
|
||||||
|
codeLayerX2_offset = this.itemProtocol.getCodeLayerX2_offset();
|
||||||
|
codeLayerY2_offset = this.itemProtocol.getCodeLayerY2_offset();
|
||||||
|
codeLayerX3_offset = this.itemProtocol.getCodeLayerX3_offset();
|
||||||
|
codeLayerY3_offset = this.itemProtocol.getCodeLayerY3_offset();
|
||||||
|
pressLayerX1_interval = this.itemProtocol.getPressLayerX1_interval();
|
||||||
|
pressLayerY1_interval = this.itemProtocol.getPressLayerY1_interval();
|
||||||
|
pressLayerX2_interval = this.itemProtocol.getPressLayerX2_interval();
|
||||||
|
pressLayerY2_interval = this.itemProtocol.getPressLayerY2_interval();
|
||||||
|
pressLayerX3_interval = this.itemProtocol.getPressLayerX3_interval();
|
||||||
|
pressLayerY3_interval = this.itemProtocol.getPressLayerY3_interval();
|
||||||
|
pressLayerX1_offset = this.itemProtocol.getPressLayerX1_offset();
|
||||||
|
pressLayerY1_offset = this.itemProtocol.getPressLayerY1_offset();
|
||||||
|
pressLayerX2_offset = this.itemProtocol.getPressLayerX2_offset();
|
||||||
|
pressLayerY2_offset = this.itemProtocol.getPressLayerY2_offset();
|
||||||
|
pressLayerX3_offset = this.itemProtocol.getPressLayerX3_offset();
|
||||||
|
pressLayerY3_offset = this.itemProtocol.getPressLayerY3_offset();
|
||||||
|
one_cribTotal = this.itemProtocol.getOne_cribTotal();
|
||||||
|
two_cribTotal = this.itemProtocol.getTwo_cribTotal();
|
||||||
|
one_qty = this.itemProtocol.getOne_qty();
|
||||||
|
two_qty = this.itemProtocol.getTwo_qty();
|
||||||
|
tool_coordinate = this.itemProtocol.getTool_coordinate();
|
||||||
|
|
||||||
if (mode != last_mode) {
|
if (mode != last_mode) {
|
||||||
this.setRequireSucess(false);
|
this.setRequireSucess(false);
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ package org.nl.acs.device_driver.lnsh.lnsh_rgv;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@@ -17,15 +17,12 @@ import org.nl.acs.instruction.service.InstructionService;
|
|||||||
import org.nl.acs.instruction.service.dto.Instruction;
|
import org.nl.acs.instruction.service.dto.Instruction;
|
||||||
import org.nl.acs.log.service.LogServer;
|
import org.nl.acs.log.service.LogServer;
|
||||||
import org.nl.acs.opc.Device;
|
import org.nl.acs.opc.Device;
|
||||||
import org.nl.acs.opc.WcsConfig;
|
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.RouteLineService;
|
||||||
import org.nl.acs.route.service.dto.RouteLineDto;
|
|
||||||
import org.nl.acs.task.service.TaskService;
|
import org.nl.acs.task.service.TaskService;
|
||||||
import org.nl.acs.task.service.dto.TaskDto;
|
import org.nl.acs.task.service.dto.TaskDto;
|
||||||
import org.nl.modules.quartz.task.AutoCreateInst;
|
|
||||||
import org.nl.modules.system.util.CodeUtil;
|
|
||||||
import org.nl.utils.SpringContextHolder;
|
import org.nl.utils.SpringContextHolder;
|
||||||
import org.nl.wql.core.bean.WQLObject;
|
|
||||||
import org.openscada.opc.lib.da.Server;
|
import org.openscada.opc.lib.da.Server;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
@@ -52,6 +49,8 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
|||||||
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
|
||||||
@Autowired
|
@Autowired
|
||||||
LogServer logServer = SpringContextHolder.getBean("logServerImpl");
|
LogServer logServer = SpringContextHolder.getBean("logServerImpl");
|
||||||
|
@Autowired
|
||||||
|
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
|
||||||
|
|
||||||
int mode = 0;
|
int mode = 0;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
@@ -63,6 +62,11 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
|||||||
String message = null;
|
String message = null;
|
||||||
Boolean iserror = false;
|
Boolean iserror = false;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
int branchProtocol = 0;
|
int branchProtocol = 0;
|
||||||
|
|
||||||
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
//暂定 0就绪 1请求取货 2取货完成 3请求放货 4放货完成 5取货完成离开 6放货完成离开 7请求进入区域 8请求离开区域
|
||||||
@@ -105,7 +109,7 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() throws Exception{
|
||||||
String message = null;
|
String message = null;
|
||||||
try {
|
try {
|
||||||
device_code = this.getDeviceCode();
|
device_code = this.getDeviceCode();
|
||||||
@@ -212,7 +216,10 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
|||||||
log.debug("设备运转模式:等待工作");
|
log.debug("设备运转模式:等待工作");
|
||||||
return;
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
|
//申请任务
|
||||||
|
if (walk_y == 1 && move_1 == 0 && !requireSucess ) {
|
||||||
|
instruction_apply();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -255,6 +262,126 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 请求指令
|
||||||
|
*/
|
||||||
|
public synchronized boolean instruction_apply() throws Exception {
|
||||||
|
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;
|
||||||
|
|
||||||
|
Object[] value = (Object[]) this.device.getExtraValue().get("get_device_code");
|
||||||
|
Object[] value2 = (Object[]) this.device.getExtraValue().get("load_device_code");
|
||||||
|
Object[] value3 = (Object[]) this.device.getExtraValue().get("put_device_code");
|
||||||
|
|
||||||
|
for (int i = 0; i < value.length; i++) {
|
||||||
|
String get_device_code = value[i].toString();
|
||||||
|
//Device device = appService.findDeviceByCode(get_device_code);
|
||||||
|
TaskDto task = taskserver.findByStartCode(get_device_code);
|
||||||
|
if (!ObjectUtil.isEmpty(task)) {
|
||||||
|
for (int j = 0; j < value2.length; j++) {
|
||||||
|
String putdevice_code = value2[j].toString();
|
||||||
|
if (StrUtil.equals(task.getNext_device_code(), putdevice_code)) {
|
||||||
|
String taskid = task.getTask_id();
|
||||||
|
String taskcode = task.getTask_code();
|
||||||
|
String vehiclecode = task.getVehicle_code();
|
||||||
|
String priority = task.getPriority();
|
||||||
|
String start_point_code = task.getStart_point_code();
|
||||||
|
String start_device_code = task.getStart_device_code();
|
||||||
|
String route_plan_code = task.getRoute_plan_code();
|
||||||
|
|
||||||
|
Instruction instdto = new Instruction();
|
||||||
|
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||||
|
instdto.setRoute_plan_code(route_plan_code);
|
||||||
|
instdto.setRemark(task.getRemark());
|
||||||
|
instdto.setMaterial(task.getMaterial());
|
||||||
|
instdto.setQuantity(task.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(putdevice_code);
|
||||||
|
instdto.setStart_point_code(start_point_code);
|
||||||
|
instdto.setNext_point_code(putdevice_code);
|
||||||
|
instdto.setPriority(priority);
|
||||||
|
instdto.setInstruction_status("0");
|
||||||
|
instdto.setExecute_device_code(start_point_code);
|
||||||
|
instructionService.create(instdto);
|
||||||
|
//创建指令后修改任务状态
|
||||||
|
task.setTask_status("1");
|
||||||
|
taskserver.update(task);
|
||||||
|
requireSucess = true;
|
||||||
|
writing(instdto);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requireSucess) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < value2.length; i++) {
|
||||||
|
String load_device_code = value2[i].toString();
|
||||||
|
//Device device = appService.findDeviceByCode(get_device_code);
|
||||||
|
TaskDto task = taskserver.findByStartCode(load_device_code);
|
||||||
|
if (!ObjectUtil.isEmpty(task)) {
|
||||||
|
for (int j = 0; j < value3.length; j++) {
|
||||||
|
String putdevice_code = value3[j].toString();
|
||||||
|
if (StrUtil.equals(task.getNext_device_code(), putdevice_code)) {
|
||||||
|
String taskid = task.getTask_id();
|
||||||
|
String taskcode = task.getTask_code();
|
||||||
|
String vehiclecode = task.getVehicle_code();
|
||||||
|
String priority = task.getPriority();
|
||||||
|
String start_point_code = task.getStart_point_code();
|
||||||
|
String start_device_code = task.getStart_device_code();
|
||||||
|
String route_plan_code = task.getRoute_plan_code();
|
||||||
|
|
||||||
|
Instruction instdto = new Instruction();
|
||||||
|
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||||
|
instdto.setRoute_plan_code(route_plan_code);
|
||||||
|
instdto.setRemark(task.getRemark());
|
||||||
|
instdto.setMaterial(task.getMaterial());
|
||||||
|
instdto.setQuantity(task.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(putdevice_code);
|
||||||
|
instdto.setStart_point_code(start_point_code);
|
||||||
|
instdto.setNext_point_code(putdevice_code);
|
||||||
|
instdto.setPriority(priority);
|
||||||
|
instdto.setInstruction_status("0");
|
||||||
|
instdto.setExecute_device_code(start_point_code);
|
||||||
|
instructionService.create(instdto);
|
||||||
|
//创建指令后修改任务状态
|
||||||
|
task.setTask_status("1");
|
||||||
|
taskserver.update(task);
|
||||||
|
requireSucess = true;
|
||||||
|
writing(instdto);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (requireSucess) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean exe_business() {
|
public boolean exe_business() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -285,6 +412,26 @@ public class LnshRGVDeviceDriver extends AbstractOpcDeviceDriver implements Devi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void writing(Instruction inst) {
|
||||||
|
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
|
+ "." + org.nl.acs.device_driver.standard_rgv.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.standard_rgv.ItemProtocol.item_to_target;
|
||||||
|
String to_onset = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
|
+ "." + org.nl.acs.device_driver.standard_rgv.ItemProtocol.item_to_onset;
|
||||||
|
String to_task = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
|
+ "." + org.nl.acs.device_driver.standard_rgv.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, 1);
|
||||||
|
itemMap.put(to_onset,appService.findDeviceByCode(inst.getStart_device_code()).getAddress());
|
||||||
|
itemMap.put(to_target,appService.findDeviceByCode(inst.getNext_device_code()).getAddress());
|
||||||
|
itemMap.put(to_task, inst.getInstruction_code());
|
||||||
|
ReadUtil.write(itemMap, server);
|
||||||
|
log.info("设备:{},下发作业命令:{},起始站{},目标站:{},任务号:{}", device_code, to_command,to_onset ,to_target, to_task);
|
||||||
|
}
|
||||||
|
|
||||||
public void writing(int type, int command) {
|
public void writing(int type, int command) {
|
||||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||||
Server server = ReadUtil.getServer(opcservcerid);
|
Server server = ReadUtil.getServer(opcservcerid);
|
||||||
|
|||||||
Reference in New Issue
Block a user