# labpy/lantz architecture

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

- Interactive diagram: https://gitdiagram.com/labpy/lantz
- Repository: https://github.com/labpy/lantz

## Overview

Lantz is a Python toolkit for controlling scientific instruments through a consistent driver interface. The main workflow is to use a driver’s features and actions, which apply processing and communicate through instrument-specific or shared I/O layers; results can then be used in applications or simulated for development. The repository also includes a broad driver catalog, native-library and NI DAQ support, and Qt interfaces. Relationships among unsampled device drivers are not expanded; the graph uses only documented or indexed references for its connections.

Main entry points: [`lantz/driver.py`](https://github.com/labpy/lantz/blob/master/lantz/driver.py) (Driver Lifecycle), [`lantz/ui/app.py`](https://github.com/labpy/lantz/blob/master/lantz/ui/app.py) (Application Framework), [`lantz/utils/qt.py`](https://github.com/labpy/lantz/blob/master/lantz/utils/qt.py) (Qt Selector), [`lantz/messagebased.py`](https://github.com/labpy/lantz/blob/master/lantz/messagebased.py) (Message-Based I/O)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_core["Driver Core"]
  node_driver["Driver Lifecycle<br/>[driver.py]"]
  node_features["Features<br/>[feat.py]"]
  node_actions["Actions<br/>[action.py]"]
  node_processors["Value Processors<br/>[processors.py]"]
  node_logging["Logging<br/>[log.py]"]
  node_stats["Driver Statistics<br/>[stats.py]"]
  node_errors["Instrument Errors<br/>[errors.py]"]
end

subgraph group_io["Instrument I/O"]
  node_foreign["Native Library Bridge<br/>[foreign.py]"]
  node_messagebased["Message-Based I/O<br/>[messagebased.py]"]
  node_legacytext["Legacy Text I/O<br/>[textual.py]"]
  node_visalib["VISA Library<br/>[visalib.py]"]
  node_catalog["Instrument Drivers"]
  node_daqbase["NI DAQ Base<br/>[base.py]"]
  node_daqtasks["NI DAQ Tasks<br/>[tasks.py]"]
  node_legacydaqbase["Legacy NI DAQ<br/>[base.py]"]
  node_legacydaqtasks["Legacy DAQ Tasks<br/>[tasks.py]"]
end

subgraph group_simulation["Simulation"]
  node_siminstrument["Instrument Simulator<br/>[instrument.py]"]
  node_simexperiment["Experiment Simulator<br/>[experiment.py]"]
  node_simfungen["Function Generator Sim<br/>[fungen.py]"]
  node_simvoltmeter["Voltmeter Simulator<br/>[voltmeter.py]"]
end

subgraph group_gui["Qt Applications"]
  node_app["Application Framework<br/>[app.py]"]
  node_widgets["Instrument Widgets<br/>[widgets.py]"]
  node_uqt["Qt Selector<br/>[qt.py]"]
  node_qtloaders["Qt Loaders<br/>[qt_loaders.py]"]
  node_scan["Feature Scan UI<br/>[scan.py]"]
  node_loop["Loop UI<br/>[loop.py]"]
  node_qtlog["Qt Log Viewer<br/>[qtlog.py]"]
end

node_user(("Application User"))
node_instrument{{"Physical Instrument"}}

node_user -->|"uses"| node_driver
node_driver -->|"registers"| node_features
node_driver -->|"registers"| node_actions
node_features -->|"applies"| node_processors
node_actions -->|"uses"| node_processors
node_driver -->|"logs"| node_logging
node_driver -->|"uses"| node_stats
node_messagebased -->|"extends"| node_driver
node_messagebased -->|"uses"| node_processors
node_messagebased -->|"logs"| node_logging
node_messagebased -->|"uses"| node_legacytext
node_foreign -->|"extends"| node_driver
node_daqbase -->|"calls"| node_foreign
node_daqtasks -->|"uses"| node_daqbase
node_legacydaqbase -->|"calls"| node_foreign
node_legacydaqtasks -->|"uses"| node_legacydaqbase
node_catalog -.->|"controls"| node_instrument
node_siminstrument -->|"uses"| node_legacytext
node_simexperiment -->|"uses"| node_simfungen
node_simexperiment -->|"uses"| node_simvoltmeter
node_simexperiment -->|"uses"| node_siminstrument
node_app -->|"initializes"| node_driver
node_app -->|"uses"| node_widgets
node_app -->|"uses"| node_uqt
node_widgets -->|"binds"| node_features
node_widgets -->|"uses"| node_uqt
node_uqt -->|"loads"| node_qtloaders
node_scan -->|"uses"| node_app
node_scan -->|"uses"| node_uqt
node_loop -->|"uses"| node_app
node_loop -->|"uses"| node_uqt
node_qtlog -->|"displays"| node_logging

click node_driver "https://github.com/labpy/lantz/blob/master/lantz/driver.py"
click node_features "https://github.com/labpy/lantz/blob/master/lantz/feat.py"
click node_actions "https://github.com/labpy/lantz/blob/master/lantz/action.py"
click node_processors "https://github.com/labpy/lantz/blob/master/lantz/processors.py"
click node_logging "https://github.com/labpy/lantz/blob/master/lantz/log.py"
click node_stats "https://github.com/labpy/lantz/blob/master/lantz/stats.py"
click node_errors "https://github.com/labpy/lantz/blob/master/lantz/errors.py"
click node_foreign "https://github.com/labpy/lantz/blob/master/lantz/foreign.py"
click node_messagebased "https://github.com/labpy/lantz/blob/master/lantz/messagebased.py"
click node_legacytext "https://github.com/labpy/lantz/blob/master/lantz/drivers/legacy/textual.py"
click node_visalib "https://github.com/labpy/lantz/blob/master/lantz/drivers/legacy/visalib.py"
click node_catalog "https://github.com/labpy/lantz/tree/master/lantz/drivers"
click node_daqbase "https://github.com/labpy/lantz/blob/master/lantz/drivers/ni/daqmx/base.py"
click node_daqtasks "https://github.com/labpy/lantz/blob/master/lantz/drivers/ni/daqmx/tasks.py"
click node_legacydaqbase "https://github.com/labpy/lantz/blob/master/lantz/drivers/legacy/ni/daqmx/base.py"
click node_legacydaqtasks "https://github.com/labpy/lantz/blob/master/lantz/drivers/legacy/ni/daqmx/tasks.py"
click node_siminstrument "https://github.com/labpy/lantz/blob/master/lantz/simulators/instrument.py"
click node_simexperiment "https://github.com/labpy/lantz/blob/master/lantz/simulators/experiment.py"
click node_simfungen "https://github.com/labpy/lantz/blob/master/lantz/simulators/fungen.py"
click node_simvoltmeter "https://github.com/labpy/lantz/blob/master/lantz/simulators/voltmeter.py"
click node_app "https://github.com/labpy/lantz/blob/master/lantz/ui/app.py"
click node_widgets "https://github.com/labpy/lantz/blob/master/lantz/ui/widgets.py"
click node_uqt "https://github.com/labpy/lantz/blob/master/lantz/utils/qt.py"
click node_qtloaders "https://github.com/labpy/lantz/blob/master/lantz/utils/qt_loaders.py"
click node_scan "https://github.com/labpy/lantz/blob/master/lantz/ui/blocks/scan.py"
click node_loop "https://github.com/labpy/lantz/blob/master/lantz/ui/blocks/loop.py"
click node_qtlog "https://github.com/labpy/lantz/blob/master/lantz/ui/qtlog.py"

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_driver,node_features,node_actions,node_processors,node_logging,node_stats,node_errors,node_user toneBlue
class node_foreign,node_messagebased,node_legacytext,node_visalib,node_catalog,node_daqbase,node_daqtasks,node_legacydaqbase,node_legacydaqtasks toneAmber
class node_siminstrument,node_simexperiment,node_simfungen,node_simvoltmeter toneMint
class node_app,node_widgets,node_uqt,node_qtloaders,node_scan,node_loop,node_qtlog toneRose
class node_instrument toneIndigo
```

## Components

### Driver Core

- [Driver Lifecycle](https://github.com/labpy/lantz/blob/master/lantz/driver.py): `lantz/driver.py`
- [Features](https://github.com/labpy/lantz/blob/master/lantz/feat.py): `lantz/feat.py`
- [Actions](https://github.com/labpy/lantz/blob/master/lantz/action.py): `lantz/action.py`
- [Value Processors](https://github.com/labpy/lantz/blob/master/lantz/processors.py): `lantz/processors.py`
- [Logging](https://github.com/labpy/lantz/blob/master/lantz/log.py): `lantz/log.py`
- [Driver Statistics](https://github.com/labpy/lantz/blob/master/lantz/stats.py): `lantz/stats.py`
- [Instrument Errors](https://github.com/labpy/lantz/blob/master/lantz/errors.py): `lantz/errors.py`

### Instrument I/O

- [Native Library Bridge](https://github.com/labpy/lantz/blob/master/lantz/foreign.py): `lantz/foreign.py`
- [Message-Based I/O](https://github.com/labpy/lantz/blob/master/lantz/messagebased.py): `lantz/messagebased.py`
- [Legacy Text I/O](https://github.com/labpy/lantz/blob/master/lantz/drivers/legacy/textual.py): `lantz/drivers/legacy/textual.py`
- [VISA Library](https://github.com/labpy/lantz/blob/master/lantz/drivers/legacy/visalib.py): `lantz/drivers/legacy/visalib.py`
- [Instrument Drivers](https://github.com/labpy/lantz/tree/master/lantz/drivers): `lantz/drivers`
- [NI DAQ Base](https://github.com/labpy/lantz/blob/master/lantz/drivers/ni/daqmx/base.py): `lantz/drivers/ni/daqmx/base.py`
- [NI DAQ Tasks](https://github.com/labpy/lantz/blob/master/lantz/drivers/ni/daqmx/tasks.py): `lantz/drivers/ni/daqmx/tasks.py`
- [Legacy NI DAQ](https://github.com/labpy/lantz/blob/master/lantz/drivers/legacy/ni/daqmx/base.py): `lantz/drivers/legacy/ni/daqmx/base.py`
- [Legacy DAQ Tasks](https://github.com/labpy/lantz/blob/master/lantz/drivers/legacy/ni/daqmx/tasks.py): `lantz/drivers/legacy/ni/daqmx/tasks.py`

### Simulation

- [Instrument Simulator](https://github.com/labpy/lantz/blob/master/lantz/simulators/instrument.py): `lantz/simulators/instrument.py`
- [Experiment Simulator](https://github.com/labpy/lantz/blob/master/lantz/simulators/experiment.py): `lantz/simulators/experiment.py`
- [Function Generator Sim](https://github.com/labpy/lantz/blob/master/lantz/simulators/fungen.py): `lantz/simulators/fungen.py`
- [Voltmeter Simulator](https://github.com/labpy/lantz/blob/master/lantz/simulators/voltmeter.py): `lantz/simulators/voltmeter.py`

### Qt Applications

- [Application Framework](https://github.com/labpy/lantz/blob/master/lantz/ui/app.py): `lantz/ui/app.py`
- [Instrument Widgets](https://github.com/labpy/lantz/blob/master/lantz/ui/widgets.py): `lantz/ui/widgets.py`
- [Qt Selector](https://github.com/labpy/lantz/blob/master/lantz/utils/qt.py): `lantz/utils/qt.py`
- [Qt Loaders](https://github.com/labpy/lantz/blob/master/lantz/utils/qt_loaders.py): `lantz/utils/qt_loaders.py`
- [Feature Scan UI](https://github.com/labpy/lantz/blob/master/lantz/ui/blocks/scan.py): `lantz/ui/blocks/scan.py`
- [Loop UI](https://github.com/labpy/lantz/blob/master/lantz/ui/blocks/loop.py): `lantz/ui/blocks/loop.py`
- [Qt Log Viewer](https://github.com/labpy/lantz/blob/master/lantz/ui/qtlog.py): `lantz/ui/qtlog.py`

### Other components

- **Application User**
- **Physical Instrument**

## Connections

- Application User → Driver Lifecycle: uses (evidence: `README`)
- Driver Lifecycle → Features: registers (evidence: `lantz/driver.py`)
- Driver Lifecycle → Actions: registers (evidence: `lantz/driver.py`)
- Features → Value Processors: applies (evidence: `lantz/feat.py`)
- Actions → Value Processors: uses (evidence: `lantz/action.py`)
- Driver Lifecycle → Logging: logs (evidence: `lantz/driver.py`)
- Driver Lifecycle → Driver Statistics: uses (evidence: `lantz/driver.py`)
- Message-Based I/O → Driver Lifecycle: extends (evidence: `lantz/messagebased.py`)
- Message-Based I/O → Value Processors: uses (evidence: `lantz/messagebased.py`)
- Message-Based I/O → Logging: logs (evidence: `lantz/messagebased.py`)
- Message-Based I/O → Legacy Text I/O: uses (evidence: `lantz/messagebased.py`)
- Native Library Bridge → Driver Lifecycle: extends (evidence: `lantz/foreign.py`)
- NI DAQ Base → Native Library Bridge: calls (evidence: `lantz/drivers/ni/daqmx/base.py`)
- NI DAQ Tasks → NI DAQ Base: uses (evidence: `lantz/drivers/ni/daqmx/tasks.py`)
- Legacy NI DAQ → Native Library Bridge: calls (evidence: `lantz/drivers/legacy/ni/daqmx/base.py`)
- Legacy DAQ Tasks → Legacy NI DAQ: uses (evidence: `lantz/drivers/legacy/ni/daqmx/tasks.py`)
- Instrument Drivers → Physical Instrument: controls (evidence: `README`)
- Instrument Simulator → Legacy Text I/O: uses (evidence: `lantz/simulators/instrument.py`)
- Experiment Simulator → Function Generator Sim: uses (evidence: `lantz/simulators/experiment.py`)
- Experiment Simulator → Voltmeter Simulator: uses (evidence: `lantz/simulators/experiment.py`)
- Experiment Simulator → Instrument Simulator: uses (evidence: `lantz/simulators/experiment.py`)
- Application Framework → Driver Lifecycle: initializes (evidence: `lantz/ui/app.py`)
- Application Framework → Instrument Widgets: uses (evidence: `lantz/ui/app.py`)
- Application Framework → Qt Selector: uses (evidence: `lantz/ui/app.py`)
- Instrument Widgets → Features: binds (evidence: `lantz/ui/widgets.py`)
- Instrument Widgets → Qt Selector: uses (evidence: `lantz/ui/widgets.py`)
- Qt Selector → Qt Loaders: loads (evidence: `lantz/utils/qt.py`)
- Feature Scan UI → Application Framework: uses (evidence: `lantz/ui/blocks/scan.py`)
- Feature Scan UI → Qt Selector: uses (evidence: `lantz/ui/blocks/scan.py`)
- Loop UI → Application Framework: uses (evidence: `lantz/ui/blocks/loop.py`)
- Loop UI → Qt Selector: uses (evidence: `lantz/ui/blocks/loop.py`)
- Qt Log Viewer → Logging: displays (evidence: `lantz/ui/qtlog.py`)
