From a3460ef70c67b64cc4bd28feb957df03b19325ad Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期二, 20 六月 2023 16:31:09 +0800 Subject: [PATCH] 充电逻辑 --- src/main/java/com/zy/core/thread/LiftThread.java | 42 ++++++++++++++++++++++++------------------ 1 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/zy/core/thread/LiftThread.java b/src/main/java/com/zy/core/thread/LiftThread.java index d1b2299..c482b12 100644 --- a/src/main/java/com/zy/core/thread/LiftThread.java +++ b/src/main/java/com/zy/core/thread/LiftThread.java @@ -6,6 +6,7 @@ import HslCommunication.ModBus.ModbusTcpNet; import com.alibaba.fastjson.JSON; import com.core.common.DateUtils; +import com.core.common.RadixTools; import com.core.common.SpringUtils; import com.core.exception.CoolException; import com.zy.asrs.entity.BasLift; @@ -21,7 +22,6 @@ import com.zy.core.cache.OutputQueue; import com.zy.core.cache.SlaveConnection; import com.zy.core.enums.*; -import com.zy.core.model.DevpSlave; import com.zy.core.model.LiftSlave; import com.zy.core.model.Task; import com.zy.core.model.command.*; @@ -127,7 +127,7 @@ liftProtocol.setLiftLock(CommonUtils.shortToBoolean(modbusTcpNet.getByteTransform().TransInt16(content, 0))); //浣嶇疆鍒拌揪鍙嶉 liftProtocol.setPositionArrivalFeedback(modbusTcpNet.getByteTransform().TransInt16(content,2)); - + byte by = modbusTcpNet.getByteTransform().TransByte(content, 5); int[] datas = CommonUtils.byteToBits(by); //鍑嗗灏辩华 @@ -283,6 +283,12 @@ array = tmp; } + try { + Thread.sleep(1000);//鍛戒护涓嬪彂鍓嶄紤鐪�1s + } catch (InterruptedException e) { + throw new RuntimeException(e); + } + OperateResult result = modbusTcpNet.Write("41088", array);; if (result != null && result.IsSuccess) { News.info("鎻愬崌鏈哄懡浠や笅鍙慬id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command)); @@ -400,6 +406,21 @@ News.info("鎻愬崌鏈哄懡浠や笅鍙戞垚鍔燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command)); liftProtocol.setWrkTime(new Date());//鏇存柊宸ヤ綔鏃堕棿 + //淇濆瓨鏁版嵁鍒版暟鎹簱鍋氭祦姘� + BasLiftOptService liftOptService = SpringUtils.getBean(BasLiftOptService.class); + if (liftOptService != null) { + BasLiftOpt opt = new BasLiftOpt( + redisCommand.getWrkNo().intValue(), + redisCommand.getLiftNo().intValue(), + new Date(), + null, + null, + null, + JSON.toJSONString(command) + ); + liftOptService.insert(opt); + } + //鍒ゆ柇鏁版嵁鏄惁鎵ц瀹屾垚 if (commandStep < size - 1) { //鏇存柊redis鏁版嵁 @@ -410,27 +431,12 @@ redisUtil.set("lift_wrk_no_" + redisCommand.getWrkNo(), JSON.toJSONString(redisCommand)); }else { //宸叉墽琛屽畬鎴� - //淇濆瓨鏁版嵁鍒版暟鎹簱鍋氭祦姘� - BasLiftOptService liftOptService = SpringUtils.getBean(BasLiftOptService.class); - if (liftOptService != null) { - BasLiftOpt opt = new BasLiftOpt( - redisCommand.getWrkNo().intValue(), - redisCommand.getLiftNo().intValue(), - new Date(), - null, - null, - null, - JSON.toJSONString(assignCommand) - ); - liftOptService.insert(opt); - } //鍒犻櫎redis redisUtil.del("lift_wrk_no_" + redisCommand.getWrkNo()); //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting liftProtocol.setProtocolStatus(LiftProtocolStatusType.WAITING); - News.info("鎻愬崌鏈轰换鍔℃墽琛屽畬鎴愮瓑寰呯‘璁や腑锛屾彁鍗囨満鍙�={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command)); - + News.info("鎻愬崌鏈轰换鍔℃墽琛屼笅鍙戝畬鎴愮瓑寰呮墽琛岀粨鏉燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command)); } } -- Gitblit v1.9.1