Base Classes

class lys_instr.Interfaces.HardwareInterface(interval=0.1, **kwargs)[source]

Bases: QThread

Abstract base class for hardware interfaces with background monitoring.

This class provides background thread management and a standard structure for device state monitoring. Each subclass represents a hardware device and runs its own monitoring thread. The thread periodically calls _loadState() to poll and update device-specific state information. The monitoring thread can be stopped by calling the instance’s kill() method, or all threads can be stopped using the killAll() class method.

Subclasses must implement _loadState() to provide device-specific behavior.

kill()[source]

Stop the monitoring thread for this device instance.

This method sets the internal stop flag under the mutex so the running thread will exit its loop and terminate cleanly.

classmethod killAll()[source]

Stop all active monitoring threads for instances of this class.

This method calls kill() on each registered device instance and clears the internal instance list __list.

run()[source]

Override QtCore.QThread.run() to define the background execution loop for a device instance.

This method is executed automatically when start() is called, which is typically done in subclasses. It repeatedly calls _loadState() at the specified interval until kill() is called.

lys_instr.Interfaces.lock(func)[source]

Decorator to ensure thread-safe execution of a method using a QMutex.

This decorator acquires the instance’s _mutex before executing the decorated method, ensuring that only one thread can execute the method at a time.

Parameters:

func (callable) – The method to be decorated.

Returns:

The wrapped method with mutex locking.

Return type:

callable