From c3434b1fe0132372b34ff0a46d84e6129a094bfc Mon Sep 17 00:00:00 2001 From: L <L@132> Date: 星期四, 28 八月 2025 08:43:15 +0800 Subject: [PATCH] * --- src/main/java/com/zy/core/thread/SiemensCrnThread.java | 98 +++++++++++++++++++++++++----------------------- 1 files changed, 51 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SiemensCrnThread.java b/src/main/java/com/zy/core/thread/SiemensCrnThread.java index 603aa3b..2a83202 100644 --- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java +++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java @@ -335,62 +335,66 @@ } catch (Exception e){log.error("寤舵椂寮傚父335琛�");} log.info("鍫嗗灈鏈轰换鍔¤100.0锛氬�硷細20 crnWrite-317琛�;"); - OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 20); - if (resultRead.IsSuccess) { - CrnCommand one = new CrnCommand(); - one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2)); - one.setTaskMode(siemensNet.getByteTransform().TransInt16(resultRead.Content, 4)); - one.setSourcePosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 6)); - one.setSourcePosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 8)); - one.setSourcePosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 10)); - one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12)); - one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14)); - one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16)); - if (!command.getTaskNo().equals(one.getTaskNo()) - || !command.getTaskMode().equals(one.getTaskMode()) - || !command.getSourcePosX().equals(one.getSourcePosX()) - || !command.getSourcePosY().equals(one.getSourcePosY()) - || !command.getSourcePosZ().equals(one.getSourcePosZ()) - || !command.getDestinationPosX().equals(one.getDestinationPosX()) - || !command.getDestinationPosY().equals(one.getDestinationPosY()) - || !command.getDestinationPosZ().equals(one.getDestinationPosZ()) - ){ - CrnErrCache.updateCrnErr(slave.getId(), "鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐�"); + try{ + OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 20); + if (resultRead.IsSuccess) { + CrnCommand one = new CrnCommand(); + one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2)); + one.setTaskMode(siemensNet.getByteTransform().TransInt16(resultRead.Content, 4)); + one.setSourcePosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 6)); + one.setSourcePosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 8)); + one.setSourcePosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 10)); + one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12)); + one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14)); + one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16)); + if (!command.getTaskNo().equals(one.getTaskNo()) + || !command.getTaskMode().equals(one.getTaskMode()) + || !command.getSourcePosX().equals(one.getSourcePosX()) + || !command.getSourcePosY().equals(one.getSourcePosY()) + || !command.getSourcePosZ().equals(one.getSourcePosZ()) + || !command.getDestinationPosX().equals(one.getDestinationPosX()) + || !command.getDestinationPosY().equals(one.getDestinationPosY()) + || !command.getDestinationPosZ().equals(one.getDestinationPosZ()) + ){ + CrnErrCache.updateCrnErr(slave.getId(), "鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐�"); - log.error("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐id:{}]>>>>閲嶅啓[{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), i,JSON.toJSON(command),JSON.toJSON(one)); + log.error("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐id:{}]>>>>閲嶅啓[{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), i,JSON.toJSON(command),JSON.toJSON(one)); - try{ - DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); - deviceErrorService.addDeviceError("CrnErr", slave.getId(), "宸烽亾鍙�"+command.getLaneNo()+";鍐欏叆娆℃暟"+i+";鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐�:"+JSON.toJSONString(command.getNowTask())); - } catch (Exception e2){ - } - try{ - BasErrLogService basErrLogService = SpringUtils.getBean(BasErrLogService.class); - BasErrLog basErrLog = new BasErrLog(command,"鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐�",""); - if (!basErrLogService.insert(basErrLog)) { - log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", slave.getId(), "鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐ヨ褰曞け璐�"); + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("CrnErr", slave.getId(), "宸烽亾鍙�"+command.getLaneNo()+";鍐欏叆娆℃暟"+i+";鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐�:"+JSON.toJSONString(command.getNowTask())); + } catch (Exception e2){ } - } catch (Exception e3){ + try{ + BasErrLogService basErrLogService = SpringUtils.getBean(BasErrLogService.class); + BasErrLog basErrLog = new BasErrLog(command,"鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐�",""); + if (!basErrLogService.insert(basErrLog)) { + log.error("鍫嗗灈鏈簆lc寮傚父璁板綍澶辫触 ===>> [id:{}] [error:{}]", slave.getId(), "鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐ヨ褰曞け璐�"); + } + } catch (Exception e3){ + } + result = siemensNet.Write("DB100.0", array); + }else{ + try{ + DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); + deviceErrorService.addDeviceError("crnWrite", slave.getId(), "宸烽亾鍙�"+command.getLaneNo()+";鍫嗗灈鏈烘寚浠や笅鍙�:"+JSON.toJSONString(command.getNowTask())); + } catch (Exception e2){ + } + break; } - result = siemensNet.Write("DB100.0", array); - }else{ + } else { + CrnErrCache.updateCrnErr(slave.getId(), "鍫嗗灈鏈哄懡浠よ鍙栧け璐�"); + + log.error("鍫嗗灈鏈哄懡浠よ鍙栧け璐id:{}]>>>>閲嶅啓[{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), i,JSON.toJSON(command),""); + try{ DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); - deviceErrorService.addDeviceError("crnWrite", slave.getId(), "宸烽亾鍙�"+command.getLaneNo()+";鍫嗗灈鏈烘寚浠や笅鍙�:"+JSON.toJSONString(command.getNowTask())); + deviceErrorService.addDeviceError("CrnErr", slave.getId(), "宸烽亾鍙�"+command.getLaneNo()+";鍐欏叆娆℃暟"+i+";鍫嗗灈鏈哄懡浠よ鍙栧け璐�:"+JSON.toJSONString(command.getNowTask())); } catch (Exception e2){ } - break; } - } else { - CrnErrCache.updateCrnErr(slave.getId(), "鍫嗗灈鏈哄懡浠よ鍙栧け璐�"); - - log.error("鍫嗗灈鏈哄懡浠よ鍙栧け璐id:{}]>>>>閲嶅啓[{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), i,JSON.toJSON(command),""); - - try{ - DeviceErrorService deviceErrorService = SpringUtils.getBean(DeviceErrorService.class); - deviceErrorService.addDeviceError("CrnErr", slave.getId(), "宸烽亾鍙�"+command.getLaneNo()+";鍐欏叆娆℃暟"+i+";鍫嗗灈鏈哄懡浠よ鍙栧け璐�:"+JSON.toJSONString(command.getNowTask())); - } catch (Exception e2){ - } + } catch (Exception e396){ + log.error("鍫嗗灈鏈轰换鍔¤100.0锛氬�硷細20 crnWrite-317琛�;寮傚父"+e396.getMessage()); } }while(i<5); -- Gitblit v1.9.1