public MainWindow()
        {
            InitializeComponent();

            UiDispatcher.Initialize();

            this.progress = new ProgressUtility(MyProgress);
            MyProgress.Visibility = Visibility.Collapsed;
            UpdateButtons();
            FlightView.ItemsSource = allFlights;
            ConnectionPanel.DownloadCompleted += OnLogDownloadComplete;
            ConnectionPanel.Connected += OnChannelConnected;
            ConnectionPanel.Disconnected += OnChannelDisconnected;
            this.Visibility = Visibility.Hidden;
            RestoreSettings();
            this.SizeChanged += OnWindowSizeChanged;
            this.LocationChanged += OnWindowLocationChanged;
            ChartStack.Visibility = Visibility.Collapsed;
            initialAttitude = ModelViewer.ModelAttitude;
            CameraPanel.Visibility = Visibility.Collapsed;
        }
示例#2
0
        public async Task Load(string fileName, ProgressUtility progress)
        {
            flights.Clear();
            // CSV doesn't have realtime clock, so go with the file date instead.
            this.startTime = File.GetLastWriteTime(fileName);

            // time (us)
            int min = int.MaxValue;
            int max = int.MinValue;


            await Task.Run(() =>
            {

                using (Stream s = File.OpenRead(fileName))
                {
                    XmlNameTable nametable = new NameTable();
                    using (XmlCsvReader reader = new XmlCsvReader(s, System.Text.Encoding.UTF8, new Uri(fileName), nametable))
                    {
                        progress.ShowProgress(0, s.Length, s.Position);
                        reader.FirstRowHasColumnNames = true;
                        data = XDocument.Load(reader);

                        this.schema = new LogItemSchema() { Name = "CsvDataLog", Type = "Root" };

                        // create the schema
                        List<LogItemSchema> children = new List<Model.LogItemSchema>();
                        foreach (String name in reader.ColumnNames)
                        {
                            children.Add(new LogItemSchema() { Name = name, Parent = this.schema });
                        }

                        this.schema.ChildItems = children;

                        progress.ShowProgress(0, s.Length, s.Position);
                    }
                }

                foreach (var e in data.Root.Elements())
                {
                    int? i = GetTimeMicroseconds(e);
                    if (i.HasValue)
                    {
                        if (i.Value < min)
                        {
                            min = i.Value;
                        }
                        if (i > max)
                        {
                            max = i.Value;
                        }
                    }
                }
            });

            // this log has no absolute UTC time, only ticks since board was booted, so we make up a start time.
            DateTime end = this.startTime.AddMilliseconds((max - min) / 1000);
            var flight = new Flight() { Log = this, StartTime = this.startTime, Duration = end - this.startTime };
            this.duration = end - this.startTime;
            this.flights.Add(flight);

        }