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

Sequencer(parent, dashboard)

SequenceWorker(sequencer[, parent])

class pymodaq.extensions.sequencer.sequencer.Sequencer(parent, dashboard)[source]
Attributes:
main_sequence
module_and_data_saver

Complex but Standardized way to save data from the CustomExt and

sequence_names

Methods

connect_things()

Connect actions and/or other widgets signal to methods

do_things_after_experiment_set(experiment_name)

do_things_after_ui_setup()

populate_status_bar()

setup_actions()

Method where to create actions to be subclassed.

setup_docks_and_widgets()

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

connect_things()[source]

Connect actions and/or other widgets signal to methods

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

setup_menus_and_toolbars(menubar=None)[source]

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

update_sequence_name(old_name, new_name)[source]

browse all elts in the sequences for SequenceElt and modify the current seq name if it has been changed!

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_things()

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

setup_actions()

Method where to create actions to be subclassed.

setup_docks_and_widgets()

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

connect_things()[source]

Connect actions and/or other widgets signal to methods

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

setup_menus_and_toolbars(menubar=None)[source]

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

SeqEltBase(id[, parent, parent_sequence])

Base class defining the interface of all elements handled by the Sequencer

SeqEltFactory()

The factory class to get Sequencer Elements

ElementError

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
parent

Get/Set this element parent

parent_sequence

Methods

check_set_is_valid()

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

do_things_with_dashboard()

If this Element is using the Dashboard, once its setter has been called, this method will be executed

do_things_with_parent_sequence()

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

initialize_element()

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

size_hint()

Returns the Size the corresponding widget will likely have

to_dict()

Serialization in a dictionary

to_dict_custom()

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:

Tuple[SeqEltBase, bytes]

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:

SeqEltBase

classmethod serialize(obj)[source]

Convert a SeqEltBase object into a bytes string

Returns:

bytes

Return type:

bytes

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

child(index)[source]

Get the child by its index within the list of children

Return type:

Optional[SeqEltBase]

child_by_index(index)[source]

Get the child by its unique index

Return type:

Optional[SeqEltBase]

create_widget(parent=None)[source]

Public API to be used to create the widget representing this elt

Return type:

QWidget

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:

Optional[SeqEltBase]

get_elts(parent_elt=None, without_ids=(), without_types=())[source]

Get as a list all element in the tree starting from parent_elt

Parameters:
Returns:

list[SeqEltBase]

Return type:

list[SeqEltBase]

get_elts_as_str(parent_elt=None, without_ids=(), without_types=())[source]

Get the elements name of all existing elements

Return type:

list[str]

get_ids(parent_elt=None, without_ids=(), without_types=())[source]

Get the ids of the existing elements

Return type:

list[int]

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

set_parent(value)[source]

to be used as a slot or …

size_hint()[source]

Returns the Size the corresponding widget will likely have

Return type:

QSize

to_dict()[source]

Serialization in a dictionary

Return type:

dict[str, Any]

to_dict_custom()[source]

adds attribute to a dict in order to produce a human readable representation/configuration for this element

to be reimplemented

Return type:

dict[str, Any]

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.

register_elt()

Class decorator method to register SubEntryHandlers class to the internal registry.

classmethod get_seq_elt(name)[source]

Factory command to get registered subentry handler.

This method gets the appropriate executor class from the registry

Return type:

type[SeqEltBase]

classmethod register_elt()[source]

Class decorator method to register SubEntryHandlers class to the internal registry. Must be used as a decorator above the definition of an SubEntryHandler inherited class.

The entry class must implement specific class attributes and methods

Return type:

Callable

class pymodaq.extensions.sequencer.utilities.element_factory.ElementError[source]

The elements shipped with PyMoDAQ:

class pymodaq.extensions.sequencer.utilities.elements.state.StateElt(*args, **kwargs)[source]
Attributes:
experiment
state
states

Methods

check_set_is_valid()

Check the validity of the element

do_things_with_dashboard()

filter_state_wrt_manager()

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()

to_dict_custom()

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:

bool

filter_state_wrt_manager()[source]

Reset the state to ‘default’ if not declared in the StateManager of 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

to_dict_custom()[source]

adds attribute to a dict in order to produce a human readable representation/configuration for this element

to be reimplemented

Return type:

dict[str, Any]

class pymodaq.extensions.sequencer.utilities.elements.move.MoveElt(*args, **kwargs)[source]

Methods

check_set_is_valid()

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()

to_dict_custom()

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!

from_dict_custom(dict_config)[source]

Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods

to_dict_custom()[source]

adds attribute to a dict in order to produce a human readable representation/configuration for this element

to be reimplemented

Return type:

dict[str, Any]

class pymodaq.extensions.sequencer.utilities.elements.grab.GrabElt(*args, **kwargs)[source]
Attributes:
detectors
selected
status

Methods

check_set_is_valid()

