Expand description
Diagnostic subscriber that writes live NATS LabJack samples to CSV files.
The streamer publishes each channelβs scans as FlatBuffer sampler::Scan messages
on NATS, and the archiver normally turns them into Parquet. This binary is for
inspecting that live stream without running the archiver. It makes a plain
(non-JetStream) core NATS subscription to the live subject wildcard from
subjects::live_labjack_stream_subject, decodes each scan, and appends one CSV
file per asset and channel. It only sees messages published while it is running.
Each CSV file is named labjack_<asset>_<channel>.csv (for example
labjack_001_ch03.csv) and has the header sequence,timestamp,raw_value. The
asset is taken from the subject for legacy subjects and from ASSET_NUMBER
otherwise. Every sample becomes one row: the scanβs sequence number, the sample time as RFC 3339
UTC, and the value as published.
Β§Configuration
NATS_SUBJECT- Subject root. Default:avenabox.ASSET_NUMBER- Asset number used in CSV file names for structured subjects, and as the source when neitherSOURCE_IDnorLABJACK_NAMEis set. Unparseable values fall back to the default. Default:1.SITE_ID- Site ID for the structured subject layout.BOX_ID- Box ID for the structured subject layout.LABJACK_NAME- LabJack name, used as the source whenSOURCE_IDis unset.SOURCE_TYPE- Read and passed on, but does not affect the subject.SOURCE_ID- Source ID for the structured subject layout.OUTPUT_DIR- Directory for the CSV files, created if missing. Default:outputs.NATS_SERVERS- Comma-separated NATS server URLs. Default:nats://127.0.0.1:4222.NATS_CREDS_FILE- NATS credentials file. Default:apt.creds.
With the defaults the subscription is the legacy wildcard avenabox.*.data.*,
which matches every asset; each file is named after the asset in its subject.
Setting any of SITE_ID, BOX_ID or SOURCE_ID, or NATS_SUBJECT=avenars,
switches to <root>.<site>.<box>.<source>.live.*.
ModulesΒ§
- nats_
config π - Shared NATS server-list and JetStream context helpers.
- sample_
data_ πgenerated - subjects π
- NATS subject builders for LabJack live data and archive exports.
FunctionsΒ§
- asset_
for_ πsubject - Finds the asset number a message belongs to.
- csv_
file_ πname - Builds the CSV file name for one asset and channel.
- extract_
channel_ πtoken - Extracts the final subject token, which is expected to be the channel name.
- main π
- Starts the live NATS subscriber and appends decoded samples to CSV.
- open_
csv_ πfor_ channel - Opens or creates the per-channel CSV file and writes its header if needed.
- timestamp_
unix_ πns_ to_ rfc3339 - Converts a Unix nanosecond timestamp into RFC 3339 text in UTC.