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.

_loadState() must be implemented in subclasses to provide device-specific behavior.

Parameters:
  • interval (float, optional) – Time interval (in seconds) between successive state polls. Default is 0.1.

  • **kwargs – Additional keyword arguments passed to QtCore.QThread.

kill()[source]

Stops the monitoring thread for this device instance.

classmethod killAll()[source]

Stops all active monitoring threads for devices instantiated from this class

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

run()[source]

Overrides 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.

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