ENLIGHTEN
Cross-platform desktop GUI for Wasatch Photonics spectrometers
Loading...
Searching...
No Matches
enlighten.scope.PresetFeature.PresetFeature Class Reference

This feature allows the user to save named presets (referring to a snapshot of key acquisition parameters), irrespective of spectrometer serial number. More...

Public Member Functions

 __init__ (self, ctl)
 
 apply (self, preset)
 The user has selected a preset from the comboBox, so apply it.
 
 clear_all (self)
 The user selected (Clear All) from the comboBox, so prompt to delete all presets.
 
 combo_callback (self)
 The user has changed the comboBox selection.
 
 create_new (self)
 The user has selected "Create New..." on the comboBox.
 
 get_default_configuration (self)
 
 load_config (self)
 Load all previously created presets from enlighten.ini / Configuration.
 
 register (self, obj, attr, getter, setter)
 Another BusinessObject or Plugin has requested to include one of their attributes as part of new Presets.
 
 remove (self, preset)
 The user selected (Remove) from the comboBox, so prompt to delete the currently selected preset.
 
 reset (self, selected=None)
 We have added or removed a preset, so rebuild the comboBox and Configuration section.
 
 store (self, preset, feature, attr, value)
 Store the given value in a local dict tree (NOT Configuration)
 
 unregister (self, obj)
 

Public Attributes

 combo = ctl.form.ui.comboBox_presets
 
 combo_callback
 
 ctl = ctl
 
dict observers = {}
 
dict presets = self.get_default_configuration()
 
 selected_preset = None
 

Static Public Attributes

str SECTION = "Presets"
 

Detailed Description

This feature allows the user to save named presets (referring to a snapshot of key acquisition parameters), irrespective of spectrometer serial number.

The proposed design is to let any Feature (or Plugin) register itself to PresetFeature and add one or more attributes for automatic inclusion when creating and applying presets.

External API would be something like:

class IntegrationTimeFeature:
    def __init__:
        ctl.presets.register(self, "integration_time_ms", setter=self.set_ms, getter=self.get_ms)

    def get_ms(self):
        return self.current_ms

    def set_ms(self, value):
        value = int(value) # presets come as strings
        ... (existing code)

Note that all values will be written and read as strings; it will be on the receiving set_preset to cast any persisted values back to the expected type.

Things we haven't fully thought-through:

  • Some spectrometers may not support a preset value (out of range), or even the feature itself; consider if we have a preset for gain_db but only have an X-Series plugged in, or a preset for 3ms integration time but are connected to a 785X-C. I am basically assuming that the individual features will be able to recognize if a given value is impossible / inapplicable to the currently connected device (or devices under Multispec.locked) and react graciously (ignore, closest approx, etc).

    Todo
    This class should probably register as an observer on Multispec, and re-fire apply(self.selected_preset) when Multispec changes the active spectrometer.

Constructor & Destructor Documentation

◆ __init__()

enlighten.scope.PresetFeature.PresetFeature.__init__ ( self,
ctl )

Member Function Documentation

◆ apply()

enlighten.scope.PresetFeature.PresetFeature.apply ( self,
preset )

The user has selected a preset from the comboBox, so apply it.

◆ clear_all()

enlighten.scope.PresetFeature.PresetFeature.clear_all ( self)

The user selected (Clear All) from the comboBox, so prompt to delete all presets.

◆ combo_callback()

enlighten.scope.PresetFeature.PresetFeature.combo_callback ( self)

The user has changed the comboBox selection.

◆ create_new()

enlighten.scope.PresetFeature.PresetFeature.create_new ( self)

The user has selected "Create New..." on the comboBox.

◆ get_default_configuration()

enlighten.scope.PresetFeature.PresetFeature.get_default_configuration ( self)

◆ load_config()

enlighten.scope.PresetFeature.PresetFeature.load_config ( self)

Load all previously created presets from enlighten.ini / Configuration.

◆ register()

enlighten.scope.PresetFeature.PresetFeature.register ( self,
obj,
attr,
getter,
setter )

Another BusinessObject or Plugin has requested to include one of their attributes as part of new Presets.

◆ remove()

enlighten.scope.PresetFeature.PresetFeature.remove ( self,
preset )

The user selected (Remove) from the comboBox, so prompt to delete the currently selected preset.

◆ reset()

enlighten.scope.PresetFeature.PresetFeature.reset ( self,
selected = None )

We have added or removed a preset, so rebuild the comboBox and Configuration section.

◆ store()

enlighten.scope.PresetFeature.PresetFeature.store ( self,
preset,
feature,
attr,
value )

Store the given value in a local dict tree (NOT Configuration)

◆ unregister()

enlighten.scope.PresetFeature.PresetFeature.unregister ( self,
obj )

Member Data Documentation

◆ combo

enlighten.scope.PresetFeature.PresetFeature.combo = ctl.form.ui.comboBox_presets

◆ combo_callback

enlighten.scope.PresetFeature.PresetFeature.combo_callback

◆ ctl

enlighten.scope.PresetFeature.PresetFeature.ctl = ctl

◆ observers

dict enlighten.scope.PresetFeature.PresetFeature.observers = {}

◆ presets

dict enlighten.scope.PresetFeature.PresetFeature.presets = self.get_default_configuration()

◆ SECTION

enlighten.scope.PresetFeature.PresetFeature.SECTION = "Presets"
static

◆ selected_preset

enlighten.scope.PresetFeature.PresetFeature.selected_preset = None

The documentation for this class was generated from the following file: