From 27d8974ee9e491e66cbbef8ae667e45fb3414364 Mon Sep 17 00:00:00 2001 From: zxd Date: Wed, 25 Jul 2018 21:35:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0LED=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=EF=BC=9A=20=E9=80=89=E6=8B=A9Copter=E9=97=AA=E7=83=81=E4=B8=80?= =?UTF-8?q?=E4=B8=8B=EF=BC=9B=20=E6=8E=A7=E5=88=B6Copter=E7=9A=84=E7=81=AF?= =?UTF-8?q?=E5=85=89=E5=BC=80=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Formation/FlightTaskManager.cs | 7 ++++++ .../ViewModels/ControlPanelViewModel.cs | 24 +++++++++++++++++++ .../Views/ControlPanelView.xaml | 5 ++-- .../Views/MapView_CopterDrawing.cs | 14 ++++++++--- .../Views/ModifyTaskView.xaml | 13 +++++++--- 5 files changed, 55 insertions(+), 8 deletions(-) diff --git a/Plane.FormationCreator/Formation/FlightTaskManager.cs b/Plane.FormationCreator/Formation/FlightTaskManager.cs index ce98b8f..1b14345 100644 --- a/Plane.FormationCreator/Formation/FlightTaskManager.cs +++ b/Plane.FormationCreator/Formation/FlightTaskManager.cs @@ -29,6 +29,10 @@ namespace Plane.FormationCreator.Formation _copterManager.SelectedCoptersChanged += (sender, e) => { + foreach (ICopter copter in _copterManager.SelectedCopters) + { + copter.LEDAsync(); + } // TODO: 林俊清, 20150803, 处理选中多个飞行器的情况。 if (_copterManager.SelectedCopters.Count() > 1) { @@ -49,6 +53,9 @@ namespace Plane.FormationCreator.Formation } if (selectedCopter!=null) selectedCopter.SetShowLEDFlashAsync(1, 100); + + if (selectedCopter != null) + selectedCopter.LEDAsync(); }; TaskAdded += (sender, e) => diff --git a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs index 420a3b3..31b678f 100644 --- a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs @@ -91,6 +91,30 @@ namespace Plane.FormationCreator.ViewModels } } + private const string NTF_GROUPLED_OFF = "NTF_GROUPLED_OFF"; + private ICommand _LEDOnOffCommand; + public ICommand LEDOnOffCommand + { + get + { + return _LEDOnOffCommand ?? (_LEDOnOffCommand = new RelayCommand(async () => + { + string paramstr = NTF_GROUPLED_OFF; + float paramvalue = 0; + await Task.WhenAll( + _copterManager.AcceptingControlCopters.Select(async copter => + { + paramvalue = await copter.GetParamAsync(paramstr); + })); + + float newParamvalue = paramvalue == 0 ? 1 : 0; + + await Task.WhenAll(_copterManager.AcceptingControlCopters.Select + (copter => copter.SetParamAsync(paramstr, newParamvalue))); + })); + } + } + private ICommand _UnlockCommand; public ICommand UnlockCommand { diff --git a/Plane.FormationCreator/Views/ControlPanelView.xaml b/Plane.FormationCreator/Views/ControlPanelView.xaml index 352967e..b9655fe 100644 --- a/Plane.FormationCreator/Views/ControlPanelView.xaml +++ b/Plane.FormationCreator/Views/ControlPanelView.xaml @@ -56,10 +56,11 @@