From 24b27647f24c5dde68fb3df5214b79795665ca3d Mon Sep 17 00:00:00 2001
From: whycq <10027870+whycq@user.noreply.gitee.com>
Date: 星期四, 20 四月 2023 13:47:54 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 79 ++++++++++++++++++++-------------------
1 files changed, 41 insertions(+), 38 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 8f384df..1757937 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -55,7 +55,7 @@
/**
* 鏉$爜鏁伴噺
*/
- private int barcodeSize = 8;
+ private int barcodeSize = 6;
/**
* 鍏ュ嚭搴撴ā寮�
@@ -162,30 +162,30 @@
}
staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*2)); // 宸ヤ綔鍙�
- staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*2)); // 鐩爣绔�
+// staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*2)); // 鐩爣绔�
}
}
-// Thread.sleep(200);
-// OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) 186);
-// if (result0.IsSuccess) {
-// for (int i = 0; i < 93; i++) {
-// Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
-// StaProtocol staProtocol = station.get(siteId);
-// if (null == staProtocol) {
-// staProtocol = new StaProtocol();
-// staProtocol.setSiteId(siteId);
-// station.put(siteId, staProtocol);
-// }
-// staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result0.Content, i*2)); // 鐩爣绔�
-// }
-// }
+ Thread.sleep(200);
+ OperateResultExOne<byte[]> result0 = siemensS7Net.Read("DB101.0", (short) (staNoSize*2));
+ if (result0.IsSuccess) {
+ for (int i = 0; i < staNoSize; i++) {
+ Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
+ StaProtocol staProtocol = station.get(siteId);
+ if (null == staProtocol) {
+ staProtocol = new StaProtocol();
+ staProtocol.setSiteId(siteId);
+ station.put(siteId, staProtocol);
+ }
+ staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result0.Content, i*2)); // 鐩爣绔�
+ }
+ }
Thread.sleep(200);
OperateResultExOne<byte[]> result1 = null;
result1 = siemensS7Net.Read("DB102.100", (short) (staNoSize * 2));
if (result1.IsSuccess) {
for (int i = 0; i < staNoSize; i++) {
Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*2, 1);
+ boolean[] status = siemensS7Net.getByteTransform().TransBool(result1.Content, i*2, 2);
StaProtocol staProtocol = station.get(siteId);
staProtocol.setAutoing(status[0]); // 鑷姩
staProtocol.setLoading(status[1]); // 鏈夌墿
@@ -193,8 +193,9 @@
staProtocol.setOutEnable(status[3]);// 鍙嚭
staProtocol.setEmptyMk(status[4]); // 绌烘澘淇″彿
staProtocol.setFullPlt(status[5]); // 婊℃墭鐩�
- staProtocol.setHigh(status[6]); // 楂樺簱浣�
- staProtocol.setLow(status[7]); // 浣庡簱浣�
+ staProtocol.setHigh(status[6]); // 楂樺簱浣� 鎹蜂赴澶ф墭鐩�
+ staProtocol.setLow(status[7]); // 浣庡簱浣� 鎹蜂赴灏忔墭鐩�
+ staProtocol.setFull(status[8]); // 鎵樼洏鏄彲鍚︽暣鍨�
if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
staProtocol.setPakMk(true);
@@ -202,19 +203,21 @@
}
}
- //鏉$爜鎵弿鍣�
- //Thread.sleep(200);
- //OperateResultExOne<byte[]> result2 = null;
- //result2 = siemensS7Net.Read("DB100.200",(short)(barcodeSize*16));
- //if (result2.IsSuccess) {
- // for (int i = 0; i < barcodeSize; i++) {
- // String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*16,8, "UTF-8");
- // BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, slave.getId() == 1 ? i + 1 : i + 3);
- // if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
- // barcodeThread.setBarcode(barcode);
- // }
- // }
- //}
+// 鏉$爜鎵弿鍣�
+ if(slave.getId() == 2) {
+ Thread.sleep(200);
+ OperateResultExOne<byte[]> result2 = null;
+ result2 = siemensS7Net.Read("DB100.200", (short) (barcodeSize * 16));
+ if (result2.IsSuccess) {
+ for (int i = 0; i < barcodeSize; i++) {
+ String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 16, 8, "UTF-8");
+ BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1);
+ if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
+ barcodeThread.setBarcode(barcode);
+ }
+ }
+ }
+ }
// //RGV灏忚溅
// Thread.sleep(200);
@@ -307,37 +310,37 @@
}
if (slave.getId() == 2 && this.ioModeOf1F3 != IoModeType.NONE) {
if (!siemensS7Net.Write("DB100.300", this.ioModeOf1F3.id).IsSuccess) {
- OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎1F3鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={1}", slave.getId()));
+ OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎1F3鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={2}", slave.getId()));
log.error("鍐欏叆杈撻�佺嚎1F3鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={}", slave.getId());
}
}
if (slave.getId() == 2 && this.ioModeOf1F4 != IoModeType.NONE) {
if (!siemensS7Net.Write("DB100.302", this.ioModeOf1F4.id).IsSuccess) {
- OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎1F4鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={1}", slave.getId()));
+ OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎1F4鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={2}", slave.getId()));
log.error("鍐欏叆杈撻�佺嚎1F4鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={}", slave.getId());
}
}
if (slave.getId() == 2 && this.ioModeOf2F1 != IoModeType.NONE) {
if (!siemensS7Net.Write("DB100.304", this.ioModeOf2F1.id).IsSuccess) {
- OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎2F1鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={1}", slave.getId()));
+ OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎2F1鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={2}", slave.getId()));
log.error("鍐欏叆杈撻�佺嚎2F1鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={}", slave.getId());
}
}
if (slave.getId() == 2 && this.ioModeOf2F2 != IoModeType.NONE) {
if (!siemensS7Net.Write("DB100.306", this.ioModeOf2F2.id).IsSuccess) {
- OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎2F2鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={1}", slave.getId()));
+ OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎2F2鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={2}", slave.getId()));
log.error("鍐欏叆杈撻�佺嚎2F2鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={}", slave.getId());
}
}
if (slave.getId() == 2 && this.ioModeOf3F1 != IoModeType.NONE) {
if (!siemensS7Net.Write("DB100.308", this.ioModeOf3F1.id).IsSuccess) {
- OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎3F1鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={1}", slave.getId()));
+ OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎3F1鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={2}", slave.getId()));
log.error("鍐欏叆杈撻�佺嚎3F1鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={}", slave.getId());
}
}
if (slave.getId() == 2 && this.ioModeOf3F2 != IoModeType.NONE) {
if (!siemensS7Net.Write("DB100.310", this.ioModeOf3F2.id).IsSuccess) {
- OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎3F2鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={1}", slave.getId()));
+ OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆戝啓鍏ヨ緭閫佺嚎3F2鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={2}", slave.getId()));
log.error("鍐欏叆杈撻�佺嚎3F2鍏ュ嚭搴撴ā寮忓け璐ャ�傝緭閫佺嚎plc缂栧彿={}", slave.getId());
}
}
--
Gitblit v1.9.1