Skip to content

Software Architecture

Dardo edited this page Apr 2, 2025 · 3 revisions

Software Architecture

Overview

The software is designed to manage and control various scientific instruments through serial communication, handling multiple tasks concurrently. It follows a modular and extensible architecture, ensuring flexibility and reliability. The core components include:

  • Connections: Manages instrument communication, discovery, and reconnection.
  • Tasks: Handles multi-threaded execution of measurement and processing routines.
  • Webapp: User interface based on streamlit

Core Components

Connections

The Connections singleton is responsible for establishing and maintaining communication with instruments. It supports:

  • Automatic baud rate detection: Determines the correct baud rate for a device.
  • Alias-based access: Instruments are referenced by predefined aliases to ensure consistency.
  • Thread-safe operations: Ensures proper synchronization in a multi-threaded environment.

Instrument Discovery

When an instrument is connected, Connections.fetch_all_instruments shall be called. If an instrument fails to respond, it is considered disconnected and removed from the active list.

Task Management

The Tasks singleton is responsible for managing and executing measurement and processing routines. For now only one task at a time is allowed. Thus when launched, maximum two threads are created: one for handling communication with instruments, the other for applying math formulas to received data. When stopped, the data gets saved in a file.

Task Lifecycle

  1. Initialization: A task is defined and registered within the Tasks manager.
  2. Execution: The task function runs in a dedicated thread, processing instrument data.
  3. Termination: When stopped, the task cleans up resources and stores results.

Each task operates in a loop, continuously collecting and processing data. The exit_flag mechanism ensures clean shutdowns.

Data Handling

Each task interacts with ChartData structures, which store:

  • Raw and processed data: The processed data is given by applying a specified math formula.
  • Timestamps and metadata: Each chart stores some data about time of creation.

If one wants to bypass the processing, it is sufficient to add data directly to x or y.

Clone this wiki locally