CsImcIo 0.4.0-beta.1

This is a prerelease version of CsImcIo.
dotnet add package CsImcIo --version 0.4.0-beta.1
                    
NuGet\Install-Package CsImcIo -Version 0.4.0-beta.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="CsImcIo" Version="0.4.0-beta.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="CsImcIo" Version="0.4.0-beta.1" />
                    
Directory.Packages.props
<PackageReference Include="CsImcIo" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add CsImcIo --version 0.4.0-beta.1
                    
#r "nuget: CsImcIo, 0.4.0-beta.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package CsImcIo@0.4.0-beta.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=CsImcIo&version=0.4.0-beta.1&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=CsImcIo&version=0.4.0-beta.1&prerelease
                    
Install as a Cake Tool

CsImcIo

NuGet

A .NET library for reading imc Famos data files (*.dat, *.raw) as written by imc FAMOS, imc STUDIO and imc measurement devices. Both file format generations are supported: imc2 (ASCII-key format, FAMOS up to 7.3) and imc3 (binary format, FAMOS 7.4+).

The library is read-only. Metadata is parsed when a file is opened; sample data is read lazily per channel.

CsImcIo is an independent open-source project and is not affiliated with or endorsed by imc Test & Measurement GmbH.

Installation

The current release is a prerelease targeting .NET 10:

dotnet add package CsImcIo --version 0.4.0-beta.1

The public API may change before version 1.0.

Usage

using CsImcIo;
using CsImcIo.Model;

using var file = FamosFile.Open("measurement.dat");

Console.WriteLine($"Producer: {file.Data.FileProducer}");

foreach (var channel in file.Data.AllChannels)
{
    if (!channel.CanReadData)
    {
        Console.WriteLine($"{channel.Name}: skipped ({channel.UnsupportedDataReason})");
        continue;
    }

    if (channel is FamosAnalogChannel analog)
    {
        var data = analog.ReadData();
        Console.WriteLine(
            $"{analog.Name} [{data.Unit}]: {data.Values.Length} samples, " +
            $"x0={data.X0} {data.XUnit}, dx={data.Dx} {data.XUnit}");
    }
}

FamosData additionally exposes Groups, SingleValues and TextValues (text variables and text arrays), each with attached properties where present.

Channel kinds

FamosChannel is an abstract base carrying the metadata every channel has: index, names, properties, trigger info, and the x-axis (X0, Dx, XUnit). The concrete type describes what one sample is, and defines the reader for it, because the kinds do not share a result shape:

  • FamosAnalogChannel.ReadData() returns scaled double[] values.

  • FamosDigitalChannel.ReadData() returns the raw 16-bit port Words. Digital data is never scaled and has no unit. Bits lists the named signals of the port, and ReadBit(indexBit) decodes one of them without materializing the other fifteen.

  • FamosTimeStampAsciiChannel holds variable-length time-stamped records rather than equidistant samples, so it has no sample count and is read by walking it. ReadRecords() streams without allocating; ReadAllRecords() materializes the log.

if (channel is FamosTimeStampAsciiChannel bus)
{
    foreach (var record in bus.ReadRecords())
    {
        Console.WriteLine($"{record.Time} {bus.XUnit}: {record.GetText()}");
    }
}

ReadRecords() returns a ref struct, so a record's Content cannot outlive the loop — the compiler rejects storing it, boxing it, or holding it across an await. Call ToRecord() to keep one. The content may be arbitrary bytes rather than text: the file's declared code page does not apply to Time Stamp ASCII, so GetText() decodes byte-preserving unless another encoding is passed.

A multi-event (multi-shot) channel records several trigger events in one block. EventCount reports how many, ReadEvents() returns their descriptors without reading samples, and ReadData() packs the samples of all events into one array — leaving out any gaps between them in the file — with Events locating each one:

var data = analog.ReadData();
foreach (var recorded in data.Events)
{
    var samples = data.Values.AsSpan(recorded.StartIndex, recorded.SampleCount);
    Console.WriteLine($"shot at {recorded.TriggerTime}: {samples.Length} samples");
}

The file records per-event trigger time, x-axis and scaling alongside flags saying which of them apply; FamosEvent reports the effective value, falling back to the channel's own where the event does not override it. Each event is scaled with its own factor.

A segmented (matrix) channel stores its segments one after another. SegmentLength says how long each is, and the data exposes them without copying:

var data = analog.ReadData();
for (var i = 0; i < data.SegmentCount; i++)
{
    ReadOnlySpan<double> segment = data.GetSegment(i);
    Console.WriteLine($"z={data.GetSegmentZ(i)} {data.ZUnit}: {segment.Length} samples");
}

Reading into your own buffer

ReadData() allocates a double[] for every call. ReadInto<T> fills a buffer you own instead, and lets you choose the sample type:

var buffer = new float[analogChannels.Max(c => c.SampleCount)];
foreach (var analog in analogChannels)
{
    analog.ReadInto<float>(buffer);
    Consume(buffer.AsSpan(0, (int)analog.SampleCount));
}

T is any IEEE floating-point type, in practice float or double. Byte, short and float storage fit in a float exactly, so an unscaled channel of those formats loses nothing by being read as one. Where a scale factor and offset apply, the physical value is a double like any other and narrowing rounds it, so double is still the choice when that precision matters. The scaling is computed in double and narrowed once at the end, so the result is exactly ReadData()'s values cast to T — never a separately accumulated one.

