Example #1
0
        private double GetValueForIndicator(TimelineFrame frame)
        {
            if (Type == IndicatorChartType.Delay)
            {
                switch (Indicator.Type)
                {
                case IndicatorType.Roll: return(frame.Roll.SecondsWhenComputed);

                case IndicatorType.Pitch: return(frame.Pitch.SecondsWhenComputed - frame.Roll.SecondsWhenComputed);

                case IndicatorType.Speed: return(frame.Speed.SecondsWhenComputed - frame.Pitch.SecondsWhenComputed);

                case IndicatorType.Altitude: return(frame.Altitude.SecondsWhenComputed - frame.Speed.SecondsWhenComputed);

                case IndicatorType.Yaw: return(frame.Heading.SecondsWhenComputed - frame.Altitude.SecondsWhenComputed);

                case IndicatorType.Gear: return(frame.LandingGear.SecondsWhenComputed - frame.Speed.SecondsWhenComputed);

                default: throw new NotImplementedException();
                }
            }
            else if (Type == IndicatorChartType.Value)
            {
                //return Timeline.LatestAvg(3, f => GetTimelineValueForIndicator(f).Value, frame.Id, Indicator.Type == IndicatorType.Yaw);
                return(GetTimelineValueForIndicator(frame).Value);
            }
            else if (Type == IndicatorChartType.InputOutput)
            {
                return(GetTimelineValueForIndicator(frame).OutputValue);
            }
            throw new NotImplementedException();
        }
        private void RenderFrame(TimelineFrame frame)
        {
            Line l = new Line();

            l.Stroke          = Brushes.Yellow;
            l.StrokeThickness = 1;

            if (_lastRenderedFrame != null)
            {
                l.X1 = _lastRenderedFrame.Location.X / Metrics.SCALE_Map4_20_TO_100;
                l.X2 = frame.Location.X / Metrics.SCALE_Map4_20_TO_100;
                l.Y1 = _lastRenderedFrame.Location.Y / Metrics.SCALE_Map4_20_TO_100;
                l.Y2 = frame.Location.Y / Metrics.SCALE_Map4_20_TO_100;

                var len = Math2.GetDistance(_lastRenderedFrame.Location, frame.Location);
                if (len > 5)
                {
                    l.Stroke = Brushes.Red;
                }
            }
            else
            {
                l.X1 = l.X2 = frame.Location.X / Metrics.SCALE_Map4_20_TO_100;
                l.Y1 = l.Y2 = frame.Location.Y / Metrics.SCALE_Map4_20_TO_100;
            }

            canvas.Children.Add(l);
        }
Example #3
0
        internal void HandleFrameArrived(FrameData data)
        {
            var frame = new TimelineFrame
            {
                Seconds = data.Seconds,
                Id      = Timeline.LatestFrameId,
            };

            Timeline.Data[Timeline.LatestFrameId] = frame;

            if (Timeline.IsInGame)
            {
                Timeline.LatestFrameId++;
            }

            if (!Timeline.IsInGame)
            {
                // Drop a lot of frames for non-game mode.
                if (data.FrameId % 10 != 0)
                {
                    return;
                }
            }

            var indicatorData = new IndicatorData
            {
                Frame   = new Image <Bgr, byte>(data.Frame),
                Id      = frame.Id,
                Seconds = data.Seconds,
            };

            Enqueue(new Data {
                Stage = Timeline.IsInGame ? Stage.Tick1 : Stage.MenuTick, IndicatorData = indicatorData
            });
        }
Example #4
0
        private double GetSetPointForIndicator(TimelineFrame frame)
        {
            if (Type == IndicatorChartType.Value)
            {
                return(GetTimelineValueForIndicator(frame).SetpointValue);
            }
            else if (Type == IndicatorChartType.InputOutput)
            {
                return(GetTimelineValueForIndicator(frame).InputValue);
            }


            return(double.NaN);
        }
        private void LocationTimer_Tick(object sender, EventArgs e)
        {
            var startId = _lastRenderedFrame != null ? _lastRenderedFrame.Id : 0;

            for (var i = startId; i < Timeline.LatestFrameId; i++)
            {
                if (Timeline.Data[i] != null && Timeline.Data[i].IsLocationCalculated)
                {
                    RenderFrame(Timeline.Data[i]);

                    _lastRenderedFrame = Timeline.Data[i];
                }
                else
                {
                    break;
                }
            }
        }
Example #6
0
        private TimelineValue GetTimelineValueForIndicator(TimelineFrame frame)
        {
            switch (Indicator.Type)
            {
            case IndicatorType.Roll: return(frame.Roll);

            case IndicatorType.Pitch: return(frame.Pitch);

            case IndicatorType.Speed: return(frame.Speed);

            case IndicatorType.Altitude: return(frame.Altitude);

            case IndicatorType.Yaw: return(frame.Heading);

            case IndicatorType.Gear: return(frame.LandingGear);

            default: throw new NotImplementedException();
            }
        }
