/// <summary> /// Generates random TelemetrySamples. /// </summary> /// <param name="sampleCount">The sample count that is used to set the size of each TelemetrySamples.Values' size.</param> /// <param name="sessionStart">Used to set the EpochNanos property of the TelemetrySamples.</param> /// <returns></returns> public static TelemetrySamples GenerateSamples(int sampleCount, DateTime sessionStart) { var sample = new TelemetryParameterSamples() { EpochNanos = sessionStart.ToTelemetryTime(), TimestampsNanos = new long[sampleCount], Values = new double[sampleCount] }; var randomRangeWalker = new RandomRangeWalker(0, 1); // Used to generated random data for (int i = 0; i < sampleCount; i++) { var nextSample = randomRangeWalker.GetNext(); sample.TimestampsNanos[i] = i * Interval; sample.Values[i] = nextSample; } var data = new TelemetrySamples() { Parameters = new Dictionary <string, TelemetryParameterSamples>() { { ParameterId, sample } // If you had more samples to send for other parameters, this is where you would add them } }; return(data); }
/// <summary> /// Generates random TelemetrySamples. /// </summary> /// <param name="sampleCount">The sample count that is used to set the size of each TelemetrySamples.Values' size.</param> /// <param name="sessionStart">Used to set the EpochNanos property of the TelemetrySamples.</param> /// <returns></returns> public static TelemetrySamples GenerateSamples(int sampleCount, DateTime sessionStart) { var vcarSamples = new TelemetryParameterSamples() { EpochNanos = sessionStart.ToTelemetryTime(), TimestampsNanos = new long[sampleCount], Values = new double[sampleCount] }; var gearSamples = new TelemetryParameterSamples() { EpochNanos = sessionStart.ToTelemetryTime(), TimestampsNanos = new long[sampleCount], Values = new double[sampleCount] }; var randomRangeWalker = new RandomRangeWalker(0, 1); // Used to generated random data for (int i = 0; i < sampleCount; i++) { var nextSample = randomRangeWalker.GetNext(); // each data has own timestamps, frequencies vcarSamples.TimestampsNanos[i] = i * Interval; vcarSamples.Values[i] = nextSample * 300; gearSamples.TimestampsNanos[i] = i * Interval; gearSamples.Values[i] = nextSample; } var max = vcarSamples.Values.Max(); var modVal = max / 7 + 1; // Assuming a car has 8 gears, we are splitting the samples to 8 equal ranges and adding 1 to it, so it will be 1 .. 8 for (int i = 0; i < sampleCount; i++) { gearSamples.TimestampsNanos[i] = vcarSamples.TimestampsNanos[i]; gearSamples.Values[i] = Math.Round(vcarSamples.Values[i] / modVal); } var data = new TelemetrySamples() { Parameters = new Dictionary <string, TelemetryParameterSamples>() { { VcarParameterId, vcarSamples }, { GearParameterId, gearSamples } // If you had more samples to send for other parameters, this is where you would add them } }; return(data); }