| | |
| | | LIFT_FLAG("lift_"), |
| | | |
| | | DUAL_CRN_COMMAND_("dual_crn_command_"), |
| | | DUAL_CRN_COMMAND_STATION_TASK_NO("dual_crn_command_station_task_no_"), |
| | | |
| | | QUEUE_CRN("queue_crn_"), |
| | | QUEUE_DUAL_CRN("queue_dual_crn_"), |
| | |
| | | CHECK_SHALLOW_LOC_STATUS_LIMIT("check_shallow_loc_status_limit_"), |
| | | GENERATE_ENABLE_IN_STATION_DATA_LIMIT("generate_enable_in_station_data_limit_"), |
| | | GENERATE_STATION_BACK_LIMIT("generate_station_back_limit_"), |
| | | STATION_EXECUTE_COMMAND_LOCK("station_execute_command_lock"), |
| | | |
| | | DUAL_CRN_PICK_WAIT_NEXT_TASK("dual_crn_pick_wait_next_task_"), |
| | | DUAL_CRN_OUT_TASK_STATION_INFO("dual_crn_out_task_station_info_"), |
| | |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.ThreadHandler; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import com.zy.core.model.CommandResponse; |
| | | import com.zy.core.model.command.StationCommand; |
| | | import com.zy.core.network.api.ZyStationConnectApi; |
| | |
| | | } |
| | | |
| | | public CommandResponse sendCommand(StationCommand command) { |
| | | return zyStationConnectApi.sendCommand(deviceConfig.getDeviceNo(), command); |
| | | while (true) { |
| | | Object lock = redisUtil.get(RedisKeyType.STATION_EXECUTE_COMMAND_LOCK.key); |
| | | if(lock != null) { |
| | | try { |
| | | Thread.sleep(500); |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | }else { |
| | | redisUtil.set(RedisKeyType.STATION_EXECUTE_COMMAND_LOCK.key, "lock", 60 * 5); |
| | | break; |
| | | } |
| | | } |
| | | CommandResponse commandResponse = zyStationConnectApi.sendCommand(deviceConfig.getDeviceNo(), command); |
| | | redisUtil.del(RedisKeyType.STATION_EXECUTE_COMMAND_LOCK.key); |
| | | return commandResponse; |
| | | } |
| | | |
| | | public CommandResponse sendOriginCommand(String address, short[] data) { |
| | |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.News; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import com.zy.core.enums.StationCommandType; |
| | | import com.zy.core.model.CommandResponse; |
| | | import com.zy.core.model.StationObjModel; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public CommandResponse sendOriginCommand(String address, short[] data) { |
| | | public synchronized CommandResponse sendOriginCommand(String address, short[] data) { |
| | | CommandResponse commandResponse = new CommandResponse(false); |
| | | if (null == data || data.length == 0) { |
| | | commandResponse.setMessage("数据为空"); |
| | |
| | | taskParam.setTaskPri(dto.getTaskPri()); |
| | | taskParam.setBarcode(barcode); |
| | | WrkMast wrkMast = commonService.createInTask(taskParam); |
| | | |
| | | StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO, |
| | | wrkMast.getWrkNo(), stationId, stationId, 0); |
| | | if (command == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败"); |
| | | continue; |
| | | } |
| | | MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command)); |
| | | stationProtocol.setSystemWarning(""); |
| | | } else { |
| | | // 接口返回非200,重新发起请求 |
| | |
| | | taskParam.setTaskPri(dto.getTaskPri()); |
| | | taskParam.setBarcode(barcode); |
| | | WrkMast wrkMast = commonService.createInTask(taskParam); |
| | | |
| | | StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO, |
| | | wrkMast.getWrkNo(), stationId, stationId, 0); |
| | | if (command == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败"); |
| | | continue; |
| | | } |
| | | MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command)); |
| | | stationProtocol.setSystemWarning(""); |
| | | } else { |
| | | // 接口返回非200,重新发起请求 |
| | |
| | | map.put("commands", commandList); |
| | | map.put("idx", 1); |
| | | redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + command.getTaskNo(), JSON.toJSONString(map, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24); |
| | | redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_STATION_TASK_NO.key + crnProtocol.getCrnNo() + "_" + command.getStation(), command.getTaskNo(), 60 * 60 * 24); |
| | | sendCommand(command); |
| | | } else if (step == 3) { |
| | | sendCommand((DualCrnCommand) task.getData()); |
| | |
| | | } |
| | | } |
| | | |
| | | if(crnProtocol.getTaskNo() > 0 && crnProtocol.getStatus().equals(DualCrnStatusType.FETCH_COMPLETE.id)) { |
| | | Integer taskNo = crnProtocol.getTaskNo(); |
| | | if(crnProtocol.getTaskNo() == 0 && crnProtocol.getStatus().equals(DualCrnStatusType.FETCH_COMPLETE.id)) { |
| | | Integer taskNo = null; |
| | | Object stationObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_STATION_TASK_NO.key + crnProtocol.getCrnNo() + "_" + 1); |
| | | if(stationObj != null) { |
| | | taskNo = Integer.parseInt(String.valueOf(stationObj)); |
| | | } |
| | | |
| | | if (taskNo == null) { |
| | | News.error("双工位堆垛机,工位1空闲等待下发命令,但未找到工作号。堆垛机号={}", crnProtocol.getCrnNo()); |
| | | continue; |
| | | } |
| | | |
| | | Object commandObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + taskNo); |
| | | if (commandObj == null) { |
| | | News.error("双工位堆垛机,工位1空闲等待下发命令,但未找到命令。堆垛机号={},工作号={}", crnProtocol.getCrnNo(), taskNo); |
| | |
| | | redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + taskNo, commandMap.toJSONString(), 60 * 60 * 24); |
| | | } |
| | | |
| | | if(crnProtocol.getTaskNoTwo() > 0 && crnProtocol.getStatusTwo() == DualCrnStatusType.IDLE.id) { |
| | | Integer taskNo = crnProtocol.getTaskNoTwo(); |
| | | if(crnProtocol.getTaskNoTwo() == 0 && crnProtocol.getStatusTwo().equals(DualCrnStatusType.FETCH_COMPLETE.id)) { |
| | | Integer taskNo = null; |
| | | Object stationObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_STATION_TASK_NO.key + crnProtocol.getCrnNo() + "_" + 2); |
| | | if(stationObj != null) { |
| | | taskNo = Integer.parseInt(String.valueOf(stationObj)); |
| | | } |
| | | |
| | | if (taskNo == null) { |
| | | News.error("双工位堆垛机,工位1空闲等待下发命令,但未找到工作号。堆垛机号={}", crnProtocol.getCrnNo()); |
| | | continue; |
| | | } |
| | | |
| | | Object commandObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + taskNo); |
| | | if (commandObj == null) { |
| | | News.error("双工位堆垛机,工位2空闲等待下发命令,但未找到命令。堆垛机号={},工作号={}", crnProtocol.getCrnNo(), taskNo); |
| | |
| | | |
| | | requestParam.put("barcode", barcode); |
| | | requestParam.put("sourceStaNo", stationNo); |
| | | requestParam.put("locType1", locType1); |
| | | requestParam.put("locType1", locType1 == null ? 1 : locType1); |
| | | requestParam.put("row", Utils.getInTaskEnableRow(sourceStaNo)); |
| | | |
| | | response = new HttpHandler.Builder() |