From 454e14ba2152f19d8e56937f409536b559f96920 Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@63.com> Date: 星期二, 15 三月 2022 16:35:14 +0800 Subject: [PATCH] # --- src/main/java/com/zy/core/thread/SteThread.java | 90 +++++++++++++++++++++++++++------------------ 1 files changed, 54 insertions(+), 36 deletions(-) diff --git a/src/main/java/com/zy/core/thread/SteThread.java b/src/main/java/com/zy/core/thread/SteThread.java index c7af558..ad4fc7d 100644 --- a/src/main/java/com/zy/core/thread/SteThread.java +++ b/src/main/java/com/zy/core/thread/SteThread.java @@ -9,6 +9,7 @@ import com.core.common.SpringUtils; import com.core.exception.CoolException; import com.zy.asrs.entity.BasSte; +import com.zy.asrs.entity.BasSteOpt; import com.zy.asrs.service.BasSteOptService; import com.zy.asrs.service.BasSteService; import com.zy.core.ThreadHandler; @@ -221,23 +222,37 @@ OperateResult result = null; // 寮�濮嬩换鍔� if (!command.getComplete()) { - OperateResult result0 = siemensS7Net.Write("D0", command.getTaskNo()); - short[] array = new short[10]; - array[0] = command.getTaskMode(); -// 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(); -// array[9] = command.getCommand(); - OperateResult result1 = siemensS7Net.Write("D0", array); - // 纭寮�濮嬩换鍔� - if (result0.IsSuccess) { - result = siemensS7Net.Write("D0", true); + + // 浣滀笟 + if (command.getTaskMode() != 0) { + // 1.浠诲姟鍙� + OperateResult result0 = siemensS7Net.Write("DB3", command.getTaskNo()); + // 2.浣滀笟 + short[] array = new short[10]; + array[0] = command.getTaskMode(); + OperateResult result1 = siemensS7Net.Write("D0", array); + // 3.纭寮�濮嬩换鍔� + if (result0.IsSuccess && result1.IsSuccess) { + result = siemensS7Net.Write("D0", true); + } + + // 鍏朵粬鎸囦护 + } else { + // 鎺у埗妯″紡 + if (command.getControlMode() != null) { + result = siemensS7Net.Write("DB3.20", command.getControlMode()); + // 澶嶄綅淇″彿 + } else if (command.getReset() != null) { + result = siemensS7Net.Write("DB3.26", command.getReset()); + // 鍒犻櫎鎸囦护 + } else if (command.getDelete() != null) { + result = siemensS7Net.Write("DB3.28", command.getDelete()); + // 鏃犳晥鎸囦护 + } else { + return false; + } } + // 浠诲姟瀹屾垚 } else { result = siemensS7Net.Write("D0", true); @@ -245,25 +260,29 @@ try { // 鏃ュ織璁板綍 - BasSteOptService bean = SpringUtils.getBean(BasSteOptService.class); -// BasSteOpt basSteOpt = new BasSteOpt( -// command.getTaskNo(), // 浠诲姟鍙� -// command.getSteNo(), // 绌挎杞闈炵┖] -// new Date(), // 涓嬪彂鏃堕棿 -// command.getTaskModeType().desc, // 妯″紡 -// command.getSourcePosX().intValue(), // 婧愭帓 -// command.getSourcePosY().intValue(), // 婧愬垪 -// command.getSourcePosZ().intValue(), // 婧愬眰 -// null, // 婧愮珯 -// command.getDestinationPosX().intValue(), // 鐩爣鎺� -// command.getDestinationPosY().intValue(), // 鐩爣鍒� -// command.getDestinationPosZ().intValue(), // 鐩爣灞� -// null, // 鐩爣绔� -// null, // 鍝嶅簲缁撴灉 -// null, // 淇敼鏃堕棿 -// null // 淇敼浜哄憳 -// ); -// bean.insert(basSteOpt); + if (!command.getComplete() && command.getTaskMode() != 0) { + BasSteOptService bean = SpringUtils.getBean(BasSteOptService.class); + BasSteOpt basSteOpt = new BasSteOpt( + command.getTaskNo(), // 浠诲姟鍙� + command.getSteNo(), // 绌挎杞� + new Date(), // 涓嬪彂鏃堕棿 + command.getTaskModeType().desc, // 浣滀笟 + null, // 婧愭帓 + null, // 婧愬垪 + null, // 婧愬眰 + null, // 婧愮珯 + null, // 鐩爣鎺� + null, // 鐩爣鍒� + null, // 鐩爣灞� + null, // 鐩爣绔� + null, // 鍝嶅簲缁撴灉 + null, // 淇敼鏃堕棿 + null, // 淇敼浜哄憳 + null // 澶囨敞 + ); + bean.insert(basSteOpt); + } + } catch (Exception ignore) {} if (result != null && result.IsSuccess) { @@ -273,7 +292,6 @@ this.lastBay = command.getBay().intValue(); this.lastLev = command.getLev().intValue(); } - log.info("绌挎杞﹀懡浠や笅鍙慬id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command)); OutputQueue.CRN.offer(MessageFormat.format("銆恵0}銆慬id:{1}] >>>>> 鍛戒护涓嬪彂锛� {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command))); -- Gitblit v1.9.1