From 15b517acc9097ba39155e1d572c007e43bf8e112 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 20 八月 2020 17:12:45 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/core/thread/CrnThread.java | 136 ++++++++++++++++++++++++++++++++-------------
1 files changed, 97 insertions(+), 39 deletions(-)
diff --git a/src/main/java/com/zy/core/thread/CrnThread.java b/src/main/java/com/zy/core/thread/CrnThread.java
index 3c3c77e..148a3e5 100644
--- a/src/main/java/com/zy/core/thread/CrnThread.java
+++ b/src/main/java/com/zy/core/thread/CrnThread.java
@@ -34,7 +34,6 @@
private CrnSlave slave;
private CrnProtocol crnProtocol;
-
public CrnThread(CrnSlave slave) {
this.slave = slave;
}
@@ -131,14 +130,17 @@
// 寮傚父淇℃伅
crnProtocol.setError1(siemensNet.getByteTransform().TransBool(result.Content, 22, 2));
crnProtocol.setError2(siemensNet.getByteTransform().TransBool(result.Content, 24, 2));
- crnProtocol.setTemp1(siemensNet.getByteTransform().TransInt16(result.Content, 26));
- crnProtocol.setXSpeed(siemensNet.getByteTransform().TransSingle(result.Content, 28));
- crnProtocol.setYSpeed(siemensNet.getByteTransform().TransSingle(result.Content, 32));
- crnProtocol.setZSpeed(siemensNet.getByteTransform().TransSingle(result.Content, 36));
- crnProtocol.setXDistance(siemensNet.getByteTransform().TransSingle(result.Content, 40));
- crnProtocol.setYDistance(siemensNet.getByteTransform().TransSingle(result.Content, 44));
- crnProtocol.setXDuration(siemensNet.getByteTransform().TransSingle(result.Content, 48));
- crnProtocol.setYDuration(siemensNet.getByteTransform().TransSingle(result.Content, 52));
+ crnProtocol.setError3(siemensNet.getByteTransform().TransBool(result.Content, 26, 2));
+ crnProtocol.setError4(siemensNet.getByteTransform().TransBool(result.Content, 28, 2));
+ crnProtocol.setError5(siemensNet.getByteTransform().TransBool(result.Content, 30, 2));
+ crnProtocol.setError6(siemensNet.getByteTransform().TransBool(result.Content, 32, 2));
+ crnProtocol.setXSpeed(siemensNet.getByteTransform().TransSingle(result.Content, 34));
+ crnProtocol.setYSpeed(siemensNet.getByteTransform().TransSingle(result.Content, 38));
+ crnProtocol.setZSpeed(siemensNet.getByteTransform().TransSingle(result.Content, 42));
+ crnProtocol.setXDistance(siemensNet.getByteTransform().TransSingle(result.Content, 46));
+ crnProtocol.setYDistance(siemensNet.getByteTransform().TransSingle(result.Content, 50));
+ crnProtocol.setXDuration(siemensNet.getByteTransform().TransSingle(result.Content, 54));
+ crnProtocol.setYDuration(siemensNet.getByteTransform().TransSingle(result.Content, 58));
/**
* 褰撹鍒皊tatus == 90.浠诲姟瀹屾垚绛夊緟WCS纭 鏃�
@@ -178,7 +180,7 @@
if (result.IsSuccess) {
System.out.println(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
- readStatus();
+// readStatus();
} else {
System.out.println(MessageFormat.format("銆恵0}銆戝啓鍏ュ爢鍨涙満plc鏁版嵁澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆戝啓鍏ュ爢鍨涙満plc鏁版嵁澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
@@ -202,7 +204,7 @@
/******************************************************************************************/
/**************************************** 娴嬭瘯涓撶敤 *****************************************/
/*****************************************************************************************/
- public static void main(String[] args) {
+ public static void main(String[] args) throws InterruptedException {
CrnSlave slave = new CrnSlave();
slave.setId(1);
slave.setIp("192.168.6.9");
@@ -212,22 +214,80 @@
crnThread.connect();
crnThread.readStatus();
System.out.println(JSON.toJSONString(crnThread.crnProtocol));
+ Thread.sleep(3000L);
+
+ // 1.鍏ュ簱 婧愬拰鐩爣閮藉彂
+// CrnCommand command = new CrnCommand();
+// command.setCrnNo(1); // 鍫嗗灈鏈虹紪鍙�
+// command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+// command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
+// command.setTaskMode(CrnTaskModeType.PAKIN); // 浠诲姟妯″紡
+// command.setSourcePosX((short) 1); // 婧愬簱浣嶆帓
+// command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪
+// command.setSourcePosZ((short) 1); // 婧愬簱浣嶅眰
+// command.setDestinationPosX((short) 2); // 鐩爣搴撲綅鎺�
+// command.setDestinationPosY((short) 3); // 鐩爣搴撲綅鍒�
+// command.setDestinationPosZ((short) 1); // 鐩爣搴撲綅灞�
+// crnThread.write(command);
+
+ // 2.鍑哄簱 婧愬拰鐩爣閮藉彂
+// CrnCommand command = new CrnCommand();
+// command.setCrnNo(1); // 鍫嗗灈鏈虹紪鍙�
+// command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+// command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
+// command.setTaskMode(CrnTaskModeType.PAKOUT); // 浠诲姟妯″紡
+// command.setSourcePosX((short) 2); // 婧愬簱浣嶆帓
+// command.setSourcePosY((short) 4); // 婧愬簱浣嶅垪
+// command.setSourcePosZ((short) 3); // 婧愬簱浣嶅眰
+// command.setDestinationPosX((short) 1); // 鐩爣搴撲綅鎺�
+// command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒�
+// command.setDestinationPosZ((short) 1); // 鐩爣搴撲綅灞�
+// crnThread.write(command);
- CrnCommand command = new CrnCommand();
- command.setCrnNo(1); // 鍫嗗灈鏈虹紪鍙�
- command.setTaskNo((short) 0); // 宸ヤ綔鍙�
- command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
- command.setTaskMode(CrnTaskModeType.OFFSET_MOVE); // 浠诲姟妯″紡
- command.setSourcePosX((short) 0); // 婧愬簱浣嶆帓
- command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪
- command.setSourcePosZ((short) 0); // 婧愬簱浣嶅眰
- command.setDestinationPosX((short) 1); // 鐩爣搴撲綅鎺�
- command.setDestinationPosY((short) 5); // 鐩爣搴撲綅鍒�
- command.setDestinationPosZ((short) 3); // 鐩爣搴撲綅灞�
- crnThread.write(command);
+// // 3.搴撲綅绉昏浆 婧愬拰鐩爣閮藉彂 pass
+// CrnCommand command = new CrnCommand();
+// command.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙�
+// command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+// command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
+// command.setTaskMode(CrnTaskModeType.LOC_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆
+// command.setSourcePosX((short)2); // 婧愬簱浣嶆帓
+// command.setSourcePosY((short)2); // 婧愬簱浣嶅垪
+// command.setSourcePosZ((short)3); // 婧愬簱浣嶅眰
+// command.setDestinationPosX((short)2); // 鐩爣搴撲綅鎺�
+// command.setDestinationPosY((short)4); // 鐩爣搴撲綅鍒�
+// command.setDestinationPosZ((short)4); // 鐩爣搴撲綅灞�
+// crnThread.write(command);
+ // 4.绔欎綅绉昏浆 婧愬拰鐩爣閮藉彂
+// CrnCommand command = new CrnCommand();
+// command.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙�
+// command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+// command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
+// command.setTaskMode(CrnTaskModeType.SITE_MOVE); // 浠诲姟妯″紡: 搴撲綅绉昏浆
+// command.setSourcePosX((short)1); // 婧愬簱浣嶆帓
+// command.setSourcePosY((short)0); // 婧愬簱浣嶅垪
+// command.setSourcePosZ((short)1); // 婧愬簱浣嶅眰
+// command.setDestinationPosX((short)2); // 鐩爣搴撲綅鎺�
+// command.setDestinationPosY((short)0); // 鐩爣搴撲綅鍒�
+// command.setDestinationPosZ((short)1); // 鐩爣搴撲綅灞�
+// crnThread.write(command);
+// // 5.鍥炲師鐐� 涓嶇敤鍙� pass
+// CrnCommand command = new CrnCommand();
+// command.setCrnNo(1); // 鍫嗗灈鏈虹紪鍙�
+// command.setTaskNo((short) 0); // 宸ヤ綔鍙�
+// command.setAckFinish((short) 0); // 浠诲姟瀹屾垚纭浣�
+// command.setTaskMode(CrnTaskModeType.GO_ORIGIN); // 浠诲姟妯″紡
+// command.setSourcePosX((short) 0); // 婧愬簱浣嶆帓
+// command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪
+// command.setSourcePosZ((short) 0); // 婧愬簱浣嶅眰
+// command.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺�
+// command.setDestinationPosY((short) 0); // 鐩爣搴撲綅鍒�
+// command.setDestinationPosZ((short) 0); // 鐩爣搴撲綅灞�
+// crnThread.write(command);
+
+// // 7.鍧愭爣绉昏 鐩爣鍙� pass
// CrnCommand command = new CrnCommand();
// command.setCrnNo(1); // 鍫嗗灈鏈虹紪鍙�
// command.setTaskNo((short) 0); // 宸ヤ綔鍙�
@@ -236,25 +296,23 @@
// command.setSourcePosX((short) 0); // 婧愬簱浣嶆帓
// command.setSourcePosY((short) 0); // 婧愬簱浣嶅垪
// command.setSourcePosZ((short) 0); // 婧愬簱浣嶅眰
-// command.setDestinationPosX((short) 0); // 鐩爣搴撲綅鎺�
-// command.setDestinationPosY((short) 5); // 鐩爣搴撲綅鍒�
+// command.setDestinationPosX((short) 2); // 鐩爣搴撲綅鎺�
+// command.setDestinationPosY((short) 1); // 鐩爣搴撲綅鍒�
// command.setDestinationPosZ((short) 1); // 鐩爣搴撲綅灞�
// crnThread.write(command);
-
-// // 鍐�
-// CrnCommand command = new CrnCommand();
-// command.setCrnNo(slave.getId()); // 鍫嗗灈鏈虹紪鍙�
-// command.setTaskNo((short) 0); // 宸ヤ綔鍙�
-// command.setAckFinish((short) 1); // 浠诲姟瀹屾垚纭浣�
-// command.setTaskMode(CrnTaskModeType.NONE); // 浠诲姟妯″紡: 搴撲綅绉昏浆
-// command.setSourcePosX((short)0); // 婧愬簱浣嶆帓
-// command.setSourcePosY((short)0); // 婧愬簱浣嶅垪
-// command.setSourcePosZ((short)0); // 婧愬簱浣嶅眰
-// command.setDestinationPosX((short)0); // 鐩爣搴撲綅鎺�
-// command.setDestinationPosY((short)0); // 鐩爣搴撲綅鍒�
-// command.setDestinationPosZ((short)0); // 鐩爣搴撲綅灞�
-// crnThread.write(command);
+ // 鍙湁鍑虹幇鎸囧畾寮傚父鎵嶈繘琛屽浣�
+// if (crnThread.crnProtocol.getCrnError2().leftTakeNoneErr
+// || crnThread.crnProtocol.getCrnError2().rightTakeNoneErr
+// || crnThread.crnProtocol.getCrnError2().leftPutLoadErr
+// || crnThread.crnProtocol.getCrnError2().rightPutLoadErr) {
+// CrnCommand command = new CrnCommand();
+// command.setCrnNo(1); // 鍫嗗灈鏈虹紪鍙�
+// command.setAckFinish((short) 1); // 浠诲姟瀹屾垚纭浣�
+// command.setTaskMode(CrnTaskModeType.NONE); // 浠诲姟妯″紡
+// Thread.sleep(3000L);
+// crnThread.write(command);
+// }
}
--
Gitblit v1.9.1