| | |
| | | import com.zy.core.ThreadHandler; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.enums.ShuttleRunDirection; |
| | | import com.zy.core.enums.ShuttleStatusType; |
| | | import com.zy.core.enums.ShuttleTaskModeType; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.ShuttleSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.ShuttleAssignCommand; |
| | |
| | | if (null == shuttleProtocol) { |
| | | shuttleProtocol = new ShuttleProtocol(); |
| | | shuttleProtocol.setShuttleNo(slave.getId().shortValue()); |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | | } |
| | | |
| | | //----------读取四向穿梭车状态----------- |
| | |
| | | } |
| | | |
| | | //分配任务 |
| | | 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("未能找到运行路径"); |
| | | } |
| | | } |
| | | |
| | | //工作号 |
| | |
| | | Object o1 = pathList.get(commandStep); |
| | | ArrayList path = JSON.parseObject(o1.toString(), ArrayList.class); |
| | | |
| | | size = path.size(); |
| | | size = Integer.parseInt(map.get("pathSize").toString()); |
| | | //开始路径 |
| | | JSONObject startPath = JSON.parseObject(path.get(0).toString()); |
| | | //目标路径 |
| | | JSONObject endPath = JSON.parseObject(path.get(size - 1).toString()); |
| | | JSONObject endPath = JSON.parseObject(path.get(path.size() - 1).toString()); |
| | | |
| | | command.setCommandWord((short) 1); |
| | | command.setStartCodeNum(NavigatePositionConvert.xyToPosition(startPath.getIntValue("x"), startPath.getIntValue("y"))); |
| | |
| | | command.setRunDirection((short) (assignCommand.getTaskMode() - 4)); |
| | | command.setCommandEnd((short) 1); |
| | | break; |
| | | case 9://状态复位 |
| | | command.setCommandWord((short) 0); |
| | | //设置四向穿梭车为空闲状态 |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | | //任务号清零 |
| | | shuttleProtocol.setTaskNo((short) 0); |
| | | break; |
| | | default: |
| | | } |
| | | |
| | | command.setCommandEnd((short) 1); |
| | |
| | | shuttleProtocol.setPakMk(false); |
| | | |
| | | //判断数据是否执行完成 |
| | | if (commandStep < size) { |
| | | if (commandStep < size - 1) { |
| | | //更新redis数据 |
| | | //步序增加 |
| | | commandStep++; |
| | |
| | | } |
| | | //删除redis |
| | | redisUtil.del("wrk_no_" + map.get("wrk_no").toString()); |
| | | |
| | | //对主线程抛出等待确认状态waiting |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.WAITING); |
| | | |
| | | News.info("四向穿梭车任务执行完成等待确认中,穿梭车号={},任务数据={}", shuttleProtocol.getShuttleNo(), JSON.toJSON(command)); |
| | | } |
| | | |
| | | } |