Browse Source

rev:删掉输送线多余信号

master
gengby 8 months ago
parent
commit
2f24f6b67e
  1. 167
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java
  2. 28
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/ItemProtocol.java

167
nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java

@ -17,6 +17,7 @@ import org.nl.acs.device.device.service.DeviceAssignedService;
import org.nl.acs.device.device.service.dto.DeviceAssignedDto; import org.nl.acs.device.device.service.dto.DeviceAssignedDto;
import org.nl.acs.device.driver.*; import org.nl.acs.device.driver.*;
import org.nl.acs.device.driver.conveyor.appearance_inspection_scannner_conveyor.enums.CommandEnum; import org.nl.acs.device.driver.conveyor.appearance_inspection_scannner_conveyor.enums.CommandEnum;
import org.nl.acs.device.driver.conveyor.strip_conveyor.StripConveyorDeviceDriver;
import org.nl.acs.device.enums.RequestTypeEnum; import org.nl.acs.device.enums.RequestTypeEnum;
import org.nl.acs.ext.UnifiedResponse; import org.nl.acs.ext.UnifiedResponse;
import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.AcsToWmsService;
@ -91,16 +92,6 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
*/ */
private int task = 0; private int task = 0;
private int lastTask = 0; private int lastTask = 0;
/**
* 托盘类型
*/
private int containerType = 0;
private int lastContainerType = 0;
/**
* 托盘方向
*/
private int containerDirection = 0;
private int lastContainerDirection = 0;
/** /**
* 高度 * 高度
*/ */
@ -134,8 +125,9 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
/** /**
* 下发托盘类型 * 下发托盘类型
*/ */
private int toContainerType = 0; private int toHeight = 0;
private int lastToContainerType = 0; private int lastToHeight = 0;
/** /**
* 当前设备编号 * 当前设备编号
*/ */
@ -205,6 +197,15 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
if (this.move != 0 && this.task > 0) { if (this.move != 0 && this.task > 0) {
this.update_instruction_status_by_task(); this.update_instruction_status_by_task();
} }
if (this.mode != this.lastMode) {
boolean pinkFlag = Optional.ofNullable(this.getExtraValue().get("pinkDevicePoint")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
if (pinkFlag) {
JSONObject req = new JSONObject();
req.put("device_code", this.currentDeviceCode);
req.put("type", this.mode);
//acsToWmsService.feedPinkStartStop(req);
}
}
} }
@Override @Override
@ -240,14 +241,35 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
this.applyInTask(); this.applyInTask();
} else if (this.mode == 7 && this.move > 0 && StrUtil.isNotEmpty(this.barcode) && !requireSuccess) { } else if (this.mode == 7 && this.move > 0 && StrUtil.isNotEmpty(this.barcode) && !requireSuccess) {
this.applyAgvTask(); this.applyAgvTask();
} else if (this.mode == 8 && this.move > 0 && StrUtil.isNotEmpty(this.barcode) && !requireSuccess) {
this.getHeightByVehicleCode();
} }
} }
} }
private boolean isTimeValid(long currentTimeMillis) { private boolean isTimeValid(long currentTimeMillis) {
return currentTimeMillis - this.requireTime >= this.requireTimeOut; return currentTimeMillis - this.requireTime >= this.requireTimeOut;
} }
private void getHeightByVehicleCode() {
long currentTimeMillis = System.currentTimeMillis();
if (!isTimeValid(currentTimeMillis)) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.requireTimeOut);
} else {
this.requireTime = currentTimeMillis;
// JSONObject requestParam = new JSONObject();
// requestParam.put("type", RequestTypeEnum.APPLY_IN_TASK.getType());
// JSONObject param = new JSONObject();
// param.put(this.barcode, this.currentDeviceCode);
// requestParam.put("param", param);
// UnifiedResponse<JSONObject> response = acsToWmsService.applyTaskToWms(requestParam);
// if (response.isSuccess()) {
// this.requireSuccess = true;
// }
}
}
/** /**
* 申请入库任务 * 申请入库任务
*/ */
@ -305,6 +327,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
return acsToWmsService.applyTaskToWms(requestParam); return acsToWmsService.applyTaskToWms(requestParam);
} }
public void createInInstruction() { public void createInInstruction() {
long currentTimeMillis = System.currentTimeMillis(); long currentTimeMillis = System.currentTimeMillis();
if (!isTimeValid(currentTimeMillis)) { if (!isTimeValid(currentTimeMillis)) {
@ -360,9 +383,43 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
} }
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
if (nextDevice == null) { if (nextDevice == null) {
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 未配置指令终点驱动信息, 终点: " + instDto.getNext_device_code())); logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 未配置指令终点驱动信息, 终点: " + next_device_code));
return; return;
} }
//判断入库任务的起点是否是双向点位,即既是起点又是终点
boolean toWayFlag = Optional.ofNullable(this.getExtraValue().get("toWay")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
//如果是双向点位
if (toWayFlag) {
//获取该点所属输送线
String belongToConveyor = Optional.ofNullable(this.getExtraValue().get("belongToConveyor")).map(Object::toString).orElse(null);
if (belongToConveyor != null) {
Device belongToConveyorDevice = deviceAppService.findDeviceByCode(belongToConveyor);
if (belongToConveyorDevice != null && belongToConveyorDevice.getDeviceDriver() instanceof StripConveyorDeviceDriver) {
StripConveyorDeviceDriver stripConveyorDeviceDriver = (StripConveyorDeviceDriver) belongToConveyorDevice.getDeviceDriver();
//如果所属输送线不是入库模式
if (stripConveyorDeviceDriver.getInOutMode() != 0) {
String samePoint = Optional.ofNullable(this.getExtraValue().get("samePoint")).map(Object::toString).orElse(null);
TaskDto existTask;
if (StrUtil.isNotEmpty(samePoint)) {
existTask = taskService.findByNextCode(samePoint);
} else {
existTask = taskService.findByNextCode(this.currentDeviceCode);
}
if (ObjectUtil.isNotEmpty(existTask)) {
return;
}
//判断所属输送线是否允许切换出入库模式
if (stripConveyorDeviceDriver.getSwitchInOut() == 0) {
//切换出入库模式
stripConveyorDeviceDriver.writing("toCommand", 0);
return;
} else {
return;
}
}
}
}
}
if (nextDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { if (nextDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
setInstruction(instDto, taskDto, start_device_code, next_device_code); setInstruction(instDto, taskDto, start_device_code, next_device_code);
} else { } else {
@ -373,7 +430,8 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskService.update(taskDto); taskService.update(taskDto);
if (nextDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { if (nextDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
if (StrUtil.equals(this.getDevice().getRegion(), nextDevice.getRegion())) { List<String> targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode");
if (targetDeviceCode != null && targetDeviceCode.contains(next_device_code)) {
int nextAddress = Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0); int nextAddress = Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0);
this.writing(Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(nextAddress, instDto.getInstruction_code(), CommandEnum.COMMAND_1.getValue())); this.writing(Arrays.asList(ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(nextAddress, instDto.getInstruction_code(), CommandEnum.COMMAND_1.getValue()));
} }
@ -386,8 +444,9 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
} else if (ObjectUtil.isEmpty(taskDto) && ObjectUtil.isNotEmpty(instDto)) { } else if (ObjectUtil.isEmpty(taskDto) && ObjectUtil.isNotEmpty(instDto)) {
String next_device_code = instDto.getNext_device_code(); String next_device_code = instDto.getNext_device_code();
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
if (nextDevice != null && StrUtil.equals(nextDevice.getDevice_type(), "conveyor")) { if (nextDevice != null && nextDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
if (StrUtil.equals(this.getDevice().getRegion(), nextDevice.getRegion())) { List<String> targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode");
if (targetDeviceCode != null && targetDeviceCode.contains(next_device_code)) {
Integer address = Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0); Integer address = Optional.ofNullable(nextDevice.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0);
this.writing(Arrays.asList(ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(instDto.getInstruction_code(), address, CommandEnum.COMMAND_1.getValue())); this.writing(Arrays.asList(ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey(), ItemProtocol.TO_COMMAND.getKey()), Arrays.asList(instDto.getInstruction_code(), address, CommandEnum.COMMAND_1.getValue()));
this.requireSuccess = true; this.requireSuccess = true;
@ -441,23 +500,25 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
Device device = deviceAppService.findDeviceByCode(next_device_code); Device device = deviceAppService.findDeviceByCode(next_device_code);
if (device != null) { if (device != null) {
String pinkDeviceCode = Optional.ofNullable(device.getExtraValue().get("pinkDeviceCode")).map(Objects::toString).orElse(""); String pinkDeviceCode = Optional.ofNullable(device.getExtraValue().get("pinkDeviceCode")).map(Objects::toString).orElse("");
Device pinkDevice = deviceAppService.findDeviceByCode(pinkDeviceCode); if (StrUtil.equals(taskDto.getNext_device_code(), pinkDeviceCode)) {
if (pinkDevice != null && pinkDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { Device pinkDevice = deviceAppService.findDeviceByCode(pinkDeviceCode);
AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) pinkDevice.getDeviceDriver(); if (pinkDevice != null && pinkDevice.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
if (appearanceInspectionScannerConveyorDeviceDriver.getMode() == 0) { AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver = (AppearanceInspectionScannerConveyorDeviceDriver) pinkDevice.getDeviceDriver();
return; if (appearanceInspectionScannerConveyorDeviceDriver.getMode() == 0) {
} return;
Instruction inst = instructionService.findReadyInstByEnd(next_device_code); }
if (ObjectUtil.isNotEmpty(inst)) { Instruction inst = instructionService.findReadyInstByEnd(next_device_code);
String pinkDeviceCode2 = Optional.ofNullable(pinkDevice.getExtraValue().get("pinkDeviceCode")).map(Object::toString).orElse(""); if (ObjectUtil.isNotEmpty(inst)) {
Device pinkDevice2 = deviceAppService.findDeviceByCode(pinkDeviceCode2); String pinkDeviceCode2 = Optional.ofNullable(pinkDevice.getExtraValue().get("pinkDeviceCode")).map(Object::toString).orElse("");
if (pinkDevice2 != null && pinkDevice2.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { Device pinkDevice2 = deviceAppService.findDeviceByCode(pinkDeviceCode2);
AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver2 = (AppearanceInspectionScannerConveyorDeviceDriver) pinkDevice2.getDeviceDriver(); if (pinkDevice2 != null && pinkDevice2.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
if (appearanceInspectionScannerConveyorDeviceDriver2.getMode() == 0) { AppearanceInspectionScannerConveyorDeviceDriver appearanceInspectionScannerConveyorDeviceDriver2 = (AppearanceInspectionScannerConveyorDeviceDriver) pinkDevice2.getDeviceDriver();
String getLinkDeviceCode = Optional.ofNullable(device.getExtraValue().get("getLinkDeviceCode")).map(Objects::toString).orElse(""); if (appearanceInspectionScannerConveyorDeviceDriver2.getMode() == 0) {
Instruction instruction = instructionService.findReadyInstByEnd(getLinkDeviceCode); String getLinkDeviceCode = Optional.ofNullable(device.getExtraValue().get("getLinkDeviceCode")).map(Objects::toString).orElse("");
if (StrUtil.isNotEmpty(getLinkDeviceCode) && ObjectUtil.isEmpty(instruction)) { Instruction instruction = instructionService.findReadyInstByEnd(getLinkDeviceCode);
next_device_code = getLinkDeviceCode; if (StrUtil.isNotEmpty(getLinkDeviceCode) && ObjectUtil.isEmpty(instruction)) {
next_device_code = getLinkDeviceCode;
}
} }
} }
} }
@ -469,12 +530,45 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
} else { } else {
start_point_code = start_device_code; start_point_code = start_device_code;
} }
setInstruction(instDto, taskDto, start_device_code, start_point_code, next_device_code, next_device_code);
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code); Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
if (nextDevice == null) { if (nextDevice == null) {
logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 未配置指令终点驱动信息, 终点: " + instDto.getNext_device_code())); logService.deviceExecuteLog(new LuceneLogDto(this.currentDeviceCode, "创建指令失败, 未配置指令终点驱动信息, 终点: " + next_device_code));
return; return;
} }
//判断终点是否是双向点位
boolean toWayFlag = Optional.ofNullable(cacheDevice.getExtraValue().get("toWay")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
//如果是双向点位
if (toWayFlag) {
//获取终点所属输送线
String belongToConveyor = Optional.ofNullable(cacheDevice.getExtraValue().get("belongToConveyor")).map(Object::toString).orElse(null);
if (belongToConveyor != null) {
Device belongToConveyorDevice = deviceAppService.findDeviceByCode(belongToConveyor);
if (belongToConveyorDevice != null && belongToConveyorDevice.getDeviceDriver() instanceof StripConveyorDeviceDriver) {
StripConveyorDeviceDriver stripConveyorDeviceDriver = (StripConveyorDeviceDriver) belongToConveyorDevice.getDeviceDriver();
//判断所属输送线是否是出库模式
if (stripConveyorDeviceDriver.getInOutMode() != 1) {
String samePoint = Optional.ofNullable(this.getExtraValue().get("samePoint")).map(Object::toString).orElse(null);
TaskDto existTask;
if (StrUtil.isNotEmpty(samePoint)) {
existTask = taskService.findByStartCode(samePoint);
} else {
existTask = taskService.findByStartCode(this.currentDeviceCode);
}
if (ObjectUtil.isNotEmpty(existTask)) {
return;
}
//不是出库模式 判断是否允许切换出入库模式
if (stripConveyorDeviceDriver.getSwitchInOut() == 0) {
stripConveyorDeviceDriver.writing("toCommand", 1);
return;
} else {
return;
}
}
}
}
}
setInstruction(instDto, taskDto, start_device_code, start_point_code, next_device_code, next_device_code);
try { try {
instructionService.create(instDto); instructionService.create(instDto);
taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex()); taskDto.setTask_status(TaskStatusEnum.BUSY.getIndex());
@ -507,7 +601,8 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
String next_device_code = inst.getNext_device_code(); String next_device_code = inst.getNext_device_code();
Device next_device = deviceAppService.findDeviceByCode(next_device_code); Device next_device = deviceAppService.findDeviceByCode(next_device_code);
if (next_device != null && next_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) { if (next_device != null && next_device.getDeviceDriver() instanceof AppearanceInspectionScannerConveyorDeviceDriver) {
if (StrUtil.equals(this.getDevice().getRegion(), next_device.getRegion())) { List<String> targetDeviceCode = this.getExtraDeviceCodes("targetDeviceCode");
if (targetDeviceCode != null && targetDeviceCode.contains(next_device_code)) {
Integer address = Optional.ofNullable(next_device.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0); Integer address = Optional.ofNullable(next_device.getExtraValue().get("address")).map(Object::toString).map(Integer::parseInt).orElse(0);
this.writing(Arrays.asList(ItemProtocol.TO_COMMAND.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey()), Arrays.asList(CommandEnum.COMMAND_1.getValue(), inst.getInstruction_code(), address)); this.writing(Arrays.asList(ItemProtocol.TO_COMMAND.getKey(), ItemProtocol.TO_TASK.getKey(), ItemProtocol.TO_TARGET.getKey()), Arrays.asList(CommandEnum.COMMAND_1.getValue(), inst.getInstruction_code(), address));
this.requireSuccess = true; this.requireSuccess = true;

28
nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/ItemProtocol.java

@ -8,21 +8,19 @@ import java.util.List;
import java.util.ArrayList; import java.util.ArrayList;
public enum ItemProtocol implements DeviceDriverBaseReader.KeyProvider { public enum ItemProtocol implements DeviceDriverBaseReader.KeyProvider {
HEARTBEAT("heartbeat", "心跳", "DB600.B0"), HEARTBEAT("heartbeat", "心跳", "DB1000.B0"),
MODE("mode", "工作模式", "DB600.B1"), MODE("mode", "工作模式", "DB1101.B0"),
MOVE("move", "光电信号", "DB600.B2"), MOVE("move", "光电信号", "DB1101.B1"),
ACTION("action", "动作信号", "DB600.B3"), ACTION("action", "动作信号", "DB1101.B2"),
ERROR("error", "报警信号", "DB600.B5"), ERROR("error", "报警信号", "DB1101.B3"),
TASK("task", "任务号", "DB600.D6"), BARCODE("barcode", "托盘条码", "DB1101.STRING6"),
CONTAINER_TYPE("containerType", "托盘类型", "DB600.B7"), WEIGHT("weight", "重量", "DB1101.D262"),
CONTAINER_DIRECTION("containerDirection", "托盘方向", "DB600.B8"), HEIGHT("height", "高度", "DB1101.B266"),
HEIGHT("height", "高度", "DB600.B9"), TASK("task", "任务号", "DB1101.D268"),
WEIGHT("weight", "重量", "DB600.D10"), TO_COMMAND("toCommand", "下发命令", "DB1101.W272"),
BARCODE("barcode", "托盘条码", "DB600.STRING1.50"), TO_TARGET("toTarget", "下发目标站", "DB1101.W274"),
TO_COMMAND("toCommand", "下发命令", "DB610.W0"), TO_TASK("toTask", "下发任务号", "DB1101.D278"),
TO_TARGET("toTarget", "下发目标站", "DB610.W4"), TO_HEIGHT("toHeight", "下发高度", "DB1101.W280");
TO_TASK("toTask", "下发任务号", "DB610.D6"),
TO_CONTAINER_TYPE("toContainerType", "下发托盘类型", "DB610.W8");
private final String key; private final String key;
private final String description; private final String description;

Loading…
Cancel
Save