| | |
| | | import com.ard.common.utils.ByteUtils; |
| | | import com.ard.tianyu.aspect.annotation.CheckTakeoffAltitude; |
| | | import com.ard.tianyu.aspect.annotation.CheckControlRight; |
| | | import com.ard.tianyu.component.netty.command.BaseCmd; |
| | | import com.ard.tianyu.component.netty.command.camera.*; |
| | | import com.ard.tianyu.component.netty.command.manual.*; |
| | | import com.ard.tianyu.component.netty.command.register.*; |
| | | import com.ard.tianyu.component.netty.command.settings.*; |
| | | import com.ard.tianyu.component.netty.command.speaker.*; |
| | | import com.ard.tianyu.component.netty.command.wayline.*; |
| | | import com.ard.tianyu.config.TyConfiguration; |
| | | import com.ard.tianyu.domain.dto.camera.*; |
| | | import com.ard.tianyu.domain.dto.manual.*; |
| | | import com.ard.tianyu.domain.dto.speaker.*; |
| | | import com.ard.tianyu.domain.dto.wayline.*; |
| | | import com.ard.tianyu.domain.receiver.*; |
| | | import com.ard.tianyu.forest.TyClient; |
| | | import com.ard.tianyu.component.forest.TyClient; |
| | | import com.ard.tianyu.domain.cache.TyTcpServerCache; |
| | | import com.ard.tianyu.domain.cache.UavSignalInfoCache; |
| | | import com.ard.tianyu.domain.cache.UavStateCache; |
| | |
| | | import com.ard.tianyu.domain.dto.signal.SignalInfo; |
| | | import com.ard.tianyu.domain.dto.state.UavState; |
| | | import com.ard.tianyu.domain.dto.telemetry.TelemetryData; |
| | | import com.ard.tianyu.netty.command.*; |
| | | import com.ard.tianyu.netty.TyNettyTcpClient; |
| | | import com.ard.tianyu.netty.command.camera.*; |
| | | import com.ard.tianyu.netty.command.control.AbsAngleControlCmd; |
| | | import com.ard.tianyu.netty.command.control.AngleControlCmd; |
| | | import com.ard.tianyu.netty.command.control.SpeedControlCmd; |
| | | import com.ard.tianyu.netty.command.manual.*; |
| | | import com.ard.tianyu.netty.command.notice.BoxPowerStatusReplyCmd; |
| | | import com.ard.tianyu.netty.command.notice.FlyWayEndReplyCmd; |
| | | import com.ard.tianyu.netty.command.notice.UavReadyReplyCmd; |
| | | import com.ard.tianyu.netty.command.real.SignalInfoCmd; |
| | | import com.ard.tianyu.netty.command.real.UavStateCmd; |
| | | import com.ard.tianyu.netty.command.real.UavTelemetryDataCmd; |
| | | import com.ard.tianyu.netty.command.register.*; |
| | | import com.ard.tianyu.netty.command.settings.*; |
| | | import com.ard.tianyu.netty.command.speaker.*; |
| | | import com.ard.tianyu.netty.command.wayline.*; |
| | | import com.ard.tianyu.netty.handler.ErrorCodeEnum; |
| | | import com.ard.tianyu.netty.protobuf.TelemetryDataPB; |
| | | import com.ard.tianyu.component.netty.TyNettyTcpClient; |
| | | import com.ard.tianyu.component.netty.command.control.AbsAngleControlCmd; |
| | | import com.ard.tianyu.component.netty.command.control.AngleControlCmd; |
| | | import com.ard.tianyu.component.netty.command.control.SpeedControlCmd; |
| | | import com.ard.tianyu.component.netty.command.notice.BoxPowerStatusReplyCmd; |
| | | import com.ard.tianyu.component.netty.command.notice.FlyWayEndReplyCmd; |
| | | import com.ard.tianyu.component.netty.command.notice.UavReadyReplyCmd; |
| | | import com.ard.tianyu.component.netty.command.real.SignalInfoCmd; |
| | | import com.ard.tianyu.component.netty.command.real.UavStateCmd; |
| | | import com.ard.tianyu.component.netty.command.real.UavTelemetryDataCmd; |
| | | import com.ard.tianyu.component.netty.handler.ErrorCodeEnum; |
| | | import com.ard.tianyu.component.netty.protobuf.TelemetryDataPB; |
| | | import com.ard.tianyu.service.ITyService; |
| | | import com.ard.tianyu.websocket.domain.UavControlType; |
| | | import com.ard.vtdu.service.IMediaService; |
| | | import com.ard.tianyu.domain.message.UavControlType; |
| | | import io.netty.channel.Channel; |
| | | import io.netty.channel.ChannelFuture; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | @Resource |
| | | private TyConfiguration tyConfiguration; |
| | | |
| | | @Resource |
| | | private IMediaService mediaService; |
| | | |
| | | /** |
| | | * 获取天宇token信息 |
| | |
| | | public List<BoxInfoReceiver> getBoxList() { |
| | | //请求云盒列表 |
| | | try { |
| | | TyHttpCommonReceiver<List<BoxInfoReceiver>> boxListReveiver = tyClient.getBoxList(); |
| | | return boxListReveiver.getContent(); |
| | | TyHttpCommonReceiver<List<BoxInfoReceiver>> boxListReceiver = tyClient.getBoxList(); |
| | | return boxListReceiver.getContent(); |
| | | } catch (Exception e) { |
| | | log.error("获取云盒列表失败:{}", e.getMessage()); |
| | | return new ArrayList<>(); |
| | |
| | | */ |
| | | @Override |
| | | public Boolean capturePic(CapturePicDTO capturePicDto) { |
| | | //设置相机模式为拍照模式 |
| | | updateCameraMode(CameraModeDTO.builder().boxSn(capturePicDto.getBoxSn()).actionParam((byte) 0x01).build()); |
| | | //设置拍照回传 |
| | | photoReturnToggle(PhotoReturnToggleDTO.builder().boxSn(capturePicDto.getBoxSn()).actionParam((byte) 0x01).build()); |
| | | |
| | | CapturePicCmd capturePicCommand = new CapturePicCmd(capturePicDto); |
| | | this.sendMessage(tyConfiguration.getIpPort(), capturePicCommand); |
| | | return true; |
| | |
| | | break; |
| | | case 0x02: |
| | | // 处理注册消息 |
| | | HeartbeatReplyCmd heartbeatReplyCmd = (HeartbeatReplyCmd) tyCommand; |
| | | logPrint("心跳消息", heartbeatReplyCmd.getTimestamp()); |
| | | HeartbeatReplyCmd heartbeatReplyCmd = (HeartbeatReplyCmd) tyCommand; |
| | | logPrint("心跳消息", heartbeatReplyCmd.getTimestamp()); |
| | | break; |
| | | case 0x03: |
| | | // 处理订阅消息 |
| | | break; |
| | | case 0x04: |
| | | // 处理取消订阅消息 |
| | | break; |
| | | case 0x09: |
| | | // 处理图片上传完成通知 |
| | | PicUploadCompletedReplyCmd picUploadCompletedReplyCmd = (PicUploadCompletedReplyCmd) tyCommand; |
| | | logPrint("图片上传完成", picUploadCompletedReplyCmd.getPicUrl()); |
| | | break; |
| | | case 0x0A: |
| | | // 处理云盒开关机通知消息 |
| | |
| | | // 处理无人机状态消息 |
| | | UavStateCmd uavStateCmd = (UavStateCmd) tyCommand; |
| | | UavStateCache.putUavState(uavStateCmd.getUavState()); |
| | | logPrint("无人机状态", uavStateCmd.getUavState().getBoxSn()); |
| | | // WebSocketUtil.sendMessageAll(uavStateCmd.getUavState()); |
| | | //logPrint("无人机状态", uavStateCmd.getUavState().getBoxSn()); |
| | | // WebSocketUtil.sendMessageAll(uavStateCmd.getUavState()); |
| | | break; |
| | | case (byte) 0xA9: |
| | | // 处理无人机遥测消息 |
| | | UavTelemetryDataCmd uavTelemetryDataCmd = (UavTelemetryDataCmd) tyCommand; |
| | | UavTelemetryDataCache.putUavTelemetryData(uavTelemetryDataCmd.getTelemetryData()); |
| | | logPrint("无人机遥测", uavTelemetryDataCmd.getTelemetryData().getBoxSn()); |
| | | //logPrint("无人机遥测", uavTelemetryDataCmd.getTelemetryData().getBoxSn()); |
| | | //WebSocketUtil.sendMessageAll(uavTelemetryDataCmd.getTelemetryData()); |
| | | break; |
| | | |
| | |
| | | // 处理无人机信道质量数据 |
| | | SignalInfoCmd signalInfoCmd = (SignalInfoCmd) tyCommand; |
| | | UavSignalInfoCache.putUavSignalInfoCache(signalInfoCmd.getSignalInfo()); |
| | | logPrint("无人机信道质量", signalInfoCmd.getSignalInfo().getBoxSn()); |
| | | //logPrint("无人机信道质量", signalInfoCmd.getSignalInfo().getBoxSn()); |
| | | break; |
| | | case (byte) 0xD1: |
| | | // 处理无人机 |
| | |
| | | //到达指点飞行位置回复 |
| | | if (tyCommand instanceof PointControlReachedReplyCmd) { |
| | | PointControlReachedReplyCmd pointControlReachedReplyCmd = (PointControlReachedReplyCmd) tyCommand; |
| | | logPrint("到达指点飞行位置", pointControlReachedReplyCmd.getResult(), pointControlReachedReplyCmd.getErrorCode()); |
| | | logPrint("到达指点飞行位置", pointControlReachedReplyCmd.getResult(), |
| | | pointControlReachedReplyCmd.getErrorCode()); |
| | | } |
| | | //紧急制动回复 |
| | | if (tyCommand instanceof EmergencyBrakeReplyCmd) { |
| | |
| | | //设置返航高度回复 |
| | | if (tyCommand instanceof ReturnHeightSettingReplyCmd) { |
| | | ReturnHeightSettingReplyCmd returnHeightSettingReplyCmd = (ReturnHeightSettingReplyCmd) tyCommand; |
| | | logPrint("设置返航高度", returnHeightSettingReplyCmd.getResult(), returnHeightSettingReplyCmd.getErrorCode()); |
| | | logPrint("设置返航高度", returnHeightSettingReplyCmd.getResult(), |
| | | returnHeightSettingReplyCmd.getErrorCode()); |
| | | } |
| | | //设置返航点回复 |
| | | if (tyCommand instanceof ReturnPointSettingReplyCmd) { |
| | | ReturnPointSettingReplyCmd returnPointSettingReplyCmd = (ReturnPointSettingReplyCmd) tyCommand; |
| | | logPrint("设置返航点", returnPointSettingReplyCmd.getResult(), returnPointSettingReplyCmd.getErrorCode()); |
| | | logPrint("设置返航点", returnPointSettingReplyCmd.getResult(), |
| | | returnPointSettingReplyCmd.getErrorCode()); |
| | | } |
| | | break; |
| | | case (byte) 0xD2: |
| | | //设置视频码流回复 |
| | | if (tyCommand instanceof VideoStreamSettingReplyCmd) { |
| | | VideoStreamSettingReplyCmd videoStreamSettingReplyCmd = (VideoStreamSettingReplyCmd) tyCommand; |
| | | logPrint("设置视频码流", videoStreamSettingReplyCmd.getResult(), videoStreamSettingReplyCmd.getErrorCode()); |
| | | logPrint("设置视频码流", videoStreamSettingReplyCmd.getResult(), |
| | | videoStreamSettingReplyCmd.getErrorCode()); |
| | | } |
| | | break; |
| | | default: |
| | |
| | | |
| | | //公共日志打印 |
| | | private void logPrint(String message, Object obj) { |
| | | log.debug("收到{}回复{}", message, obj); |
| | | log.warn("收到{}回复{}", message, obj); |
| | | } |
| | | |
| | | //公共日志打印 |