From 892b13a55e27a950993f3d0fafb997be5360177d Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 11 八月 2020 14:25:38 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/CrnThread.java | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/CrnThread.java b/src/main/java/com/zy/core/thread/CrnThread.java
index 6545d5b..4839c5b 100644
--- a/src/main/java/com/zy/core/thread/CrnThread.java
+++ b/src/main/java/com/zy/core/thread/CrnThread.java
@@ -44,10 +44,11 @@
switch (step) {
// 璇绘暟鎹�
case 1:
- readStatus(); // 璇诲彇鐘舵��
+ readStatus();
break;
+ // 鍐欏叆鏁版嵁
case 2:
- CrnCommand command = (CrnCommand) task.getData();
+ write((CrnCommand) task.getData());
break;
case 3:
break;
@@ -86,7 +87,7 @@
* 璇诲彇鐘舵��
*/
private void readStatus(){
- OperateResultExOne<byte[]> result = siemensNet.Read("DB8.18", (short) 10);
+ OperateResultExOne<byte[]> result = siemensNet.Read("DB8.18", (short) 46);
if (result.IsSuccess) {
if (null == crnProtocol) {
crnProtocol = new CrnProtocol();
@@ -120,7 +121,27 @@
* 鍐欏叆鏁版嵁
*/
private void write(CrnCommand command){
-
+ if (null == command) {
+ log.error("鍫嗗灈鏈哄啓鍏ュ懡浠や负绌�");
+ return;
+ }
+ command.setCrnNo(slave.getId());
+ short[] array = new short[9];
+ array[0] = command.getAckFinish();
+ array[1] = command.getTaskNo();
+ array[2] = command.getTaskMode();
+ array[3] = command.getSourcePosX();
+ array[4] = command.getSourcePosY();
+ array[5] = command.getSourcePosZ();
+ array[6] = command.getDestinationPosX();
+ array[7] = command.getDestinationPosY();
+ array[8] = command.getDestinationPosZ();
+ OperateResult result = siemensNet.Write("DB8.0", array);
+ if (result.IsSuccess) {
+ readStatus();
+ } else {
+ log.error("鍐欏叆鍫嗗灈鏈簆lc鏁版嵁澶辫触 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
+ }
}
@Override
--
Gitblit v1.9.1