From 44fa920bbcf6cd94c81f3a6d2f3008925a8635ca Mon Sep 17 00:00:00 2001 From: Junjie <fallin.jie@qq.com> Date: 星期四, 11 五月 2023 09:40:39 +0800 Subject: [PATCH] 四向穿梭车命令封装 --- src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java | 129 +++++++++--------------------------------- 1 files changed, 28 insertions(+), 101 deletions(-) diff --git a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java index ca20843..247c1eb 100644 --- a/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java +++ b/src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java @@ -708,18 +708,15 @@ if (wrkMast.getWrkSts() == 8 || Boolean.parseBoolean(searchIdleShuttle.get("sameLay").toString())) { //鍚屼竴灞傜洿鎺ュ彇璐ф棤闇�缁忚繃鎻愬崌鏈� //鐩存帴璁$畻杞﹀埌鎻愬崌鏈哄彇璐у啀鍒板簱浣嶈矾寰勬寚浠� - List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, locNo, assignCommand); + List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, locNo, assignCommand,shuttleThread); if (wrkMast.getWrkSts() == 8) { //姝ゆ椂杞﹀湪鎻愬崌鏈哄唴閮紝闇�瑕佸涓嬭揪涓�姝ユ寚浠よ杞︾Щ鍔ㄥ埌鎻愬崌鏈哄彛 BasDevp basDevp = basDevpService.selectById(109);//鑾峰彇鎻愬崌鏈轰俊鎭� - ShuttleCommand moveCommand = new ShuttleCommand(); - moveCommand.setCommandWord((short) 1); - moveCommand.setStartCodeNum(Short.parseShort(basDevp.getQrCodeValue()));//鎻愬崌鏈哄唴閮ㄤ簩缁寸爜 - moveCommand.setDistCodeNum(commands.get(0).getStartCodeNum());//鎻愬崌鏈哄彛浜岀淮鐮� - moveCommand.setStartToDistDistance(1300); - moveCommand.setMiddleToDistDistance(0); - moveCommand.setRunDirection(commands.get(0).getRunDirection()); - moveCommand.setCommandEnd((short) 1); + short startCode = Short.parseShort(basDevp.getQrCodeValue());//鎻愬崌鏈哄唴閮ㄤ簩缁寸爜 + Short distCode = commands.get(0).getStartCodeNum();//鎻愬崌鏈哄彛浜岀淮鐮� + Short runDirection = commands.get(0).getRunDirection();//杩愯鏂瑰悜 + //鑾峰彇鍛戒护 + ShuttleCommand moveCommand = shuttleThread.getMoveCommand(startCode, distCode, 1300, runDirection); commands.add(0, moveCommand);//灏嗚鎸囦护娣诲姞鍒伴槦澶� } assignCommand.setCommands(commands); @@ -732,7 +729,7 @@ //涓嶅悓灞傦紝灏嗙洰鏍囧簱浣嶅垎閰嶆垚鎻愬崌鏈哄簱浣嶅彿 //灏忚溅绉诲姩鍒版彁鍗囨満鍙o紝璁$畻璺緞 - List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand); + List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand, shuttleThread); //鍒嗛厤鐩爣搴撲綅 shuttleProtocol.setLocNo(liftLocNo); //鐩爣搴撲綅 @@ -756,7 +753,7 @@ } //鑾峰彇璧风偣-缁堢偣鎸囦护銆俶apType锛�1=銆嬫棤璐у湴鍥撅紝2=銆嬫湁璐у湴鍥� - public synchronized List<ShuttleCommand> shuttleAssignCommand(String startLocNo, String locNo, Integer mapType, ShuttleAssignCommand assignCommand) { + public synchronized List<ShuttleCommand> shuttleAssignCommand(String startLocNo, String locNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { //璁$畻灏忚溅璧风偣鍒颁腑鐐规墍闇�鍛戒护 List<NavigateNode> calc = NavigateUtils.calc(startLocNo, locNo, mapType); List<ShuttleCommand> commands = new ArrayList<>(); @@ -776,29 +773,12 @@ //鐩爣璺緞 NavigateNode endPath = nodes.get(nodes.size() - 1); Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂� - - ShuttleCommand command = new ShuttleCommand(); - command.setCommandWord((short) 1); - //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮� Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ()); - command.setStartCodeNum(startCodeNum); - - command.setMiddleCodeNum((short) 1); - //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮� Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); - command.setDistCodeNum(distCodeNum); - - command.setStartToDistDistance(allDistance); - command.setMiddleToDistDistance(0); - command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id); - command.setPalletLift((short) 1); - command.setForceMoveDistance(0); - command.setChargeSwitch((short) 2); - command.setIOControl((short) 0); - command.setRadarTmp((short) 0); - command.setCommandEnd((short) 1); + //鑾峰彇绉诲姩鍛戒护 + ShuttleCommand command = shuttleThread.getMoveCommand(startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id); commands.add(command); } @@ -811,7 +791,7 @@ } //鑾峰彇璧风偣-涓偣-缁堢偣鎸囦护 - public synchronized List<ShuttleCommand> shuttleAssignCommand(String startLocNo, String middleLocNo, String locNo, ShuttleAssignCommand assignCommand) { + public synchronized List<ShuttleCommand> shuttleAssignCommand(String startLocNo, String middleLocNo, String locNo, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { //璁$畻灏忚溅璧风偣鍒颁腑鐐规墍闇�鍛戒护 List<NavigateNode> calc = NavigateUtils.calc(startLocNo, middleLocNo, 1);//灏忚溅鏃犺揣锛岃蛋鍏ュ簱鍦板浘 List<ShuttleCommand> commands = new ArrayList<>(); @@ -832,37 +812,17 @@ NavigateNode endPath = nodes.get(nodes.size() - 1); Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂� - ShuttleCommand command = new ShuttleCommand(); - command.setCommandWord((short) 1); - //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮� Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ()); - command.setStartCodeNum(startCodeNum); - - command.setMiddleCodeNum((short) 1); - //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮� Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); - command.setDistCodeNum(distCodeNum); - - command.setStartToDistDistance(allDistance); - command.setMiddleToDistDistance(0); - command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id); - command.setPalletLift((short) 1); - command.setForceMoveDistance(0); - command.setChargeSwitch((short) 2); - command.setIOControl((short) 0); - command.setRadarTmp((short) 0); - command.setCommandEnd((short) 1); + //鑾峰彇绉诲姩鍛戒护 + ShuttleCommand command = shuttleThread.getMoveCommand(startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id); commands.add(command); } //灏忚溅鎸囦护鍒拌揪鐩爣浣嶇疆鍚庯紝鍐嶅彂鍑轰竴鏉¢《鍗囨寚浠� - ShuttleCommand command = new ShuttleCommand(); - command.setCommandWord((short) 2); - command.setPalletLift((short) 1); - command.setCommandEnd((short) 1); - commands.add(command); + commands.add(shuttleThread.getPalletCommand((short) 1)); //璁$畻灏忚溅涓偣鍒扮粓鐐规墍闇�鍛戒护 List<NavigateNode> calc2 = NavigateUtils.calc(middleLocNo, locNo, 2);//灏忚溅鏈夎揣锛岃蛋鍑哄簱鍦板浘(鍑哄簱鍦板浘鏈変笓鐢ㄨ揣閬�) @@ -881,37 +841,16 @@ NavigateNode endPath = nodes.get(nodes.size() - 1); Integer allDistance = NavigateUtils.getCurrentPathAllDistance(nodes);//璁$畻褰撳墠璺緞琛岃蛋鎬昏窛绂� - command = new ShuttleCommand(); - command.setCommandWord((short) 1); - //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮� Short startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ()); - command.setStartCodeNum(startCodeNum); - - command.setMiddleCodeNum((short) 1); - //閫氳繃xy鍧愭爣灏忚溅浜岀淮鐮� Short distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); - command.setDistCodeNum(distCodeNum); - - command.setStartToDistDistance(allDistance); - command.setMiddleToDistDistance(0); - command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id); - command.setPalletLift((short) 1); - command.setForceMoveDistance(0); - command.setChargeSwitch((short) 2); - command.setIOControl((short) 0); - command.setRadarTmp((short) 0); - command.setCommandEnd((short) 1); - commands.add(command); + ShuttleCommand moveCommand = shuttleThread.getMoveCommand(startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id); + commands.add(moveCommand); } //灏忚溅鎸囦护鍒拌揪鐩爣浣嶇疆鍚庯紝鍐嶅彂鍑轰竴鏉℃墭鐩樹笅闄嶆寚浠� - command = new ShuttleCommand(); - command.setCommandWord((short) 2); - command.setPalletLift((short) 2); - command.setCommandEnd((short) 1); - commands.add(command); + commands.add(shuttleThread.getPalletCommand((short) 2)); assignCommand.setNodes(allNode);//褰撳墠浠诲姟鎵�鍗犵敤鐨勮妭鐐筶ist //鎵�浣跨敤鐨勮矾寰勮繘琛岄攣瀹氱鐢� @@ -1001,7 +940,7 @@ if (Boolean.parseBoolean(searchIdleShuttle.get("sameLay").toString())) { //鍚屼竴灞�(灏嗗皬杞︾Щ鍔ㄥ埌璐х墿浣嶇疆) - List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, wrkMast.getSourceLocNo(), liftLocNo, assignCommand); + List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, wrkMast.getSourceLocNo(), liftLocNo, assignCommand, shuttleThread); //鍒嗛厤鐩爣搴撲綅 shuttleProtocol.setLocNo(wrkMast.getSourceLocNo()); //鐩爣搴撲綅 @@ -1012,7 +951,7 @@ //涓嶅悓灞傦紝灏嗙洰鏍囧簱浣嶅垎閰嶆垚鎻愬崌鏈哄簱浣嶅彿(灏嗗皬杞︾Щ鍔ㄥ埌鎻愬崌鏈轰綅缃�) //灏忚溅鍒版彁鍗囨満鍙f寚浠� - List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand); + List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand, shuttleThread); shuttleProtocol.setLocNo(liftLocNo); //鐩爣搴撲綅 assignCommand.setLocNo(liftLocNo); @@ -1020,17 +959,13 @@ wrkMast.setWrkSts(22L);//灏忚溅杩佺Щ鐘舵�� } } else if (wrkMast.getWrkSts() == 25) { - List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, wrkMast.getSourceLocNo(), liftLocNo, assignCommand); + List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, wrkMast.getSourceLocNo(), liftLocNo, assignCommand, shuttleThread); //姝ゆ椂杞﹀湪鎻愬崌鏈哄唴閮紝闇�瑕佸涓嬭揪涓�姝ユ寚浠よ杞︾Щ鍔ㄥ埌鎻愬崌鏈哄彛 BasDevp basDevp = basDevpService.selectById(109);//鑾峰彇鎻愬崌鏈轰俊鎭� - ShuttleCommand moveCommand = new ShuttleCommand(); - moveCommand.setCommandWord((short) 1);//灏忚溅绉诲姩鎸囦护瀛� - moveCommand.setStartCodeNum(Short.parseShort(basDevp.getQrCodeValue()));//鎻愬崌鏈轰簩缁寸爜 - moveCommand.setDistCodeNum(commands.get(0).getStartCodeNum()); - moveCommand.setStartToDistDistance(1300); - moveCommand.setMiddleToDistDistance(0); - moveCommand.setRunDirection(commands.get(0).getRunDirection()); - moveCommand.setCommandEnd((short) 1); + short startCode = Short.parseShort(basDevp.getQrCodeValue());//鎻愬崌鏈轰簩缁寸爜 + Short distCode = commands.get(0).getStartCodeNum();//鐩爣浜岀淮鐮� + //鑾峰彇绉诲姩鍛戒护 + ShuttleCommand moveCommand = shuttleThread.getMoveCommand(startCode, distCode, 1300, commands.get(0).getRunDirection()); commands.add(0, moveCommand);//灏嗚鎸囦护娣诲姞鍒伴槦澶� //鍒嗛厤鐩爣搴撲綅 @@ -2261,7 +2196,7 @@ ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); //鑾峰彇灏忚溅鍒板厖鐢靛簱浣嶈矾寰勬寚浠� - List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, chargeLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand); + List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, chargeLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand, shuttleThread); //杩涜鍏呯數涓� shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.CHARGING); @@ -2271,11 +2206,7 @@ assignCommand.setCharge(true);//鍏呯數浠诲姟 //鍒涘缓鍏呯數鎸囦护 - ShuttleCommand command = new ShuttleCommand(); - command.setCommandWord((short) 5);//鍏呯數 - command.setShuttleNo(shuttleProtocol.getShuttleNo()); - command.setChargeSwitch((short) 1);//寮�濮嬪厖鐢� - command.setCommandEnd((short) 1); + ShuttleCommand command = shuttleThread.getChargeSwitchCommand((short) 1);//寮�濮嬪厖鐢� commands.add(command); //鎸囦护闆嗗垎閰� @@ -2292,7 +2223,7 @@ ShuttleAssignCommand assignCommand = new ShuttleAssignCommand(); //灏忚溅绉诲姩鍒版彁鍗囨満鍙o紝璁$畻璺緞 - List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand); + List<ShuttleCommand> commands = this.shuttleAssignCommand(currentLocNo, liftLocNo, ShuttleTaskModeType.PAK_IN.id, assignCommand, shuttleThread); //鍒嗛厤鐩爣搴撲綅 shuttleProtocol.setLocNo(liftLocNo); @@ -2404,11 +2335,7 @@ assignCommand.setCharge(true); //鍒涘缓鍏呯數鎸囦护 - ShuttleCommand command = new ShuttleCommand(); - command.setCommandWord((short) 5);//鍏呯數 - command.setShuttleNo(shuttleProtocol.getShuttleNo()); - command.setChargeSwitch((short) 2);//鏂紑鍏呯數 - command.setCommandEnd((short) 1); + ShuttleCommand command = shuttleThread.getChargeSwitchCommand((short) 2);//鏂紑鍏呯數 commands.add(command); //鎸囦护闆嗗垎閰� -- Gitblit v1.9.1