From 86cb750364e49debb8586a29f0469ba37ce0f85c Mon Sep 17 00:00:00 2001
From: zhangchao <zc857179121@qq.com>
Date: 星期日, 01 九月 2024 15:24:21 +0800
Subject: [PATCH] 对照协议调整
---
src/main/java/com/zy/core/thread/SiemensCrnThread.java | 93 +++++++++++++++++++++++++++++++++-------------
src/main/java/com/zy/core/thread/SiemensDevpThread.java | 6 +-
2 files changed, 70 insertions(+), 29 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/SiemensCrnThread.java b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
index a3dcf6f..ba4b33a 100644
--- a/src/main/java/com/zy/core/thread/SiemensCrnThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -331,37 +331,78 @@
one.setDestinationPosXTwo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 22));
one.setDestinationPosYTwo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 24));
one.setDestinationPosZTwo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 26));
- if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode())
- || !command.getSourcePosX().equals(one.getSourcePosX()) || !command.getSourcePosY().equals(one.getSourcePosY())
- || !command.getSourcePosZ().equals(one.getSourcePosZ()) || !command.getDestinationPosX().equals(one.getDestinationPosX())
- || !command.getDestinationPosY().equals(one.getDestinationPosY()) || !command.getDestinationPosZ().equals(one.getDestinationPosZ())
- || !command.getSourcePosXTwo().equals(one.getSourcePosXTwo()) || !command.getSourcePosYTwo().equals(one.getSourcePosYTwo())
- || !command.getSourcePosZTwo().equals(one.getSourcePosZTwo()) || !command.getDestinationPosXTwo().equals(one.getDestinationPosXTwo())
- || !command.getDestinationPosYTwo().equals(one.getDestinationPosYTwo()) || !command.getDestinationPosZTwo().equals(one.getDestinationPosZTwo())
- ) {
- System.out.println(command.getTaskNo().equals(one.getTaskNo()));
- System.out.println(one);
- try {
- log.error("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐�==>涓嶄竴鑷碵id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(one));
- } catch (Exception e) {
+ if (command.getTaskMode() != 2) {
+ if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode())
+ || !command.getSourcePosX().equals(one.getSourcePosX()) || !command.getSourcePosY().equals(one.getSourcePosY())
+ || !command.getSourcePosZ().equals(one.getSourcePosZ()) || !command.getDestinationPosX().equals(one.getDestinationPosX())
+ || !command.getDestinationPosY().equals(one.getDestinationPosY()) || !command.getDestinationPosZ().equals(one.getDestinationPosZ())
+ ) {
+ System.out.println(command.getTaskNo().equals(one.getTaskNo()));
+ System.out.println(command.getTaskMode().equals(one.getTaskMode()));
+ System.out.println(command.getDestinationPosX().equals(one.getDestinationPosX()));
+ System.out.println(command.getDestinationPosY().equals(one.getDestinationPosY()));
+ System.out.println(command.getDestinationPosZ().equals(one.getDestinationPosZ()));
+ System.out.println(command.getSourcePosZ().equals(one.getSourcePosZ()));
+ System.out.println(command.getSourcePosY().equals(one.getSourcePosY()));
+ System.out.println(command.getSourcePosX().equals(one.getSourcePosX()));
try {
- log.error("鏃ュ織鎵撳嵃澶辫触锛�===>>鍙傛暟one鎶ラ敊 [id:{}],{}", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(resultRead));
- } catch (Exception e1) {
- log.error("鏃ュ織鎵撳嵃澶辫触锛�===>> [id:{}],{}", slave.getId(), JSON.toJSONString(command));
+ log.error("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐�==>涓嶄竴鑷碵id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(one));
+ } catch (Exception e) {
+ try {
+ log.error("鏃ュ織鎵撳嵃澶辫触锛�===>>鍙傛暟one鎶ラ敊 [id:{}],{}", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(resultRead));
+ } catch (Exception e1) {
+ log.error("鏃ュ織鎵撳嵃澶辫触锛�===>> [id:{}],{}", slave.getId(), JSON.toJSONString(command));
+ }
}
- }
- try {
- Thread.sleep(100);
- } catch (Exception e) {
+ try {
+ Thread.sleep(100);
+ } catch (Exception e) {
+ }
+ log.error("鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触锛岄噸鏂颁笅鍙戜换鍔� 鍥炶涓嶄竴鑷� ===>> [id:{}],{},[鍐欏叆娆℃暟:{}]", slave.getId(), JSON.toJSONString(command), writeCount);
+ result = siemensNet.Write("DB100.0", array);
+ writeCount++;
+ continue;
+ } else {
+ log.info("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇绘垚鍔焄id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(one));
+ break;
}
- log.error("鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触锛岄噸鏂颁笅鍙戜换鍔� 鍥炶涓嶄竴鑷� ===>> [id:{}],{},[鍐欏叆娆℃暟:{}]", slave.getId(), JSON.toJSONString(command), writeCount);
- result = siemensNet.Write("DB100.0", array);
- writeCount++;
- continue;
} else {
- log.info("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇绘垚鍔焄id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(one));
- break;
+ if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode())
+ || !command.getSourcePosXTwo().equals(one.getSourcePosXTwo()) || !command.getSourcePosYTwo().equals(one.getSourcePosYTwo())
+ || !command.getSourcePosZTwo().equals(one.getSourcePosZTwo()) || !command.getDestinationPosXTwo().equals(one.getDestinationPosXTwo())
+ || !command.getDestinationPosYTwo().equals(one.getDestinationPosYTwo()) || !command.getDestinationPosZTwo().equals(one.getDestinationPosZTwo())
+ ) {
+ System.out.println(command.getTaskNo().equals(one.getTaskNo()));
+ System.out.println(command.getTaskMode().equals(one.getTaskMode()));
+ System.out.println(command.getSourcePosXTwo().equals(one.getSourcePosXTwo()));
+ System.out.println(command.getDestinationPosYTwo().equals(one.getDestinationPosYTwo()));
+ System.out.println(command.getDestinationPosZTwo().equals(one.getDestinationPosZTwo()));
+ System.out.println(command.getSourcePosZTwo().equals(one.getSourcePosZTwo()));
+ System.out.println(command.getSourcePosYTwo().equals(one.getSourcePosYTwo()));
+ System.out.println(command.getDestinationPosXTwo().equals(one.getDestinationPosXTwo()));
+ try {
+ log.error("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇诲け璐�==>涓嶄竴鑷碵id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(one));
+ } catch (Exception e) {
+ try {
+ log.error("鏃ュ織鎵撳嵃澶辫触锛�===>>鍙傛暟one鎶ラ敊 [id:{}],{}", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(resultRead));
+ } catch (Exception e1) {
+ log.error("鏃ュ織鎵撳嵃澶辫触锛�===>> [id:{}],{}", slave.getId(), JSON.toJSONString(command));
+ }
+ }
+ try {
+ Thread.sleep(100);
+ } catch (Exception e) {
+
+ }
+ log.error("鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触锛岄噸鏂颁笅鍙戜换鍔� 鍥炶涓嶄竴鑷� ===>> [id:{}],{},[鍐欏叆娆℃暟:{}]", slave.getId(), JSON.toJSONString(command), writeCount);
+ result = siemensNet.Write("DB100.0", array);
+ writeCount++;
+ continue;
+ } else {
+ log.info("鍫嗗灈鏈哄懡浠ゅ湴鍧�鍐欏叆鍚庡洖璇绘垚鍔焄id:{}] >>>>> 鍐欏叆[{}],===>>鍥炶[{}]", slave.getId(), JSON.toJSONString(command), JSON.toJSONString(one));
+ break;
+ }
}
}
} catch (Exception e) {
diff --git a/src/main/java/com/zy/core/thread/SiemensDevpThread.java b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
index 371cf81..be67d37 100644
--- a/src/main/java/com/zy/core/thread/SiemensDevpThread.java
+++ b/src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -263,7 +263,7 @@
//鏉$爜鎵弿鍣�
Thread.sleep(200);
//ArrayList<Integer> barcodeList = BarcodeList;
- OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.200", (short) (3 * 8));
+ OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.200", (short) (24));
if (result2.IsSuccess) {
for (int i = 0; i < 3; i++) {
String barcode = siemensS7Net.getByteTransform().TransString(result2.Content, i * 8, 8, "UTF-8");
@@ -388,8 +388,8 @@
OperateResultExOne<byte[]> readResult = siemensS7Net.Read("DB100." + index * 6, (short) 4);
OperateResultExOne<byte[]> readResult1 = siemensS7Net.Read("DB100." + (index * 6 + 4), (short) 2);
if (readResult.IsSuccess && readResult1.IsSuccess) {
- short workNo = siemensS7Net.getByteTransform().TransInt16(readResult.Content, 0);
- short staNo = siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 0);
+ short workNo = siemensS7Net.getByteTransform().TransInt16(readResult.Content, 4);
+ short staNo = siemensS7Net.getByteTransform().TransInt16(readResult1.Content, 2);
if (staProtocol.getWorkNo().equals(workNo) && staProtocol.getStaNo().equals(staNo)) {
//浠诲姟鍛戒护鍐欏叆鎴愬姛
log.info("鍐欏叆鍫嗗灈鏈哄懡浠ゅ悗杩斿洖鎴愬姛锛屽苟涓斿洖璇绘垚鍔熴�傚爢鍨涙満plc缂栧彿={}锛寋}锛屽啓鍏ユ鏁�={}", slave.getId(), JSON.toJSON(staProtocol), writeCount);
--
Gitblit v1.9.1