A buffer longer than the channel keeps its tail, which is what lets one buffer serve channels of different lengths. Pass componentIndex: 1 for the second component of an XY or complex channel. Everything else the data carries is on the channel itself: the x-axis, the units through Components, and SegmentLength.

The events have a matching call, so both halves of a multi-event read can fill buffers you own — FamosEvent is a value type. ReadEventsInto returns how many it wrote:

// sized once and reused, like the sample buffer above
var samples = new float[analogChannels.Max(c => c.SampleCount)];
var events = new FamosEvent[analogChannels.Max(c => c.EventCount)];

foreach (var analog in analogChannels)
{
    var eventCount = analog.ReadEventsInto(events);
    analog.ReadInto<float>(samples);

    foreach (var recorded in events.AsSpan(0, eventCount))
    {
        Consume(samples.AsSpan(recorded.StartIndex, recorded.SampleCount));
    }
}

Both counts come from the file and are bounded only by int, so size these buffers from the channels rather than with stackalloc: a file may declare far more events or samples than a stack frame can hold. Where a buffer has to come off the stack, cap it and rent beyond the cap, which is what the library does internally.

The hierarchy is closed — only the library can derive from FamosChannel — so a type switch over the channel kinds stays exhaustive.

if (channel is FamosDigitalChannel port)
{
    foreach (var bit in port.Bits)
    {
        bool[] signal = port.ReadBit(bit.IndexBit);
        Console.WriteLine($"{bit.Name}: {signal.Count(v => v)} samples high");
    }
}

To test a bit against the raw words yourself, use bit.Mask rather than shifting by bit.IndexBit, which is a file-format value and not a shift amount.

Indices that come from the file are presented as the file states them: ChannelIndex and GroupIndex are 1-based, and IndexBit on a channel name or a property is 1 to 16 for the bits of a digital port from least to most significant, with 0 meaning the name or property applies to the whole channel. These are file-format values rather than .NET collection indices, so they can be compared directly against the FAMOS user interface and the format documentation.

Supported

  • imc2 and imc3 files, including format auto-detection
  • Groups, channels, single values, text variables/arrays, properties
  • Equidistant (1-component), XY and complex (2-component) channels
  • Digital ports: 16-bit words with per-bit names, comments and properties
  • Multi-event (multi-shot) imc3 channels with one component: per-event trigger time, x-axis and scaling, and chunks whose events are separated by gaps
  • Segmented (matrix) channels: the segments of the matrix and their z-axis
  • Time Stamp ASCII channels: time-stamped records streamed out of their 512-byte synchronisation clusters, including records that span cluster boundaries
  • All fixed-size numerical formats (integers 8–64 bit, 48-bit time tracks, float, double)
  • Value scaling (physical = raw * factor + offset)
  • Channel-multiplexed imc2 data (interleaved buffers)
  • ANSI code pages (via |NL / |CL1 keys) and UTF-8 (imc3); files without a declared code page fall back to Latin-1

Not supported

Opening a file with unsupported channel-level features succeeds; the affected channels keep their metadata but report CanReadData == false with the reason in UnsupportedDataReason, and ReadData() throws NotSupportedException:

  • Multi-event imc2 channels: their events are stored as separate buffers (|Cb NewEvent), which needs multi-buffer support
  • Multi-event channels with two components, multi-event digital ports and multi-event Time Stamp ASCII channels
  • Segmented digital ports, and segmented multi-event channels
  • Digital and Time Stamp ASCII channels with more than one component, and channels mixing them with numeric components
  • Extraction rules for deriving channels from a Time Stamp ASCII stream (|NE, |CX1)
  • Ring buffers and channels spanning multiple buffers (imc2)
  • zlib-compressed data blocks (|CS,2)

File-level obstacles (imc3 compression, online variants) throw at Open, as do files in the older imc1 format (|CF,1), which is out of scope. A file that contradicts the format throws as well, rather than reporting it as a feature that is missing. Writing files is out of scope.

Notes

  • The parsed metadata is immutable; channel data can be read from multiple threads concurrently (e.g. Parallel.ForEach over AllChannels). Files opened from a path or an in-memory stream read in parallel; other streams serialize reads internally. Do not dispose the FamosFile while reads are in flight, and do not access a stream you passed to Open yourself while the file is open.
  • All times (TriggerTime, TimeOfOrigin) are local wall-clock times with DateTimeKind.Unspecified. When an imc3 file declares its UTC offset, the stored time is shifted to local time accordingly.
  • The file formats are documented in the "imc Shared Components" manual, chapter imc File format.

Benchmarks

./scripts/benchmark-portable.sh runs the benchmarks that use committed test data. dotnet run -c Release --project CsImcIo.Benchmarks -- --filter "*" runs the complete BenchmarkDotNet suite, including scenarios that require the local-only large measurement file. Recorded results and the optimization log live in CsImcIo.Benchmarks/Optimization.

Tests

./scripts/verify.sh restores dependencies, verifies formatting, builds in Release with warnings treated as errors, and runs the test suite. Tests use the sample files in CsImcIo.Tests/TestData plus synthetically generated files. One large measurement file used by MeasurementDataTests is not committed; the test reports inconclusive when it is absent.

The code boundaries and performance constraints used for maintenance are documented in the architecture notes.

Release preparation and publishing are documented in RELEASING.md.

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.4.0-beta.1 129 8/4/2026
0.3.0-beta.1 86 8/3/2026
0.2.0-beta.2 86 8/1/2026
0.2.0-beta.1 90 7/31/2026