From ff28b7ce248f4f4b36e0cd1c6db71dc25d308189 Mon Sep 17 00:00:00 2001 From: 野心家 <1051256694@qq.com> Date: 星期日, 25 五月 2025 15:09:13 +0800 Subject: [PATCH] 初始化 --- src/main/java/com/zy/core/thread/RgvThread.java | 255 ++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 204 insertions(+), 51 deletions(-) diff --git a/src/main/java/com/zy/core/thread/RgvThread.java b/src/main/java/com/zy/core/thread/RgvThread.java index 6ba22dd..2abca84 100644 --- a/src/main/java/com/zy/core/thread/RgvThread.java +++ b/src/main/java/com/zy/core/thread/RgvThread.java @@ -12,6 +12,7 @@ import com.zy.asrs.entity.BasRgvOpt; import com.zy.asrs.service.BasRgvOptService; import com.zy.asrs.service.BasRgvService; +import com.zy.asrs.service.DeviceErrorService; import com.zy.asrs.utils.RouteUtils; import com.zy.asrs.utils.TrackRangeUtils; import com.zy.core.DevpThread; @@ -114,7 +115,13 @@ } } } catch (Exception e) { - log.error("RGV鏁版嵁璇诲彇绾跨▼寮傚父锛侊紒锛�" + e.getMessage()); + log.error("rgv杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "rgv杩炴帴澶辫触"+e.getMessage()); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } initRgv(); // e.printStackTrace(); } @@ -129,7 +136,13 @@ readStatus(); } catch (Exception e) { - log.error("RGV鏁版嵁璇诲彇绾跨▼寮傚父锛侊紒锛�" + e.getMessage()); + log.error("RGV鏁版嵁璇诲彇绾跨▼寮傚父锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV鏁版嵁璇诲彇绾跨▼寮傚父"+e.getMessage()); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } initRgv(); // e.printStackTrace(); } @@ -156,7 +169,13 @@ OperateResult result4 = siemensNet.Write("DB100.12.0", false); } } catch (Exception e) { - log.error("RGV鏁版嵁璇诲彇绾跨▼寮傚父锛侊紒锛�" + e.getMessage()); + log.error("RGV鏁版嵁浠诲姟涓嬪彂澶嶄綅绾跨▼寮傚父锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV鏁版嵁浠诲姟涓嬪彂澶嶄綅绾跨▼寮傚父"+e.getMessage()); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } initRgv(); // e.printStackTrace(); } @@ -216,7 +235,13 @@ } } } catch (Exception e) { - log.error("RGV鍙栬揣浠诲姟涓嬪彂绾跨▼寮傚父锛侊紒锛�" + e.getMessage()); + log.error("RGV浠诲姟涓嬪彂绾跨▼寮傚父锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV浠诲姟涓嬪彂绾跨▼寮傚父"+e.getMessage()); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } // e.printStackTrace(); } } @@ -267,7 +292,7 @@ while (true) { try { // 浼戠湢 1 绉� - Thread.sleep(100); + Thread.sleep(50); if (!deviceDetection()) { continue; } @@ -294,7 +319,8 @@ write(issued); rgvTaskProtocol.setAvoid(0); - Thread.sleep(200); + try{Thread.sleep(50L);} catch (Exception e){} + RgvTaskCache.updateRgvStatus(rgvTaskProtocol); } continue; @@ -327,22 +353,6 @@ } else { for (TaskProtocol taskProtocol : allTakeTaskProtocol) { if (taskProtocol.getIsRunning() == 1) {//鍑嗗涓嬪彂 -// RgvProtocol rgvProtocolOther = RgvStatusCache.getRgvStatus(slave.getOtherId()); - if (taskProtocol.getTaskStatus()==3){ - DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, taskProtocol.getTargetPositionStaNoPlcId()); - StaProtocol staProtocol = devpThread.getStation().get(taskProtocol.getTargetPositionStaNo()); - if (staProtocol == null ) { - continue; - } - // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 - if (!staProtocol.isAutoing() || staProtocol.isLoading() - || staProtocol.getWorkNo() != 0 - ){ - Thread.sleep(500); -// System.out.println("<鏀捐揣鐩爣绔�>" + taskProtocol.getTargetPositionStaNo() + "<闈炶嚜鍔ㄦ垨鑰呮湁鐗╂垨鑰呭瓨鍦ㄥ伐浣滃彿锛侊紒锛�>"); -// continue; - } - } //鍙岃溅 if (rgvOtherStatusEnable()) { //鍙︿竴鍙拌溅鏄惁鍏佽姝ゅ彴杞︽墽琛� @@ -362,8 +372,6 @@ if (!staProtocol.isAutoing() || staProtocol.isLoading() || staProtocol.getWorkNo() != 0 ){ - Thread.sleep(500); -// System.out.println("<鏀捐揣鐩爣绔�>" + taskProtocol.getTargetPositionStaNo() + "<闈炶嚜鍔ㄦ垨鑰呮湁鐗╂垨鑰呭瓨鍦ㄥ伐浣滃彿锛侊紒锛�>"); continue; } } @@ -380,7 +388,13 @@ } } } catch (Exception e) { - log.error("RGV鍙栬揣浠诲姟涓嬪彂绾跨▼寮傚父锛侊紒锛�" + e.getMessage()); + log.error("RGV浠诲姟涓嬪彂绾跨▼寮傚父锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV浠诲姟涓嬪彂绾跨▼寮傚父"+e.getMessage()); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } // e.printStackTrace(); } } @@ -437,12 +451,43 @@ if (rgvProtocolOther.getStatusType().equals(RgvStatusType.IDLE)) { if ((rgvProtocolOther.getRgvPos() - rgvProtocolOther.getCarBodyJiaoMing()) - (targetPosition + rgvProtocol.getCarBodyKunPeng()) - > avoidDistance) {//鏃犻渶閬胯 + > avoidDistance - 50) {//鏃犻渶閬胯 return true; } else { + + RgvThread rgvThreadOther = (RgvThread) SlaveConnection.get(SlaveType.Rgv, slave.getOtherId()); + TaskProtocolCache taskProtocolCacheOther = rgvThreadOther.getTaskProtocolCache(); + TaskProtocol nowPosRunTask = taskProtocolCacheOther.getNowPosRunTask(rgvProtocolOther.getRgvPos()); + if (!Cools.isEmpty(nowPosRunTask)){ + boolean signNowPosRun = true; + if (nowPosRunTask.getTaskStatus()==3){ + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, nowPosRunTask.getTargetPositionStaNoPlcId()); + StaProtocol staProtocol = devpThread.getStation().get(nowPosRunTask.getTargetPositionStaNo()); + if (staProtocol == null ) { + signNowPosRun =false; + } + if (signNowPosRun){ + // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 + if (!staProtocol.isAutoing() || staProtocol.isLoading() + || staProtocol.getWorkNo() != 0 + ){ + signNowPosRun =false; + } + } + } + if (signNowPosRun){ + return false; + } + } long avoid = targetPosition + rgvProtocol.getCarBodyKunPeng() + avoidDistance + rgvProtocolOther.getCarBodyJiaoMing(); if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[0])) { - log.error("琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛佷换鍔″紓甯� 鑱旂郴绠$悊鍛橈紒锛侊紒"); + log.error("RGV琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿"); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } return false; } long avoidAbs = Math.abs(avoid - rgvProtocolOther.getRgvPos()); @@ -452,17 +497,23 @@ rgvTaskProtocolOther.setAvoid(1); rgvTaskProtocolOther.setAvoidingTheDestination(avoid); RgvTaskCache.updateRgvStatus(rgvTaskProtocolOther); - return true; + return false; } } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.ROAM)) { if ((rgvProtocolOther.getRgvPosDestination() - rgvProtocolOther.getCarBodyJiaoMing()) - (targetPosition + rgvProtocol.getCarBodyKunPeng()) - > avoidDistance) {//鏃犻渶閬胯 + > avoidDistance - 50) {//鏃犻渶閬胯 return true; } else { long avoid = targetPosition + rgvProtocol.getCarBodyKunPeng() + avoidDistance + rgvProtocolOther.getCarBodyJiaoMing(); if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[0])) { - log.error("琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛佷换鍔″紓甯� 鑱旂郴绠$悊鍛橈紒锛侊紒"); + log.error("RGV琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿"); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } return false; } long avoidAbs = Math.abs(avoid - rgvProtocolOther.getRgvPos()); @@ -472,18 +523,24 @@ rgvTaskProtocolOther.setAvoid(1); rgvTaskProtocolOther.setAvoidingTheDestination(avoid); RgvTaskCache.updateRgvStatus(rgvTaskProtocolOther); - return true; + return false; } } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.WORKING)) { if ((rgvProtocolOther.getRgvPosDestination() - rgvProtocolOther.getCarBodyJiaoMing()) - (targetPosition + rgvProtocol.getCarBodyKunPeng()) - > avoidDistance) {//鏃犻渶閬胯 + > avoidDistance - 50) {//鏃犻渶閬胯 return true; } else { if (rgvProtocolOther.getRgvPosDestination() >= rgvProtocolOther.getRgvPos()-50) { long avoid = rgvProtocolOther.getRgvPos() - rgvProtocolOther.getCarBodyJiaoMing() - avoidDistance - rgvProtocol.getCarBodyKunPeng(); if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[1])) { - log.error("琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛佷换鍔″紓甯� 鑱旂郴绠$悊鍛橈紒锛侊紒"); + log.error("RGV琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿"); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } return false; } long avoidAbs = Math.abs(avoid - rgvProtocol.getRgvPos()); @@ -500,7 +557,7 @@ } else { if ((rgvProtocolOther.getRgvPosDestinationOrPos(true) - rgvProtocolOther.getCarBodyJiaoMing()) - (targetPosition + rgvProtocol.getCarBodyKunPeng()) - > avoidDistance) {//鏃犻渶閬胯 + > avoidDistance - 50) {//鏃犻渶閬胯 return true; } } @@ -508,12 +565,42 @@ if (rgvProtocolOther.getStatusType().equals(RgvStatusType.IDLE)) { if ((targetPosition - rgvProtocol.getCarBodyJiaoMing()) - (rgvProtocolOther.getRgvPos() + rgvProtocolOther.getCarBodyKunPeng()) - > avoidDistance) {//鏃犻渶閬胯 + > avoidDistance - 50) {//鏃犻渶閬胯 return true; } else { + RgvThread rgvThreadOther = (RgvThread) SlaveConnection.get(SlaveType.Rgv, slave.getOtherId()); + TaskProtocolCache taskProtocolCacheOther = rgvThreadOther.getTaskProtocolCache(); + TaskProtocol nowPosRunTask = taskProtocolCacheOther.getNowPosRunTask(rgvProtocolOther.getRgvPos()); + if (!Cools.isEmpty(nowPosRunTask)){ + boolean signNowPosRun = true; + if (nowPosRunTask.getTaskStatus()==3){ + DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, nowPosRunTask.getTargetPositionStaNoPlcId()); + StaProtocol staProtocol = devpThread.getStation().get(nowPosRunTask.getTargetPositionStaNo()); + if (staProtocol == null ) { + signNowPosRun =false; + } + if (signNowPosRun){ + // 鍒ゆ柇鏄惁婊¤冻鍏ュ簱鏉′欢 + if (!staProtocol.isAutoing() || staProtocol.isLoading() + || staProtocol.getWorkNo() != 0 + ){ + signNowPosRun =false; + } + } + } + if (signNowPosRun){ + return false; + } + } long avoid = targetPosition - rgvProtocol.getCarBodyJiaoMing() - avoidDistance - rgvProtocolOther.getCarBodyKunPeng(); if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[1])) { - log.error("琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛佷换鍔″紓甯� 鑱旂郴绠$悊鍛橈紒锛侊紒"); + log.error("RGV琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿"); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } return false; } long avoidAbs = Math.abs(avoid - rgvProtocolOther.getRgvPos()); @@ -523,17 +610,23 @@ rgvTaskProtocolOther.setAvoid(1); rgvTaskProtocolOther.setAvoidingTheDestination(avoid); RgvTaskCache.updateRgvStatus(rgvTaskProtocolOther); - return true; + return false; } } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.ROAM)) { if ((targetPosition - rgvProtocol.getCarBodyJiaoMing()) - (rgvProtocolOther.getRgvPosDestination() + rgvProtocolOther.getCarBodyKunPeng()) - > avoidDistance) {//鏃犻渶閬胯 + > avoidDistance - 50) {//鏃犻渶閬胯 return true; } else { long avoid = targetPosition - rgvProtocol.getCarBodyJiaoMing() - avoidDistance - rgvProtocolOther.getCarBodyKunPeng(); if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[1])) { - log.error("琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛佷换鍔″紓甯� 鑱旂郴绠$悊鍛橈紒锛侊紒"); + log.error("RGV琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿"); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } return false; } long avoidAbs = Math.abs(avoid - rgvProtocolOther.getRgvPos()); @@ -543,19 +636,25 @@ rgvTaskProtocolOther.setAvoid(1); rgvTaskProtocolOther.setAvoidingTheDestination(avoid); RgvTaskCache.updateRgvStatus(rgvTaskProtocolOther); - return true; + return false; } } else if (rgvProtocolOther.getStatusType().equals(RgvStatusType.WORKING)) { if ((targetPosition - rgvProtocol.getCarBodyJiaoMing()) - (rgvProtocolOther.getRgvPosDestination() + rgvProtocolOther.getCarBodyKunPeng()) - > avoidDistance) {//鏃犻渶閬胯 + > avoidDistance-50) {//鏃犻渶閬胯 return true; } else { if (rgvProtocolOther.getRgvPosDestination() <= rgvProtocolOther.getRgvPos() + 50) { long avoid = rgvProtocolOther.getRgvPos() + rgvProtocolOther.getCarBodyKunPeng() + avoidDistance + rgvProtocol.getCarBodyJiaoMing(); if (!new TrackRangeUtils().avoidRange(avoid, avoidRange[0])) { - log.error("琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛佷换鍔″紓甯� 鑱旂郴绠$悊鍛橈紒锛侊紒"); + log.error("RGV琛岃蛋瓒呭嚭鑼冨洿锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV琛岃蛋瓒呭嚭鑼冨洿"); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } return false; } long avoidAbs = Math.abs(avoid - rgvProtocol.getRgvPos()); @@ -572,7 +671,7 @@ } else { if ((rgvProtocolOther.getRgvPosDestinationOrPos(false) - rgvProtocolOther.getCarBodyJiaoMing()) - (targetPosition + rgvProtocol.getCarBodyKunPeng()) - > avoidDistance) {//鏃犻渶閬胯 + > avoidDistance - 50) {//鏃犻渶閬胯 return true; } } @@ -608,7 +707,13 @@ rgvProtocol.setStatusEnable(false); } } catch (Exception e) { - log.error("RGV寮傚父锛侊紒锛�" + e.getMessage()); + log.error("RGV寮傚父锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV寮傚父"+e.getMessage()); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } rgvProtocol.setStatusEnable(true); } @@ -641,6 +746,12 @@ // OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆慠GV plc杩炴帴澶辫触锛侊紒锛� ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); log.error("RGV plc杩炴帴澶辫触锛侊紒锛� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGVplc杩炴帴澶辫触"); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } } initRgv(); // siemensNet.ConnectClose(); @@ -652,7 +763,7 @@ */ private void readStatus() { try { - OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 19); + OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 20); if (result.IsSuccess) { // 鏋勫缓璁惧鐘舵�佸璞� RgvProtocol rgvProtocol = RgvStatusCache.getRgvStatus(slave.getId()); @@ -679,8 +790,14 @@ // rgvProtocol.setxDuration(siemensNet.getByteTransform().TransInt16(result.Content, 48)); // OperateResultExOne<byte[]> result11 = siemensNet.Read("DB100.12", (short) 1); - boolean[] status = siemensNet.getByteTransform().TransBool(result.Content, 18, 1); + boolean[] status = siemensNet.getByteTransform().TransBool(result.Content, 18, 2); rgvProtocol.setLoaded(status[0]? (short)1:(short)0); + rgvProtocol.setErr1(status[8]); + rgvProtocol.setErr2(status[9]); + rgvProtocol.setErr3(status[10]); + rgvProtocol.setErr4(status[11]); + rgvProtocol.setErr5(status[12]); + rgvProtocol.setErr6(status[13]); OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛", DateUtils.convert(new Date()), slave.getId())); // // 宸ヤ綅1澶嶄綅淇″彿 @@ -709,6 +826,13 @@ basRgv.setRgvSts((int) rgvProtocol.getMode()); if (!basRgvService.updateById(rgvProtocol.toSqlModel(basRgv))) { log.error("RGV plc鏁版嵁搴撴洿鏂板け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); + + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV plc鏁版嵁搴撴洿鏂板け璐�"); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } } } catch (Exception ignore) { @@ -723,11 +847,25 @@ connectRgv = false; // OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆戣鍙朢GV plc鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot())); log.error("璇诲彇RGV plc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()); + + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "璇诲彇RGV plc鐘舵�佷俊鎭け璐�"); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } } } catch (Exception e) { // e.printStackTrace(); // OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆戣鍙朢GV plc鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort())); log.error("璇诲彇RGV plc鐘舵�佷俊鎭け璐� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "璇诲彇RGV plc鐘舵�佷俊鎭け璐�"); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } initRgv(); } } @@ -737,7 +875,14 @@ */ private boolean write(TaskProtocol taskProtocol) throws InterruptedException { if (null == taskProtocol) { - log.error("RGV鍐欏叆鍛戒护涓虹┖"); + log.error("RGV鍐欏叆鍛戒护涓虹┖ ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV鍐欏叆鍛戒护涓虹┖"); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } return false; } // convertRow(command); @@ -786,9 +931,17 @@ } if (result != null && result.IsSuccess) { - Thread.sleep(200); - this.readStatus(); +// Thread.sleep(50); +// this.readStatus(); log.info("RGV 鍛戒护涓嬪彂[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(taskProtocol)); + log.error("RGV 鍛戒护涓嬪彂 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort()); + + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("rgv", slave.getId(), "RGV 鍛戒护涓嬪彂"+JSON.toJSON(taskProtocol)); + } catch (Exception e2){ + log.error("e2:"+e2.getMessage()); + } OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(taskProtocol))); return true; } else { @@ -828,8 +981,8 @@ } if (result != null && result.IsSuccess) { - Thread.sleep(200); - this.readStatus(); +// Thread.sleep(200); +// this.readStatus(); log.info("RGV 鍛戒护涓嬪彂[id:{}] >>>>> {}", slave.getId(), JSON.toJSON("null")); OutputQueue.RGV.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON("null"))); return true; -- Gitblit v1.9.1