From 87cba28b3dc8389e1df61f3ba7d986b09fd89db0 Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: Sat, 02 Nov 2024 11:26:21 +0800
Subject: [PATCH] 增加:无人机设置接口

---
 ard-work/src/main/java/com/ard/tianyu/service/impl/TyServiceImpl.java |  113 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 107 insertions(+), 6 deletions(-)

diff --git a/ard-work/src/main/java/com/ard/tianyu/service/impl/TyServiceImpl.java b/ard-work/src/main/java/com/ard/tianyu/service/impl/TyServiceImpl.java
index 8132128..8c16ec9 100644
--- a/ard-work/src/main/java/com/ard/tianyu/service/impl/TyServiceImpl.java
+++ b/ard-work/src/main/java/com/ard/tianyu/service/impl/TyServiceImpl.java
@@ -19,12 +19,14 @@
 import com.ard.tianyu.model.dto.converter.UavTelemetryDataConverter;
 import com.ard.tianyu.model.dto.converter.wayline.PlanLineDataConverter;
 import com.ard.tianyu.model.dto.manual.*;
+import com.ard.tianyu.model.dto.settings.ReturnHeightSettingDTO;
+import com.ard.tianyu.model.dto.settings.ReturnPointSettingDTO;
+import com.ard.tianyu.model.dto.settings.VideoStreamSettingDTO;
 import com.ard.tianyu.model.dto.signal.SignalInfo;
 import com.ard.tianyu.model.dto.speaker.*;
 import com.ard.tianyu.model.dto.state.UavState;
 import com.ard.tianyu.model.dto.telemetry.TelemetryData;
-import com.ard.tianyu.model.dto.wayline.PlanLineData;
-import com.ard.tianyu.model.dto.wayline.WayLineUploadDTO;
+import com.ard.tianyu.model.dto.wayline.*;
 import com.ard.tianyu.model.receiver.*;
 import com.ard.tianyu.netty.command.*;
 import com.ard.tianyu.netty.TyNettyTcpClient;
@@ -40,9 +42,9 @@
 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.WayLineUploadCmd;
-import com.ard.tianyu.netty.command.wayline.WayLineUploadReplyCmd;
+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.service.ITyService;
@@ -148,6 +150,33 @@
     public Boolean updateBoxSettings(BoxSettingsDTO boxSettingsDTO) {
         TyHttpCommonReceiver<?> result = tyClient.updateBoxSettings(boxSettingsDTO, tyConfiguration.getAccessToken().convertFromDTO());
         return result.getState() == 1;
+    }
+
+    /**
+     * 设置返航高度
+     */
+    @Override
+    public void updateReturnHeight(ReturnHeightSettingDTO returnHeightSettingDTO) {
+        ReturnHeightSettingCmd returnHeightSettingCmd = new ReturnHeightSettingCmd(returnHeightSettingDTO);
+        this.sendMessage(tyConfiguration.getIpPort(), returnHeightSettingCmd);
+    }
+
+    /**
+     * 设置返航点
+     */
+    @Override
+    public void updateReturnPoint(ReturnPointSettingDTO returnPointSettingDTO) {
+        ReturnPointSettingCmd returnPointSettingCmd = new ReturnPointSettingCmd(returnPointSettingDTO);
+        this.sendMessage(tyConfiguration.getIpPort(), returnPointSettingCmd);
+    }
+
+    /**
+     * 设置视频码流
+     */
+    @Override
+    public void updateVideoStream(VideoStreamSettingDTO videoStreamSettingDTO) {
+        VideoStreamSettingCmd videoStreamSettingCmd = new VideoStreamSettingCmd(videoStreamSettingDTO);
+        this.sendMessage(tyConfiguration.getIpPort(), videoStreamSettingCmd);
     }
 
     /**
@@ -501,6 +530,42 @@
     }
 
     /**
+     * 航线开始
+     */
+    @Override
+    public void wayLineBegin(WayLineBeginDTO wayLineBeginDTO) {
+        WayLineBeginCmd wayLineBeginCmd = new WayLineBeginCmd(wayLineBeginDTO);
+        this.sendMessage(tyConfiguration.getIpPort(), wayLineBeginCmd);
+    }
+
+    /**
+     * 航线暂停
+     */
+    @Override
+    public void wayLinePause(WayLinePauseDTO wayLinePauseDTO) {
+        WayLinePauseCmd wayLinePauseCmd = new WayLinePauseCmd(wayLinePauseDTO);
+        this.sendMessage(tyConfiguration.getIpPort(), wayLinePauseCmd);
+    }
+
+    /**
+     * 航线恢复
+     */
+    @Override
+    public void wayLineResume(WayLineResumeDTO wayLineResumeDTO) {
+        WayLineResumeCmd wayLineResumeCmd = new WayLineResumeCmd(wayLineResumeDTO);
+        this.sendMessage(tyConfiguration.getIpPort(), wayLineResumeCmd);
+    }
+
+    /**
+     * 航线结束
+     */
+    @Override
+    public void wayLineEnd(WayLineEndDTO wayLineEndDTO) {
+        WayLineEndCmd wayLineEndCmd = new WayLineEndCmd(wayLineEndDTO);
+        this.sendMessage(tyConfiguration.getIpPort(), wayLineEndCmd);
+    }
+
+    /**
      * 处理天宇服务器返回的消息
      */
     @Override
