pytweezer.loggers.ni_adc_logger module

Example logger that owns its own device: an NI ADC read with nidaqmx.

This is the template for the intended Logger model — a Logger opens and owns its data source directly (real or virtual), rather than polling an existing device RPC server. Here the source is a National Instruments analog-input DAQ: the logger creates its own nidaqmx.Task, reads the configured channels on each interval, and pushes the voltages to InfluxDB.

Config entry shape (CONFIG["Loggers"][name]):

{
    "active": True,
    "script": "../pytweezer/servers/logger_server.py",
    "logger": "ni_adc",
    "host": SERVER_HOST,
    "interval": 1.0,
    "simulate": SIMULATING,             # True -> no hardware, fake readings
    "channels": ["Dev1/ai0", "Dev1/ai1"],
    "measurement": "ni_adc",            # optional; defaults to "ni_adc"
    "tags": {"system": "Rb"},           # optional static tags
}

To add another owns-its-device logger, copy this class, override setup/ read/close, and register it in logger_server.LOGGER_REGISTRY.

class pytweezer.loggers.ni_adc_logger.NIADCLogger(name, conf)[source]

Bases: Logger

Read analog-input voltages off an NI DAQ and log them as one measurement.

close()[source]

Release resources. Override to add teardown, but call super().close().

read()[source]

Return an iterable of (measurement, fields, tags) tuples, or None.

Called every interval seconds by run(). Override this in a polling logger. tags may be None.

setup()[source]

Open connections / prepare state. Override as needed (default: no-op).