# gunnarluebbermann/go-tdms architecture

> Architecture diagram of the GitHub repository gunnarluebbermann/go-tdms, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gunnarluebbermann/go-tdms
- Repository: https://github.com/gunnarluebbermann/go-tdms

## Overview

go-tdms is a pure-Go TDMS file parser. The main workflow opens a file or index, parses segment metadata into file properties, groups, and channels, then streams channel values in batches with optional DAQmx interpretation and scaling. Users can also inspect properties and derive waveform x-axis values. The graph follows the documented capabilities; unsampled implementation details are represented only where the tree or README supports them.

Main entry points: [`file.go`](https://github.com/gunnarluebbermann/go-tdms/blob/main/file.go) (File API), [`stream_reader.go`](https://github.com/gunnarluebbermann/go-tdms/blob/main/stream_reader.go) (Batch stream reader), [`scaling.go`](https://github.com/gunnarluebbermann/go-tdms/blob/main/scaling.go) (Channel scaling), [`channel.go`](https://github.com/gunnarluebbermann/go-tdms/blob/main/channel.go) (Channel API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_parsing["File parsing"]
  node_tdmsfile["File API<br/>[file.go]"]
  node_segment["Segment parser<br/>[segment.go]"]
end

subgraph group_reading["Channel reading"]
  node_channel["Channel API<br/>[channel.go]"]
  node_stream["Batch stream reader<br/>[stream_reader.go]"]
end

subgraph group_interpretation["Data interpretation"]
  node_properties["Properties<br/>[property.go]"]
  node_daqmx["DAQmx scalers<br/>[daqmx.go]"]
  node_scaling["Channel scaling<br/>[scaling.go]"]
  node_promotion["Type promotion<br/>[type_promotion.go]"]
  node_waveform["Waveform values<br/>[waveform.go]"]
  node_thermocouple["Thermocouple math<br/>[thermocouple.go]"]
end

node_user(("Go caller"))
node_rawdata["TDMS file data"]
node_results["Channel values"]

node_user -->|"opens or constructs"| node_tdmsfile
node_tdmsfile -->|"reads metadata"| node_rawdata
node_tdmsfile -->|"parses segments"| node_segment
node_segment -->|"provides metadata"| node_tdmsfile
node_tdmsfile -->|"exposes properties"| node_properties
node_tdmsfile -->|"builds channels"| node_channel
node_user -->|"requests reads"| node_channel
node_channel -->|"creates stream"| node_stream
node_stream -->|"reads channel bytes"| node_rawdata
node_stream -->|"interprets DAQmx"| node_daqmx
node_stream -->|"applies scaling"| node_scaling
node_scaling -->|"promotes types"| node_promotion
node_scaling -->|"uses thermocouple math"| node_thermocouple
node_stream -->|"yields batches"| node_results
node_user -->|"requests x-axis"| node_waveform
node_waveform -->|"reads waveform properties"| node_properties

click node_tdmsfile "https://github.com/gunnarluebbermann/go-tdms/blob/main/file.go"
click node_segment "https://github.com/gunnarluebbermann/go-tdms/blob/main/segment.go"
click node_channel "https://github.com/gunnarluebbermann/go-tdms/blob/main/channel.go"
click node_stream "https://github.com/gunnarluebbermann/go-tdms/blob/main/stream_reader.go"
click node_properties "https://github.com/gunnarluebbermann/go-tdms/blob/main/property.go"
click node_daqmx "https://github.com/gunnarluebbermann/go-tdms/blob/main/daqmx.go"
click node_scaling "https://github.com/gunnarluebbermann/go-tdms/blob/main/scaling.go"
click node_promotion "https://github.com/gunnarluebbermann/go-tdms/blob/main/type_promotion.go"
click node_waveform "https://github.com/gunnarluebbermann/go-tdms/blob/main/waveform.go"
click node_thermocouple "https://github.com/gunnarluebbermann/go-tdms/blob/main/thermocouple.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_tdmsfile,node_segment toneBlue
class node_channel,node_stream toneAmber
class node_properties,node_daqmx,node_scaling,node_promotion,node_waveform,node_thermocouple toneMint
class node_user,node_rawdata,node_results toneIndigo
```

## Components

### File parsing

- [File API](https://github.com/gunnarluebbermann/go-tdms/blob/main/file.go): `file.go`
- [Segment parser](https://github.com/gunnarluebbermann/go-tdms/blob/main/segment.go): `segment.go`

### Channel reading

- [Channel API](https://github.com/gunnarluebbermann/go-tdms/blob/main/channel.go): `channel.go`
- [Batch stream reader](https://github.com/gunnarluebbermann/go-tdms/blob/main/stream_reader.go): `stream_reader.go`

### Data interpretation

- [Properties](https://github.com/gunnarluebbermann/go-tdms/blob/main/property.go): `property.go`
- [DAQmx scalers](https://github.com/gunnarluebbermann/go-tdms/blob/main/daqmx.go): `daqmx.go`
- [Channel scaling](https://github.com/gunnarluebbermann/go-tdms/blob/main/scaling.go): `scaling.go`
- [Type promotion](https://github.com/gunnarluebbermann/go-tdms/blob/main/type_promotion.go): `type_promotion.go`
- [Waveform values](https://github.com/gunnarluebbermann/go-tdms/blob/main/waveform.go): `waveform.go`
- [Thermocouple math](https://github.com/gunnarluebbermann/go-tdms/blob/main/thermocouple.go): `thermocouple.go`

### Other components

- **Go caller**
- **TDMS file data**
- **Channel values**

## Connections

- Go caller → File API: opens or constructs
- File API → TDMS file data: reads metadata
- File API → Segment parser: parses segments
- Segment parser → File API: provides metadata
- File API → Properties: exposes properties
- File API → Channel API: builds channels
- Go caller → Channel API: requests reads
- Channel API → Batch stream reader: creates stream
- Batch stream reader → TDMS file data: reads channel bytes
- Batch stream reader → DAQmx scalers: interprets DAQmx
- Batch stream reader → Channel scaling: applies scaling
- Channel scaling → Type promotion: promotes types
- Channel scaling → Thermocouple math: uses thermocouple math
- Batch stream reader → Channel values: yields batches
- Go caller → Waveform values: requests x-axis
- Waveform values → Properties: reads waveform properties
