| | |
| | | Optional<OsdSubDeviceReceiver> deviceOpt = SpringBeanUtils.getBean(IDeviceRedisService.class) |
| | | .getDeviceOsd(deviceSn, OsdSubDeviceReceiver.class); |
| | | if (deviceOpt.isEmpty()) { |
| | | throw new RuntimeException("The device is offline."); |
| | | throw new RuntimeException("设备离线"); |
| | | } |
| | | osdCamera = deviceOpt.get().getCameras().stream() |
| | | .filter(osdCamera -> param.getPayloadIndex().equals(osdCamera.getPayloadIndex())) |
| | | .findAny() |
| | | .orElseThrow(() -> new RuntimeException("Did not receive osd information about the camera, please check the cache data.")); |
| | | .orElseThrow(() -> new RuntimeException("没有收到相机osd信息,请检查缓存数据")); |
| | | return true; |
| | | } |
| | | |
| | | private String checkDockOnline(String dockSn) { |
| | | Optional<DeviceDTO> deviceOpt = SpringBeanUtils.getBean(IDeviceRedisService.class).getDeviceOnline(dockSn); |
| | | if (deviceOpt.isEmpty()) { |
| | | throw new RuntimeException("The dock is offline."); |
| | | throw new RuntimeException("设备离线"); |
| | | } |
| | | return deviceOpt.get().getChildDeviceSn(); |
| | | } |
| | |
| | | private void checkDeviceOnline(String deviceSn) { |
| | | boolean isOnline = SpringBeanUtils.getBean(IDeviceRedisService.class).checkDeviceOnline(deviceSn); |
| | | if (!isOnline) { |
| | | throw new RuntimeException("The device is offline."); |
| | | throw new RuntimeException("设备离线"); |
| | | } |
| | | } |
| | | |
| | |
| | | boolean hasAuthority = SpringBeanUtils.getBean(IDevicePayloadService.class) |
| | | .checkAuthorityPayload(deviceSn, param.getPayloadIndex()); |
| | | if (!hasAuthority) { |
| | | throw new RuntimeException("The device does not have payload control authority."); |
| | | throw new RuntimeException("设备没有有效载荷控制权限"); |
| | | } |
| | | } |
| | | |
| | | public final void checkCondition(String dockSn) { |
| | | if (!valid()) { |
| | | throw new RuntimeException("illegal argument"); |
| | | throw new RuntimeException("非法参数"); |
| | | } |
| | | |
| | | String deviceSn = checkDockOnline(dockSn); |
| | |
| | | checkAuthority(deviceSn); |
| | | |
| | | if (!canPublish(deviceSn)) { |
| | | throw new RuntimeException("The current state of the drone does not support this function, please try again later."); |
| | | throw new RuntimeException("无人机当前状态不支持此功能,请稍后再试"); |
| | | } |
| | | } |
| | | |