| | |
| | | import HslCommunication.Core.Types.OperateResultExOne; |
| | | import HslCommunication.ModBus.ModbusTcpNet; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.SpringUtils; |
| | | import com.core.exception.CoolException; |
| | |
| | | } |
| | | |
| | | //分配任务 |
| | | private void assignWork(ShuttleAssignCommand assignCommand) { |
| | | private void assignWork(ShuttleAssignCommand assignCommand) throws Exception { |
| | | //将此map存入redis中 |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | |
| | |
| | | ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(calc); |
| | | //路径数据 |
| | | map.put("path", data); |
| | | //路径次数 |
| | | map.put("pathSize", data.size()); |
| | | }else { |
| | | if (assignCommand.getTaskMode() == ShuttleTaskModeType.PAK_IN.id.shortValue() || assignCommand.getTaskMode() == ShuttleTaskModeType.PAK_OUT.id.shortValue()) { |
| | | //属于入库出库,必须要计算路径,则抛出异常 |
| | | throw new Exception("未能找到运行路径"); |
| | | } |
| | | } |
| | | |
| | | //四向穿梭车号 |
| | | map.put("shuttle_no", assignCommand.getShuttleNo()); |
| | | //工作号 |
| | | map.put("wrk_no", assignCommand.getTaskNo()); |
| | | //命令执行步序 |
| | |
| | | ArrayList pathList = JSON.parseObject(data.toString(), ArrayList.class); |
| | | //取第一条路径 |
| | | Object o1 = pathList.get(commandStep); |
| | | ArrayList path = JSON.parseObject(o1.toString(), ArrayList.class); |
| | | ArrayList objectPath = JSON.parseObject(o1.toString(), ArrayList.class); |
| | | ArrayList<NavigateNode> path = new ArrayList<>(); |
| | | for (Object o2 : objectPath) { |
| | | NavigateNode navigateNode = JSON.parseObject(o2.toString(), NavigateNode.class); |
| | | path.add(navigateNode); |
| | | } |
| | | Integer allDistance = NavigateUtils.getCurrentPathAllDistance(path);//计算当前路径行走总距离 |
| | | |
| | | size = path.size(); |
| | | size = Integer.parseInt(map.get("pathSize").toString()); |
| | | //开始路径 |
| | | JSONObject startPath = JSON.parseObject(path.get(0).toString()); |
| | | NavigateNode startPath = path.get(0); |
| | | //目标路径 |
| | | JSONObject endPath = JSON.parseObject(path.get(size - 1).toString()); |
| | | NavigateNode endPath = path.get(path.size() - 1); |
| | | |
| | | command.setCommandWord((short) 1); |
| | | command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getIntValue("x"), startPath.getIntValue("y"))); |
| | | command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY())); |
| | | command.setMiddleCodeNum((short) 0); |
| | | command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getIntValue("x"), endPath.getIntValue("y"))); |
| | | command.setStartToDistDistance(1000); |
| | | command.setDistCodeNum(NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY())); |
| | | command.setStartToDistDistance(allDistance); |
| | | command.setMiddleToDistDistance(1000); |
| | | command.setRunDirection(ShuttleRunDirection.get(startPath.get("direction").toString()).id); |
| | | command.setRunDirection(ShuttleRunDirection.get(startPath.getDirection()).id); |
| | | command.setPalletLift((short) 1); |
| | | command.setForceMoveDistance(1000); |
| | | command.setChargeSwitch((short) 2); |
| | |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | | //任务号清零 |
| | | shuttleProtocol.setTaskNo((short) 0); |
| | | //标记复位 |
| | | shuttleProtocol.setPakMk(true); |
| | | break; |
| | | default: |
| | | } |
| | |
| | | shuttleProtocol.setPakMk(false); |
| | | |
| | | //判断数据是否执行完成 |
| | | if (commandStep < size) { |
| | | if (commandStep < size - 1) { |
| | | //更新redis数据 |
| | | //步序增加 |
| | | commandStep++; |