From 5d97178e5fd734ec2a741677223dc18ab5ec1805 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 09 四月 2024 15:45:28 +0800
Subject: [PATCH] Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java | 9 -
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ConveyorDispatcher.java | 34 ++---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ConveyorCommandService.java | 307 +++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 325 insertions(+), 25 deletions(-)
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ConveyorCommandService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ConveyorCommandService.java
new file mode 100644
index 0000000..13fd2bd
--- /dev/null
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ConveyorCommandService.java
@@ -0,0 +1,307 @@
+package com.zy.asrs.wcs.core.kernel.command;
+
+import com.zy.asrs.wcs.core.entity.Motion;
+import com.zy.asrs.wcs.core.utils.ConveyorDispatcher;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by vincent on 2023/10/23
+ */
+@Slf4j
+@Service
+public class ConveyorCommandService {
+
+ @Autowired
+ private ConveyorDispatcher conveyorDispatcher;
+
+ public Boolean accept(Motion motion) {
+// Integer deviceNo = Integer.parseInt(motion.getDevice());
+// SiemensDevpThread devpThread;
+// StaProtocol staProtocol;
+// BasDevp staDetl;
+// StaProtocol clone;
+// SiemensLiftThread liftThread;
+// LiftProtocol liftProtocol;
+// switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl()))){
+// // 杈撻�佺嚎鎸囦护涓嬪彂
+// case CONVEYOR_INBOUND:
+// devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, deviceNo);
+//
+// staProtocol = devpThread.getStation().get(Integer.parseInt(motion.getOrigin()));
+// if (staProtocol == null) {
+// return false;
+// }
+// // 鏌ヨ绔欑偣璇︾粏淇℃伅
+// staDetl = basDevpService.selectById(staProtocol.getSiteId());
+// if (staDetl == null || Cools.isEmpty(staDetl.getCanining()) || !"Y".equals(staDetl.getCanining())) {
+// News.error("鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", staProtocol.getSiteId());
+// return false;
+// }
+// if (!staProtocol.isAutoing()
+// || !staProtocol.isLoading()
+// || !staProtocol.isInEnable()
+// || !(staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9990)) {
+// return false;
+// }
+//
+// if (!staProtocol.getWorkNo().equals(motion.getWrkNo().shortValue())) {
+// return false;
+// }
+//
+// clone = staProtocol.clone();
+//
+// clone.setWorkNo(motion.getWrkNo().shortValue());
+// clone.setStaNo(Short.parseShort(motion.getTarget()));
+//
+// devpThread.setPakMk(staProtocol.getSiteId(), false);
+//
+// return MessageQueue.offer(SlaveType.Devp, deviceNo, new Task(2, clone));
+//
+// case CONVEYOR_INBOUND_TO_LIFT:
+// // 杈撻�佺嚎 -----------------------------------------------
+// devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, deviceNo);
+//
+// staProtocol = devpThread.getStation().get(Integer.parseInt(motion.getOrigin()));
+// if (staProtocol == null) {
+// return false;
+// }
+// // 鏌ヨ绔欑偣璇︾粏淇℃伅
+// staDetl = basDevpService.selectById(staProtocol.getSiteId());
+// if (staDetl == null || Cools.isEmpty(staDetl.getCanining()) || !"Y".equals(staDetl.getCanining())) {
+// News.error("鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", staProtocol.getSiteId());
+// return false;
+// }
+// if (!staProtocol.isAutoing()
+// || !staProtocol.isLoading()
+//// || !staProtocol.isInEnable()
+// || (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9991)
+// || !staProtocol.isPakMk()) {
+// return false;
+// }
+//
+// // 鎻愬崌鏈哄垽鏂� -----------------------------------------------
+// liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getDockNo()));
+// liftProtocol = liftThread.getLiftProtocol();
+// if (null == liftProtocol) {
+// return false;
+// }
+// DevpSlave.Sta inSta = devpThread.getSlave().queryInSta(staProtocol.getSiteId());
+// if (!(liftProtocol.getMode()
+// || liftProtocol.getReady()
+// || !liftProtocol.getRunning()
+// || !liftProtocol.getLev().equals(Short.parseShort(motion.getTarget())))) {
+// return false;
+// }
+//
+// // 涓嬪彂鍛戒护 -----------------------------------------------
+//
+// // 1.椹卞姩鎻愬崌鏈虹數鏈�
+// LiftCommand liftCommand = new LiftCommand();
+//
+// LiftInteractiveModeType liftInteractiveModeType = null;
+// switch (Integer.parseInt(motion.getOrigin())) {
+// case 2:
+// liftInteractiveModeType = LiftInteractiveModeType.ENGINE_EMPTY_TURN;
+// break;
+// case 7:
+// liftInteractiveModeType = LiftInteractiveModeType.ENGINE_EMPTY_TURN;
+// break;
+// case 9:
+// case 10:
+// case 11:
+// liftInteractiveModeType = LiftInteractiveModeType.ENGINE_EMPTY_TURN;
+// break;
+// default:
+// break;
+// }
+//
+// if (liftInteractiveModeType == null) {
+// return false;
+// }
+// liftCommand = liftThread.getLiftTurnCommand(liftInteractiveModeType.id);
+// liftCommand.setLiftNo(liftProtocol.getLiftNo());
+// liftCommand.setTaskNo(motion.getWrkNo().shortValue());
+// if (!liftThread.assignWork(liftCommand)) {
+// return false;
+// }
+//
+// try {
+// Thread.sleep(1000);
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+//
+// // 2.涓嬪彂杈撻�佺嚎浠诲姟
+// clone = staProtocol.clone();
+// // 鍒ゆ柇鏄惁瀛樺湪鎻愬崌鏈轰唬鐞嗙珯鐐�
+// ConveyorProxyType conveyorProxyType = ConveyorProxyType.queryByLift(Integer.parseInt(motion.getDockNo()), true);
+// clone.setWorkNo(motion.getWrkNo().shortValue());
+// clone.setStaNo(conveyorProxyType.liftProxyStaNo.shortValue());
+// devpThread.setPakMk(staProtocol.getSiteId(), false);
+// return MessageQueue.offer(SlaveType.Devp, deviceNo, new Task(2, clone));
+//
+// case CONVEYOR_OUTBOUND:
+// devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, deviceNo);
+//
+// staProtocol = devpThread.getStation().get(Integer.parseInt(motion.getOrigin()));
+// if (staProtocol == null) {
+// return false;
+// }
+// if (!staProtocol.isAutoing()
+// || !staProtocol.isLoading()
+// || staProtocol.getWorkNo() != 0
+// || !staProtocol.isPakMk()) {
+// return false;
+// }
+//
+// // 涓嬪彂鍛戒护 -----------------------------------------------
+// clone = staProtocol.clone();
+// clone.setWorkNo(motion.getWrkNo().shortValue());
+// clone.setStaNo(Short.parseShort(motion.getTarget()));
+//
+// devpThread.setPakMk(clone.getSiteId(), false);
+//
+// return MessageQueue.offer(SlaveType.Devp, deviceNo, new Task(2, clone));
+//
+//// case CONVEYOR_OUTBOUND_FROM_LIFT:
+//// Integer liftNo = Integer.parseInt(motion.getDockNo());
+////
+//// LiftNeighborType.query(liftNo, )
+////
+//// // 杈撻�佺嚎 -----------------------------------------------
+//// devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, deviceNo);
+////
+//// staProtocol = devpThread.getStation().get(Integer.parseInt(motion.getTarget()));
+//// if (staProtocol == null) {
+//// return false;
+//// }
+//// // 鏌ヨ绔欑偣璇︾粏淇℃伅
+//// staDetl = basDevpService.selectById(staProtocol.getSiteId());
+//// if (staDetl == null || Cools.isEmpty(staDetl.getCanouting()) || !"Y".equals(staDetl.getCanouting())) {
+//// News.error("鍏ュ簱 ===>> 鍫嗗灈鏈虹珯鐐瑰湪鏁版嵁搴撲笉瀛樺湪, 绔欑偣缂栧彿={}", staProtocol.getSiteId());
+//// return false;
+//// }
+//// if (!staProtocol.isAutoing()
+//// || !staProtocol.isLoading()
+//// || !staProtocol.isInEnable()
+//// || !(staProtocol.getWorkNo() >= 9991 && staProtocol.getWorkNo() <= 9999)) {
+//// return false;
+//// }
+//// if (!staProtocol.getWorkNo().equals(motion.getWrkNo().shortValue())) {
+//// return false;
+//// }
+////
+//// // 鎻愬崌鏈哄垽鏂� -----------------------------------------------
+//// liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, liftNo);
+//// liftProtocol = liftThread.getLiftProtocol();
+//// if (null == liftProtocol) {
+//// return false;
+//// }
+//// DevpSlave.Sta inSta = devpThread.getSlave().queryOutSta(staProtocol.getSiteId());
+//// if (liftProtocol.getMode() != 1
+//// || liftProtocol.getAlarm() != 2
+//// || liftProtocol.getLoadingByGoods() != 1
+//// || liftProtocol.getPos() != inSta.getLiftLev().shortValue()) {
+//// return false;
+//// }
+//
+//
+// default:
+// break;
+// }
+ return Boolean.TRUE;
+ }
+
+ public Boolean finish(Motion motion) {
+// Integer deviceNo = Integer.parseInt(motion.getDevice());
+// SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, deviceNo);
+// StaProtocol staProtocol;
+// switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl()))){
+// case CONVEYOR_INBOUND:
+// staProtocol = devpThread.getStation().get(Integer.parseInt(motion.getTarget()));
+// if (staProtocol == null) {
+// return false;
+// }
+// if (!staProtocol.isAutoing() || !staProtocol.isLoading() || !(staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9990)) {
+// return false;
+// }
+// if (!staProtocol.getWorkNo().equals(motion.getWrkNo().shortValue())) {
+// return false;
+// }
+// break;
+// case CONVEYOR_OUTBOUND:
+// // todo:luxiaotao 鍑哄簱鍒扮洰鏍囩珯鏄惁闇�瑕佽窡韪�
+//// staProtocol = devpThread.getStation().get(Integer.parseInt(motion.getTarget()));
+//// if (staProtocol == null) {
+//// return false;
+//// }
+//// if (!staProtocol.isAutoing() || !staProtocol.isLoading() || !(staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9990)) {
+//// return false;
+//// }
+//// if (!staProtocol.getWorkNo().equals(motion.getWrkNo().shortValue())) {
+//// return false;
+//// }
+// break;
+// case CONVEYOR_INBOUND_TO_LIFT:
+// // 鍒ゆ柇鎻愬崌鏈虹姸鎬�
+// SiemensLiftThread liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getDockNo()));
+// LiftProtocol liftProtocol = liftThread.getLiftProtocol();
+// if (null == liftProtocol) {
+// return false;
+// }
+//
+// DevpSlave.Sta inSta = devpThread.getSlave().queryInSta(Integer.parseInt(motion.getOrigin()));
+// if (!(liftProtocol.getMode()
+// || liftProtocol.getReady()
+// || !liftProtocol.getRunning()
+// || liftProtocol.getLev() != Short.parseShort(motion.getTarget()))) {
+// return false;
+// }
+//
+// //璐х墿宸茬粡杩涘叆鎻愬崌鏈�
+// if (!(liftProtocol.getLineFrontHasStock() && liftProtocol.getLineEndHasStock())) {
+// return false;
+// }
+//
+// //娓呯┖鎻愬崌鏈哄伐浣滃彿
+// if (liftProtocol.getTaskNo().intValue() == motion.getWrkNo()) {
+// liftThread.setTaskNo(0);
+// }
+//
+// // 鍒ゆ柇杈撻�佺嚎鐘舵��
+// int originSta = Integer.parseInt(motion.getOrigin());
+// if (originSta == 6) {
+// originSta = 7;
+// }
+// staProtocol = devpThread.getStation().get(originSta);
+//
+// // 鍋滄杈撻�佺嚎鐢垫満
+// int times = 0;boolean staProtocolMotorRes = false;
+// while (times < 5) {
+// if (staProtocol.getStaMotorType().equals(StaMotorType.STANDBY)) {
+// staProtocolMotorRes = true;
+// break;
+// }
+// if (!devpThread.controlMotor(originSta, StaMotorType.REQ_STOP)) {
+// continue;
+// }
+// try {
+// Thread.sleep(500);
+// } catch (InterruptedException ignore) {}
+// times++;
+// }
+// if (!staProtocolMotorRes) {
+// return false;
+// }
+//
+// break;
+// default:
+// break;
+// }
+
+ return true;
+ }
+
+}
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java
index 7b1ce95..362443f 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/timer/MotionTimer.java
@@ -2,10 +2,7 @@
import com.zy.asrs.framework.exception.CoolException;
import com.zy.asrs.wcs.core.entity.Task;
-import com.zy.asrs.wcs.core.kernel.command.AgvCommandService;
-import com.zy.asrs.wcs.core.kernel.command.CraneCommandService;
-import com.zy.asrs.wcs.core.kernel.command.LiftCommandService;
-import com.zy.asrs.wcs.core.kernel.command.ShuttleCommandService;
+import com.zy.asrs.wcs.core.kernel.command.*;
import com.zy.asrs.wcs.core.model.enums.DeviceCtgType;
import com.zy.asrs.wcs.core.model.enums.MotionCtgType;
import com.zy.asrs.wcs.core.model.enums.MotionStsType;
@@ -35,8 +32,8 @@
private MotionService motionService;
@Autowired
private AgvCommandService agvCommandService;
-// @Autowired
-// private ConveyorCommandService conveyorCommandService;
+ @Autowired
+ private ConveyorCommandService conveyorCommandService;
@Autowired
private CraneCommandService craneCommandService;
@Autowired
diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ConveyorDispatcher.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ConveyorDispatcher.java
index 3b268b3..c59fc38 100644
--- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ConveyorDispatcher.java
+++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ConveyorDispatcher.java
@@ -1,18 +1,16 @@
-//package com.zy.asrs.wcs.core.utils;
-//
-//import com.zy.core.model.DevpSlave;
-//import com.zy.core.properties.SlaveProperties;
-//import lombok.extern.slf4j.Slf4j;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.stereotype.Service;
-//
-///**
-// * Created by vincent on 2023/10/20
-// */
-//@Slf4j
-//@Service
-//public class ConveyorDispatcher {
-//
+package com.zy.asrs.wcs.core.utils;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * Created by vincent on 2023/10/20
+ */
+@Slf4j
+@Service
+public class ConveyorDispatcher {
+
// @Autowired
// private SlaveProperties slaveProperties;
//
@@ -39,7 +37,5 @@
// }
// return null;
// }
-//
-//
-//
-//}
+
+}
--
Gitblit v1.9.1