From 6d25ccf7d7a582ab861e4b9dc0a38cb6cbf21588 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 16 六月 2023 09:43:44 +0800
Subject: [PATCH] 提升机状态读取
---
src/main/java/com/zy/core/thread/LiftThread.java | 98 ++++++++++++++++++++++++++----------------------
1 files changed, 53 insertions(+), 45 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/LiftThread.java b/src/main/java/com/zy/core/thread/LiftThread.java
index d5d2986..d1b2299 100644
--- a/src/main/java/com/zy/core/thread/LiftThread.java
+++ b/src/main/java/com/zy/core/thread/LiftThread.java
@@ -14,15 +14,19 @@
import com.zy.asrs.service.BasLiftService;
import com.zy.common.utils.CommonUtils;
import com.zy.common.utils.RedisUtil;
+import com.zy.core.DevpThread;
import com.zy.core.News;
import com.zy.core.ThreadHandler;
import com.zy.core.cache.MessageQueue;
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.*;
import com.zy.core.model.protocol.LiftProtocol;
+import com.zy.core.model.protocol.StaProtocol;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
@@ -169,15 +173,13 @@
///璇诲彇鎻愬崌鏈虹姸鎬�-end
- //灏忚溅澶勪簬杩愯鐘舵�侊紝灏嗘爣璁扮疆涓簍rue
+ //鎻愬崌鏈哄浜庤繍琛岀姸鎬侊紝灏嗘爣璁扮疆涓簍rue
if (liftProtocol.getRunning()) {
liftProtocol.setPakMk(true);
}
- //鎻愬崌鏈哄浜庨攣瀹氥�佹湭杩愯銆佸氨缁�佹爣璁皌rue銆佹湁浠诲姟鍙�
- if (liftProtocol.getLiftLock()
- && !liftProtocol.getRunning()
- && liftProtocol.getReady()
+ //鎻愬崌鏈哄浜庢湭杩愯銆佸氨缁�佹爣璁皌rue銆佹湁浠诲姟鍙�
+ if (!liftProtocol.getRunning()
&& liftProtocol.getPakMk()
&& liftProtocol.getTaskNo() != 0) {
//杩樻湁鏈畬鎴愮殑鍛戒护
@@ -273,6 +275,14 @@
array[29] = command.getLiftLockShortValue();
}
+ if (array[2] == 0) {
+ // 寮�濮嬩换鍔�
+ short[] tmp = new short[2];
+ tmp[0] = array[0];
+ tmp[1] = array[1];
+ array = tmp;
+ }
+
OperateResult result = modbusTcpNet.Write("41088", array);;
if (result != null && result.IsSuccess) {
News.info("鎻愬崌鏈哄懡浠や笅鍙慬id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
@@ -362,12 +372,33 @@
//鍙栧嚭鍛戒护
LiftCommand command = commands.get(commandStep);
+ if (command.getOperaStaNo() != null && command.getDevpId() != null) {
+ //绔欑偣鍜岃緭閫佺嚎ID涓嶄负null锛岄渶瑕佷笅鍙戠珯鐐规寚浠よ皟搴︽寚瀹氱珯鐐硅繘琛岄摼鏉¤浆鍔�
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, command.getDevpId());
+ StaProtocol staProtocol = devpThread.getStation().get(command.getOperaStaNo().intValue());
+ if (!staProtocol.isLiftArrival()) {//閾炬潯杞姩鏉′欢锛岄渶瑕佹湁鎻愬崌鏈哄埌浣嶄俊鍙�
+ liftProtocol.setPakMk(true);
+ return false;
+ }
+ staProtocol.setWorkNo(wrkNo);//璁剧疆浠诲姟鍙�
+ if (command.getStaNo() != null) {
+ staProtocol.setStaNo(command.getStaNo());//璁剧疆鐩爣绔�
+ }
+
+ if (command.getRotationDire() != null) {
+ staProtocol.setRotationDire(command.getRotationDire());//绔欑偣閾炬潯杞姩淇″彿
+ }
+ Integer devpId = command.getDevpId();
+ boolean result1 = MessageQueue.offer(SlaveType.Devp, devpId, new Task(3, staProtocol));//涓嬪彂鍛戒护浣胯緭閫佺嚎閾炬潯杩愯浆
+ }
+
//涓嬪彂鍛戒护
if (!write(command)) {
News.error("鎻愬崌鏈哄懡浠や笅鍙戝け璐ワ紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command));
return false;
}else {
News.info("鎻愬崌鏈哄懡浠や笅鍙戞垚鍔燂紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command));
+ liftProtocol.setWrkTime(new Date());//鏇存柊宸ヤ綔鏃堕棿
//鍒ゆ柇鏁版嵁鏄惁鎵ц瀹屾垚
if (commandStep < size - 1) {
@@ -396,19 +427,9 @@
//鍒犻櫎redis
redisUtil.del("lift_wrk_no_" + redisCommand.getWrkNo());
- if (assignCommand.getAuto()) {
- //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting
- liftProtocol.setProtocolStatus(LiftProtocolStatusType.WAITING);
- News.info("鎻愬崌鏈轰换鍔℃墽琛屽畬鎴愮瓑寰呯‘璁や腑锛屾彁鍗囨満鍙�={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command));
- }else {
- //鎵嬪姩妯″紡涓嶆姏鍑虹瓑寰呯姸鎬�
- liftProtocol.setTaskNo((short) 0);
- liftProtocol.setShuttleNo((short) 0);
- liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE);
- liftProtocol.setPakMk(true);
- liftProtocol.setSecurityMk(false);
- News.info("鎻愬崌鏈烘墜鍔ㄤ换鍔℃墽琛屽畬鎴愶紝鎻愬崌鏈哄彿={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command));
- }
+ //瀵逛富绾跨▼鎶涘嚭绛夊緟纭鐘舵�亀aiting
+ liftProtocol.setProtocolStatus(LiftProtocolStatusType.WAITING);
+ News.info("鎻愬崌鏈轰换鍔℃墽琛屽畬鎴愮瓑寰呯‘璁や腑锛屾彁鍗囨満鍙�={}锛屼换鍔℃暟鎹�={}", command.getLiftNo(), JSON.toJSON(command));
}
}
@@ -443,44 +464,31 @@
public LiftCommand getLiftUpDownCommand(Integer lev) {
LiftCommand command = new LiftCommand();
command.setRun((short) 1);//鍗囬檷
- Short position = 1;
- switch (lev) {
- case 1:
- position = 1;
- break;
- case 2:
- position = 2;
- break;
- case 3:
- position = 4;
- break;
- case 4:
- position = 8;
- break;
- case 5:
- position = 16;
- break;
- default:
- position = 1;
- }
+ Short position = LiftLevType.getRealLev(lev);//鑾峰彇鎻愬崌鏈哄疄闄呮ゼ灞傛暟鍊�
command.setDistPosition(position);
- command.setSpeed((short) 200);
- command.setHeight2((short) 180);
- command.setHeight3((short) 1645);
- command.setHeight4((short) (2 * 1645));
- command.setHeight5((short) (3 * 1645));
+// command.setSpeed((short) 200);
+// command.setHeight2((short) 180);
+// command.setHeight3((short) 1645);
+// command.setHeight4((short) (2 * 1645));
+// command.setHeight5((short) (3 * 1645));
return command;
}
/**
* 鑾峰彇鎻愬崌鏈轰笂鍗囦笅闄嶅懡浠�
*/
- public LiftCommand getLiftUpDownCommand(Short liftNo, Short taskNo, Short lev) {
+ public LiftCommand getLiftUpDownCommand(Short liftNo, Short taskNo, Integer lev) {
LiftCommand command = new LiftCommand();
+ Short position = LiftLevType.getRealLev(lev);//鑾峰彇鎻愬崌鏈哄疄闄呮ゼ灞傛暟鍊�
command.setRun((short) 1);//鍗囬檷
command.setLiftNo(liftNo);//鎻愬崌鏈哄彿
command.setTaskNo(taskNo);//浠诲姟鍙�
- command.setDistPosition(lev);//鐩爣妤煎眰1灞�
+ command.setDistPosition(position);//鐩爣妤煎眰
+// command.setSpeed((short) 200);
+// command.setHeight2((short) 180);
+// command.setHeight3((short) 1645);
+// command.setHeight4((short) 3290);
+// command.setHeight5((short) 4945);
return command;
}
--
Gitblit v1.9.1