add: 开发

This commit is contained in:
2024-01-17 20:36:44 +08:00
parent 62fc812853
commit 54f0a10efd
8 changed files with 56 additions and 297 deletions

View File

@@ -171,52 +171,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i
heartbeat = this.itemProtocol.getHeartbeat();
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) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode + "复位请求标记:" + requireSucess);
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode);
}
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) {
if (error != 0) {
DeviceErrorLogDto dto = new DeviceErrorLogDto();
dto.setDevice_code(device_code);
dto.setError_code(String.valueOf(error));
String errorInfo = ErrorUtil.getDictDetail("ssx_error_type", String.valueOf(error));
dto.setError_info(errorInfo);
deviceErrorLogService.create(dto);
}
logServer.deviceItemValue(this.device_code, "error", String.valueOf(error));
logServer.deviceExecuteLog(this.device_code, "", "", "信号error" + last_error + "->" + error);
}
if (move != 0 && task > 0) {
update_instruction_status();

View File

@@ -64,6 +64,9 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
//工作模式
int mode = 0;
int last_mode = 0;
@@ -267,8 +270,8 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
applyIn();
}
//申请任务
if (mode == 2 && move == 0 && task == 0 && !requireSucess) {
//申请入库指令、异常位指令
if (mode == 2 && move == 1 && task > 0 && !requireSucess) {
boolean res = instruction_require();
if (res) {
notCreateInstMessage = "";
@@ -400,85 +403,22 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
//判断是否存在起点相同 任务状态就绪的任务
TaskDto taskdto = taskserver.findByStartCodeAndReady(device_code);
if (!ObjectUtil.isEmpty(taskdto)) {
//需要判断当前设备是否已经存在就绪的指令 如果存在就直接下发 不存在则创建
Instruction inst = instructionService.findByTaskcodeAndStatus(taskdto.getTask_code());
if (ObjectUtil.isNotEmpty(inst)) {
List list = new ArrayList();
Map map2 = new HashMap();
map2.put("code", "to_task");
map2.put("value", inst.getInstruction_code());
list.add(map2);
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map3);
this.writing(list);
requireSucess = true;
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, inst.getInstruction_code())) {
this.writing(list);
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;
}
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(taskdto.getStart_device_code(), taskdto.getNext_device_code(), route_plan_code);
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str);
Integer start = 2;
String start_point_code = pathlist.get(start);
String start_device_code = pathlist.get(start);
String next_device_code = pathlist.get(start+1);
Instruction instdto = new Instruction();
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(route_plan_code);
@@ -494,7 +434,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
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.setNext_point_code(next_device_code);
instdto.setPriority(priority);
instdto.setInstruction_status("0");
instdto.setExecute_device_code(start_point_code);
@@ -505,6 +445,8 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
log.error("指令创建失败!", e.getMessage());
return false;
}
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code);
//创建指令后修改任务状态
taskdto.setTask_status("1");
taskserver.update(taskdto);
@@ -540,45 +482,6 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
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();
List list = new ArrayList();
Map map = new HashMap();
map.put("code", "to_target");
map.put("value", next_addr);
list.add(map);
Map map2 = new HashMap();
map2.put("code", "to_task");
map2.put("value", inst.getInstruction_code());
list.add(map2);
Map map3 = new HashMap();
map3.put("code", "to_command");
map3.put("value", "1");
list.add(map3);
this.writing(list);
requireSucess = true;
while (!StrUtil.equals(this.getOpcValueAccessor().getValue(this.getOpcServer() + "." + this.getOpcPlc() + "." + this.getDevice_code() + ".task").toString()
, inst.getInstruction_code())) {
this.writing(list);
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;
}

View File

