diff --git a/Plane.FormationCreator/App.xaml.cs b/Plane.FormationCreator/App.xaml.cs index b0aa765..e2cc631 100644 --- a/Plane.FormationCreator/App.xaml.cs +++ b/Plane.FormationCreator/App.xaml.cs @@ -35,6 +35,7 @@ namespace Plane.FormationCreator _logger = ServiceLocator.Current.GetInstance(); _copterManager = ServiceLocator.Current.GetInstance(); _formationController = ServiceLocator.Current.GetInstance(); + _mapManager = ServiceLocator.Current.GetInstance(); AppDomain.CurrentDomain.AssemblyResolve += (s, e) => { @@ -71,6 +72,7 @@ namespace Plane.FormationCreator private ILogger _logger; private CopterManager _copterManager; private FormationController _formationController; + private MapManager _mapManager; private Assembly LoadAssembly(string simpleName) { @@ -154,14 +156,17 @@ namespace Plane.FormationCreator { await Dispatcher.BeginInvoke(new Action(() => { - copter = new Copter(Connection, SynchronizationContext.Current) + copter = new Copter(Connection, SynchronizationContext.Current, _mapManager.Center.Lat, _mapManager.Center.Lng) { Id = ip, Name = ip.Substring(ip.LastIndexOf('.') + 1) + }; + + int _index; _index=copters.AddCopter(copter); - copterStatus.Insert(_index,false); + copterStatus.Insert(_index,false); copter.TextReceived += Copter_TextReceived; diff --git a/Plane.FormationCreator/Formation/Copter.cs b/Plane.FormationCreator/Formation/Copter.cs index cacb720..8c8d5be 100644 --- a/Plane.FormationCreator/Formation/Copter.cs +++ b/Plane.FormationCreator/Formation/Copter.cs @@ -15,6 +15,15 @@ namespace Plane.FormationCreator.Formation public Copter(IConnection Connection, SynchronizationContext uiThreadContext) : base(Connection, uiThreadContext,false) { Brush = _brushes[NextBrushIndex()]; + + } + + public Copter(IConnection Connection, SynchronizationContext uiThreadContext, double lat, double lng) : base(Connection, uiThreadContext, false) + { + Brush = _brushes[NextBrushIndex()]; + RecordLat = lat; + RecordLng = lng; + //RaiseLocationChangedIfNeeded(); } static SolidColorBrush[] _brushes = new[] diff --git a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs index afd24ac..420a3b3 100644 --- a/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs +++ b/Plane.FormationCreator/ViewModels/ControlPanelViewModel.cs @@ -674,6 +674,20 @@ namespace Plane.FormationCreator.ViewModels case FlightTaskType.FlyTo: + foreach (LEDInfo ledInfo in _flightTaskManager.Tasks[j].SingleCopterInfos[i].LEDInfos) + { + Color color = (Color)ColorConverter.ConvertFromString("#" + ledInfo.LEDRGB); + IMission LEDMission = Mission.CreateLEDControlMission( + ledInfo.Delay * 10, + ledInfo.LEDMode, + ledInfo.LEDRate, + 0, //ledInfo.LEDTimes, + color.R, + color.G, + color.B + ); + missions.Add(LEDMission); + } missions.Add(Mission.CreateWaypointMission( //5,//_flightTaskManager.Tasks[j].SingleCopterInfos[i].LoiterTime, //5,// _flightTaskManager.Tasks[j].SingleCopterInfos[i].FlytoTime, @@ -685,20 +699,7 @@ namespace Plane.FormationCreator.ViewModels //_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLng, _flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetAlt) ); - foreach(LEDInfo ledInfo in _flightTaskManager.Tasks[j].SingleCopterInfos[i].LEDInfos) - { - Color color = (Color)ColorConverter.ConvertFromString("#" + ledInfo.LEDRGB); - IMission LEDMission = Mission.CreateLEDControlMission( - ledInfo.Delay, - ledInfo.LEDMode, - ledInfo.LEDRate, - 0, //ledInfo.LEDTimes, - color.R, - color.G, - color.B - ); - missions.Add(LEDMission); - } + break; case FlightTaskType.Loiter: // missions[missindex++] = Mission.CreateWaypointMission(10,10,_flightTaskManager.Tasks[j].SingleCopterInfos[i].TargetLat, diff --git a/Plane.FormationCreator/Views/MapView_CopterDrawing.cs b/Plane.FormationCreator/Views/MapView_CopterDrawing.cs index 1147c4f..00e2881 100644 --- a/Plane.FormationCreator/Views/MapView_CopterDrawing.cs +++ b/Plane.FormationCreator/Views/MapView_CopterDrawing.cs @@ -95,6 +95,17 @@ namespace Plane.FormationCreator.Views try { var location = new Location(Copter.Latitude, Copter.Longitude, Copter.Altitude); + + if (this.Dot != null ) + { + if (Copter is PLCopter && !Copter.IsGpsAccurate) + this.Dot.Fill = new SolidColorBrush(Color.FromRgb(0, 0, 0)); + else + this.Dot.Fill = _brush; + } + + + Point center = _map.LocationToViewportPoint(location); bool locationUpdated = true; SolidColorBrush blackBrush = new SolidColorBrush(); @@ -114,7 +125,8 @@ namespace Plane.FormationCreator.Views Dot.Points.Add(new Point(-COPTER_RADIUS * 2 / 3, COPTER_RADIUS)); Dot.Points.Add(new Point(COPTER_RADIUS * 2 / 3, COPTER_RADIUS)); - Dot.Fill = _brush; // new SolidColorBrush(Color.FromArgb(200, 0, 122, 204)); + + Dot.Fill = _brush; // new SolidColorBrush(Color.FromArgb(200, 0, 122, 204)); Dot.StrokeThickness = 1; Dot.Width = COPTER_RADIUS * 2; Dot.Height = COPTER_RADIUS * 2; @@ -218,6 +230,10 @@ namespace Plane.FormationCreator.Views public void AddWaypoint(Location location, FlightTaskType type) { // Add waypoint. + /* + if (!Copter.IsGpsAccurate && !(Copter is FakeCopter)) + location = _map.Center; + */ var wp = new Ellipse { Tag = WAYPOINT_TAG, diff --git a/Plane.FormationCreator/Views/ModifyTaskView.xaml b/Plane.FormationCreator/Views/ModifyTaskView.xaml index 9097159..4a3a15a 100644 --- a/Plane.FormationCreator/Views/ModifyTaskView.xaml +++ b/Plane.FormationCreator/Views/ModifyTaskView.xaml @@ -249,6 +249,7 @@ diff --git a/Plane.FormationCreator/Views/TaskBarView.xaml b/Plane.FormationCreator/Views/TaskBarView.xaml index 3563da5..6b2b2f4 100644 --- a/Plane.FormationCreator/Views/TaskBarView.xaml +++ b/Plane.FormationCreator/Views/TaskBarView.xaml @@ -7,7 +7,7 @@ xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" x:Class="Plane.FormationCreator.Views.TaskBarView" mc:Ignorable="d" - d:DesignHeight="40" + d:DesignHeight="156.968" d:DesignWidth="500"> @@ -112,27 +112,85 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -