From bb3a7ee1496fe02d8a0eefd2281345ac00e3c8bd Mon Sep 17 00:00:00 2001
From: lsh <1>
Date: 星期四, 18 七月 2024 09:24:01 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 73 +++++++++++++++++++++++++++++++-----
1 files changed, 62 insertions(+), 11 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 03e5255..afbcd87 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -133,7 +133,7 @@
/**
* 鏉$爜鏁伴噺
*/
- private int barcodeSize = 5;
+ private int barcodeSize = 9;
/**
* 鍏ュ嚭搴撴ā寮�
@@ -207,6 +207,8 @@
case 11:
write11((StaProtocol)task.getData());
break;
+ case 99:
+ write99((Integer) task.getData());
default:
break;
}
@@ -310,9 +312,7 @@
Integer siteId = staNosRgv[i]; // 绔欑偣缂栧彿
StaProtocol staProtocol = station.get(siteId);
if (null == staProtocol) {
- staProtocol = new StaProtocol();
- staProtocol.setSiteId(siteId);
- station.put(siteId, staProtocol);
+ continue;
}
try{
staProtocol.setEndRow(siemensS7Net.getByteTransform().TransInt16(resultRgv2.Content, 0)); // 灏忚溅鐩爣浣�
@@ -353,7 +353,7 @@
Thread.sleep(200);
OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.2440",(short)(barcodeSize*8));
if (result2.IsSuccess) {
- int[] staNosRgv = {281,292,173,214,120};
+ int[] staNosRgv = {281,292,173,214,120,100,101,102,103};
for (int i = 0; i < barcodeSize; i++) { //1:281 2:292 3:174(173) 4:214 5:120
String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8");
@@ -362,9 +362,7 @@
Integer siteId = staNosRgv[i]; // 绔欑偣缂栧彿
StaProtocol staProtocol = station.get(siteId);
if (null == staProtocol) {
- staProtocol = new StaProtocol();
- staProtocol.setSiteId(siteId);
- station.put(siteId, staProtocol);
+ continue;
}
staProtocol.setBarcode(barcode);
barcodeThread.setBarcode(barcode);
@@ -433,9 +431,9 @@
//浠诲姟涓嬪彂娆℃暟
int writeCount = 0;
do {
- write = siemensS7Net.Write("DB100." + index*6, staProtocol.getWorkNo()); // 宸ヤ綔鍙�
- Thread.sleep(500);
write1 = siemensS7Net.Write("DB100." + (index*6+4), staProtocol.getStaNo().shortValue()); // 鐩爣绔�
+// Thread.sleep(500);
+ write = siemensS7Net.Write("DB100." + index*6, staProtocol.getWorkNo()); // 宸ヤ綔鍙�
if(write.IsSuccess || write1.IsSuccess){
writeCount=6;
}else {
@@ -972,7 +970,60 @@
}
}
- // 鏇存柊鍏ュ嚭搴撴ā寮�
+ private void write99(Integer devNo) throws InterruptedException {
+ String resultV1 = "";
+ switch (devNo){
+ case 1:
+ resultV1 = "DB500.0.0";
+ break;
+ case 2:
+ resultV1 = "DB500.0.1";
+ break;
+ case 3:
+ resultV1 = "DB500.0.2";
+ break;
+ default:
+ return;
+ }
+ OperateResult result = siemensS7Net.Write(resultV1, true);
+ Integer writeCount = 0;
+ do {
+ try{
+ if(!result.IsSuccess){
+ log.error("鍐欏叆RGV鏁版嵁澶辫触锛岄噸鏂颁笅鍙戜换鍔� 鍐欏叆鐩存帴澶辫触 ===>> [id:{}],{},[鍐欏叆娆℃暟:{}]", slave.getId(), JSON.toJSONString(devNo),writeCount);
+ result = siemensS7Net.Write(resultV1, true);
+ Thread.sleep(100);
+ writeCount++;
+ continue;
+ }
+ OperateResultExOne<byte[]> resultRead1 = siemensS7Net.Read("resultV1", (short) 1);
+ if (resultRead1.IsSuccess) {
+ boolean[] status = siemensS7Net.getByteTransform().TransBool(resultRead1.Content, 0, 1);
+ if (status[devNo-1]){
+ break;
+ } else {
+ log.error("鍐欏叆RGV鏁版嵁澶辫触锛岄噸鏂颁笅鍙戜换鍔� 鍐欏叆鐩存帴澶辫触 ===>> [id:{}],{},[鍐欏叆娆℃暟:{}]", slave.getId(), JSON.toJSONString(devNo),writeCount);
+ result = siemensS7Net.Write(resultV1, true);
+ Thread.sleep(100);
+ writeCount++;
+ continue;
+ }
+ } else {
+ log.error("鍐欏叆RGV鏁版嵁澶辫触锛岄噸鏂颁笅鍙戜换鍔� 鍐欏叆鐩存帴澶辫触 ===>> [id:{}],{},[鍐欏叆娆℃暟:{}]", slave.getId(), JSON.toJSONString(devNo),writeCount);
+ result = siemensS7Net.Write(resultV1, true);
+ Thread.sleep(100);
+ writeCount++;
+ continue;
+ }
+ }catch (Exception e){
+ log.error("鍐欏叆鏁版嵁鍚庡洖璇诲嚭閿�,寮傚父锛�"+e);
+ }
+ writeCount++;
+ } while (writeCount<6);
+ }
+
+
+ // 鏇存柊鍏ュ嚭搴撴ā寮�
private void updateIoMode() throws InterruptedException {
if (this.ioModeOf2F != IoModeType.NONE) {
if (!siemensS7Net.Write("DB100.180", this.ioModeOf2F.id).IsSuccess) {
--
Gitblit v1.9.1