private static void trace(TraceEventType eventType, string message) { Exception exception; switch (eventType) { case TraceEventType.Information: exception = new TraceInformation(message); break; case TraceEventType.Error: exception = new TraceError(message); break; case TraceEventType.Warning: exception = new TraceWarning(message); break; default: exception = new TraceWrite(message); break; } Trace(exception); }
public void OutputWarning(string message) { TraceWarning?.Invoke(this, message); }
/// <summary> /// Assumes the game is in paused mode /// Filters the samples to just single frame numbers, that the game moves after invoking the moveReplay action (eg: which sends message to the game - MoveToNextIncident) /// If the game does not advance to another frame within about 1second, it will stop enumerating /// </summary> /// <param name="samples"></param> /// <param name="moveReplay"></param> /// <param name="sampleScanSettle">The number of samples to take, which must all have the same frame number - to identify that iRacing has paused.</param> /// <returns></returns> static IEnumerable <DataSample> PositionsOf(this IEnumerable <DataSample> samples, int sampleScanSettle) { var lastSamples = new List <int>(); var lastFrameNumber = -2; Func <DataSample, states> waitForMessage = ignored => states.RequestPaceCar; foreach (var dx in samples) { switch (waitForMessage(dx)) { case states.Continue: break; case states.RequestPaceCar: iRacing.Replay.NoWait.CameraOnDriver(0, 0); waitForMessage = d => d.Telemetry.CamCarIdx == 0 ? states.RequestNextIncident : states.Continue; break; case states.RequestNextIncident: iRacing.Replay.NoWait.MoveToNextIncident(); waitForMessage = d => { lastSamples.Add(d.Telemetry.ReplayFrameNum); if (lastSamples.Count == sampleScanSettle) { lastSamples.RemoveAt(0); } if (lastSamples.Count == (sampleScanSettle - 1) && lastSamples.All(f => f == d.Telemetry.ReplayFrameNum)) { if (d.Telemetry.ReplayFrameNum == lastFrameNumber) { TraceDebug.WriteLine("Incidents: Frame number did not change - asuming no more incidents. Current Frame: {0}", d.Telemetry.ReplayFrameNum); return(states.Break); } if (d.Telemetry.CamCarIdx == 0) //Pace Car { TraceWarning.WriteLine("Incident scan aborted - iRacing has not progressed to incident. Frame Number: {0}", d.Telemetry.ReplayFrameNum); return(states.Break); } lastFrameNumber = d.Telemetry.ReplayFrameNum; TraceDebug.WriteLine("Incidents: last {0} samples have settled on frame number {1}", sampleScanSettle, d.Telemetry.ReplayFrameNum); lastSamples.Add(-1); lastSamples.RemoveAt(0); return(states.Yield); } ; return(states.Continue); }; break; case states.Yield: yield return(dx); waitForMessage = ignored => states.RequestPaceCar; break; case states.Break: yield break; } } }
public void RaiseWarning(string message) { TraceWarning?.Invoke(this, message); Log.Warning("{class} {method} {message}", "QueryTraceEngine", "RaiseWarning", message); }