From 2a66c437952971e9065dff5c48d76c6ae50b6c5d Mon Sep 17 00:00:00 2001 From: whycq <whycq> Date: 星期三, 16 三月 2022 11:03:08 +0800 Subject: [PATCH] # 加vue --- src/main/java/com/zy/core/thread/SteThread.java | 153 ++++++++++++++------------------------------------- 1 files changed, 42 insertions(+), 111 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SteThread.java b/src/main/java/com/zy/core/thread/SteThread.java index ad4fc7d..10c7a5e 100644 --- a/src/main/java/com/zy/core/thread/SteThread.java +++ b/src/main/java/com/zy/core/thread/SteThread.java @@ -16,6 +16,8 @@ import com.zy.core.cache.MessageQueue; import com.zy.core.cache.OutputQueue; import com.zy.core.enums.SlaveType; +import com.zy.core.enums.SteStatusType; +import com.zy.core.enums.SteTaskModeType; import com.zy.core.model.SteSlave; import com.zy.core.model.Task; import com.zy.core.model.command.SteCommand; @@ -25,6 +27,7 @@ import java.text.MessageFormat; import java.util.Date; +import java.util.Random; /** * shuttle 绌挎杞︾嚎绋� @@ -89,23 +92,12 @@ if (null == steProtocol) { steProtocol = new SteProtocol(); } -// steProtocol.setMode((short) -1); -// steProtocol.setTaskNo((short)0); -// steProtocol.setStatus((short)-1); -// steProtocol.setBay((short)0); -// steProtocol.setLevel((short)0); -// steProtocol.setForkPos((short) -1); -// steProtocol.setLiftPos((short) -1); -// steProtocol.setWalkPos((short)0); -// steProtocol.setLoaded((short)0); -// steProtocol.setAlarm((short)0); -// steProtocol.setXSpeed(0F); -// steProtocol.setYSpeed(0F); -// steProtocol.setZSpeed(0F); -// steProtocol.setXDistance(0F); -// steProtocol.setYDistance(0F); -// steProtocol.setXDuration(0F); -// steProtocol.setYDuration(0F); + steProtocol.setSteNo(slave.getId().shortValue()); + steProtocol.setMode((short) 0); + steProtocol.setStatus(SteStatusType.OFF_LINE); + steProtocol.setTaskNo(0); + steProtocol.setExecute(false); + steProtocol.setWaiting(false); } @Override @@ -226,11 +218,9 @@ // 浣滀笟 if (command.getTaskMode() != 0) { // 1.浠诲姟鍙� - OperateResult result0 = siemensS7Net.Write("DB3", command.getTaskNo()); + OperateResult result0 = siemensS7Net.Write("DB3.0", command.getTaskNo()); // 2.浣滀笟 - short[] array = new short[10]; - array[0] = command.getTaskMode(); - OperateResult result1 = siemensS7Net.Write("D0", array); + OperateResult result1 = siemensS7Net.Write("DB3.4", command.getTaskMode()); // 3.纭寮�濮嬩换鍔� if (result0.IsSuccess && result1.IsSuccess) { result = siemensS7Net.Write("D0", true); @@ -363,101 +353,42 @@ /**************************************** 娴嬭瘯涓撶敤 *****************************************/ /*****************************************************************************************/ public static void main(String[] args) throws InterruptedException { -// CrnSlave slave = new CrnSlave(); -// slave.setId(1); -// slave.setIp("192.168.3.39"); -// slave.setPort(5015); -// slave.setRack(0); -// slave.setSlot(0); -// SteThread melsecCrnThread = new SteThread(slave); -// melsecCrnThread.connect(); -// melsecCrnThread.readStatus(); -// System.out.println(JSON.toJSONString(melsecCrnThread.crnProtocol)); + SteSlave slave = new SteSlave(); + slave.setId(1); + slave.setIp("192.168.3.39"); + slave.setPort(5015); + SteThread thread = new SteThread(slave); + thread.connect(); + thread.readStatus(); + System.out.println(JSON.toJSONString(thread.steProtocol)); - // 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); + // 浠诲姟浣滀笟 + SteCommand command = new SteCommand(); + command.setSteNo(1); // 鍫嗗灈鏈虹紪鍙� + command.setTaskNo(new Random().nextInt(9000)); // 宸ヤ綔鍙� + command.setTaskMode(SteTaskModeType.IN_LEFT); // 浠诲姟妯″紡 + thread.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); + // 浠诲姟瀹屾垚 +// SteCommand command = new SteCommand(); +// command.setSteNo(1); // 鍫嗗灈鏈虹紪鍙� +// command.setComplete(Boolean.TRUE); // 浠诲姟妯″紡 +// thread.write(command); + // 鎺у埗妯″紡 +// SteCommand command = new SteCommand(); +// command.setControlMode((short) 1); +// thread.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); + // 澶嶄綅淇″彿 +// SteCommand command = new SteCommand(); +// command.setReset((short) 1); +// thread.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); - - - // 鍙湁鍑虹幇鎸囧畾寮傚父鎵嶈繘琛屽浣� -// 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); -// } + // 鍒犻櫎鎸囦护 +// SteCommand command = new SteCommand(); +// command.setDelete((short) 1); +// thread.write(command); } -- Gitblit v1.9.1