Check the validity of the element

do_things_with_dashboard()

filter_selected_wrt_manager()

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()

to_dict_custom()

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

from_dict_custom(dict_config)[source]

Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods

to_dict_custom()[source]

adds attribute to a dict in order to produce a human readable representation/configuration for this element

to be reimplemented

Return type:

dict[str, Any]

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

to_dict_custom()

adds attribute to a dict in order to produce a human readable representation/configuration for this element

done

set_wait_time_from_spinbox

from_dict_custom(dict_config)[source]

Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods

to_dict_custom()[source]

adds attribute to a dict in order to produce a human readable representation/configuration for this element

to be reimplemented

Return type:

dict[str, Any]

class pymodaq.extensions.sequencer.utilities.elements.repeat.RepeatElt(*args, **kwargs)[source]
Attributes:
n_repeat

Methods

check_set_is_valid()

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()

to_dict_custom()

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!

from_dict_custom(dict_config)[source]

Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods

to_dict_custom()[source]

adds attribute to a dict in order to produce a human readable representation/configuration for this element

to be reimplemented

Return type:

dict[str, Any]

class pymodaq.extensions.sequencer.utilities.elements.scanner.ScannerElt(*args, **kwargs)[source]

Methods

check_set_is_valid()

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()

to_dict_custom()

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!

from_dict_custom(dict_config)[source]

Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods

to_dict_custom()[source]

adds attribute to a dict in order to produce a human readable representation/configuration for this element

to be reimplemented

Return type:

dict[str, Any]

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_set_is_valid()

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

to_dict_custom()

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:

bool

from_dict_custom(dict_config)[source]

Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods

set_go_to_true(value)[source]

set go_true given the value which is the index of the get_ids or self.get_elts_as_str return lists

to_dict_custom()[source]

adds attribute to a dict in order to produce a human readable representation/configuration for this element

to be reimplemented

Return type:

dict[str, Any]

class pymodaq.extensions.sequencer.utilities.elements.sequence.SequenceElt(*args, **kwargs)[source]
Attributes:
sequence
sequence_obj

Methods

check_set_is_valid()

Check the validity of the element

do_things_with_dashboard()

do_things_with_parent_sequence()

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_sequences()

Get the list of Sequences that can be started, removing the one this element belong to

get_sequences_name()

Get the list of Sequences that can be started, removing the one this element belong to

to_dict_custom()

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:

bool

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

Return type:

list[Sequence]

get_sequences_name()[source]

Get the list of Sequences that can be started, removing the one this element belong to

Return type:

list[str]

to_dict_custom()[source]

adds attribute to a dict in order to produce a human readable representation/configuration for this element

to be reimplemented

Return type:

dict[str, Any]

8.2.3.3. Choice models

class pymodaq.extensions.sequencer.utilities.choice_models.model.ChoiceModelBase(parent_elt)[source]
Attributes:
selected

Methods

check_set_is_valid()

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

updated_module_manager()

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

to_dict()[source]

adds attribute to a dict in order to produce a human readable representation/configuration for this model params

to be reimplemented

Return type:

dict[str, Any]

updated_module_manager()[source]

called whenever the parent modules manager is updated

to be reimplemented

pymodaq.extensions.sequencer.utilities.choice_models.model.get_choice_models()[source]

Register ChoiceModels in pymodaq models entrypoints

Returns:

list

Return type:

list of dict containing the name and python module of the 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.

register_choice()

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:

type[ChoiceModelBase]

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:

Callable

The models shipped with PyMoDAQ:

class pymodaq.extensions.sequencer.models.threshold_choice_model.ThresholdChoiceModel(*args, **kwargs)[source]

Methods

check_set_is_valid()

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

updated_module_manager()

called whenever the parent modules manager is updated

execute

probe_data

process_dte

check_set_is_valid()[source]

Check if the current settings of this model are valid

from_dict(dict_config)[source]

Create/set the custom part of the element to finish initialization using setters, attribute assignment or methods

to_dict()[source]

adds attribute to a dict in order to produce a human readable representation/configuration for this model params

Return type:

dict[str, Any]

updated_module_manager()[source]

called whenever the parent modules manager is updated

class pymodaq.extensions.sequencer.models.user_input_choice.UserInput(parent_elt)[source]

Methods

execute

class pymodaq.extensions.sequencer.models.true_choice_model.TrueChoiceModel(parent_elt)[source]

Methods

execute

class pymodaq.extensions.sequencer.models.false_choice_model.FalseChoiceModel(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

static is_child_of(child_state, target_parent)[source]

Walks up the parent chain to see if target_parent is an ancestor.

class pymodaq.extensions.sequencer.utilities.states.ValueTransition(signal, value, source_state, target_state=None)[source]

Methods

eventTest

class pymodaq.extensions.sequencer.utilities.states.InterruptState(*args, **kwargs)[source]

Methods

onEntry