From 52b286bff3895b8490f365d77584f1458ab1564e Mon Sep 17 00:00:00 2001
From: whycq <123456>
Date: 星期二, 30 一月 2024 09:50:48 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 194 ++++++++---------------------------------------
1 files changed, 35 insertions(+), 159 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index f1118d8..d92ca90b 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -48,10 +48,9 @@
private Map<Integer, StaProtocol> station = new ConcurrentHashMap<>();
private short heartBeatVal = 1;
public static final ArrayList<Integer> staNos1 = new ArrayList<Integer>() {{
- add(100);add(101);add(102);add(103);add(104);add(105);add(106);add(107);add(108);add(109);add(110);add(111);
- add(112);add(113);add(114);add(115);add(116);add(117);add(118);add(119);add(120);add(121);add(122);add(123);
+ add(100);add(101);add(102);add(103);add(104);add(105);add(106);add(107);
}};
- public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
+ /*public static final ArrayList<Integer> staNos2 = new ArrayList<Integer>() {{
add(200);add(201);add(202);add(203);
add(204);add(205);add(206);add(207);
add(208);add(209);add(210);add(211);
@@ -69,7 +68,7 @@
public static final ArrayList<Integer> staNos4 = new ArrayList<Integer>() {{
add(400);add(401);add(402);add(403);
add(404);add(405);add(406);add(407);
- }};
+ }};*/
/**
* 鏉$爜鏁伴噺
@@ -90,12 +89,12 @@
switch (slave.getId()) {
case 1:
return staNos1;
- case 2:
+ /*case 2:
return staNos2;
case 3:
return staNos3;
case 4:
- return staNos4;
+ return staNos4;*/
default:
throw new CoolException("鏈嶅姟鍣ㄥ紓甯�");
}
@@ -126,10 +125,10 @@
write((StaProtocol)task.getData());
read();
break;
- case 3:
+ /* case 3:
write2((StaProtocol)task.getData());
read();
- break;
+ break;*/
default:
break;
}
@@ -200,7 +199,7 @@
// updateIoMode();
ArrayList<Integer> staNos = getStaNo();
int staNoSize = staNos.size();
- OperateResultExOne<byte[]> result = siemensS7Net.Read("DB100.0", (short) (staNoSize*4));
+ OperateResultExOne<byte[]> result = siemensS7Net.Read("DB101.0", (short) (staNoSize*8));
if (result.IsSuccess) {
for (int i = 0; i < staNoSize; i++) {
Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
@@ -210,26 +209,18 @@
staProtocol.setSiteId(siteId);
station.put(siteId, staProtocol);
}
- staProtocol.setWorkNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4)); // 宸ヤ綔鍙�
+ staProtocol.setWorkNo((short)siemensS7Net.getByteTransform().TransInt32(result.Content, i*8)); // 宸ヤ綔鍙�
- staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*4 + 2)); // 鐩爣绔�
- }
- }
+ staProtocol.setStaNo(siemensS7Net.getByteTransform().TransInt16(result.Content, i*8 + 4)); // 鐩爣绔�
- //Thread.sleep(200);
- OperateResultExOne<byte[]> result1 = siemensS7Net.Read("DB101.0", (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);
- StaProtocol staProtocol = station.get(siteId);
+ boolean[] status = siemensS7Net.getByteTransform().TransBool(result.Content, i*8 + 6, 2);
staProtocol.setAutoing(status[0]); // 鑷姩
staProtocol.setLoading(status[1]); // 鏈夌墿
staProtocol.setInEnable(status[2]); // 鍙叆
staProtocol.setOutEnable(status[3]);// 鍙嚭
staProtocol.setEmptyMk(status[4]); // 绌烘澘淇″彿
staProtocol.setFullPlt(status[5]); // 婊℃墭鐩�
- staProtocol.setCar(status[6]); // 鏄惁鏈夎溅
+ staProtocol.setHigh(status[6]); // 楂樺簱浣�
staProtocol.setLow(status[7]); // 浣庡簱浣�
if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
@@ -239,155 +230,40 @@
}
- if (slave.getId() == 1){
+ if (slave.getId() == 1) {
//鏉$爜
//Thread.sleep(200);
- OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.102",(short)60);
+ OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840.0", (short) 60);
if (result2.IsSuccess) {
- for (int i = 0; i < 6; i++) {
- String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*10,8, "UTF-8");
+ for (int i = 0; i < 4; i++) {
+ String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 10, 8, "UTF-8");
BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1);
- if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
+ if (!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
barcodeThread.setBarcode(barcode);
}
}
}
- // 澶栧舰妫�娴� - 102
- //Thread.sleep(100);
- OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB101.160", (short)1);
- if (result4.IsSuccess) {
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result4.Content, 0, 1);
- StaProtocol staProtocol = station.get(103);
- staProtocol.setFrontErr(status[0]);
- staProtocol.setBackErr(status[1]);
- staProtocol.setHighErr(status[2]);
- staProtocol.setLeftErr(status[3]);
- staProtocol.setRightErr(status[4]);
- staProtocol.setWeightErr(status[5]);
- staProtocol.setBarcodeErr(status[6]);
- }
- // 澶栧舰妫�娴� - 107
- //Thread.sleep(50);
- OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB101.164", (short)1);
- if (result5.IsSuccess) {
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result5.Content, 0, 1);
- StaProtocol staProtocol = station.get(107);
- staProtocol.setFrontErr(status[0]);
- staProtocol.setBackErr(status[1]);
- staProtocol.setHighErr(status[2]);
- staProtocol.setLeftErr(status[3]);
- staProtocol.setRightErr(status[4]);
- staProtocol.setWeightErr(status[5]);
- staProtocol.setBarcodeErr(status[6]);
- }
- // 澶栧舰妫�娴� - 111
- //Thread.sleep(50);
- OperateResultExOne<byte[]> result6 = siemensS7Net.Read("DB101.168", (short)1);
- if (result6.IsSuccess) {
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result6.Content, 0, 1);
- StaProtocol staProtocol = station.get(111);
- staProtocol.setFrontErr(status[0]);
- staProtocol.setBackErr(status[1]);
- staProtocol.setHighErr(status[2]);
- staProtocol.setLeftErr(status[3]);
- staProtocol.setRightErr(status[4]);
- staProtocol.setWeightErr(status[5]);
- staProtocol.setBarcodeErr(status[6]);
- }
- // 澶栧舰妫�娴� - 115
- //Thread.sleep(50);
- OperateResultExOne<byte[]> result7 = siemensS7Net.Read("DB101.172", (short)1);
- if (result7.IsSuccess) {
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result7.Content, 0, 1);
- StaProtocol staProtocol = station.get(115);
- staProtocol.setFrontErr(status[0]);
- staProtocol.setBackErr(status[1]);
- staProtocol.setHighErr(status[2]);
- staProtocol.setLeftErr(status[3]);
- staProtocol.setRightErr(status[4]);
- staProtocol.setWeightErr(status[5]);
- staProtocol.setBarcodeErr(status[6]);
- }
- // 澶栧舰妫�娴� - 119
- //Thread.sleep(50);
- OperateResultExOne<byte[]> result8 = siemensS7Net.Read("DB101.176", (short)1);
- if (result8.IsSuccess) {
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result8.Content, 0, 1);
- StaProtocol staProtocol = station.get(119);
- staProtocol.setFrontErr(status[0]);
- staProtocol.setBackErr(status[1]);
- staProtocol.setHighErr(status[2]);
- staProtocol.setLeftErr(status[3]);
- staProtocol.setRightErr(status[4]);
- staProtocol.setWeightErr(status[5]);
- staProtocol.setBarcodeErr(status[6]);
- }
- // 澶栧舰妫�娴� - 123
- //Thread.sleep(50);
- OperateResultExOne<byte[]> result9 = siemensS7Net.Read("DB101.180", (short)1);
- if (result9.IsSuccess) {
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result9.Content, 0, 1);
- StaProtocol staProtocol = station.get(123);
- staProtocol.setFrontErr(status[0]);
- staProtocol.setBackErr(status[1]);
- staProtocol.setHighErr(status[2]);
- staProtocol.setLeftErr(status[3]);
- staProtocol.setRightErr(status[4]);
- staProtocol.setWeightErr(status[5]);
- staProtocol.setBarcodeErr(status[6]);
- }
- } else if (slave.getId() == 3) {
- //鏉$爜
- //Thread.sleep(200);
- OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.18",(short)10);
- if (result2.IsSuccess) {
+ OperateResultExOne<byte[]> resultErr = siemensS7Net.Read("DB13.2", (short) (staNoSize * 4));
+ if (resultErr.IsSuccess) {
+ for (int i = 0; i < staNoSize; i++) {
+ Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
+ boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr.Content, i * 4, 1);
+ StaProtocol staProtocol = station.get(siteId);
+ staProtocol.setBreakerErr(status[0]);
+ staProtocol.setInfraredErr(status[1]);
+ staProtocol.setOutTimeErr(status[2]);
+ staProtocol.setSeizeSeatErr(status[3]);
+ staProtocol.setWrkYgoodsN(status[4]);
+ staProtocol.setInverterErr(status[5]);
+ staProtocol.setContactErr(status[6]);
+ staProtocol.setUpcontactErr(status[7]);
- String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,0,8, "UTF-8");
- BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 7);
- if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
- barcodeThread.setBarcode(barcode);
- }
-
+ }
}
- // 澶栧舰妫�娴� - 111
- //Thread.sleep(50);
- OperateResultExOne<byte[]> result10 = siemensS7Net.Read("DB101.26", (short)1);
- if (result10.IsSuccess) {
- boolean[] status = siemensS7Net.getByteTransform().TransBool(result10.Content, 0, 1);
- StaProtocol staProtocol = station.get(301);
- staProtocol.setFrontErr(status[0]);
- staProtocol.setBackErr(status[1]);
- staProtocol.setHighErr(status[2]);
- staProtocol.setLeftErr(status[3]);
- staProtocol.setRightErr(status[4]);
- staProtocol.setWeightErr(status[5]);
- staProtocol.setBarcodeErr(status[6]);
- }
}
-
-
- OperateResultExOne<byte[]> resultErr = siemensS7Net.Read("DB13.2", (short) (staNoSize*4));
- if (resultErr.IsSuccess) {
- for (int i = 0; i < staNoSize; i++) {
- Integer siteId = staNos.get(i); // 绔欑偣缂栧彿
- boolean[] status = siemensS7Net.getByteTransform().TransBool(resultErr.Content, i*4, 1);
- StaProtocol staProtocol = station.get(siteId);
- staProtocol.setBreakerErr(status[0]);
- staProtocol.setInfraredErr(status[1]);
- staProtocol.setOutTimeErr(status[2]);
- staProtocol.setSeizeSeatErr(status[3]);
- staProtocol.setWrkYgoodsN(status[4]);
- staProtocol.setInverterErr(status[5]);
- staProtocol.setContactErr(status[6]);
- staProtocol.setUpcontactErr(status[7]);
-
- }
- }
-
-
// //RGV鍙拌溅浣嶇疆
@@ -413,7 +289,7 @@
// this.ioMode = IoModeType.get(result2.Content);
// }
- if (result.IsSuccess && result1.IsSuccess) {
+ if (result.IsSuccess ) {
OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆慬id:{1}] <<<<< 瀹炴椂鏁版嵁鏇存柊鎴愬姛",DateUtils.convert(new Date()), slave.getId()));
@@ -573,7 +449,7 @@
return;
} else {
OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆� 杈撻�佺嚎鍛戒护涓嬪彂鎴愬姛 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
- log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}", slave.getId(), JSON.toJSON(staProtocol));
+ //log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}", slave.getId(), JSON.toJSON(staProtocol));
Integer siteId = staProtocol.getSiteId();
staProtocol = station.get(siteId);
@@ -654,7 +530,7 @@
return;
} else {
OutputQueue.DEVP.offer(MessageFormat.format("銆恵0}銆� 杈撻�佺嚎鍛戒护涓嬪彂鎴愬姛 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
- log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}", slave.getId(), JSON.toJSON(staProtocol));
+ //log.info("杈撻�佺嚎鍛戒护涓嬪彂 [id:{}] >>>>> 鍛戒护涓嬪彂鎴愬姛锛� {}", slave.getId(), JSON.toJSON(staProtocol));
Integer siteId = staProtocol.getSiteId();
staProtocol = station.get(siteId);
--
Gitblit v1.9.1