Example #7
0
        public static void Load(string filePath)
        {
            var lines = System.IO.File.ReadAllLines(filePath);

            for (var i = 0; i < lines.Length; i++)
            {
                var d = Data[i] = new TimelineFrame {
                    Id = i
                };

                var parts = lines[i].Split(',');
                d.Seconds        = double.Parse(parts[0]);
                d.Roll.Value     = double.Parse(parts[1]);
                d.Pitch.Value    = double.Parse(parts[2]);
                d.Speed.Value    = double.Parse(parts[3]);
                d.Altitude.Value = double.Parse(parts[4]);
                d.Heading.Value  = Math2.SafeAddAngle(double.Parse(parts[5]), 0);
                CompleteFrame(i);
                LatestFrameId = i;
            }
        }
Example #8
0
        public void Tick()
        {
            if (Indicator != null)
            {
                double current_x = Width - 1;
                double x_size    = 250f / NUM_FRAMES;

                zeroLine.X1 = 0;
                zeroLine.X2 = Width;
                zeroLine.Y1 = Height / 2;
                zeroLine.Y2 = Height / 2;

                topLine.X1 = 0;
                topLine.X2 = Width;
                topLine.Y1 = 0;
                topLine.Y2 = 0;

                bottomLine.X1 = 0;
                bottomLine.X2 = Width;
                bottomLine.Y1 = Height;
                bottomLine.Y2 = Height;

                bottomText.Text = "" + GetRangeForIndicator()[0];
                topText.Text    = "" + GetRangeForIndicator()[1];

                Canvas.SetTop(topText, 4);
                Canvas.SetLeft(topText, 4);

                Canvas.SetTop(bottomText, Height - 20);
                Canvas.SetLeft(bottomText, 4);

                int           childIndex = SKIP_LINES + NUM_FRAMES;
                TimelineFrame last       = null;
                for (var i = Timeline.LatestFrameId; i >= 0 && i > Timeline.LatestFrameId - NUM_FRAMES; i--)
                {
                    var current = Timeline.Data[i];
                    if (last == null || current == null)
                    {
                        last = current;
                    }
                    else
                    {
                        var l = (Line)Children[childIndex];
                        var s = (Line)Children[childIndex - NUM_FRAMES];

                        if (!double.IsNaN(GetValueForIndicator(current)) && !double.IsNaN(GetValueForIndicator(last)))
                        {
                            l.Stroke = Brushes.Blue;

                            if (Type == IndicatorChartType.Delay)
                            {
                                if (GetValueForIndicator(current) > 0.2)
                                {
                                    l.Stroke = Brushes.Red;
                                }
                                else
                                {
                                    l.Stroke = Brushes.Green;
                                }
                            }


                            l.X1 = current_x;
                            l.X2 = current_x - x_size;
                            l.Y2 = Math2.MapValue(GetRangeForIndicator()[0], GetRangeForIndicator()[1], Height, 0, GetValueForIndicator(current));
                            l.Y1 = Math2.MapValue(GetRangeForIndicator()[0], GetRangeForIndicator()[1], Height, 0, GetValueForIndicator(last));
                        }
                        else
                        {
                            if (Type == IndicatorChartType.Value)
                            {
                                s.X1 = s.X2 = s.Y1 = s.Y2 = 0;
                            }

                            if (Type != IndicatorChartType.InputOutput)
                            {
                                l.Stroke = Brushes.Gray;
                                l.X1     = current_x;
                                l.X2     = current_x;
                                l.Y1     = 0;
                                l.Y2     = Height;
                            }
                            else
                            {
                                l.X1 = l.X2 = l.Y1 = l.Y2 = 0;
                            }
                        }

                        if (Type == IndicatorChartType.Value || Type == IndicatorChartType.InputOutput)
                        {
                            s.X1 = current_x;
                            s.X2 = current_x - x_size;

                            if (!double.IsNaN(GetSetPointForIndicator(current)) && !double.IsNaN(GetSetPointForIndicator(last)))
                            {
                                s.Y1 = Math2.MapValue(GetRangeForIndicator()[0], GetRangeForIndicator()[1], Height, 0, GetSetPointForIndicator(current));
                                s.Y2 = Math2.MapValue(GetRangeForIndicator()[0], GetRangeForIndicator()[1], Height, 0, GetSetPointForIndicator(last));
                            }
                            else
                            {
                                s.X1 = s.X2 = s.Y1 = s.Y2 = 0;
                            }
                        }

                        current_x = current_x - x_size;
                        childIndex++;
                        last = current;
                    }
                }
            }
        }