add: 装箱\开箱驱动开发

This commit is contained in:
2024-01-16 20:30:42 +08:00
parent 1e7de370dc
commit 3fca1045f1
5 changed files with 134 additions and 81 deletions

View File

@@ -124,6 +124,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
String message = null;
Boolean iserror = false;
private Date instruction_update_time = new Date();
private Date require_apply_strangulation_time = new Date();
private int instruction_update_time_out = 1000;
Integer heartbeat_tag;
private Date instruction_require_time = new Date();
@@ -242,10 +243,8 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
// 更新指令状态
updateInstruct();
} catch (Exception var17) {
var17.printStackTrace();
feedMessage = var17.getMessage();
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
} catch (Exception e) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(e.getStackTrace()));
}
@@ -319,34 +318,48 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
}
private void applyErrorTask() {
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
param.put("vehicle_code", barcode);
param.put("type", StorageTypeEnum.ERROR.getType());
logServer.deviceExecuteLog(this.device_code, "", "", "木箱入库申请入库任务,参数:" + param);
HttpResponse response = acsToWmsService.shipDeviceUpdate(param);
if (response == null || response.getStatus() == 200) {
logServer.deviceExecuteLog(this.device_code, "", "", "木箱入库申请入库任务,接口返回:" + response.body());
Date date = new Date();
if (date.getTime() - this.require_apply_strangulation_time.getTime()
< (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
param.put("vehicle_code", barcode);
param.put("type", StorageTypeEnum.ERROR.getType());
logServer.deviceExecuteLog(this.device_code, "", "", "木箱入库申请异常位任务,参数:" + param);
HttpResponse response = acsToWmsService.shipDeviceUpdate(param);
if (response == null || response.getStatus() == 200) {
logServer.deviceExecuteLog(this.device_code, "", "", "木箱入库申请异常位任务,接口返回:" + response.body());
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void applyIn() {
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
param.put("vehicle_code", barcode);
param.put("type", StorageTypeEnum.STORAGE.getType());
logServer.deviceExecuteLog(this.device_code, "", "", "木箱入库申请入库任务,参数:" + param);
HttpResponse response = acsToWmsService.shipDeviceUpdate(param);
if (response == null || response.getStatus() == 200) {
logServer.deviceExecuteLog(this.device_code, "", "", "木箱入库申请入库任务,接口返回:" + response.body());
Date date = new Date();
if (date.getTime() - this.require_apply_strangulation_time.getTime()
< (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
param.put("vehicle_code", barcode);
param.put("type", StorageTypeEnum.STORAGE.getType());
logServer.deviceExecuteLog(this.device_code, "", "", "木箱入库申请入库任务,参数:" + param);
HttpResponse response = acsToWmsService.shipDeviceUpdate(param);
if (response == null || response.getStatus() == 200) {
logServer.deviceExecuteLog(this.device_code, "", "", "木箱入库申请入库任务,接口返回:" + response.body());
}
} catch (Exception e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}

View File

@@ -4,6 +4,7 @@ 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.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@@ -17,6 +18,7 @@ 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.enums.StorageTypeEnum;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.history.ErrorUtil;
import org.nl.acs.history.service.DeviceErrorLogService;
@@ -205,14 +207,14 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error);
}
if (move != 0 && task > 0) {
// if (move != 0 && task > 0) {
//
// update_instruction_status();
// }
update_instruction_status();
}
} catch (Exception e) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(e.getStackTrace()));
} catch (Exception var17) {
var17.printStackTrace();
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
}
@@ -231,35 +233,51 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
Instruction instruction = null;
List toInstructions;
switch (mode) {
case 1:
log.debug("设备运转模式:等待工作");
break;
case 2:
//申请任务
if (move > 0 && !requireSucess) {
instruction_require();
}
break;
//空箱出库开盖位,申请开盖
if (mode == 7 && move == 1 && task > 0) {
applyUnbox();
}
}
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;
}
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;
}
private void applyUnbox() {
Date date = new Date();
if (date.getTime() - this.require_apply_strangulation_time.getTime()
< (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return;
} else {
try {
JSONObject param = new JSONObject();
param.put("device_code", device_code);
param.put("task", task);
logServer.deviceExecuteLog(this.device_code, "", "", "木箱申请开盖任务,参数:" + param);
HttpResponse response = acsToWmsService.shipDeviceUpdate(param);
if (response == null || response.getStatus() == 200) {
logServer.deviceExecuteLog(this.device_code, "", "", "木箱申请开盖任务,接口返回:" + response.body());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
public boolean exe_error() {
if (this.error == 0) {
return true;

View File

@@ -35,10 +35,7 @@ import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.config.SpringContextHolder;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 装箱智能行架
@@ -237,10 +234,8 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
updateInstrction();
}
} catch (Exception var17) {
var17.printStackTrace();
feedMessage = var17.getMessage();
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
} catch (Exception e) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(e.getStackTrace()));
}
@@ -325,6 +320,38 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
}
}
}
//放货完成
if (mode == 3 && action == 4 && move == 0) {
if (inst != null) {
try {
logServer.deviceExecuteLog(this.device_code,"","","放货完成");
finish_instruction(inst);
Map<String, Object> map = new LinkedHashMap<>();
map.put("to_command", 5);
this.writing(map);
message = "放货完成";
} catch (Exception e) {
message = "放货失败";
e.printStackTrace();
}
feedMessage = "";
}else {
feedMessage = "行架机械手:";
if (mode != 3) {
feedMessage = feedMessage + "工作模式(mode)不为运行中状态,";
}
if (action != 8) {
feedMessage = feedMessage + "动作信号(action)不为放货完成状态,";
}
if (move != 0) {
feedMessage = feedMessage + "光电信号(move)不为无货状态,";
}
if (task == 0) {
feedMessage = feedMessage + "当前上报任务号(task)不应该为0。";
}
}
}
}
}
@@ -417,6 +444,11 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
}
public synchronized boolean finish_instruction(Instruction inst) throws Exception {
instructionService.finish(inst);
return true;
}
/**
* 下发
* @param map

View File

@@ -35,10 +35,7 @@ import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.config.SpringContextHolder;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 木箱入库行架
@@ -195,10 +192,8 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
updateInstructionStatus();
}
} catch (Exception var17) {
var17.printStackTrace();
feedMessage = var17.getMessage();
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
} catch (Exception e) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(e.getStackTrace()));
}

View File

@@ -35,10 +35,7 @@ import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.config.SpringContextHolder;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 退货入库行架
@@ -193,10 +190,8 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
updateInstructionStatus();
}
} catch (Exception var17) {
var17.printStackTrace();
feedMessage = var17.getMessage();
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + var17.getMessage() + ",this.itemProtocol is null:" + ObjectUtil.isEmpty(this.itemProtocol));
} catch (Exception e) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(e.getStackTrace()));
}