public void HandleFrameArrived(IndicatorData data, DebugState debugState) { var text = Utils.ReadTextFromImage(data.Frame.Copy(LoadingTextRect), debugState); IsLoading = text == LoadingText; LoadingTextRead = text; }
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 }); }
void Tick(Stage stage, IndicatorData data) { switch (stage) { case Stage.Tick1: Timeline.Data[data.Id].Roll.Value = Roll.Tick(data); _computer.OnRollDataSampled(data.Id); Timeline.Data[data.Id].Roll.SecondsWhenComputed = Timeline.Duration.Elapsed.TotalSeconds - Timeline.Data[data.Id].Seconds; break; case Stage.Tick2: Timeline.Data[data.Id].Pitch.Value = Pitch.Tick(data); _computer.OnPitchDataSampled(data.Id); Timeline.Data[data.Id].Pitch.SecondsWhenComputed = Timeline.Duration.Elapsed.TotalSeconds - Timeline.Data[data.Id].Seconds; break; case Stage.Tick3: Timeline.Data[data.Id].Speed.Value = Airspeed.Tick(data); _computer.OnSpeedDataSampled(data.Id); Timeline.Data[data.Id].Speed.SecondsWhenComputed = Timeline.Duration.Elapsed.TotalSeconds - Timeline.Data[data.Id].Seconds; break; case Stage.Tick4: Timeline.Data[data.Id].Altitude.Value = Altitude.Tick(data); _computer.OnAltidudeDataSampled(data.Id); Timeline.Data[data.Id].Altitude.SecondsWhenComputed = Timeline.Duration.Elapsed.TotalSeconds - Timeline.Data[data.Id].Seconds; Timeline.Data[data.Id].LandingGear.Value = LandingGear.Tick(data); Timeline.Data[data.Id].LandingGear.SecondsWhenComputed = Timeline.Duration.Elapsed.TotalSeconds - Timeline.Data[data.Id].Seconds; break; case Stage.Tick5: Timeline.Data[data.Id].Heading.Value = Compass.Tick(data); _computer.OnCompassDataSampled(data.Id); Timeline.Data[data.Id].Heading.SecondsWhenComputed = Timeline.Duration.Elapsed.TotalSeconds - Timeline.Data[data.Id].Seconds; Timeline.Data[data.Id].IsDataComplete = true; break; case Stage.MenuTick: var menuDS = new DebugState(); Menu.HandleFrameArrived(data.Frame, menuDS); Roll.Image = menuDS.Get(10); Loading.HandleFrameArrived(data, menuDS); // TODO: do something with break; default: throw new NotImplementedException(); } }