From c4bf4428c1204763e585fe19af65cfb0c24b16af Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期日, 13 七月 2025 19:41:32 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/impl/LfdZyForkLiftMasterThread.java | 42 ++++++++++++++++++++----------------------
1 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/impl/LfdZyForkLiftMasterThread.java b/src/main/java/com/zy/core/thread/impl/LfdZyForkLiftMasterThread.java
index c94ebb5..46353b4 100644
--- a/src/main/java/com/zy/core/thread/impl/LfdZyForkLiftMasterThread.java
+++ b/src/main/java/com/zy/core/thread/impl/LfdZyForkLiftMasterThread.java
@@ -4,13 +4,12 @@
import HslCommunication.Core.Types.OperateResultExOne;
import HslCommunication.Profinet.Siemens.SiemensPLCS;
import HslCommunication.Profinet.Siemens.SiemensS7Net;
-import com.core.common.DateUtils;
+import com.zy.common.utils.DateUtils;
import com.zy.common.utils.RedisUtil;
import com.zy.core.News;
import com.zy.core.ThreadHandler;
import com.zy.core.cache.OutputQueue;
-import com.zy.core.model.ForkLiftSlave;
-import com.zy.core.model.protocol.ForkLiftProtocol;
+import com.zy.core.properties.DeviceConfig;
import lombok.extern.slf4j.Slf4j;
import java.text.MessageFormat;
@@ -23,20 +22,19 @@
@SuppressWarnings("all")
public class LfdZyForkLiftMasterThread implements ThreadHandler {
- private ForkLiftSlave slave;
- private ForkLiftProtocol forkLiftProtocol;
+ private DeviceConfig deviceConfig;
private RedisUtil redisUtil;
private SiemensS7Net siemensS7Net;
private List<HashMap<String,Object>> slaveAddressList = null;
private boolean connect = false;
- public LfdZyForkLiftMasterThread(ForkLiftSlave slave, RedisUtil redisUtil) {
- this.slave = slave;
+ public LfdZyForkLiftMasterThread(DeviceConfig deviceConfig, RedisUtil redisUtil) {
+ this.deviceConfig = deviceConfig;
this.redisUtil = redisUtil;
ArrayList<HashMap<String, Object>> addressList = new ArrayList<>();
HashMap<String, Object> lift1 = new HashMap<>();
- lift1.put("status", new DbData("DB101.0", (short) 16));//鎻愬崌鏈烘暟鎹�
+ lift1.put("status", new DbData("DB101.0", (short) 18));//鎻愬崌鏈烘暟鎹�
lift1.put("staStatusTray", new DbData("DB102.0", (short) 14));//绔欑偣鏁版嵁
lift1.put("staStatusCar", new DbData("DB102.50", (short) 14));//绔欑偣鏁版嵁
lift1.put("write", new DbData("DB103.0", null));//鍐欏叆鏁版嵁
@@ -45,9 +43,9 @@
lift1.put("switchIOMode", new DbData("DB103.12", null));//鍑哄叆搴撴ā寮�
HashMap<String, Object> lift2 = new HashMap<>();
- lift2.put("status", new DbData("DB104.0", (short) 16));//鎻愬崌鏈烘暟鎹�
- lift1.put("staStatusTray", new DbData("DB105.0", (short) 14));//绔欑偣鏁版嵁
- lift1.put("staStatusCar", new DbData("DB105.50", (short) 14));//绔欑偣鏁版嵁
+ lift2.put("status", new DbData("DB104.0", (short) 18));//鎻愬崌鏈烘暟鎹�
+ lift2.put("staStatusTray", new DbData("DB105.0", (short) 14));//绔欑偣鏁版嵁
+ lift2.put("staStatusCar", new DbData("DB105.50", (short) 14));//绔欑偣鏁版嵁
lift2.put("write", new DbData("DB106.0", null));//鍐欏叆鏁版嵁
lift2.put("writeConfirm", new DbData("DB106.8", null));//鍐欏叆纭鏁版嵁
lift2.put("confirm", new DbData("DB106.10", null));//纭鍛戒护
@@ -61,17 +59,17 @@
@Override
public boolean connect() {
boolean result = false;
- siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200, slave.getIp());
- siemensS7Net.setRack(slave.getRack().byteValue());
- siemensS7Net.setSlot(slave.getSlot().byteValue());
+ siemensS7Net = new SiemensS7Net(SiemensPLCS.S1200, deviceConfig.getIp());
+ siemensS7Net.setRack(Integer.valueOf(0).byteValue());
+ siemensS7Net.setSlot(Integer.valueOf(0).byteValue());
OperateResult connect = siemensS7Net.ConnectServer();
if(connect.IsSuccess){
result = true;
- OutputQueue.FORKLIFT.offer(MessageFormat.format( "銆恵0}銆戣揣鍙夋彁鍗囨満杩炴帴鎴愬姛 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
- News.info("璐у弶鎻愬崌鏈鸿繛鎺ユ垚鍔� ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
+ OutputQueue.FORKLIFT.offer(MessageFormat.format( "銆恵0}銆戣揣鍙夋彁鍗囨満杩炴帴鎴愬姛 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort(), 0, 0));
+ News.info("璐у弶鎻愬崌鏈鸿繛鎺ユ垚鍔� ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
} else {
- OutputQueue.FORKLIFT.offer(MessageFormat.format( "銆恵0}銆戣揣鍙夋彁鍗囨満杩炴帴澶辫触锛侊紒锛� ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
- News.error("璐у弶鎻愬崌鏈鸿繛鎺ュけ璐ワ紒锛侊紒 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
+ OutputQueue.FORKLIFT.offer(MessageFormat.format( "銆恵0}銆戣揣鍙夋彁鍗囨満杩炴帴澶辫触锛侊紒锛� ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort(), 0, 0));
+ News.error("璐у弶鎻愬崌鏈鸿繛鎺ュけ璐ワ紒锛侊紒 ===>> [id:{}] [ip:{}] [port:{}]", deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort());
}
// siemensS7Net.ConnectClose();
this.connect = result;
@@ -85,7 +83,7 @@
@Override
public void run() {
- News.info("{}鍙疯揣鍙夋彁鍗囨満Master绾跨▼鍚姩", slave.getId());
+ News.info("{}鍙疯揣鍙夋彁鍗囨満Master绾跨▼鍚姩", deviceConfig.getDeviceNo());
this.connect();
while (true) {
try {
@@ -111,7 +109,7 @@
OperateResultExOne<byte[]> result = siemensS7Net.Read(dbData.dbAddress, dbData.dbAddressLength);
return result;
} catch (Exception e) {
- OutputQueue.FORKLIFT.offer(MessageFormat.format("銆恵0}銆戣鍙栨彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
+ OutputQueue.FORKLIFT.offer(MessageFormat.format("銆恵0}銆戣鍙栨彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()));
}
return null;
}
@@ -123,7 +121,7 @@
OperateResult result = siemensS7Net.Write(dbData.dbAddress, array);
return result;
} catch (Exception e) {
- OutputQueue.FORKLIFT.offer(MessageFormat.format("銆恵0}銆戝啓鍏ユ彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
+ OutputQueue.FORKLIFT.offer(MessageFormat.format("銆恵0}銆戝啓鍏ユ彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()));
}
return null;
}
@@ -135,7 +133,7 @@
OperateResult result = siemensS7Net.Write(dbData.dbAddress, val);
return result;
} catch (Exception e) {
- OutputQueue.FORKLIFT.offer(MessageFormat.format("銆恵0}銆戝啓鍏ユ彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
+ OutputQueue.FORKLIFT.offer(MessageFormat.format("銆恵0}銆戝啓鍏ユ彁鍗囨満鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), deviceConfig.getDeviceNo(), deviceConfig.getIp(), deviceConfig.getPort()));
}
return null;
}
--
Gitblit v1.9.1