8.2.3. The Sequencer Extension
Summary of the main classes of the Sequencer extension. See also Extending the Sequencer.
8.2.3.1. The Extension
|
|
|
- class pymodaq.extensions.sequencer.sequencer.Sequencer(parent, dashboard)[source]
- Attributes:
- main_sequence
module_and_data_saverComplex but Standardized way to save data from the CustomExt and
- sequence_names
Methods
Connect actions and/or other widgets signal to methods
do_things_after_experiment_set(experiment_name)do_things_after_ui_setup()populate_status_bar()Method where to create actions to be subclassed.
Mandatory method to be subclassed to setup the docks layout
setup_menus_and_toolbars([menubar])Non mandatory method to be subclassed in order to create a menubar
update_sequence_name(old_name, new_name)browse all elts in the sequences for SequenceElt and modify the current seq name if it has been changed!
add_sequence
load_sequence
remove_sequence
save_sequence
show_settings
- setup_actions()[source]
Method where to create actions to be subclassed. Mandatory
Examples
>>> self.add_action('quit', 'Quit', 'close2', "Quit program") >>> self.add_action('grab', 'Grab', 'camera', "Grab from camera", checkable=True) >>> self.add_action('load', 'Load', 'Open', "Load target file (.h5, .png, .jpg) or data from camera" , checkable=False) >>> self.add_action('save', 'Save', 'SaveAs', "Save current data", checkable=False)
See also
ActionManager.add_action
- setup_docks_and_widgets()[source]
Mandatory method to be subclassed to setup the docks layout
See also
Non mandatory method to be subclassed in order to create a menubar
create menu for actions contained into the self._actions, for instance:
See also
pymodaq.utils.managers.action_manager.ActionManager
- class pymodaq.extensions.sequencer.sequencer.SequenceWorker(sequencer, parent=None)[source]
- Attributes:
- app
- status_manager
Methods
save_callback
stop
stopped
- class pymodaq.extensions.sequencer.utilities.sequencer.sequence.Sequence(title, parent, dashboard)[source]
- Attributes:
- model
- root_elt
Methods
Connect actions and/or other widgets signal to methods
do_things_after_experiment_set(experiment_name)do_things_after_ui_setup()set_log_callback(log_callback)Set a Callback for all element to log (if any) their data into the log h5 file
Method where to create actions to be subclassed.
Mandatory method to be subclassed to setup the docks layout
setup_menus_and_toolbars([menubar])Non mandatory method to be subclassed in order to create a menubar
is_valid
iterate_elts
load_sequence
name_changed
pause_sequence
recursive_connect_elts
recursive_disconnect_elts
selected_index_from_entered_state
sequence_finished
sequence_stopped
setup_machine
start_sequence
update_name
- set_log_callback(log_callback)[source]
Set a Callback for all element to log (if any) their data into the log h5 file
- setup_actions()[source]
Method where to create actions to be subclassed. Mandatory
Examples
>>> self.add_action('quit', 'Quit', 'close2', "Quit program") >>> self.add_action('grab', 'Grab', 'camera', "Grab from camera", checkable=True) >>> self.add_action('load', 'Load', 'Open', "Load target file (.h5, .png, .jpg) or data from camera" , checkable=False) >>> self.add_action('save', 'Save', 'SaveAs', "Save current data", checkable=False)
See also
ActionManager.add_action
- setup_docks_and_widgets()[source]
Mandatory method to be subclassed to setup the docks layout
See also
Non mandatory method to be subclassed in order to create a menubar
create menu for actions contained into the self._actions, for instance:
See also
pymodaq.utils.managers.action_manager.ActionManager
8.2.3.2. Elements
|
Base class defining the interface of all elements handled by the Sequencer |
The factory class to get Sequencer Elements |
|
- class pymodaq.extensions.sequencer.utilities.element_factory.SeqEltBase(id, parent=None, parent_sequence=None, **label_kwargs)[source]
Base class defining the interface of all elements handled by the Sequencer
- Attributes:
- children
- children_without_add
- dashboard
- id
- mstate
- name
parentGet/Set this element parent
- parent_sequence
Methods
Check the validity of the element
child(index)Get the child by its index within the list of children
child_by_index(index)Get the child by its unique index
create_widget([parent])Public API to be used to create the widget representing this elt
deserialize(bytes_str)Convert bytes into a SeqEltBase object
If this Element is using the Dashboard, once its setter has been called, this method will be executed
If this Element is using the Dashboard, once its setter has been called, this method will be executed
execute([dte])Execute the Element
from_dict(dict_config)Deserialization from a dictionary
from_dict_custom(dict_config)Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
get_elt_from_id(elt_id[, start_parent])Get the Element having the specified id starting from start_parent in the tree
get_elts([parent_elt, without_ids, ...])Get as a list all element in the tree starting from parent_elt
get_elts_as_str([parent_elt, without_ids, ...])Get the elements name of all existing elements
get_ids([parent_elt, without_ids, without_types])Get the ids of the existing elements
Perform Initialization of the element if needed when called
save_data(dte[, done])By calling this method, data will be logged using the TimeSaver
serialize(obj)Convert a SeqEltBase object into a bytes string
set_parent(value)to be used as a slot or ...
Returns the Size the corresponding widget will likely have
to_dict()Serialization in a dictionary
adds attribute to a dict in order to produce a human readable representation/configuration for this element
append_child
children_signal
data_to_log_signal
done_signal
get_root_elt
go_to_signal
save_signal
set_dashboard
set_parent_sequence
- classmethod deserialize(bytes_str)[source]
Convert bytes into a SeqEltBase object
- Return type:
- Returns:
SeqEltBase (
the decoded object)bytes (
the remaining bytes string if any)
- classmethod from_dict(dict_config)[source]
Deserialization from a dictionary
- Returns:
SeqEltBase
- Return type:
- classmethod serialize(obj)[source]
Convert a SeqEltBase object into a bytes string
- Returns:
bytes
- Return type:
- check_set_is_valid()[source]
Check the validity of the element
Will be called before executing the element. Try to make sure the element is valid or return None if the user may do something!
To be reimplemented
if not valid should raise an ElementError exception else return None
- create_widget(parent=None)[source]
Public API to be used to create the widget representing this elt
- Return type:
- do_things_with_dashboard()[source]
If this Element is using the Dashboard, once its setter has been called, this method will be executed
Do whatever is needed to instantiate your element with the Dashboard
- do_things_with_parent_sequence()[source]
If this Element is using the Dashboard, once its setter has been called, this method will be executed
Do whatever is needed to instantiate your element with the Dashboard
- execute(dte=None)[source]
Execute the Element
Should emit the done_signal when executed (could be with empty DataToExport)
- from_dict_custom(dict_config)[source]
Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
to be reimplemented
- get_elt_from_id(elt_id, start_parent=None)[source]
Get the Element having the specified id starting from start_parent in the tree
- Parameters:
elt_id (
int)start_parent (
SeqEltBase) – Optional, if not specified or None, start from the Root of this element hierarchy
- Return type:
- get_elts(parent_elt=None, without_ids=(), without_types=())[source]
Get as a list all element in the tree starting from parent_elt
- Parameters:
without_types (
Iterable[type[SeqEltBase]])parent_elt (
SeqEltBase)without_ids (
Iterable[int]) – tuple of ids to remove from the resultwithout_types – tuple of elements type to remove from the result
- Returns:
list[SeqEltBase]
- Return type:
- get_elts_as_str(parent_elt=None, without_ids=(), without_types=())[source]
Get the elements name of all existing elements
- get_ids(parent_elt=None, without_ids=(), without_types=())[source]
Get the ids of the existing elements
- initialize_element()[source]
Perform Initialization of the element if needed when called
Will be called automatically during the machine execution if the elt it comes from (using the StateMachine) is not a child of itself
To be reimplemented
- save_data(dte, done=True)[source]
By calling this method, data will be logged using the TimeSaver
- Parameters:
dte (
DataToExport) – data to log and eventually custom save in self._save_data (reimplemented)done (
bool) – if True (default)the done signal is emitted ending this state
- to_dict_custom()[source]
adds attribute to a dict in order to produce a human readable representation/configuration for this element
to be reimplemented
- property parent: SeqEltBase
Get/Set this element parent
- class pymodaq.extensions.sequencer.utilities.element_factory.SeqEltFactory[source]
The factory class to get Sequencer Elements
- Attributes:
- elements
Methods
get_seq_elt(name)Factory command to get registered subentry handler.
Class decorator method to register SubEntryHandlers class to the internal registry.
The elements shipped with PyMoDAQ:
- class pymodaq.extensions.sequencer.utilities.elements.state.StateElt(*args, **kwargs)[source]
- Attributes:
- experiment
- state
- states
Methods
Check the validity of the element
do_things_with_dashboard()Reset the state to 'default' if not declared in the StateManager of the DashBoard
from_dict_custom(dict_config)Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
size_hint()adds attribute to a dict in order to produce a human readable representation/configuration for this element
save_actuator_moved
set_state
set_states
update_combo_states
update_states
- check_set_is_valid()[source]
Check the validity of the element
Will be called before executing the element. Try to make sure the element is valid or return None if the user may do something!
- Return type:
- filter_state_wrt_manager()[source]
Reset the state to ‘default’ if not declared in the StateManager of the DashBoard
- class pymodaq.extensions.sequencer.utilities.elements.move.MoveElt(*args, **kwargs)[source]
Methods
Check the validity of the element
do_things_with_dashboard()from_dict_custom(dict_config)Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
initialize_element()size_hint()adds attribute to a dict in order to produce a human readable representation/configuration for this element
set_wait_move_done
- check_set_is_valid()[source]
Check the validity of the element
Will be called before executing the element. Try to make sure the element is valid or raise ElementError if the user may do something!
- class pymodaq.extensions.sequencer.utilities.elements.grab.GrabElt(*args, **kwargs)[source]
- Attributes:
- detectors
- selected
- status
Methods
Check the validity of the element
do_things_with_dashboard()Filter selected given the presence of the detector in the manager
from_dict_custom(dict_config)Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
size_hint()adds attribute to a dict in order to produce a human readable representation/configuration for this element
clean_signals
get_selected_detectors
set_status
update_detectors_from_combo
update_modules
- check_set_is_valid()[source]
Check the validity of the element
Will be called before executing the element. Try to make sure the element is valid or return None if the user may do something!
- filter_selected_wrt_manager()[source]
Filter selected given the presence of the detector in the manager
- class pymodaq.extensions.sequencer.utilities.elements.wait.WaitElt(*args, **kwargs)[source]
- Attributes:
- wait_time
Methods
check_set_is_valid()from_dict_custom(dict_config)Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
adds attribute to a dict in order to produce a human readable representation/configuration for this element
done
set_wait_time_from_spinbox
- class pymodaq.extensions.sequencer.utilities.elements.repeat.RepeatElt(*args, **kwargs)[source]
- Attributes:
- n_repeat
Methods
Check the validity of the element
do_things_with_dashboard()from_dict_custom(dict_config)Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
initialize_element()adds attribute to a dict in order to produce a human readable representation/configuration for this element
set_repeat_from_spinbox
- check_set_is_valid()[source]
Check the validity of the element
Will be called before executing the element. Try to make sure the element is valid or return None if the user may do something!
- class pymodaq.extensions.sequencer.utilities.elements.scanner.ScannerElt(*args, **kwargs)[source]
Methods
Check the validity of the element
do_things_with_dashboard()from_dict_custom(dict_config)Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
initialize_element()size_hint()adds attribute to a dict in order to produce a human readable representation/configuration for this element
- check_set_is_valid()[source]
Check the validity of the element
Will be called before executing the element. Try to make sure the element is valid or return None if the user may do something!
- class pymodaq.extensions.sequencer.utilities.elements.choice.ChoiceElt(*args, **kwargs)[source]
- Attributes:
- choice_model
- go_to_false
- go_to_true
- without_ids
- without_types
Methods
Check the validity of the element
do_things_with_dashboard()from_dict_custom(dict_config)Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
set_go_to_true(value)set go_true given the value which is the index of the get_ids or self.get_elts_as_str return lists
adds attribute to a dict in order to produce a human readable representation/configuration for this element
set_choice_model
set_go_to_false
update_modules
update_params
update_target_states
- check_set_is_valid()[source]
Check the validity of the element
Will be called before executing the element. Try to make sure the element is valid or return None if the user may do something!
- Return type:
- from_dict_custom(dict_config)[source]
Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
- class pymodaq.extensions.sequencer.utilities.elements.sequence.SequenceElt(*args, **kwargs)[source]
- Attributes:
- sequence
- sequence_obj
Methods
Check the validity of the element
do_things_with_dashboard()If this Element is using the Dashboard, once its setter has been called, this method will be executed
from_dict_custom(dict_config)Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
Get the list of Sequences that can be started, removing the one this element belong to
Get the list of Sequences that can be started, removing the one this element belong to
adds attribute to a dict in order to produce a human readable representation/configuration for this element
register_sequence
set_sequence
unregister_sequence
update_combo_sequences
- check_set_is_valid()[source]
Check the validity of the element
Will be called before executing the element. Try to make sure the element is valid or return None if the user may do something!
- Return type:
- do_things_with_parent_sequence()[source]
If this Element is using the Dashboard, once its setter has been called, this method will be executed
Do whatever is needed to instantiate your element with the Dashboard
- from_dict_custom(dict_config)[source]
Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
- get_sequences()[source]
Get the list of Sequences that can be started, removing the one this element belong to
8.2.3.3. Choice models
- class pymodaq.extensions.sequencer.utilities.choice_models.model.ChoiceModelBase(parent_elt)[source]
- Attributes:
- selected
Methods
Check if the current settings of this model are valid
from_dict(dict_config)Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
to_dict()adds attribute to a dict in order to produce a human readable representation/configuration for this model params
called whenever the parent modules manager is updated
execute
- check_set_is_valid()[source]
Check if the current settings of this model are valid
To be reimplemented
Should raise ElementError if not valid
- from_dict(dict_config)[source]
Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
to be reimplemented
- pymodaq.extensions.sequencer.utilities.choice_models.model.get_choice_models()[source]
Register ChoiceModels in pymodaq models entrypoints
- Returns:
list
- Return type:
listofdict containing the nameandpython moduleofthe found models
Example
model = [{‘name’: ‘MyModel’, ‘class’: DataModel}]
- class pymodaq.extensions.sequencer.utilities.choice_models.factory.ChoiceModelFactory[source]
The factory class to get Sequencer Elements
- Attributes:
- models
Methods
get_model(name)Factory command to get registered subentry handler.
Class decorator method to register Models to be used with the Choice Element class to the internal registry.
- classmethod get_model(name)[source]
Factory command to get registered subentry handler.
This method gets the appropriate executor class from the registry
- Return type:
- classmethod register_choice()[source]
Class decorator method to register Models to be used with the Choice Element class to the internal registry. Must be used as a decorator above the definition of a ChoiceModelBase inherited class.
The class must implement the ChoiceModelBase interface
- Return type:
The models shipped with PyMoDAQ:
- class pymodaq.extensions.sequencer.models.threshold_choice_model.ThresholdChoiceModel(*args, **kwargs)[source]
Methods
Check if the current settings of this model are valid
from_dict(dict_config)Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
to_dict()adds attribute to a dict in order to produce a human readable representation/configuration for this model params
called whenever the parent modules manager is updated
execute
probe_data
process_dte
- from_dict(dict_config)[source]
Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods
- class pymodaq.extensions.sequencer.models.user_input_choice.UserInput(parent_elt)[source]
Methods
execute
8.2.3.4. State machine
- class pymodaq.extensions.sequencer.utilities.states.CompositeState(elt, *args, **kwargs)[source]
- Attributes:
- external_transitions
Methods
add_external_transition
clear_state_and_transitions
clear_transitions
set_do_init
setup_states
- class pymodaq.extensions.sequencer.utilities.states.TrackedTransition(signal, source_state, target_state=None)[source]
Methods
is_child_of(child_state, target_parent)Walks up the parent chain to see if target_parent is an ancestor.
eventTest
onTransition
targetState
update_target