From dd3fb4ab39ede8427e3f106fc5c654ea6562365c Mon Sep 17 00:00:00 2001 From: Junjie <xjj@123> Date: 星期六, 13 四月 2024 11:40:08 +0800 Subject: [PATCH] # --- zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java | 465 +++++++++++++++++++-------------------------------------- 1 files changed, 155 insertions(+), 310 deletions(-) diff --git a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java index 4851e47..f15d1ae 100644 --- a/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java +++ b/zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/ShuttleCommandService.java @@ -1,9 +1,12 @@ package com.zy.asrs.wcs.core.kernel.command; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.zy.asrs.framework.common.Cools; import com.zy.asrs.framework.exception.CoolException; +import com.zy.asrs.wcs.core.action.LiftAction; import com.zy.asrs.wcs.core.action.ShuttleAction; +import com.zy.asrs.wcs.core.entity.BasShuttle; import com.zy.asrs.wcs.core.entity.Loc; import com.zy.asrs.wcs.core.model.NavigateNode; import com.zy.asrs.wcs.core.model.command.ShuttleAssignCommand; @@ -18,17 +21,16 @@ import com.zy.asrs.wcs.core.entity.Motion; import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; import com.zy.asrs.wcs.rcs.model.enums.SlaveType; +import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; import com.zy.asrs.wcs.core.service.MotionService; +import com.zy.asrs.wcs.rcs.thread.LiftThread; import com.zy.asrs.wcs.rcs.thread.ShuttleThread; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Optional; +import java.util.*; /** * Created by vincent on 2023/10/23 @@ -53,19 +55,21 @@ private NavigateMapUtils navigateMapUtils; @Autowired private ShuttleAction shuttleAction; + @Autowired + private LiftAction liftAction; // 璁$畻 public Boolean accept(Motion motion) { Integer deviceNo = Integer.parseInt(motion.getDevice()); ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, deviceNo); + if (shuttleThread == null) { + return false; + } ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); if (null == shuttleProtocol) { return false; } - if (!shuttleProtocol.getIdle()) {//璁惧涓嶇┖闂� - return false; - } - if (!shuttleProtocol.getPakMk()) { + if (!shuttleThread.isIdle()) {//璁惧涓嶇┖闂� return false; } if (motionService.count(new LambdaQueryWrapper<Motion>() @@ -76,68 +80,103 @@ } ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); - assignCommand.setShuttleNo(deviceNo.shortValue()); - assignCommand.setTaskNo(motion.getWrkNo().shortValue()); + assignCommand.setShuttleNo(deviceNo); + assignCommand.setTaskNo(motion.getWrkNo()); assignCommand.setSourceLocNo(motion.getOrigin()); assignCommand.setLocNo(motion.getTarget()); + assignCommand.setDeviceId(Integer.parseInt(motion.getDevice())); List<ShuttleCommand> shuttleCommands = new ArrayList<>(); ShuttleTaskModeType shuttleTaskModeType = null; -// SiemensLiftThread liftThread = null; -// LiftProtocol liftProtocol = null; - - //鍒ゆ柇灏忚溅鐘舵�� - if (shuttleProtocol.getIdle() - && shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.IDLE) - && shuttleProtocol.getTaskNo() != 0 - ) { - return false; - } + LiftThread liftThread = null; + LiftProtocol liftProtocol = null; switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl()))){ case SHUTTLE_MOVE: // 濡傛灉宸茬粡鍦ㄥ綋鍓嶆潯鐮佸垯杩囨护 if (String.valueOf(shuttleProtocol.getCurrentCode()).equals(locService.getOne(new LambdaQueryWrapper<Loc>() .eq(Loc::getLocNo, motion.getTarget()) - .eq(Loc::getHostId, motion.getHostId())).getCode())) { + .eq(Loc::getHostId, motion.getHostId())).getCode())) { return true; } shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; break; -// case SHUTTLE_MOVE_LIFT_PALLET://绌挎杞﹂《鍗囧苟绉诲姩 -// shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); -// shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; -// shuttleCommands.add(0, shuttleThread.getPalletCommand((short) 1)); -// break; -// case SHUTTLE_MOVE_DOWN_PALLET://绌挎杞︾Щ鍔ㄥ苟鎵樼洏涓嬮檷 -// shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); -// shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; -// shuttleCommands.add(shuttleCommands.size(), shuttleThread.getPalletCommand((short) 2)); -// break; -// case SHUTTLE_MOVE_FROM_LIFT://鍑烘彁鍗囨満 -// // 鍒ゆ柇鎻愬崌鏈虹姸鎬� -// liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); -// if (liftThread == null) { -// return false; -// } -// liftProtocol = liftThread.getLiftProtocol(); -// // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佺┖闂层�佸噯澶囧氨缁�侀摼鏉℃病鏈夎浆鍔ㄣ�佹病鏈夋湭灏辩华鎶ラ敊 -// if (!liftProtocol.getMode() -// || liftProtocol.getRunning() -// || !liftProtocol.getReady() -// || liftProtocol.getForwardRotationFeedback() -// || liftProtocol.getReverseFeedback() -// || liftProtocol.getNotReady().intValue() != 0 -// ) { -// return false; -// } + case SHUTTLE_MOVE_LIFT_PALLET://绌挎杞﹂《鍗囧苟绉诲姩 + shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); + shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; + shuttleCommands.add(0, shuttleThread.getLiftCommand(motion.getWrkNo(), true)); + break; + case SHUTTLE_MOVE_DOWN_PALLET://绌挎杞︾Щ鍔ㄥ苟鎵樼洏涓嬮檷 + shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); + shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; + shuttleCommands.add(shuttleCommands.size(), shuttleThread.getLiftCommand(motion.getWrkNo(), false)); + break; + case SHUTTLE_MOVE_FROM_LIFT://鍑烘彁鍗囨満 + // 鍒ゆ柇鎻愬崌鏈虹姸鎬� + liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); + if (liftThread == null) { + return false; + } + + liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + return false; + } + + // 鍒ゆ柇鎻愬崌鏈烘槸鍚︾┖闂� + if (!liftThread.isIdle()) { + return false; + } + + if (liftProtocol.getLev() != Utils.getLev(motion.getTarget())) {//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁揪鍒扮洰鏍囧眰 + return false; + } + +// //鍒ゆ柇鎻愬崌鏈烘槸鍚﹁閿佸畾 +// if (!liftProtocol.getLock()) { +// //閿佸畾鎻愬崌鏈� +// LiftCommand lockCommand = liftThread.getLockCommand(motion.getWrkNo(), true);//鑾峰彇鎻愬崌鏈洪攣瀹氬懡浠� // -// if (liftProtocol.getLev().intValue() != Utils.getLev(motion.getTarget())) {//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁揪鍒扮洰鏍囧眰 -// return false; -// } +// LiftAssignCommand liftAssignCommand = new LiftAssignCommand(); +// liftAssignCommand.setLiftNo(liftThread.getStatus().getLiftNo()); +// liftAssignCommand.setTaskNo(motion.getWrkNo()); +// ArrayList<LiftCommand> list = new ArrayList<>(); +// list.add(lockCommand); +// liftAssignCommand.setCommands(list); // +// liftAction.assignWork(liftThread.getDevice(), liftAssignCommand); +// return false;//绛夊緟涓嬩竴娆¤疆璇� +// } + + //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚� + if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { + return false; + } + + shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); + shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; + break; + case SHUTTLE_MOVE_TO_LIFT://杩涙彁鍗囨満 + // 鍒ゆ柇鎻愬崌鏈虹姸鎬� + liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); + if (liftThread == null) { + return false; + } + liftProtocol = liftThread.getStatus(); + if (liftProtocol == null) { + return false; + } + // 鍒ゆ柇鎻愬崌鏈烘槸鍚︾┖闂� + if (!liftThread.isIdle()) { + return false; + } + + if (liftProtocol.getLev() != Utils.getLev(motion.getTarget())) {//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁揪鍒扮洰鏍囧眰 + return false; + } + // //鍒ゆ柇鎻愬崌鏈烘槸鍚﹁閿佸畾 // if (!liftProtocol.getLiftLock()) { // //閿佸畾鎻愬崌鏈� @@ -147,213 +186,33 @@ // liftThread.assignWork(lockCommand); // return false;//绛夊緟涓嬩竴娆¤疆璇� // } -// -// //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚� -// if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { -// return false; -// } -// -// shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); -// shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; -// break; -// case SHUTTLE_MOVE_TO_LIFT://杩涙彁鍗囨満 -// // 鍒ゆ柇鎻愬崌鏈虹姸鎬� -// liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); -// if (liftThread == null) { -// return false; -// } -// liftProtocol = liftThread.getLiftProtocol(); -// // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佺┖闂层�佸噯澶囧氨缁�侀摼鏉℃病鏈夎浆鍔ㄣ�佹病鏈夋湭灏辩华鎶ラ敊 -// if (!liftProtocol.getMode() -// || liftProtocol.getRunning() -// || !liftProtocol.getReady() -// || liftProtocol.getForwardRotationFeedback() -// || liftProtocol.getReverseFeedback() -// || liftProtocol.getNotReady().intValue() != 0 -// ) { -// return false; -// } -// -// if (liftProtocol.getLev().intValue() != Utils.getLev(motion.getTarget())) {//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁揪鍒扮洰鏍囧眰 -// return false; -// } -// -// //鍒ゆ柇鎻愬崌鏈烘槸鍚﹁閿佸畾 -// if (!liftProtocol.getLiftLock()) { -// //閿佸畾鎻愬崌鏈� -// LiftCommand lockCommand = liftThread.getLockCommand(true);//鑾峰彇鎻愬崌鏈洪攣瀹氬懡浠� -// lockCommand.setLiftNo(liftProtocol.getLiftNo()); -// lockCommand.setTaskNo(motion.getWrkNo().shortValue());//鑾峰彇浠诲姟鍙� -// liftThread.assignWork(lockCommand); -// return false;//绛夊緟涓嬩竴娆¤疆璇� -// } -// -// //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚� -// if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { -// return false; -// } -// -// shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); -// shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; -// break; -// case SHUTTLE_MOVE_FROM_CONVEYOR: -// shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); -// shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; -// break; -// case SHUTTLE_MOVE_TO_CONVEYOR: -// shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); -// shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; -// break; -// case SHUTTLE_MOVE_FROM_LIFT_TO_CONVEYOR://绌挎杞﹀嚭鎻愬崌鏈哄幓杈撻�佺嚎 -// // 鍒ゆ柇鎻愬崌鏈虹姸鎬� -// liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); -// if (liftThread == null) { -// return false; -// } -// liftProtocol = liftThread.getLiftProtocol(); -// // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佺┖闂层�佸噯澶囧氨缁�侀摼鏉℃病鏈夎浆鍔ㄣ�佹病鏈夋湭灏辩华鎶ラ敊 -// if (!liftProtocol.getMode() -// || liftProtocol.getRunning() -// || !liftProtocol.getReady() -// || liftProtocol.getForwardRotationFeedback() -// || liftProtocol.getReverseFeedback() -// || liftProtocol.getNotReady().intValue() != 0 -// ) { -// return false; -// } -// -// if (liftProtocol.getLev().intValue() != Utils.getLev(motion.getTarget())) {//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁揪鍒扮洰鏍囧眰 -// return false; -// } -// -// //鍒ゆ柇鎻愬崌鏈烘槸鍚﹁閿佸畾 -// if (!liftProtocol.getLiftLock()) { -// //閿佸畾鎻愬崌鏈� -// LiftCommand lockCommand = liftThread.getLockCommand(true);//鑾峰彇鎻愬崌鏈洪攣瀹氬懡浠� -// lockCommand.setLiftNo(liftProtocol.getLiftNo()); -// lockCommand.setTaskNo(motion.getWrkNo().shortValue());//鑾峰彇浠诲姟鍙� -// liftThread.assignWork(lockCommand); -// return false;//绛夊緟涓嬩竴娆¤疆璇� -// } -// -// //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚� -// if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { -// return false; -// } -// -// shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); -// shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; -// break; -// case SHUTTLE_TRANSPORT: -// shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); -// shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; -// -// shuttleCommands.add(0, shuttleThread.getPalletCommand((short) 1)); -// shuttleCommands.add(shuttleCommands.size(), shuttleThread.getPalletCommand((short) 2)); -// break; -// case SHUTTLE_TRANSPORT_FROM_LIFT://绌挎杞﹁浇璐у嚭鎻愬崌鏈� -// // 鍒ゆ柇鎻愬崌鏈虹姸鎬� -// liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); -// if (liftThread == null) { -// return false; -// } -// liftProtocol = liftThread.getLiftProtocol(); -// // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佺┖闂层�佸噯澶囧氨缁�侀摼鏉℃病鏈夎浆鍔ㄣ�佹病鏈夋湭灏辩华鎶ラ敊 -// if (!liftProtocol.getMode() -// || liftProtocol.getRunning() -// || !liftProtocol.getReady() -// || liftProtocol.getForwardRotationFeedback() -// || liftProtocol.getReverseFeedback() -// || liftProtocol.getNotReady().intValue() != 0 -// ) { -// return false; -// } -// -// if (liftProtocol.getLev().intValue() != Utils.getLev(motion.getTarget())) {//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁揪鍒扮洰鏍囧眰 -// return false; -// } -// -// //鍒ゆ柇鎻愬崌鏈烘槸鍚﹁閿佸畾 -// if (!liftProtocol.getLiftLock()) { -// //閿佸畾鎻愬崌鏈� -// LiftCommand lockCommand = liftThread.getLockCommand(true);//鑾峰彇鎻愬崌鏈洪攣瀹氬懡浠� -// lockCommand.setLiftNo(liftProtocol.getLiftNo()); -// lockCommand.setTaskNo(motion.getWrkNo().shortValue());//鑾峰彇浠诲姟鍙� -// liftThread.assignWork(lockCommand); -// return false;//绛夊緟涓嬩竴娆¤疆璇� -// } -// -// //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚� -// if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { -// return false; -// } -// -// shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); -// shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; -// shuttleCommands.add(0, shuttleThread.getPalletCommand((short) 1)); -//// shuttleCommands.add(shuttleCommands.size(), shuttleThread.getPalletCommand((short) 2)); -// break; -// case SHUTTLE_TRANSPORT_TO_LIFT://绌挎杞﹁浇璐ц繘鎻愬崌鏈� -// // 鍒ゆ柇鎻愬崌鏈虹姸鎬� -// liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); -// if (liftThread == null) { -// return false; -// } -// liftProtocol = liftThread.getLiftProtocol(); -// // 鍒ゆ柇鎻愬崌鏈烘槸鍚﹁嚜鍔ㄣ�佺┖闂层�佸噯澶囧氨缁�侀摼鏉℃病鏈夎浆鍔ㄣ�佹病鏈夋湭灏辩华鎶ラ敊 -// if (!liftProtocol.getMode() -// || liftProtocol.getRunning() -// || !liftProtocol.getReady() -// || liftProtocol.getForwardRotationFeedback() -// || liftProtocol.getReverseFeedback() -// || liftProtocol.getNotReady().intValue() != 0 -// ) { -// return false; -// } -// -// if (liftProtocol.getLev().intValue() != Utils.getLev(motion.getTarget())) {//鍒ゆ柇鎻愬崌鏈烘槸鍚﹁揪鍒扮洰鏍囧眰 -// return false; -// } -// -// //鍒ゆ柇鎻愬崌鏈烘槸鍚﹁閿佸畾 -// if (!liftProtocol.getLiftLock()) { -// //閿佸畾鎻愬崌鏈� -// LiftCommand lockCommand = liftThread.getLockCommand(true);//鑾峰彇鎻愬崌鏈洪攣瀹氬懡浠� -// lockCommand.setLiftNo(liftProtocol.getLiftNo()); -// lockCommand.setTaskNo(motion.getWrkNo().shortValue());//鑾峰彇浠诲姟鍙� -// liftThread.assignWork(lockCommand); -// return false;//绛夊緟涓嬩竴娆¤疆璇� -// } -// -// //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚� -// if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { -// return false; -// } -// -// shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); -// shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; -//// shuttleCommands.add(0, shuttleThread.getPalletCommand((short) 1)); -// shuttleCommands.add(shuttleCommands.size(), shuttleThread.getPalletCommand((short) 2)); -// break; -// case SHUTTLE_TRANSPORT_FROM_CONVEYOR: -// shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); -// shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; -// -// shuttleCommands.add(0, shuttleThread.getPalletCommand((short) 1)); -// shuttleCommands.add(shuttleCommands.size(), shuttleThread.getPalletCommand((short) 2)); -// break; -// case SHUTTLE_TRANSPORT_TO_CONVEYOR: -// shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); -// shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; -// -// shuttleCommands.add(0, shuttleThread.getPalletCommand((short) 1)); -// shuttleCommands.add(shuttleCommands.size(), shuttleThread.getPalletCommand((short) 2)); -// break; -// case SHUTTLE_CHARGE_ON: -// shuttleTaskModeType = ShuttleTaskModeType.CHARGE; -// shuttleCommands.add(shuttleThread.getChargeSwitchCommand((short) 1)); -// assignCommand.setCharge(Boolean.TRUE); -// break; + + //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚� + if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { + return false; + } + + shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); + shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; + break; + case SHUTTLE_CHARGE_ON://鍏呯數寮� + shuttleTaskModeType = ShuttleTaskModeType.CHARGE; + shuttleCommands.add(shuttleThread.getChargeCommand(motion.getWrkNo(), true)); + assignCommand.setCharge(Boolean.TRUE); + break; + case SHUTTLE_CHARGE_OFF://鍏呯數鍏� + shuttleTaskModeType = ShuttleTaskModeType.CHARGE; + shuttleCommands.add(shuttleThread.getChargeCommand(motion.getWrkNo(), false)); + assignCommand.setCharge(Boolean.TRUE); + break; + case SHUTTLE_PALLET_LIFT://鎵樼洏椤跺崌 + shuttleTaskModeType = ShuttleTaskModeType.PALLET_LIFT; + shuttleCommands.add(shuttleThread.getLiftCommand(motion.getWrkNo(), true)); + break; + case SHUTTLE_PALLET_DOWN://鎵樼洏涓嬮檷 + shuttleTaskModeType = ShuttleTaskModeType.PALLET_DOWN; + shuttleCommands.add(shuttleThread.getLiftCommand(motion.getWrkNo(), false)); + break; default: throw new CoolException(motion.getMotionCtgEl() + "娌℃湁鎸囧畾浠诲姟浣滀笟娴佺▼锛侊紒锛�"); } @@ -363,7 +222,7 @@ } assert null != shuttleTaskModeType; - assignCommand.setTaskMode(shuttleTaskModeType.id.shortValue());//鍏ュ嚭搴撴ā寮� + assignCommand.setTaskMode(shuttleTaskModeType.id);//鍏ュ嚭搴撴ā寮� assignCommand.setCommands(shuttleCommands); if (motion.getOrigin() != null && motion.getTarget() != null) { @@ -393,7 +252,7 @@ //鍏呯數浠诲姟 if (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl())).equals(MotionCtgType.SHUTTLE_CHARGE_ON)) { // 澶嶄綅绌挎杞� - shuttleProtocol.setTaskNo(0); + shuttleProtocol.setSyncTaskNo(0); shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); shuttleProtocol.setPakMk(true); return true; @@ -405,12 +264,13 @@ return false; } - if (!shuttleProtocol.getIdle()) { + //鍒ゆ柇璁惧鏄惁绌洪棽 + if (!shuttleThread.isIdle()) { return false; } -// SiemensLiftThread liftThread = null; -// LiftProtocol liftProtocol = null; + LiftThread liftThread = null; + LiftProtocol liftProtocol = null; switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl()))){ case SHUTTLE_MOVE: @@ -422,21 +282,21 @@ return false; } break; -// case SHUTTLE_MOVE_TO_LIFT: -// case SHUTTLE_MOVE_FROM_LIFT: -// case SHUTTLE_TRANSPORT_FROM_LIFT: -// case SHUTTLE_TRANSPORT_TO_LIFT: -// case SHUTTLE_MOVE_FROM_LIFT_TO_CONVEYOR: -// liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); -// if (liftThread == null) { -// return false; -// } -// liftProtocol = liftThread.getLiftProtocol(); -// -// if (!shuttleProtocol.getCurrentLocNo().equals(motion.getTarget())) { -// return false; -// } -// + case SHUTTLE_MOVE_TO_LIFT: + case SHUTTLE_MOVE_FROM_LIFT: + case SHUTTLE_TRANSPORT_FROM_LIFT: + case SHUTTLE_TRANSPORT_TO_LIFT: + case SHUTTLE_MOVE_FROM_LIFT_TO_CONVEYOR: + liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); + if (liftThread == null) { + return false; + } + liftProtocol = liftThread.getStatus(); + + if (!shuttleProtocol.getCurrentLocNo().equals(motion.getTarget())) { + return false; + } + // //鍒ゆ柇鎻愬崌鏈烘槸鍚﹁閿佸畾 // if (liftProtocol.getLiftLock()) { // //瑙i攣鎻愬崌鏈� @@ -446,24 +306,24 @@ // liftThread.assignWork(lockCommand); // return false; // } -// -// //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚� -// if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { -// return false; -// } -// -// if (liftProtocol.getTaskNo().intValue() != 0) { + + //鍒ゆ柇鎻愬崌鏈哄伐浣滃彿鏄惁鍜屽綋鍓嶄换鍔$浉鍚� + if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { + return false; + } + +// if (liftProtocol.getTaskNo() != 0) { // //娓呯┖鎻愬崌鏈哄彿 // liftThread.setTaskNo(0); // } -// -// break; + + break; default: break; } // 澶嶄綅绌挎杞� - shuttleProtocol.setTaskNo(0); + shuttleProtocol.setSyncTaskNo(0); shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); shuttleProtocol.setPakMk(true); @@ -472,14 +332,18 @@ public synchronized List<ShuttleCommand> shuttleAssignCommand(String startLocNo, String endLocNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { //鑾峰彇灏忚溅绉诲姩閫熷害 - Integer runSpeed = Optional.ofNullable(basShuttleService.getById(assignCommand.getShuttleNo()).getRunSpeed()).orElse(1000); + Integer runSpeed = Optional.ofNullable(basShuttleService.getOne(new LambdaQueryWrapper<BasShuttle>().eq(BasShuttle::getDeviceId, assignCommand.getDeviceId())).getRunSpeed()).orElse(1000); Long hostId = shuttleThread.getDevice().getHostId(); List<NavigateNode> nodeList = NavigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(Integer.parseInt(shuttleThread.getDevice().getDeviceNo()), Utils.getLev(startLocNo))); if (nodeList == null) { News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo); return null; } - List<NavigateNode> allNode = new ArrayList<>(nodeList); + + List<NavigateNode> allNode = new ArrayList<>(); + for (NavigateNode node : nodeList) { + allNode.add(node.clone()); + } List<ShuttleCommand> commands = new ArrayList<>(); //鑾峰彇鍒嗘璺緞 @@ -489,25 +353,6 @@ //寮�濮嬭矾寰� NavigateNode startPath = nodes.get(0); - //涓棿璺緞 - NavigateNode middlePath = null; - //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮� - String middleCodeNum = null; - Integer middleToDistDistance = null;//璁$畻涓棿鐐瑰埌鐩爣鐐硅璧拌窛绂� - if (nodes.size() > 10) {//涓鐮佷紶鍊掓暟绗笁涓� - //涓棿璺緞 - middlePath = nodes.get(nodes.size() - 3); - //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮� - middleCodeNum = NavigatePositionConvert.xyToPosition(middlePath.getX(), middlePath.getY(), middlePath.getZ(), hostId); - middleToDistDistance = NavigateUtils.getMiddleToDistDistance(nodes, middlePath);//璁$畻涓棿鐐瑰埌鐩爣鐐硅璧拌窛绂� - } else if (nodes.size() > 5) {//涓鐮佷紶鍊掓暟绗簩涓� - //涓棿璺緞 - middlePath = nodes.get(nodes.size() - 2); - //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮� - middleCodeNum = NavigatePositionConvert.xyToPosition(middlePath.getX(), middlePath.getY(), middlePath.getZ(), hostId); - middleToDistDistance = NavigateUtils.getMiddleToDistDistance(nodes, middlePath);//璁$畻涓棿鐐瑰埌鐩爣鐐硅璧拌窛绂� - } - //鐩爣璺緞 NavigateNode endPath = nodes.get(nodes.size() - 1); Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂� @@ -516,7 +361,7 @@ //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮� String distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ(), hostId); //鑾峰彇绉诲姩鍛戒护 - ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getTaskNo().intValue(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed); + ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed); command.setNodes(nodes);//灏嗚璧拌妭鐐规坊鍔犲埌姣忎竴姝ュ懡浠や腑 commands.add(command); } -- Gitblit v1.9.1