@@ -48,6 +48,11 @@ public class ItemProtocol {
*/
public static String item_task = "task";
/**
* 干燥机模板
*/
public static String item_desiccant = "desiccant";
/**
* 动作信号
*/
@@ -76,7 +81,7 @@ public class ItemProtocol {
public String getMaterialBarCode() {
return this.getOpcStringValue(item_material_barcode);
}
}
public int getContainer_type() {
return this.getOpcIntegerValue(item_container_type);
@@ -163,6 +168,7 @@ public class ItemProtocol {
list.add(new ItemDto(item_error, "报警信号", "DB600.B6"));
list.add(new ItemDto(item_container_type, "托盘类型", "DB101.B7"));
list.add(new ItemDto(item_task, "任务号", "DB600.D10"));
list.add(new ItemDto(item_desiccant, "干燥机模板", "DB600.D10"));
return list;
}

View File

@@ -171,47 +171,6 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
to_task = this.itemProtocol.getTo_task();
heartbeat = this.itemProtocol.getHeartbeat();
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) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode + "复位请求标记:" + requireSucess);
logServer.deviceExecuteLog(this.device_code, "", "", "信号mode" + last_mode + "->" + mode);
}
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 (move != 0 && task > 0) {
//
// update_instruction_status();
// }
} catch (Exception e) {
logServer.deviceExecuteLog(this.device_code, "", "", "读取信号值时出现异常:" + Arrays.toString(e.getStackTrace()));
@@ -231,11 +190,20 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
message = "有报警";
}
Instruction instruction = null;
List toInstructions;
//空箱出库开盖位,申请开盖
if (mode == 7 && move == 1 && task > 0) {
applyUnbox();
//不允许开盖,完成出库任务,自动去扫码位
if (!applyUnbox()){
Instruction instruction = instructionService.findByCode(String.valueOf(task));
if (ObjectUtil.isNotEmpty(instruction)) {
try {
instructionService.finish(instruction);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
}
@@ -256,12 +224,12 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
last_to_height =to_height;
}
private void applyUnbox() {
private Boolean 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;
return false;
} else {
try {
JSONObject param = new JSONObject();
@@ -271,11 +239,13 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
HttpResponse response = acsToWmsService.shipDeviceUpdate(param);
if (response == null || response.getStatus() == 200) {
logServer.deviceExecuteLog(this.device_code, "", "", "木箱申请开盖任务,接口返回:" + response.body());
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}
public boolean exe_error() {

View File

@@ -171,63 +171,6 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
to_direction = this.itemProtocol.getTo_direction();
to_last = this.itemProtocol.getTo_last();
if (to_last != last_to_last) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_last" + last_to_last + "->" + to_last);
}
if (to_max_no != last_to_max_no) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_max_no" + last_to_max_no + "->" + to_max_no);
}
if (to_direction != last_to_direction) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_direction" + last_to_direction + "->" + to_direction);
}
if (to_seq != last_to_seq) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_seq" + last_to_seq + "->" + to_seq);
}
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) {

View File

@@ -48,6 +48,18 @@ public class ItemProtocol {
*/
public static String item_y_position = "y_position";
/**
* 木箱数量
*/
public static String item_number = "number";
/**
* 木箱位置
*/
public static String item_position = "position";
/**
* 下发命令
*/
@@ -207,6 +219,8 @@ public class ItemProtocol {
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"));
list.add(new ItemDto(item_position, "木箱位置", "DB1.REAL16"));
list.add(new ItemDto(item_number, "木箱数量", "DB1.REAL18"));
return list;
}

View File

@@ -152,39 +152,7 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
to_task = this.itemProtocol.getTo_task();
to_layer = this.itemProtocol.getTo_layer();
to_barcode = this.itemProtocol.getTo_barcode();
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 (task != last_task) {
logServer.deviceItemValue(this.device_code, "task", String.valueOf(task));
logServer.deviceExecuteLog(this.device_code, "", "", "信号task" + last_task + "->" + task);
}
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_onset != last_to_onset) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_onset" + last_to_target + "->" + to_target);
}
if (to_task != last_to_task) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号to_task" + last_to_task + "->" + to_task);
}
// 更新指令状态