From 725c4b6d718336630680f32040165ee19379bcbd Mon Sep 17 00:00:00 2001 From: zxd Date: Thu, 11 Apr 2019 13:20:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=9A=E4=BF=A1=E6=A8=A1=E5=9D=97=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=E7=9A=84=E6=B7=BB=E5=8A=A0=E5=92=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=20=E5=B0=8F=E6=89=B9=E9=87=8F=E3=80=81=E8=AF=BB=E5=86=99?= =?UTF-8?q?=E9=80=9A=E4=BF=A1=E5=9C=B0=E9=9D=A2=E7=AB=99=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=94=B9=E8=BF=9E=E6=8E=A5id=E6=80=BB?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Formation/FlightTask_FlyTo.cs | 11 +-- .../ViewModels/ConnectViewModel.cs | 74 ++++++++++++++++++- .../Views/ConnectWindow.xaml | 34 ++++++++- 3 files changed, 109 insertions(+), 10 deletions(-) diff --git a/Plane.FormationCreator/Formation/FlightTask_FlyTo.cs b/Plane.FormationCreator/Formation/FlightTask_FlyTo.cs index fc01eb5..ecd4079 100644 --- a/Plane.FormationCreator/Formation/FlightTask_FlyTo.cs +++ b/Plane.FormationCreator/Formation/FlightTask_FlyTo.cs @@ -169,7 +169,7 @@ namespace Plane.FormationCreator.Formation if (prevTask.TaskType == FlightTaskType.FlyTo && prevTask.LoiterTime == 0) flyToTime += prevTask.RuningTaskRemaining; } - + int LEDIndex = 0; //while (!info.Copter.ArrivedTarget(info.TargetLat, info.TargetLng, info.TargetAlt)) //按航点飞 :所有Copter到达目标点开始飞下个航点 while (ts.TotalMilliseconds < (flyToTime + loiterTime)) //按时间轴飞:当前任务时间到达后自动飞往下个航点 { @@ -212,20 +212,21 @@ namespace Plane.FormationCreator.Formation double time = 0; for (int i = 0; i < LedControl.Count; i++) { - var led = LedControl[i]; time += led.Delay * 1000; if (ts.TotalMilliseconds >= time) + { LEDRGB = info.LEDInfos[i].LEDRGB; + LEDIndex = i; + + } else break; } + Message.Show(LEDIndex.ToString()); info.Copter.LEDColor = LEDRGB; - } - - if (ts.TotalMilliseconds / 10 > sendFlyToTimes) // 每500ms发送一遍指点坐标 { sendFlyToTimes++; diff --git a/Plane.FormationCreator/ViewModels/ConnectViewModel.cs b/Plane.FormationCreator/ViewModels/ConnectViewModel.cs index 1af61e9..9cd9151 100644 --- a/Plane.FormationCreator/ViewModels/ConnectViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ConnectViewModel.cs @@ -86,7 +86,7 @@ namespace Plane.FormationCreator.ViewModels { return _SendCommand ?? (_SendCommand = new RelayCommand(async () => { - await SendCommandAsync(CopterNum); + await commModule.SetCommCount(CopterCount, (short)(CopterStartNum - 1)); } )); } @@ -132,6 +132,27 @@ namespace Plane.FormationCreator.ViewModels set { Set(nameof(CopterColor), ref _CopterColor, value); } } + private byte _TransmittedPower = 5; + public byte TransmittedPower + { + get { return _TransmittedPower; } + set { Set(nameof(TransmittedPower), ref _TransmittedPower, value); } + } + + private short _CopterCount; + public short CopterCount + { + get { return _CopterCount; } + set { Set(nameof(CopterCount), ref _CopterCount, value); } + } + + private short _CopterStartNum; + public short CopterStartNum + { + get { return _CopterStartNum; } + set { Set(nameof(CopterStartNum), ref _CopterStartNum, value); } + } + private ICommand _WriteIdCommand; public ICommand WriteIdCommand { @@ -215,6 +236,9 @@ namespace Plane.FormationCreator.ViewModels } } + /// + /// 全部1S一次闪灯 主要用于测试通信 + /// private ICommand _CommDataAsync; public ICommand CommDataAsync { @@ -228,6 +252,54 @@ namespace Plane.FormationCreator.ViewModels } } + /// + /// 设置回传功率 + /// + private ICommand _CommSetPowerAsync; + public ICommand CommSetPowerAsync + { + get + { + return _CommSetPowerAsync ?? (_CommSetPowerAsync = new RelayCommand(async () => + { + if (TransmittedPower >= 1 && TransmittedPower <= 16) + await commModule.SetCopterCommBackPower((short)CopterNum, TransmittedPower); + else + Alert.Show("功率范围只能设置为1-16"); + })); + } + } + + /// + /// 获取配置 + /// + private ICommand _CommGetCurrSysParmAsync; + public ICommand CommGetCurrSysParmAsync + { + get + { + return _CommGetCurrSysParmAsync ?? (_CommGetCurrSysParmAsync = new RelayCommand(async () => + { + await commModule.GetCurr_Sys_Parm(); + })); + } + } + + /// + /// 改写配置 + /// + private ICommand _CommSetCurrSysParmAsync; + public ICommand CommSetCurrSysParmAsync + { + get + { + return _CommSetCurrSysParmAsync ?? (_CommSetCurrSysParmAsync = new RelayCommand(async () => + { + await commModule.SetCurr_Sys_Parm(); + })); + } + } + private List CreateLEDMissions(IEnumerable LEDInfos) { List missions = new List(); diff --git a/Plane.FormationCreator/Views/ConnectWindow.xaml b/Plane.FormationCreator/Views/ConnectWindow.xaml index b5a8da8..2d15135 100644 --- a/Plane.FormationCreator/Views/ConnectWindow.xaml +++ b/Plane.FormationCreator/Views/ConnectWindow.xaml @@ -68,6 +68,8 @@ + + @@ -89,7 +91,8 @@ HorizontalAlignment="Center" Grid.Row="1" Grid.ColumnSpan="3" - Name="panel1"> + Name="panel1" + Visibility="Collapsed">