|
|
@ -38,32 +38,32 @@ public class NL4StationDeviceDriver extends AbstractOpcDeviceDriver implements D |
|
|
|
|
|
|
|
// 心跳
|
|
|
|
private int heartbeat = 0; |
|
|
|
private int lastHeartbeat = this.heartbeat; |
|
|
|
private int lastHeartbeat = 0; |
|
|
|
// 工作模式
|
|
|
|
private int mode = 0; |
|
|
|
private int lastMode = this.mode; |
|
|
|
private int lastMode = 0; |
|
|
|
// 光电信号
|
|
|
|
private int move = 0; |
|
|
|
private int lastMove = this.move; |
|
|
|
private int lastMove = 0; |
|
|
|
// 动作信号
|
|
|
|
private int action = 0; |
|
|
|
private int lastAction = this.action; |
|
|
|
private int lastAction = 0; |
|
|
|
// error
|
|
|
|
private int error = 0; |
|
|
|
private int lastError = this.error; |
|
|
|
private int lastError = 0; |
|
|
|
// 任务号
|
|
|
|
private int task = 0; |
|
|
|
private int lastTask = this.task; |
|
|
|
private int lastTask = 0; |
|
|
|
|
|
|
|
// 下发命令
|
|
|
|
private int toCommand = 0; |
|
|
|
private int lastToCommand = this.toCommand; |
|
|
|
private int lastToCommand = 0; |
|
|
|
// 下发物料
|
|
|
|
private int toMaterial = 0; |
|
|
|
private int lastToMaterial = this.toMaterial; |
|
|
|
private int lastToMaterial = 0; |
|
|
|
// 下发数量
|
|
|
|
private int toQty = 0; |
|
|
|
private int lastToQty = this.toQty; |
|
|
|
private int lastToQty = 0; |
|
|
|
|
|
|
|
private String currentDeviceCode = null; |
|
|
|
private boolean isOnline = false; |
|
|
@ -103,37 +103,28 @@ public class NL4StationDeviceDriver extends AbstractOpcDeviceDriver implements D |
|
|
|
if (mode == 2) { |
|
|
|
this.writing("to_command", "0"); |
|
|
|
} |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", "mode信号发生变化,进行复位标记,此时标记值:" + requireSuccess); |
|
|
|
this.deviceExecuteLogService.deviceItemValue(this.currentDeviceCode, ItemProtocol.ITEM_MODE, String.valueOf(mode)); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", ItemProtocol.ITEM_MODE + " " + this.lastMode + " -> " + this.mode); |
|
|
|
} |
|
|
|
if (this.move != this.lastMove) { |
|
|
|
this.deviceExecuteLogService.deviceItemValue(this.currentDeviceCode, ItemProtocol.ITEM_MOVE, String.valueOf(this.move)); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", ItemProtocol.ITEM_MOVE + " " + this.lastMove + " -> " + this.move); |
|
|
|
} |
|
|
|
if (this.action != this.lastAction) { |
|
|
|
this.deviceExecuteLogService.deviceItemValue(this.currentDeviceCode, ItemProtocol.ITEM_ACTION, String.valueOf(this.action)); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", ItemProtocol.ITEM_ACTION + " " + this.lastAction + " -> " + this.action); |
|
|
|
} |
|
|
|
if (this.error != this.lastError) { |
|
|
|
this.deviceExecuteLogService.deviceItemValue(this.currentDeviceCode, ItemProtocol.ITEM_ERROR, String.valueOf(this.error)); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", ItemProtocol.ITEM_ERROR + " " + this.lastError + " -> " + this.error); |
|
|
|
} |
|
|
|
if (this.task != this.lastTask) { |
|
|
|
this.deviceExecuteLogService.deviceItemValue(this.currentDeviceCode, ItemProtocol.ITEM_TASK, String.valueOf(this.task)); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", ItemProtocol.ITEM_TASK + " " + this.lastTask + " -> " + this.task); |
|
|
|
} |
|
|
|
|
|
|
|
if (this.toCommand != this.lastToCommand) { |
|
|
|
this.deviceExecuteLogService.deviceItemValue(this.currentDeviceCode, ItemProtocol.ITEM_TO_COMMAND, String.valueOf(this.toCommand)); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", ItemProtocol.ITEM_TO_COMMAND + " " + this.lastToCommand + " -> " + this.toCommand); |
|
|
|
} |
|
|
|
if (this.toMaterial != this.lastToMaterial) { |
|
|
|
this.deviceExecuteLogService.deviceItemValue(this.currentDeviceCode, ItemProtocol.ITEM_TO_MATERIAL, String.valueOf(this.toMaterial)); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", ItemProtocol.ITEM_TO_MATERIAL + " " + this.lastToMaterial + " -> " + this.toMaterial); |
|
|
|
} |
|
|
|
if (this.toQty != this.lastToQty) { |
|
|
|
this.deviceExecuteLogService.deviceItemValue(this.currentDeviceCode, ItemProtocol.ITEM_TO_QTY, String.valueOf(this.toQty)); |
|
|
|
this.deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", ItemProtocol.ITEM_TO_QTY + " " + this.lastToQty + " -> " + this.toQty); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
@ -271,8 +262,12 @@ public class NL4StationDeviceDriver extends AbstractOpcDeviceDriver implements D |
|
|
|
private Device findHasGoodsDevice(JSONArray deviceCodes) { |
|
|
|
for (int i = 0; i < deviceCodes.size(); i++) { |
|
|
|
Device device = this.deviceAppService.findDeviceByCode(deviceCodes.getString(i)); |
|
|
|
if (device != null && "0".equals(device.getIslock()) && 1 == device.getHas_goods()) { |
|
|
|
if (device != null && ("0".equals(device.getIslock()) || "false".equals(device.getIslock())) && 1 == device.getHas_goods()) { |
|
|
|
return device; |
|
|
|
} else { |
|
|
|
if (device != null) { |
|
|
|
deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", "查找设备时,对应的设备:" + device.getDevice_code() + ",锁定状态:" + device.getIslock() + ",有货状态:" + device.getHas_goods()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
@ -281,8 +276,12 @@ public class NL4StationDeviceDriver extends AbstractOpcDeviceDriver implements D |
|
|
|
private Device findNotHasGoodsDevice(JSONArray deviceCodes) { |
|
|
|
for (int i = 0; i < deviceCodes.size(); i++) { |
|
|
|
Device device = this.deviceAppService.findDeviceByCode(deviceCodes.getString(i)); |
|
|
|
if (device != null && "0".equals(device.getIslock()) && 0 == device.getHas_goods()) { |
|
|
|
if (device != null && ("0".equals(device.getIslock()) || "false".equals(device.getIslock())) && 0 == device.getHas_goods()) { |
|
|
|
return device; |
|
|
|
} else { |
|
|
|
if (device != null) { |
|
|
|
deviceExecuteLogService.deviceExecuteLog(this.currentDeviceCode, "", "", "查找设备时,对应的设备:" + device.getDevice_code() + ",锁定状态:" + device.getIslock() + ",有货状态:" + device.getHas_goods()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|