From fa4a85ebcc0a162b32eb917d8a4145bdd1139073 Mon Sep 17 00:00:00 2001 From: yanps Date: Tue, 21 May 2024 18:38:01 +0800 Subject: [PATCH] =?UTF-8?q?add:=20agv=E5=81=8F=E7=A7=BB=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HongXiangConveyorDeviceDriver.java | 10 +- .../org/nl/acs/agv/server/NDCAgvService.java | 9 ++ .../agv/server/impl/NDCAgvServiceImpl.java | 33 ++++ .../agv/ndctwo/AgvNdcTwoDeviceDriver.java | 142 ++++++++++++------ .../StandardInspectSiteDeviceDriver.java | 22 ++- .../oven_manipulator/ItemProtocol.java | 2 - .../ranging_stations/ItemProtocol.java | 37 ++++- .../RangingStationsDeviceDriver.java | 16 +- 8 files changed, 209 insertions(+), 62 deletions(-) diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/HongXiangConveyorDeviceDriver.java b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/HongXiangConveyorDeviceDriver.java index 5c019438c..9e0081c25 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/HongXiangConveyorDeviceDriver.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/hongxiang_device/HongXiangConveyorDeviceDriver.java @@ -173,12 +173,16 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple logServer.deviceExecuteLog(this.device_code, "", "", "信号door:" + last_door + "->" + door); } if (mode != last_mode) { - //this.setRequireSucess(false); + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + mode + "->" + last_mode); + } + if(action != last_action){ + logServer.deviceExecuteLog(this.device_code, "", "", "信号action:" + action + "->" + last_action); } if (move != last_move) { if (move == 0) { thingToNothing(); } + logServer.deviceExecuteLog(this.device_code, "", "", "信号mode:" + mode + "->" + last_mode); } if (error != last_error) { if (error != 0) { @@ -188,6 +192,10 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple dto.setError_info(ErrorUtil.getDictDetail("hx_error_type", String.valueOf(error))); deviceErrorLogService.create(dto); } + logServer.deviceExecuteLog(this.device_code, "", "", "信号error:" + error + "->" + last_error); + } + if (error1 != last_error1) { + logServer.deviceExecuteLog(this.device_code, "", "", "信号error1:" + error1 + "->" + last_error1); } if (finish != last_finish) { if (finish == 1) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/NDCAgvService.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/NDCAgvService.java index 10f237fb4..d94524c3e 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/NDCAgvService.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/NDCAgvService.java @@ -55,6 +55,15 @@ public interface NDCAgvService { */ public byte[] sendAgvTwoModeInst(int phase, int index, int result); + /** + * 下发agv偏移指令 + * @param phase + * @param index + * @param result + * @return + */ + public byte[] sendAgvTwoModeInst(int phase, int index, int result,int offset,int quantity); + /** * 下发一号agv指令 * @param phase diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java index 59f633ce6..d5b88d4bb 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/NDCAgvServiceImpl.java @@ -336,6 +336,39 @@ public class NDCAgvServiceImpl implements NDCAgvService { return b; } + @Override + public byte[] sendAgvTwoModeInst(int phase, int index, int result,int offset,int quantity) { + if (phase < 0 || index < 0) + return null; + byte indexhigh = (byte) IntToHexHigh(index); + byte indexlow = (byte) IntToHexLow(index); + byte phasehigh = (byte) IntToHexHigh(phase); + byte phaselow = (byte) IntToHexLow(phase); + byte offsethigh = (byte) IntToHexHigh(offset); + byte offsetlow = (byte) IntToHexLow(offset); + byte quantityhigh = (byte) IntToHexHigh(quantity); + byte quantitylow = (byte) IntToHexLow(quantity); + + byte[] b = new byte[]{(byte) 0X87, (byte) 0XCD, + (byte) 0X00, (byte) 0X08, + (byte) 0X00, (byte) 0X0E, + (byte) 0X00, (byte) 0X01, + (byte) 0X00, (byte) 0X6D, + (byte) 0X00, (byte) 0X0A, + (byte) indexhigh, (byte) indexlow, + (byte) 0X01, (byte) 0X12, + (byte) phasehigh, (byte) phaselow, + (byte) offsethigh, (byte) offsetlow, + (byte) quantityhigh, (byte) quantitylow + }; + + + log.info("反馈agv动作数据--index:" + hexToString(indexhigh & 0xFF) + hexToString(indexlow & 0xFF) + ",phase:" + hexToString(phasehigh & 0xFF) + hexToString(phaselow & 0xFF)); + + System.out.println("反馈agv动作数据:" + Bytes2HexString(b)); + return b; + } + @Override public byte[] sendAgvOneModeInst(int phase, int index, int result) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java index bbbb8ea35..426488d94 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/agv/ndctwo/AgvNdcTwoDeviceDriver.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.agv.ndctwo; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; @@ -21,6 +22,7 @@ import org.nl.acs.device_driver.storage.standard_storage.StandardStorageDeviceDr import org.nl.acs.device_driver.driver.AbstractDeviceDriver; import org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor.HongXiangStationDeviceDriver; import org.nl.acs.device_driver.two_conveyor.manipulator_agv_station.ManipulatorAgvStationDeviceDriver; +import org.nl.acs.device_driver.two_conveyor.ranging_stations.RangingStationsDeviceDriver; import org.nl.acs.ext.wms.service.AcsToWmsService; import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl; import org.nl.acs.history.ErrorUtil; @@ -162,6 +164,8 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic HongXiangStationDeviceDriver hongXiangStationDeviceDriver; //行架-agv对接位 ManipulatorAgvStationDeviceDriver manipulatorAgvStationDeviceDriver; + //行架-agv对接位 + RangingStationsDeviceDriver rangingStationsDeviceDriver; if (phase == 0x02) { if (ObjectUtil.isEmpty(inst)) { @@ -236,15 +240,15 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey; logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code() + ",指令号" + ikey); } else { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } - }else { + } else { log.info("等待LMS系统进行确认允许取货,设备号{},指令号{}", device_code, ikey); message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey; logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code() + ",指令号" + ikey); } - }else { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + } else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); @@ -256,7 +260,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic } if ((standardInspectSiteDeviceDriver.getMove() == 1 && standardInspectSiteDeviceDriver.getAction() == 1 && standardInspectSiteDeviceDriver.getError() == 0)) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + standardInspectSiteDeviceDriver.getMove() + ",动作信号:" + standardInspectSiteDeviceDriver.getAction() + "报警信号:" + standardInspectSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, standardInspectSiteDeviceDriver.getMove(), standardInspectSiteDeviceDriver.getAction() @@ -271,7 +275,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey); @@ -284,7 +288,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if (hongXiangStationDeviceDriver.getMove() > 0) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + hongXiangStationDeviceDriver.getMove() + ",动作信号:" + hongXiangStationDeviceDriver.getAction() + "报警信号:" + hongXiangStationDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, hongXiangStationDeviceDriver.getMove(), hongXiangStationDeviceDriver.getAction() @@ -298,14 +302,27 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if (paperTubePickSiteDeviceDriver.getMove() > 0) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + paperTubePickSiteDeviceDriver.getMove() + ",动作信号:" + paperTubePickSiteDeviceDriver.getAction() + "报警信号:" + paperTubePickSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, paperTubePickSiteDeviceDriver.getMove(), paperTubePickSiteDeviceDriver.getAction() , paperTubePickSiteDeviceDriver.getError(), ikey); } + } else if (device.getDeviceDriver() instanceof RangingStationsDeviceDriver) { + rangingStationsDeviceDriver = (RangingStationsDeviceDriver) device.getDeviceDriver(); + String length1 = rangingStationsDeviceDriver.getLength1(); + Float len = 0.0F; + if (ObjectUtil.isNotEmpty(length1) && !"null".equals(length1)) { + len = Float.parseFloat(length1); + } + int roundedNumber = ObjectUtil.isNotEmpty(len) ? NumberUtil.round(len, 0).intValue() : 0; + if (roundedNumber == 0) { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, roundedNumber); + } else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 1, roundedNumber); + } } else { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); LuceneLogDto logDto = LuceneLogDto.builder() .device_code(device_code) .content("agvphase:" + phase + "反馈:" + data) @@ -371,9 +388,9 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic && StrUtil.equals("true", this.device.getExtraValue().get("wait").toString()) && StrUtil.equals(task.getTask_type(), "1")) { standardOrdinarySiteDeviceDriver.setOption(0); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); - }else { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); + } else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } this.setPhase(phase); } else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) { @@ -385,7 +402,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey); @@ -398,7 +415,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if (hongXiangStationDeviceDriver.getMove() > 0) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + hongXiangStationDeviceDriver.getMove() + ",动作信号:" + hongXiangStationDeviceDriver.getAction() + "报警信号:" + hongXiangStationDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, hongXiangStationDeviceDriver.getMove(), hongXiangStationDeviceDriver.getAction() @@ -412,7 +429,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if (paperTubePickSiteDeviceDriver.getMove() == 0) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + paperTubePickSiteDeviceDriver.getMove() + ",动作信号:" + paperTubePickSiteDeviceDriver.getAction() + "报警信号:" + paperTubePickSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, paperTubePickSiteDeviceDriver.getMove(), paperTubePickSiteDeviceDriver.getAction() @@ -427,14 +444,14 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if ((standardInspectSiteDeviceDriver.getMove() != 1 && standardInspectSiteDeviceDriver.getAction() == 1 && standardInspectSiteDeviceDriver.getError() == 0)) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + standardInspectSiteDeviceDriver.getMove() + ",动作信号:" + standardInspectSiteDeviceDriver.getAction() + "报警信号:" + standardInspectSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, standardInspectSiteDeviceDriver.getMove(), standardInspectSiteDeviceDriver.getAction() , standardInspectSiteDeviceDriver.getError(), ikey); } } else { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); LuceneLogDto logDto = LuceneLogDto.builder() .device_code(device_code) .content("agvphase:" + phase + "反馈:" + data) @@ -501,15 +518,15 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey; logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code() + ",指令号" + ikey); } else { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } } else { log.info("等待LMS系统进行确认允许取货,设备号{},指令号{}", device_code, ikey); message = "等待LMS系统进行确认允许取货,设备号:" + device_code + ",指令号:" + ikey; logServer.deviceExecuteLog(this.device_code, "", "", "等待LMS系统进行确认允许取货,设备号" + device.getDevice_code()); } - }else { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + } else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } } else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) { manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver(); @@ -520,7 +537,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey); @@ -533,7 +550,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if (paperTubePickSiteDeviceDriver.getMove() == 1) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + paperTubePickSiteDeviceDriver.getMove() + ",动作信号:" + paperTubePickSiteDeviceDriver.getAction() + "报警信号:" + paperTubePickSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, paperTubePickSiteDeviceDriver.getMove(), paperTubePickSiteDeviceDriver.getAction() @@ -547,7 +564,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if (hongXiangStationDeviceDriver.getMove() > 0) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + hongXiangStationDeviceDriver.getMove() + ",动作信号:" + hongXiangStationDeviceDriver.getAction() + "报警信号:" + hongXiangStationDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, hongXiangStationDeviceDriver.getMove(), hongXiangStationDeviceDriver.getAction() @@ -562,14 +579,27 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if ((standardInspectSiteDeviceDriver.getMove() == 1 && standardInspectSiteDeviceDriver.getAction() == 1 && standardInspectSiteDeviceDriver.getError() == 0)) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + standardInspectSiteDeviceDriver.getMove() + ",动作信号:" + standardInspectSiteDeviceDriver.getAction() + "报警信号:" + standardInspectSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, standardInspectSiteDeviceDriver.getMove(), standardInspectSiteDeviceDriver.getAction() , standardInspectSiteDeviceDriver.getError(), ikey); } + } else if (device.getDeviceDriver() instanceof RangingStationsDeviceDriver) { + rangingStationsDeviceDriver = (RangingStationsDeviceDriver) device.getDeviceDriver(); + String length1 = rangingStationsDeviceDriver.getLength1(); + Float len = 0.0F; + if (ObjectUtil.isNotEmpty(length1) && !"null".equals(length1)) { + len = Float.parseFloat(length1); + } + int roundedNumber = ObjectUtil.isNotEmpty(len) ? NumberUtil.round(len, 0).intValue() : 0; + if (roundedNumber == 0) { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, roundedNumber); + } else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 1, roundedNumber); + } } else { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); LuceneLogDto logDto = LuceneLogDto.builder() .device_code(device_code) .content("agvphase:" + phase + "反馈:" + data) @@ -625,7 +655,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic if (ObjectUtil.isNotEmpty(standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait")) && StrUtil.equals("true", standardOrdinarySiteDeviceDriver.getDevice().getExtraValue().get("wait").toString())) { standardOrdinarySiteDeviceDriver.setOption(0); - }else { + } else { data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); } data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); @@ -771,7 +801,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic if (device.getDeviceDriver() instanceof StandardOrdinarySiteDeviceDriver) { standardOrdinarySiteDeviceDriver = (StandardOrdinarySiteDeviceDriver) device.getDeviceDriver(); - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); standardOrdinarySiteDeviceDriver.setAgvphase(phase); standardOrdinarySiteDeviceDriver.setIndex(index); @@ -785,7 +815,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if (paperTubePickSiteDeviceDriver.getMove() == 0) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + paperTubePickSiteDeviceDriver.getMove() + ",动作信号:" + paperTubePickSiteDeviceDriver.getAction() + "报警信号:" + paperTubePickSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, paperTubePickSiteDeviceDriver.getMove(), paperTubePickSiteDeviceDriver.getAction() @@ -800,7 +830,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey); @@ -813,7 +843,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if (hongXiangStationDeviceDriver.getMove() == 0) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + hongXiangStationDeviceDriver.getMove() + ",动作信号:" + hongXiangStationDeviceDriver.getAction() + "报警信号:" + hongXiangStationDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, hongXiangStationDeviceDriver.getMove(), hongXiangStationDeviceDriver.getAction() @@ -823,14 +853,27 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); standardInspectSiteDeviceDriver.writing(1); if ((standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getAction() == 1 && standardInspectSiteDeviceDriver.getError() == 0)) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + standardInspectSiteDeviceDriver.getMove() + ",动作信号:" + standardInspectSiteDeviceDriver.getAction() + "报警信号:" + standardInspectSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足放货条件"; log.info("设备{}当前光电信号{},动作信号{} ,报警信号{},不满足放货条件,指令号{}", device_code, standardInspectSiteDeviceDriver.getMove(), standardInspectSiteDeviceDriver.getAction() , standardInspectSiteDeviceDriver.getError(), ikey); } + } else if (device.getDeviceDriver() instanceof RangingStationsDeviceDriver) { + rangingStationsDeviceDriver = (RangingStationsDeviceDriver) device.getDeviceDriver(); + String length1 = rangingStationsDeviceDriver.getLength1(); + Float len = 0.0F; + if (ObjectUtil.isNotEmpty(length1) && !"null".equals(length1)) { + len = Float.parseFloat(length1); + } + int roundedNumber = ObjectUtil.isNotEmpty(len) ? NumberUtil.round(len, 0).intValue() : 0; + if (roundedNumber == 0) { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, roundedNumber); + } else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 1, roundedNumber); + } } else { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } } //放货完成 @@ -888,7 +931,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic // } else { // data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); // } - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); this.setPhase(phase); } else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) { manipulatorAgvStationDeviceDriver = (ManipulatorAgvStationDeviceDriver) device.getDeviceDriver(); @@ -899,7 +942,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey); @@ -912,7 +955,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if (hongXiangStationDeviceDriver.getMove() > 0) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + hongXiangStationDeviceDriver.getMove() + ",动作信号:" + hongXiangStationDeviceDriver.getAction() + "报警信号:" + hongXiangStationDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, hongXiangStationDeviceDriver.getMove(), hongXiangStationDeviceDriver.getAction() @@ -926,7 +969,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if (paperTubePickSiteDeviceDriver.getMove() > 0) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + paperTubePickSiteDeviceDriver.getMove() + ",动作信号:" + paperTubePickSiteDeviceDriver.getAction() + "报警信号:" + paperTubePickSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, paperTubePickSiteDeviceDriver.getMove(), paperTubePickSiteDeviceDriver.getAction() @@ -936,10 +979,10 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); standardInspectSiteDeviceDriver.writing(0); if ((standardInspectSiteDeviceDriver.getMove() == 1)) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } } else { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } } //到达放货点 @@ -999,7 +1042,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic // } else { // data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); // } - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); this.setPhase(phase); } else if (device.getDeviceDriver() instanceof ManipulatorAgvStationDeviceDriver) { @@ -1011,7 +1054,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if ((manipulatorAgvStationDeviceDriver.getAction() == 1)) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + ",动作信号:" + manipulatorAgvStationDeviceDriver.getAction() + "报警信号:" + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{},动作信号{} ,不满足取货条件,指令号{}", device_code, manipulatorAgvStationDeviceDriver.getAction(), ikey); @@ -1024,7 +1067,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if (hongXiangStationDeviceDriver.getMove() == 0) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + hongXiangStationDeviceDriver.getMove() + ",动作信号:" + hongXiangStationDeviceDriver.getAction() + "报警信号:" + hongXiangStationDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, hongXiangStationDeviceDriver.getMove(), hongXiangStationDeviceDriver.getAction() @@ -1038,14 +1081,27 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic e.printStackTrace(); } if (paperTubePickSiteDeviceDriver.getMove() == 0) { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } else { message = "设备号:" + device_code + "光电信号:" + paperTubePickSiteDeviceDriver.getMove() + ",动作信号:" + paperTubePickSiteDeviceDriver.getAction() + "报警信号:" + paperTubePickSiteDeviceDriver.getError() + ",指令号:" + ikey + "不满足取货条件"; log.info("设备{}当前光电信号{},动作信号{} ,错误信号{},不满足取货条件,指令号{}", device_code, paperTubePickSiteDeviceDriver.getMove(), paperTubePickSiteDeviceDriver.getAction() , paperTubePickSiteDeviceDriver.getError(), ikey); } + } else if (device.getDeviceDriver() instanceof RangingStationsDeviceDriver) { + rangingStationsDeviceDriver = (RangingStationsDeviceDriver) device.getDeviceDriver(); + String length1 = rangingStationsDeviceDriver.getLength1(); + Float len = 0.0F; + if (ObjectUtil.isNotEmpty(length1) && !"null".equals(length1)) { + len = Float.parseFloat(length1); + } + int roundedNumber = ObjectUtil.isNotEmpty(len) ? NumberUtil.round(len, 0).intValue() : 0; + if (roundedNumber == 0) { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, roundedNumber); + } else { + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 1, roundedNumber); + } } else { - data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0); + data = ndcAgvService.sendAgvTwoModeInst(phase, index, 0, 0, 0); } } } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java index a94354146..3e0932572 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/conveyor/standard_inspect_site/StandardInspectSiteDeviceDriver.java @@ -30,7 +30,10 @@ import org.nl.acs.utils.ConvertUtil; import org.nl.common.utils.CodeUtil; import org.nl.config.SpringContextHolder; import org.nl.config.language.LangProcess; +import org.nl.config.lucene.service.LuceneExecuteLogService; +import org.nl.config.lucene.service.dto.LuceneLogDto; import org.openscada.opc.lib.da.Server; +import org.springframework.beans.factory.annotation.Autowired; import java.util.Date; import java.util.HashMap; @@ -57,6 +60,9 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp TaskMapper taskMapper; AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl"); + @Autowired + LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class); + String container; String container_type_desc; @@ -330,13 +336,19 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp public void writing(int command) { String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "." + ItemProtocol.item_to_command; - - //String opcservcerid = this.getDevice().getOpc_server_id(); -//Server server = ReadUtil.getServer(opcservcerid); Map itemMap = new HashMap(); itemMap.put(to_command, command); - this.control(itemMap); - + try { + this.checkcontrol(itemMap); + } catch (Exception e) { + e.printStackTrace(); + } + LuceneLogDto logDto = LuceneLogDto.builder() + .device_code(devicecode) + .content("下发多个电气信号" + itemMap) + .build(); + logDto.setLog_level(3); + luceneExecuteLogService.deviceExecuteLog(logDto); } public void writing(int type, int command) { diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/ItemProtocol.java index a3ce60cd0..2a779a2fe 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/oven_manipulator/ItemProtocol.java @@ -123,8 +123,6 @@ public class ItemProtocol { public String getOpcStringValue(String protocol) { String value = this.driver.getStringValue(protocol); if (StrUtil.isBlank(value)) { - //throw new BusinessException("{} : {}", new Object[]{protocol, DeviceErrorProtocol.getMessage(10000)}); - } else { return value; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/ranging_stations/ItemProtocol.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/ranging_stations/ItemProtocol.java index fd89df48f..1d27ca3b4 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/ranging_stations/ItemProtocol.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/ranging_stations/ItemProtocol.java @@ -1,5 +1,6 @@ package org.nl.acs.device_driver.two_conveyor.ranging_stations; +import cn.hutool.core.util.StrUtil; import lombok.Data; import lombok.extern.slf4j.Slf4j; import org.nl.acs.device.device_driver.standard_inspect.ItemDto; @@ -13,7 +14,8 @@ public class ItemProtocol { public static String item_mode = "mode"; - public static String item_length = "length"; + public static String item_length1 = "length1"; + public static String item_length2 = "length2"; public static String item_action = "action"; public static String item_to_command = "to_command"; @@ -26,12 +28,16 @@ public class ItemProtocol { public int getMode() { return this.getOpcIntegerValue(item_mode); } - public int getLength() { - return this.getOpcIntegerValue(item_length); + public String getLength1() { + return this.getOpcStringValue(item_length1); } - public int getAction() { - return this.getOpcIntegerValue(item_action); + public String getLength2() { + return this.getOpcStringValue(item_length2); + } + + public String getAction() { + return this.getOpcStringValue(item_action); } public int getToCommand() { @@ -61,10 +67,29 @@ public class ItemProtocol { } + public String getOpcStringValue(String protocol) { + String value = this.driver.getStringValue(protocol); + if (StrUtil.isBlank(value)) { + } else { + return value; + } + return "0"; + } + + public float getOpcFloatValue(String protocol) { + Float value = this.driver.getDoubleValue(protocol); + if (value == null) { + setIsonline(false); + } + return 0; + + } + public static List getReadableItemDtos() { ArrayList list = new ArrayList(); list.add(new ItemDto(item_mode, "工作模式", "DB600.B2", Boolean.valueOf(true))); - list.add(new ItemDto(item_length, "测距", "DB600.D6")); + list.add(new ItemDto(item_length1, "测距1", "DB600.D6")); + list.add(new ItemDto(item_length2, "测距2", "DB600.D6")); list.add(new ItemDto(item_action, "取放信号", "DB600.D8")); return list; } diff --git a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/ranging_stations/RangingStationsDeviceDriver.java b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/ranging_stations/RangingStationsDeviceDriver.java index b455f83e1..73abec909 100644 --- a/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/ranging_stations/RangingStationsDeviceDriver.java +++ b/acs2/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/two_conveyor/ranging_stations/RangingStationsDeviceDriver.java @@ -2,6 +2,7 @@ package org.nl.acs.device_driver.two_conveyor.ranging_stations; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson.JSONObject; import lombok.Data; @@ -77,10 +78,14 @@ public class RangingStationsDeviceDriver extends AbstractOpcDeviceDriver impleme String message = null; Boolean iserror = false; - int length = 0; - int last_length = 0; - int action = 0; - int last_action = 0; + String length1 = ""; + String last_length1 = ""; + + String length2 = ""; + String last_length2 = ""; + + String action = ""; + String last_action = ""; boolean hasVehicle = false; @@ -156,7 +161,8 @@ public class RangingStationsDeviceDriver extends AbstractOpcDeviceDriver impleme try { devicecode = this.getDeviceCode(); mode = this.itemProtocol.getMode(); - length = this.itemProtocol.getLength(); + length1 = this.itemProtocol.getLength1(); + length2 = this.itemProtocol.getLength2(); action = this.itemProtocol.getAction(); if (mode != last_mode) { this.setRequireSucess(false);