Export a numeric track, the series of values a module records with sink.Sample. Use CounterModule.cs and counter.replay from the zip.
dotnet add package RecursiveAI.OneScope.SdkRequires .NET 10 (net10.0); .NET 9 and earlier aren’t supported.
var history = CounterModule .OpenHistory("counter.replay"); history.Scan(); var track = history.Tracks.Single( t => t.Info.Id == "count"); if (track.Truncated) throw new InvalidOperationException( "Incomplete track."); Console.WriteLine("step,count"); foreach (var sample in track.Samples) { long step = sample.Step; double value = sample.Value; FormattableString row = $"{step},{value}"; Console.WriteLine( FormattableString.Invariant(row)); }
Unzip the example, then dotnet run.
step,count 1,2 2,4 3,6 4,8
Program and sample recording
The included counter.replay contains:
COUNT 4OpenHistory is a helper in CounterModule.cs that reads the file, calls the module’s Open method, and creates a History. The module reads this recording as four steps. The counter adds two each step, and Advance calls sink.Sample("count", Count) to record each new count. The program prints CSV to standard output; to save it instead, use the file-writing variation below.
If track.Truncated is true, the track reached its sample cap; the example stops instead of labeling the CSV as complete.
Variations
To save the CSV directly, replace the Console.WriteLine block after the truncation check:
using var csv = File.CreateText("count.csv"); csv.WriteLine("step,count"); foreach (var sample in track.Samples) csv.WriteLine(FormattableString.Invariant($"{sample.Step},{sample.Value}"));
Related recipes
The short answer
Open the recording with its module, create a History, and call Scan() before reading the track. Find the numeric track by its ID and write each TrackSample.Step and TrackSample.Value as a row. This exports the samples the module emits while replaying; it does not infer values for steps that produced no sample.
How do you plot replay telemetry and check for missing samples?
Use the tick as the horizontal coordinate and the numeric sample as the vertical coordinate. The file-writing variation saves both columns through File.CreateText; load count.csv into a spreadsheet or plotter with step as the x value and count as the y value. Use invariant formatting even if the example happens to contain whole numbers. A decimal comma in a fractional sample would otherwise share the same character as your CSV field separator. Keep units in the column name or the chart label when they matter. Do not label raw ticks as seconds unless you know the simulation’s tick duration.
Select the track by ID rather than by its order in the list: a module can declare several tracks, and event or marker tracks carry labels rather than a numeric series. Scan() fills the timeline and returns the time cursor to where it started. Check Truncated before treating the rows as the full series. For a bounded recording, you can raise ScopeHistoryOptions.MaxTrackSamples when constructing the history and scan again with the new history; the cap is per track.