trspectrometer.signalstorage module

This module is used to store references to Qt Signals for use by various other components of the application.

Since Qt Signals can only be sent by QObjects, an instance of the SignalStorage class is used to store and emit the various Signals. Do not create new instances of the SignalStorage class, instead access the shared instance as the signals attribute of this module.

An example usage is:

from signalstorage import signals
signals.data_changed.emit(True)

This signals instance may be used to store custom signals created dynamically. Do not try to assign to new attributes to it, it won’t work! Instead, use the create_signal() method:

from signalstorage import signals
signals.create_signal("custom_signal", str, int, object)
signals.custom_signal.connect(lambda s, i, o: print(f"Received: {s}, {i}, {o}"))
signals.emit("one", 2, bytearray([0x33, 0x34]))
class trspectrometer.signalstorage.SignalStorage[source]

Bases: QObject

A class to store and emit Qt Signals from.

Do not create new instances of this class, instead access the shared instance as the signals attribute of the signalstorage module.

The built-in signals are:

  • data_changed: Signal that new data has been loaded. If the parameter is True`, it indicates that a complete data set was loaded from a file, and thus user interface controls should be updated to match. If False, it indicates that the new data is from an acquisition process, and UI updates should not be performed.

  • raw_data_updated: Signal that raw data has been updated. The parameters are lists of scan, time, wavelength indices which may have changed. None indicates that all elements have potentially changed.

  • raw_selection_changed: Signal that the selection of raw data traces has changed.

  • acquisition_started: Signal that data acquisition has started. Components may want to connect to this in order to disable functionality while acquisition is in progress.

  • acquisition_stopped: Signal that data acquisition has stopped. An Exception will be included if an error occurred. Components may want to connect to this to re-enable functions which were disabled during acquisition. An Exception instance may be passed to provide information about any errors which occurred.

  • laser_reprate_changed: Signal that the laser repetition rate has changed in the configuration. Components may want to respond to this by restarting or re-configuring themselves for the new reprate.

create_signal(signal_name: str, *args)[source]

Create a new signal and store it in this class.

Note, Qt Signals must be created during class definition and can’t normally be created dynamically. We actually make a new class definition and swap this instance’s class type to the newly created class. It’s some arcane python magic.

Parameters:
  • signal_name – Name for the new Signal.

  • args – Type arguments for the new Signal.

acquisition_started
acquisition_stopped
data_changed
laser_reprate_changed
raw_data_updated
raw_selection_changed
staticMetaObject = PySide6.QtCore.QMetaObject("SignalStorage" inherits "QObject": Methods:   #4 type=Signal, signature=data_changed(bool), parameters=bool   #5 type=Signal, signature=raw_data_updated(QVariantList,QVariantList,QVariantList), parameters=QVariantList, QVariantList, QVariantList   #6 type=Signal, signature=raw_selection_changed()   #7 type=Signal, signature=acquisition_started()   #8 type=Signal, signature=acquisition_stopped(PyObject), parameters=PyObject   #9 type=Signal, signature=laser_reprate_changed() )