From d9cea3d7757a8d580bb0574d419ba6dd9c2478e7 Mon Sep 17 00:00:00 2001
From: Junjie <540245094@qq.com>
Date: 星期五, 13 十二月 2024 15:11:50 +0800
Subject: [PATCH] #search shuttle
---
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ConveyorCommandService.java | 328 ++++++++----------------------------------------------
1 files changed, 48 insertions(+), 280 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
index 13fd2bd..181deb3 100644
--- 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
@@ -1,10 +1,17 @@
package com.zy.asrs.wcs.core.kernel.command;
import com.zy.asrs.wcs.core.entity.Motion;
+import com.zy.asrs.wcs.core.model.enums.MotionCtgType;
import com.zy.asrs.wcs.core.utils.ConveyorDispatcher;
+import com.zy.asrs.wcs.rcs.cache.SlaveConnection;
+import com.zy.asrs.wcs.rcs.model.enums.SlaveType;
+import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol;
+import com.zy.asrs.wcs.rcs.thread.DevpThread;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+
+import java.util.Objects;
/**
* Created by vincent on 2023/10/23
@@ -17,290 +24,51 @@
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;
-// }
+ Integer deviceNo = Integer.parseInt(motion.getDevice());
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, deviceNo);
+ if (devpThread == null) {
+ return false;
+ }
+
+ switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl()))){
+ // 杈撻�佺嚎鎸囦护涓嬪彂
+ case CONVEYOR_INBOUND://杈撻�佺嚎鍏ュ簱
+ break;
+ case CONVEYOR_INBOUND_TO_LIFT://杈撻�佺嚎鍏ュ簱鑷虫彁鍗囨満
+ break;
+ case CONVEYOR_OUTBOUND://杈撻�佺嚎鍑哄簱
+ StaProtocol staProtocol = devpThread.getStation().get(Integer.parseInt(motion.getOrigin()));
+ if (!(staProtocol.isAutoing() && staProtocol.isLoading())) {
+ return false;
+ }
+
+ boolean result = devpThread.writeWorkSta(Integer.parseInt(motion.getOrigin()), motion.getTaskNo().shortValue(), Short.parseShort(motion.getTarget()));
+ if (!result) {
+ return false;
+ }
+ break;
+ 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;
-// }
-
+ Integer deviceNo = Integer.parseInt(motion.getDevice());
+ DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, deviceNo);
+ if (devpThread == null) {
+ return false;
+ }
+ switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl()))){
+ case CONVEYOR_INBOUND:
+ break;
+ case CONVEYOR_OUTBOUND:
+ break;
+ case CONVEYOR_INBOUND_TO_LIFT:
+ break;
+ default:
+ break;
+ }
return true;
}
--
Gitblit v1.9.1