From 87c4efe93e6fe31a9c989b4aa5cc0c8f559b845d Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期五, 31 三月 2023 16:50:47 +0800 Subject: [PATCH] 提升机代码,四向穿梭车线程优化 --- src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java | 145 ++++++++++++++++++++++------------------------- 1 files changed, 68 insertions(+), 77 deletions(-) diff --git a/src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java b/src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java index 0a29623..d370e72 100644 --- a/src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java +++ b/src/main/java/com/zy/core/model/protocol/ShuttleProtocol.java @@ -1,5 +1,11 @@ package com.zy.core.model.protocol; +import com.core.common.SpringUtils; +import com.zy.asrs.entity.LocMast; +import com.zy.asrs.service.BasShuttleService; +import com.zy.asrs.service.LocMastService; +import com.zy.core.News; +import com.zy.core.enums.ShuttleErrorCodeType; import com.zy.core.enums.ShuttleProtocolStatusType; import com.zy.core.enums.ShuttleStatusType; import com.zy.core.model.command.ShuttleAssignCommand; @@ -82,6 +88,11 @@ private Short errorCode; /** + * 閿欒缂栧彿鏋氫妇 + */ + private ShuttleErrorCodeType errorCodeType; + + /** * Plc杈撳嚭鐘舵�両O */ private Short plcOutputStatusIO; @@ -146,82 +157,6 @@ */ private Boolean pakMk = true; - // 浠诲姟淇℃伅 --------------------------------------------------------- - /** - * 96.鍏ュ簱浠诲姟涓� - */ - private boolean pakInTask; - - /** - * 97. 鍑哄簱浠诲姟涓� - */ - private boolean pakOutTask; - - /** - * 98. 绉诲簱浠诲姟涓� - */ - private boolean pakMoveTask; - - /** - * 99. 鍥炲師鐐逛换鍔′腑 - */ - private boolean goHpTask; - - /** - * 100. 鍘诲弽鍘熺偣浠诲姟涓� - */ - private boolean goOHpTask; - - /** - * 101. 鍘诲師鐐归伩璁╀綅 - */ - private boolean goHpAvoid; - - /** - * 102. 鍘诲弽鍘熺偣閬胯浣� - */ - private boolean goOHpAvoid; - - /** - * 104. 鍏ュ簱鍙栫┖缁撴潫 - */ - private boolean pakInEmpty; - - /** - * 105. 鍏ュ簱姝e父缁撴潫 - */ - private boolean pakInFinish; - - /** - * 106. 鍑哄簱鍙栫┖缁撴潫 - */ - private boolean pakOutEmpty; - - /** - * 107. 鍑哄簱姝e父缁撴潫 - */ - private boolean pakOutFinish; - - /** - * 108. 鍘诲師鐐归伩璁╁畬鎴� - */ - private boolean goHpAvoidFinish; - - /** - * 109. 鍘诲弽鍘熺偣閬胯瀹屾垚 - */ - private boolean goOHpAvoidFinish; - - /** - * 110. 鍘诲師鐐归伩璁╁畬鎴� - */ - private boolean goHpAvoidErr; - - /** - * 111. 鍘诲弽鍘熺偣閬胯瀹屾垚 - */ - private boolean goOHpAvoidErr; - public void setBusyStatus(Short status) { this.busyStatus = status; this.busyStatusType = ShuttleStatusType.get(status); @@ -233,8 +168,13 @@ } //鑾峰彇鐢垫睜鐢甸噺 - public Short getBatteryPower() { + public Short getBatteryPower$() { return (short) (this.batteryPower * 0.1); + } + + //鑾峰彇鐢垫睜娓╁害 + public Short getBatteryTemp$() { + return (short) (this.batteryTemp * 0.1); } /** @@ -253,4 +193,55 @@ this.protocolStatusType = status; } + /** + * 璁剧疆閿欒缂栧彿 + */ + public void setErrorCode(Short errorCode) { + this.errorCode = errorCode; + this.errorCodeType = ShuttleErrorCodeType.get(errorCode.intValue()); + } + + /** + * 璁剧疆閿欒缂栧彿 + */ + public void setErrorCode(ShuttleErrorCodeType type) { + this.errorCode = type.id.shortValue(); + this.errorCodeType = type; + } + + // 鏄惁澶勪簬绌洪棽寰呭懡鐘舵�� + public Boolean isIdle() { + boolean res = this.busyStatusType.equals(ShuttleStatusType.IDLE) + && this.pakMk.equals(true) + && this.errorCodeType.equals(ShuttleErrorCodeType.NORMAL) + && this.taskNo == 0 + ; + if (!res) { + return res; + } else { + // 鐢甸噺 + try { + Integer chargeLine = SpringUtils.getBean(BasShuttleService.class).selectById(this.shuttleNo).getChargeLine(); + return this.getBatteryPower$() > chargeLine; + } catch (Exception e) { + News.error("fail", e); + return false; + } + } + } + + //閫氳繃褰撳墠浜岀淮鐮佽幏鍙栧綋鍓嶅簱浣嶅彿 + public String getCurrentLocNo() { + LocMastService locMastService = SpringUtils.getBean(LocMastService.class); + if (locMastService == null) { + return null; + } + //婧愬簱浣�(灏忚溅褰撳墠浣嶇疆) + LocMast currentLocMast = locMastService.queryByQrCode(this.currentCode.toString()); + if (currentLocMast == null) { + return null; + } + return currentLocMast.getLocNo(); + } + } -- Gitblit v1.9.1