From 449e4e9df08162b1e7e04ac0d4e05a1387298171 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期二, 08 七月 2025 16:48:16 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/impl/ZyForkLiftThread.java | 93 ++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 84 insertions(+), 9 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/impl/ZyForkLiftThread.java b/src/main/java/com/zy/core/thread/impl/ZyForkLiftThread.java
index f48bd4d..e795ce3 100644
--- a/src/main/java/com/zy/core/thread/impl/ZyForkLiftThread.java
+++ b/src/main/java/com/zy/core/thread/impl/ZyForkLiftThread.java
@@ -19,6 +19,7 @@
import com.zy.core.action.ForkLiftAction;
import com.zy.core.action.ShuttleAction;
import com.zy.core.cache.OutputQueue;
+import com.zy.core.enums.ForkLiftIoModeType;
import com.zy.core.enums.ForkLiftProtocolStatusType;
import com.zy.core.enums.ForkLiftTaskModeType;
import com.zy.core.enums.RedisKeyType;
@@ -170,6 +171,21 @@
OutputQueue.FORKLIFT.offer(MessageFormat.format("銆恵0}銆憑1}璇诲彇璐у弶鎻愬崌鏈虹姸鎬佷俊鎭け璐�", DateUtils.convert(new Date()), slave.getId()));
}
+ OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB102.0", (short) 8);
+ if (result2.IsSuccess) {
+ for (int i = 0; i < this.slave.getSta().size(); i++) {
+ ForkLiftSlave.Sta sta = this.slave.getSta().get(i);
+ if (forkLiftStaProtocols.isEmpty()) {
+ continue;
+ }
+
+ ForkLiftStaProtocol forkLiftStaProtocol = forkLiftStaProtocols.get(i);
+ boolean[] status1 = siemensS7Net.getByteTransform().TransBool(result2.Content, i * 2, 2);
+ forkLiftStaProtocol.setHasTray(status1[0]);
+ forkLiftStaProtocol.setHasCar(status1[1]);
+ }
+ }
+
if (System.currentTimeMillis() - forkLiftProtocol.getDeviceDataLog() > 1000 * 5) {
//閲囬泦鏃堕棿瓒呰繃5s锛屼繚瀛樹竴娆℃暟鎹褰�
//淇濆瓨鏁版嵁璁板綍
@@ -241,7 +257,7 @@
array[3] = command.getPut();//鏀捐揣鏁版嵁
OperateResult result = siemensS7Net.Write("DB103.0", array);
if (result.IsSuccess) {
- OperateResult result2 = siemensS7Net.Write("DB103.16", command.getConfirm());
+ OperateResult result2 = siemensS7Net.Write("DB103.8", command.getConfirm());
if (result2.IsSuccess) {
response.setResult(true);
}
@@ -269,10 +285,30 @@
}
@Override
+ public CommandResponse move(ForkLiftCommand command) {
+ CommandResponse response = new CommandResponse(false);
+
+ short[] array = new short[4];
+ array[0] = command.getTaskNo();//浠诲姟鍙�
+ array[1] = command.getMode();//浠诲姟妯″紡
+ array[2] = command.getPick();//鍙栬揣鏁版嵁
+ array[3] = command.getPut();//鏀捐揣鏁版嵁
+ OperateResult result = siemensS7Net.Write("DB103.0", array);
+ if (result.IsSuccess) {
+ OperateResult result2 = siemensS7Net.Write("DB103.8", command.getConfirm());
+ if (result2.IsSuccess) {
+ response.setResult(true);
+ }
+ }
+ return response;
+ }
+
+ @Override
public CommandResponse reset() {
CommandResponse response = new CommandResponse(false);
- OperateResult result = siemensS7Net.Write("DB103.20", (short) 1);
+ OperateResult result = siemensS7Net.Write("DB103.10", (short) 1);
if (result.IsSuccess) {
+ News.info("璐у弶鎻愬崌鏈虹‘璁ゅ懡浠や笅鍙戞垚鍔燂紝鎻愬崌鏈哄彿={}", forkLiftProtocol.getLiftNo());
response.setResult(true);
}
return response;
@@ -283,6 +319,7 @@
if (this.forkLiftProtocol.getTaskNo() == null
|| this.forkLiftProtocol.getProtocolStatus() == null
|| this.forkLiftProtocol.getModel() == null
+ || this.forkLiftProtocol.getErrorCode() == null
) {
return false;
}
@@ -290,7 +327,9 @@
boolean res = this.forkLiftProtocol.getProtocolStatus() == ForkLiftProtocolStatusType.IDLE.id
&& this.forkLiftProtocol.getWrkNo() == 0
&& this.forkLiftProtocol.getTaskNo() == 0
- && this.forkLiftProtocol.getModel() == 2;
+ && this.forkLiftProtocol.getModel() == 2
+ && this.forkLiftProtocol.getErrorCode() == 0
+ ;
return res;
}
@@ -311,13 +350,16 @@
if (this.forkLiftProtocol.getTaskNo() == null
|| this.forkLiftProtocol.getProtocolStatus() == null
|| this.forkLiftProtocol.getModel() == null
+ || this.forkLiftProtocol.getErrorCode() == null
) {
return false;
}
boolean res = this.forkLiftProtocol.getProtocolStatus() == ForkLiftProtocolStatusType.IDLE.id
&& this.forkLiftProtocol.getWrkNo() == 0
- && this.forkLiftProtocol.getModel() == 2;
+ && this.forkLiftProtocol.getModel() == 2
+ && this.forkLiftProtocol.getErrorCode() == 0
+ ;
return res;
}
@@ -333,19 +375,31 @@
}
@Override
+ public boolean switchIOMode(ForkLiftIoModeType type) {
+ OperateResult result = siemensS7Net.Write("DB103.12", type.id.shortValue());
+ if (result.IsSuccess) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
public int generateDeviceTaskNo(int taskNo, ForkLiftTaskModeType type) {
return taskNo;
}
@Override
public List<ForkLiftCommand> getPickAndPutCommand(Integer taskNo, Integer pick, Integer put) {
+ Integer realPick = pick % 1000;
+ Integer realPut = put % 1000;
+
List<ForkLiftCommand> commands = new ArrayList<>();
ForkLiftCommand command = new ForkLiftCommand();
command.setLiftNo(slave.getId());
command.setTaskNo(taskNo.shortValue());
command.setMode(ForkLiftTaskModeType.PICK_PUT.id.shortValue());
- command.setPick(pick.shortValue());
- command.setPut(put.shortValue());
+ command.setPick(realPick.shortValue());
+ command.setPut(realPut.shortValue());
command.setConfirm((short) 1);
commands.add(command);
@@ -353,14 +407,35 @@
}
@Override
- public List<ForkLiftCommand> getShuttleSwitchCommand(Integer taskNo, Integer originLev, Integer targetLev) {
+ public List<ForkLiftCommand> getShuttleSwitchCommand(Integer taskNo, Integer pick, Integer put) {
+ Integer realPick = pick % 1000;
+ Integer realPut = put % 1000;
+
List<ForkLiftCommand> commands = new ArrayList<>();
ForkLiftCommand command = new ForkLiftCommand();
command.setLiftNo(slave.getId());
command.setTaskNo(taskNo.shortValue());
command.setMode(ForkLiftTaskModeType.SHUTTLE_SWITCH.id.shortValue());
- command.setPick(originLev.shortValue());
- command.setPut(targetLev.shortValue());
+ command.setPick(realPick.shortValue());
+ command.setPut(realPut.shortValue());
+ command.setConfirm((short) 1);
+
+ commands.add(command);
+ return commands;
+ }
+
+ @Override
+ public List<ForkLiftCommand> getMoveCommand(Integer taskNo, Integer pick, Integer put) {
+ Integer realPick = pick % 1000;
+ Integer realPut = put % 1000;
+
+ List<ForkLiftCommand> commands = new ArrayList<>();
+ ForkLiftCommand command = new ForkLiftCommand();
+ command.setLiftNo(slave.getId());
+ command.setTaskNo(taskNo.shortValue());
+ command.setMode(ForkLiftTaskModeType.MOVE.id.shortValue());
+ command.setPick(realPick.shortValue());
+ command.setPut(realPut.shortValue());
command.setConfirm((short) 1);
commands.add(command);
--
Gitblit v1.9.1