@@ -650,6 +715,43 @@
                     WayLineUploadReplyCmd wayLineUploadReplyCmd = (WayLineUploadReplyCmd) tyCommand;
                     logPrint("上传航线", wayLineUploadReplyCmd.getResult(), wayLineUploadReplyCmd.getErrorCode());
                 }
+                //开始航线回复
+                if (tyCommand instanceof WayLineBeginReplyCmd) {
+                    WayLineBeginReplyCmd wayLineBeginReplyCmd = (WayLineBeginReplyCmd) tyCommand;
+                    logPrint("开始航线", wayLineBeginReplyCmd.getResult(), wayLineBeginReplyCmd.getErrorCode());
+                }
+                //暂停航线回复
+                if (tyCommand instanceof WayLinePauseReplyCmd) {
+                    WayLinePauseReplyCmd wayLinePauseReplyCmd = (WayLinePauseReplyCmd) tyCommand;
+                    logPrint("暂停航线", wayLinePauseReplyCmd.getResult(), wayLinePauseReplyCmd.getErrorCode());
+                }
+                //恢复航线回复
+                if (tyCommand instanceof WayLineResumeReplyCmd) {
+                    WayLineResumeReplyCmd wayLineResumeReplyCmd = (WayLineResumeReplyCmd) tyCommand;
+                    logPrint("恢复航线", wayLineResumeReplyCmd.getResult(), wayLineResumeReplyCmd.getErrorCode());
+                }
+                //结束航线回复
+                if (tyCommand instanceof WayLineEndReplyCmd) {
+                    WayLineEndReplyCmd wayLineEndReplyCmd = (WayLineEndReplyCmd) tyCommand;
+                    logPrint("结束航线", wayLineEndReplyCmd.getResult(), wayLineEndReplyCmd.getErrorCode());
+                }
+                //设置返航高度回复
+                if (tyCommand instanceof ReturnHeightSettingReplyCmd) {
+                    ReturnHeightSettingReplyCmd returnHeightSettingReplyCmd = (ReturnHeightSettingReplyCmd) tyCommand;
+                    logPrint("设置返航高度", returnHeightSettingReplyCmd.getResult(), returnHeightSettingReplyCmd.getErrorCode());
+                }
+                //设置返航点回复
+                if (tyCommand instanceof ReturnPointSettingReplyCmd) {
+                    ReturnPointSettingReplyCmd returnPointSettingReplyCmd = (ReturnPointSettingReplyCmd) tyCommand;
+                    logPrint("设置返航点", returnPointSettingReplyCmd.getResult(), returnPointSettingReplyCmd.getErrorCode());
+                }
+                break;
+            case (byte) 0xD2:
+                //设置视频码流回复
+                if (tyCommand instanceof VideoStreamSettingReplyCmd) {
+                    VideoStreamSettingReplyCmd videoStreamSettingReplyCmd = (VideoStreamSettingReplyCmd) tyCommand;
+                    logPrint("设置视频码流", videoStreamSettingReplyCmd.getResult(), videoStreamSettingReplyCmd.getErrorCode());
+                }
                 break;
             default:
                 // 处理其他消息
@@ -676,8 +778,7 @@
      */
     @Scheduled(fixedRate = 3000)
     public void sendHeartBeat() {
-        if(!TyTcpServerCache.getTcpServerCache(tyConfiguration.getTcpserver() + ":" + tyConfiguration.getTcpport()))
-        {
+        if (!TyTcpServerCache.getTcpServerCache(tyConfiguration.getTcpserver() + ":" + tyConfiguration.getTcpport())) {
             return;
         }
         long timestamp = System.currentTimeMillis();

--
Gitblit v1.9.3