From 9344a225856b767c2b9be543993707dc635523d9 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 24 十二月 2020 09:35:17 +0800
Subject: [PATCH] #newVersion
---
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 49 +++++--------------------------------------------
1 files changed, 5 insertions(+), 44 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/DevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
similarity index 82%
rename from src/main/java/com/zy/core/thread/DevpThread.java
rename to src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 90d5837..aaef15b 100644
--- a/src/main/java/com/zy/core/thread/DevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -9,7 +9,7 @@
import com.core.common.SpringUtils;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.service.BasDevpService;
-import com.zy.core.ThreadHandler;
+import com.zy.core.DevpThread;
import com.zy.core.cache.MessageQueue;
import com.zy.core.cache.OutputQueue;
import com.zy.core.enums.SlaveType;
@@ -32,14 +32,14 @@
*/
@Data
@Slf4j
-public class DevpThread implements Runnable, ThreadHandler {
+public class SiemensDevpThread implements Runnable, DevpThread {
private DevpSlave slave;
private SiemensS7Net siemensS7Net;
private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
private short heartBeatVal = 1;
- public DevpThread(DevpSlave slave) {
+ public SiemensDevpThread(DevpSlave slave) {
this.slave = slave;
}
@@ -62,14 +62,6 @@
// 鍐欐暟鎹� ID+鐩爣绔�
case 2:
write((StaProtocol)task.getData());
- break;
- // 鍐欐暟鎹� ID
- case 3:
- writeId((StaProtocol)task.getData());
- break;
- // 鍐欐暟鎹� 鐩爣绔�
- case 4:
- writeStaNo((StaProtocol)task.getData());
break;
default:
break;
@@ -205,38 +197,6 @@
}
/**
- * 鍐欏叆 ID =====> 鍗曠珯鐐瑰啓鍏�
- */
- private void writeId(StaProtocol staProtocol){
- if (null == staProtocol) {
- return;
- }
- OperateResult write = siemensS7Net.Write("DB100." + (staProtocol.getSiteId() - 1) * 2, staProtocol.getWorkNo()); // 宸ヤ綔鍙�
- if (!write.IsSuccess ) {
- OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2}", slave.getId(), JSON.toJSON(staProtocol)));
- log.error("鍐欏叆杈撻�佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol));
- } else {
- OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
- }
- }
-
- /**
- * 鍐欏叆 鐩爣绔� =====> 鍗曠珯鐐瑰啓鍏�
- */
- private void writeStaNo(StaProtocol staProtocol){
- if (null == staProtocol) {
- return;
- }
- OperateResult write = siemensS7Net.Write("DB100." + ((staProtocol.getSiteId() - 1) * 2 + 20), staProtocol.getStaNo()); // 鐩爣绔�
- if (!write.IsSuccess ) {
- OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={1}锛岀珯鐐规暟鎹�={2}", slave.getId(), JSON.toJSON(staProtocol)));
- log.error("鍐欏叆杈撻�佺嚎绔欑偣鏁版嵁澶辫触銆傝緭閫佺嚎plc缂栧彿={}锛岀珯鐐规暟鎹�={}", slave.getId(), JSON.toJSON(staProtocol));
- } else {
- OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
- }
- }
-
- /**
* 蹇冭烦
*/
private void heartbeat(){
@@ -254,6 +214,7 @@
/**
* 璁剧疆鍏ュ簱鏍囪
*/
+ @Override
public void setPakMk(Integer siteId, boolean pakMk) {
StaProtocol staProtocol = station.get(siteId);
if (null != staProtocol) {
@@ -269,7 +230,7 @@
public static void main(String[] args) throws Exception {
DevpSlave slave = new DevpSlave();
slave.setIp("192.168.2.125");
- DevpThread devpThread = new DevpThread(slave);
+ SiemensDevpThread devpThread = new SiemensDevpThread(slave);
devpThread.connect();
devpThread.read();
// 鍐�
--
Gitblit v1.9.1