Exemple #1
0
        void ShowMap()
        {
            myMap.Children.Clear();

            List <Flight> selected = GetSelectedFlights();

            if (selected.Count == 0)
            {
                // show everything.
                selected.Add(new Flight()
                {
                    StartTime = DateTime.MinValue, Duration = TimeSpan.MaxValue
                });
            }
            var glitchIcon = XamlExtensions.LoadImageResource("Assets.GpsGlitchIcon.png");
            var imageLayer = new MapLayer();

            myMap.Children.Add(imageLayer);
            MapPolyline last = currentFlight;

            foreach (IDataLog log in this.logs)
            {
                if (log != null)
                {
                    bool gpsIsBad = false;
                    foreach (var flight in selected)
                    {
                        if (flight.Log == null || flight.Log == log)
                        {
                            MapPolyline line = new MapPolyline();
                            line.StrokeThickness = 4;
                            line.Stroke          = new SolidColorBrush(GetRandomColor());
                            LocationCollection points = new LocationCollection();

                            Debug.WriteLine("time,\t\tlat,\t\tlong,\t\t\tnsat,\talt,\thdop,\tfix");
                            foreach (var row in log.GetRows("GPS", flight.StartTime, flight.Duration))
                            {
                                LogEntryGPS gps = new LogEntryGPS(row);
                                Debug.WriteLine("{0},\t{1},\t{2},\t{3},\t\t{4:F2},\t{5},\t{6}", gps.GPSTime, gps.Lat, gps.Lon, gps.nSat, gps.Alt, gps.EPH, gps.Fix);
                                if (!(Math.Floor(gps.Lat) == 0 && Math.Floor(gps.Lon) == 0))
                                {
                                    var pos = new Location()
                                    {
                                        Altitude = gps.Alt, Latitude = gps.Lat, Longitude = gps.Lon
                                    };
                                    points.Add(pos);
                                    ulong time = (ulong)gps.GPSTime;
                                    if (time != 0)
                                    {
                                        if ((gps.nSat < 5 || gps.EPH > 20))
                                        {
                                            if (!gpsIsBad)
                                            {
                                                gpsIsBad = true;
                                                Debug.WriteLine("{0},\t{1},\t{2},\t{3},\t\t{4:F2},\t{5},\t{6}", gps.GPSTime, gps.Lat, gps.Lon, gps.nSat, gps.Alt, gps.EPH, gps.Fix);
                                                Image img = new Image();
                                                img.Width   = 30;
                                                img.Height  = 30;
                                                img.Source  = glitchIcon;
                                                img.Stretch = Stretch.None;
                                                img.ToolTip = "GPS Glitch!";
                                                imageLayer.AddChild(img, pos, PositionOrigin.Center);
                                            }
                                        }
                                        else
                                        {
                                            gpsIsBad = false;
                                        }
                                    }
                                }
                            }

                            if (points.Count > 0)
                            {
                                line.Locations = points;
                                myMap.Children.Add(line);
                                last = line;
                            }
                        }
                    }
                }
            }

            // hide the stuff on top...
            QuadButton.IsChecked    = false;
            ConsoleButton.IsChecked = false;
            SystemConsole.Hide();
            ChartStack.Visibility = Visibility.Collapsed;
            myMap.Visibility      = Visibility.Visible;
            myMap.UpdateLayout();

            if (last != null)
            {
                try
                {
                    myMap.SetView(last.Locations, new Thickness(20.0), 0);
                }
                catch (Exception ex)
                {
                    ShowStatus(ex.Message);
                }
            }
        }
Exemple #2
0
        private void GraphItem(LogItemSchema schema)
        {
            if (schema.IsNumeric)
            {
                ChartStack.Visibility = Visibility.Visible;
                ChartStack.UpdateLayout();
                SimpleLineChart chart = new SimpleLineChart();
                chart.Margin          = defaultChartMargin;
                chart.Focusable       = false;
                chart.Closed         += OnChartClosed;
                chart.LineColor       = GetRandomColor();
                chart.StrokeThickness = 1;
                chart.Tag             = schema;

                if (currentFlightLog != null && schema.Root == currentFlightLog.Schema)
                {
                    List <DataValue> values = new List <DataValue>(currentFlightLog.GetDataValues(schema, DateTime.MinValue, TimeSpan.MaxValue));
                    InitializeChartData(schema, chart, values);

                    // now turn on live scrolling...
                    chart.LiveScrolling = true;
                    // the X values are in microseconds (s0 the numerator is the speed of scrolling).
                    chart.LiveScrollingXScale = 50.0 / 1000000.0;

                    liveScrolling.Add(chart);

                    // now start watching the live update for new values that need to be added to this chart.
                    Task.Run(() =>
                    {
                        LiveUpdate(chart, currentFlightLog, schema);
                    });
                }
                else
                {
                    List <DataValue> values = new List <DataValue>(GetSelectedDataValues(schema));
                    if (values.Count > 0)
                    {
                        InitializeChartData(schema, chart, values);
                    }
                    else
                    {
                        chart = null;
                    }
                    ShowStatus(string.Format("Found {0} data values", values.Count));
                }

                if (chart != null)
                {
                    if (chartGroup != null)
                    {
                        chartGroup.AddChart(chart);
                        if (chartGroup.Parent == null)
                        {
                            ChartStack.AddChartGroup(chartGroup);
                        }
                    }
                    else
                    {
                        ChartStack.AddChart(chart);
                    }
                    LayoutCharts();
                }

                ConsoleButton.IsChecked = false;
                SystemConsole.Hide();
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                foreach (var value in GetSelectedDataValues(schema))
                {
                    sb.AppendLine(value.Label);
                }

                SystemConsole.Write(sb.ToString());
                ConsoleButton.IsChecked = true;
                SystemConsole.Show();
            }
        }
Exemple #3
0
 private void OnHideConsole(object sender, RoutedEventArgs e)
 {
     SystemConsole.Hide();
 }