MVC Models: rafcon.gui.models

This package contains all models of the MVC architecture.

The models hold the data for, which are shown in the views. These models typically hold an element of the core, which is observable. For example, the StateModel holds a reference to a State class object from the core. If the core element changes, the model recognizes these changes and forwards the notification to the controllers, if they observe the changed model property.

AbstractStateModel (in abstract_state)

class rafcon.gui.models.abstract_state.AbstractStateModel(state, parent=None, meta=None)

Bases: MetaModel, Hashable

This is an abstract class serving as base class for state models

The model class is part of the MVC architecture. It holds the data to be shown (in this case a state).

Parameters:
property action_signal
action_signal_triggered(model, prop_name, info)

This method notifies the parent state and child state models about complex actions

child_model_changed(notification_overview)
copy_meta_data_from_state_m(source_state_m)

Dismiss current meta data and copy meta data from given state model

The meta data of the given state model is used as meta data for this state. Also the meta data of all state elements (data ports, outcomes, etc.) is overwritten with the meta data of the elements of the given state.

Parameters:

source_state_m – State model to load the meta data from

property core_element
property destruction_signal
get_data_port_m(data_port_id)

Searches and returns the model of a data port of a given state

The method searches a port with the given id in the data ports of the given state model. If the state model is a container state, not only the input and output data ports are looked at, but also the scoped variables.

Parameters:

data_port_id – The data port id to be searched

Returns:

The model of the data port or None if it is not found

get_input_data_port_m(data_port_id)

Returns the input data port model for the given data port id

Parameters:

data_port_id – The data port id to search for

Returns:

The model of the data port with the given id

get_observable_action_signal()
get_observable_destruction_signal()
get_observable_income()
get_observable_input_data_ports()
get_observable_is_start()
get_observable_meta_signal()
get_observable_outcomes()
get_observable_output_data_ports()
get_observable_state()
get_outcome_m(outcome_id)

Returns the outcome model for the given outcome id

Parameters:

outcome_id – The outcome id to search for

Returns:

The model of the outcome with the given id

get_output_data_port_m(data_port_id)

Returns the output data port model for the given data port id

Parameters:

data_port_id – The data port id to search for

Returns:

The model of the data port with the given id

get_state_machine_m(two_factor_check=True)

Get respective state machine model

Get a reference of the state machine model the state model belongs to. As long as the root state model has no direct reference to its state machine model the state machine manager model is checked respective model.

Return type:

rafcon.gui.models.state_machine.StateMachineModel

Returns:

respective state machine model

property hierarchy_level
property income
property input_data_ports
property is_about_to_be_destroyed_recursively
property is_start
load_meta_data(path=None)

Load meta data of state model from the file system

The meta data of the state model is loaded from the file system and stored in the meta property of the model. Existing meta data is removed. Also the meta data of all state elements (data ports, outcomes, etc) are loaded, as those stored in the same file as the meta data of the state.

This is either called on the __init__ of a new state model or if a state model for a container state is created, which then calls load_meta_data for all its children.

Parameters:

path (str) – Optional file system path to the meta data file. If not given, the path will be derived from the state’s path on the filesystem

Returns:

if meta data file was loaded True otherwise False

Return type:

bool

meta_changed(model, prop_name, info)

This method notifies the parent state about changes made to the meta data

property meta_signal
model_changed(model, prop_name, info)

This method notifies parent state about changes made to the state

property outcomes
property output_data_ports
property parent
prepare_destruction(recursive=True)

Prepares the model for destruction

Recursively un-registers all observers and removes references to child models

set_observable_action_signal(value)
set_observable_destruction_signal(value)
set_observable_income(value)
set_observable_input_data_ports(value)
set_observable_is_start(value)
set_observable_meta_signal(value)
set_observable_outcomes(value)
set_observable_output_data_ports(value)
set_observable_state(value)
property state
state_counter = 0
store_meta_data(copy_path=None)

Save meta data of state model to the file system

This method generates a dictionary of the meta data of the state together with the meta data of all state elements (data ports, outcomes, etc.) and stores it on the filesystem. Secure that the store meta data method is called after storing the core data otherwise the last_stored_path is maybe wrong or None. The copy path is considered to be a state machine file system path but not the current one but e.g. of a as copy saved state machine. The meta data will be stored in respective relative state folder in the state machine hierarchy. This folder has to exist. Dues the core elements of the state machine has to be stored first.

Parameters:

copy_path (str) – Optional copy path if meta data is not stored to the file system path of state machine

update_hash(obj_hash)

Should be implemented by derived classes to update the hash with their data fields

Parameters:

obj_hash – The hash object (see Python hashlib)

update_is_start()

Updates the is_start property of the state

A state is a start state, if it is the root state, it has no parent, the parent is a LibraryState or the state’s state_id is identical with the ContainerState.start_state_id of the ContainerState it is within.

update_meta_data_hash(obj_hash)

Should be implemented by derived classes to update the hash with their meta data fields

Parameters:

obj_hash – The hash object (see Python hashlib)

rafcon.gui.models.abstract_state.get_state_model_class_for_state(state)

Determines the model required for the given state class

Parameters:

state – Instance of a state (ExecutionState, BarrierConcurrencyState, …)

Returns:

The model class required for holding such a state instance

rafcon.gui.models.abstract_state.mirror_y_axis_in_vividict_element(vividict, key)

StateModel (in state)

class rafcon.gui.models.state.StateModel(state, parent=None, meta=None, load_meta_data=True, expected_future_models=None)

Bases: AbstractStateModel

This model class manages a State, for the moment only ExecutionStates

The model class is part of the MVC architecture. It holds the data to be shown (in this case a state).

Parameters:
add_missing_model(model_list_or_dict, core_elements_dict, model_name, model_class, model_key)

Adds one missing model

The method will search for the first core-object out of core_object_dict not represented in the list or dict of models handed by model_list_or_dict, adds it and returns without continue to search for more objects which maybe are missing in model_list_or_dict with respect to the core_object_dict.

Parameters:
  • model_list_or_dict – could be a list or dictionary of one model type

  • core_elements_dict – dictionary of one type of core-elements (rafcon.core)

  • model_name – prop_name for the core-element hold by the model, this core-element is covered by the model

  • model_class – model-class of the elements that should be insert

  • model_key – if model_list_or_dict is a dictionary the key is the id of the respective element (e.g. ‘state_id’)

Returns:

True, is a new model was added, False else

Return type:

bool

expected_future_models = None
get_cause_and_affected_model_list(model)
get_model_info(model)
model_changed(model, prop_name, info)

This method notifies the model lists and the parent state about changes

The method is called each time, the model is changed. This happens, when the state itself changes or one of its children (outcomes, ports) changes. Changes of the children cannot be observed directly, therefore children notify their parent about their changes by calling this method. This method then checks, what has been changed by looking at the method that caused the change. In the following, it notifies the list in which the change happened about the change. E.g. one input data port changes its name. The model of the port observes itself and notifies the parent ( i.e. the state model) about the change by calling this method with the information about the change. This method recognizes that the method “modify_input_data_port” caused the change and therefore triggers a notify on the list if input data port models. “notify_before” is used as trigger method when the changing function is entered and “notify_after” is used when the changing function returns. This changing function in the example would be “modify_input_data_port”.

Parameters:
  • model – The model that was changed

  • prop_name – The property that was changed

  • info – Information about the change (e.g. the name of the changing function)

re_initiate_model_list(model_list_or_dict, core_objects_dict, model_name, model_class, model_key)

Recreate model list

The method re-initiate a handed list or dictionary of models with the new dictionary of core-objects.

Parameters:
  • model_list_or_dict – could be a list or dictionary of one model type

  • core_objects_dict – new dictionary of one type of core-elements (rafcon.core)

  • model_name – prop_name for the core-element hold by the model, this core-element is covered by the model

  • model_class – model-class of the elements that should be insert

  • model_key – if model_list_or_dict is a dictionary the key is the id of the respective element (e.g. ‘state_id’)

Returns:

remove_additional_model(model_list_or_dict, core_objects_dict, model_name, model_key, destroy=True)

Remove one unnecessary model

The method will search for the first model-object out of model_list_or_dict that represents no core-object in the dictionary of core-objects handed by core_objects_dict, remove it and return without continue to search for more model-objects which maybe are unnecessary, too.

Parameters:
  • model_list_or_dict – could be a list or dictionary of one model type

  • core_objects_dict – dictionary of one type of core-elements (rafcon.core)

  • model_name – prop_name for the core-element hold by the model, this core-element is covered by the model

  • model_key – if model_list_or_dict is a dictionary the key is the id of the respective element (e.g. ‘state_id’)

Returns:

remove_specific_model(model_list_or_dict, core_element, model_key=None, recursive=True, destroy=True)
update_models(model, name, info)

This method is always triggered when the core state changes

It keeps the following models/model-lists consistent: input-data-port models output-data-port models outcome models

ContainerStateModel (in container_state)

class rafcon.gui.models.container_state.ContainerStateModel(container_state, parent=None, meta=None, load_meta_data=True, expected_future_models=None)

Bases: StateModel

This model class manages a ContainerState

The model class is part of the MVC architecture. It holds the data to be shown (in this case a container state).

Parameters:

container_state (ContainerState) – The container state to be managed

copy_meta_data_from_state_m(source_state_m)

Dismiss current meta data and copy meta data from given state model

In addition to the state model method, also the meta data of container states is copied. Then, the meta data of child states are recursively copied.

Parameters:

source_state_m – State model to load the meta data from

property data_flows
get_cause_and_affected_model_list(model)
get_data_flow_m(data_flow_id)

Searches and return the data flow model with the given in the given container state model

Parameters:

data_flow_id – The data flow id to be searched

Returns:

The model of the data flow or None if it is not found

get_data_port_m(data_port_id)

Searches and returns the model of a data port of a given state

The method searches a port with the given id in the data ports of the given state model. If the state model is a container state, not only the input and output data ports are looked at, but also the scoped variables.

Parameters:

data_port_id – The data port id to be searched

Returns:

The model of the data port or None if it is not found

get_observable_data_flows()
get_observable_scoped_variables()
get_observable_states()
get_observable_transitions()
get_scoped_variable_m(data_port_id)

Returns the scoped variable model for the given data port id

Parameters:

data_port_id – The data port id to search for

Returns:

The model of the scoped variable with the given id

get_transition_m(transition_id)

Searches and return the transition model with the given in the given container state model

Parameters:

transition_id – The transition id to be searched

Returns:

The model of the transition or None if it is not found

group_states(model, prop_name, info)
insert_meta_data_from_models_dict(source_models_dict, notify_logger_method)
model_changed(model, prop_name, info)

This method notifies the model lists and the parent state about changes

The method is called each time, the model is changed. This happens, when the state itself changes or one of its children (states, transitions, data flows) changes. Changes of the children cannot be observed directly, therefore children notify their parent about their changes by calling this method. This method then checks, what has been changed by looking at the model that is passed to it. In the following it notifies the list in which the change happened about the change. E.g. one child state changes its name. The model of that state observes itself and notifies the parent ( i.e. this state model) about the change by calling this method with the information about the change. This method recognizes that the model is of type StateModel and therefore triggers a notify on the list of state models. “notify_before” is used as trigger method when the changing function is entered and “notify_after” is used when the changing function returns. This changing function in the example would be the setter of the property name. :param model: The model that was changed :param prop_name: The property that was changed :param info: Information about the change (e.g. the name of the changing function)

prepare_destruction(recursive=True)

Prepares the model for destruction

Recursively un-registers all observers and removes references to child models. Extends the destroy method of the base class by child elements of a container state.

property scoped_variables
set_observable_data_flows(value)
set_observable_scoped_variables(value)
set_observable_states(value)
set_observable_transitions(value)
property states
store_meta_data(copy_path=None)

Store meta data of container states to the filesystem

Recursively stores meta data of child states. For further insides read the description of also called respective super class method.

Parameters:

copy_path (str) – Optional copy path if meta data is not stored to the file system path of state machine

substitute_state(model, prop_name, info)
property transitions
ungroup_state(model, prop_name, info)
update_child_is_start()

Updates the is_child property of its child states

update_child_models(_, name, info)

This method is always triggered when the state model changes

It keeps the following models/model-lists consistent: transition models data-flow models state models scoped variable models

update_hash(obj_hash)

Should be implemented by derived classes to update the hash with their data fields

Parameters:

obj_hash – The hash object (see Python hashlib)

update_meta_data_hash(obj_hash)

Should be implemented by derived classes to update the hash with their meta data fields

Parameters:

obj_hash – The hash object (see Python hashlib)

LibraryStateModel (in library_state)

class rafcon.gui.models.library_state.LibraryStateModel(state, parent=None, meta=None, load_meta_data=True)

Bases: AbstractStateModel

This model class manages a LibraryState

The model class is part of the MVC architecture. It holds the data to be shown (in this case a state).

Parameters:

state (rafcon.core.states.library_state.LibraryState) – The state to be managed

copy_meta_data_from_state_m(source_state_m)

Dismiss current meta data and copy meta data from given state model

The meta data of the given state model is used as meta data for this state. Also the meta data of all state elements (data ports, outcomes, etc.) is overwritten with the meta data of the elements of the given state.

Parameters:

source_state_m – State model to load the meta data from

enforce_generation_of_state_copy_model()

This enforce a load of state copy model without considering meta data

initiate_library_root_state_model()
property is_about_to_be_destroyed_recursively
model_changed(model, prop_name, info)

This method notifies parent state about changes made to the state

prepare_destruction(recursive=True)

Prepares the model for destruction

Recursively un-registers all observers and removes references to child models

recursive_generate_models(load_meta_data)
show_content()

Check if content of library is to be shown

Content is shown, if the uppermost state’s meta flag “show_content” is True and the library hierarchy depth (up to MAX_VISIBLE_LIBRARY_HIERARCHY level) is not to high.

Returns:

Whether the content is to be shown

Return type:

bool

state_copy = None
update_hash(obj_hash)

Should be implemented by derived classes to update the hash with their data fields

Parameters:

obj_hash – The hash object (see Python hashlib)

StateElementModel (in state_element)

class rafcon.gui.models.state_element.StateElementModel(parent, meta=None)

Bases: MetaModel, Hashable

This model class serves as base class for all models within a state model (ports, connections)

Each state element model has a parent, meta and temp data. If observes itself and informs the parent about changes.

Parameters:
property core_element

Return the core element represented by this model

Returns:

core element of the model

Return type:

rafcon.core.state_elements.state_element.StateElement

property destruction_signal
get_observable_destruction_signal()
get_observable_meta_signal()
get_state_machine_m()
meta_changed(model, prop_name, info)

This method notifies the parent state about changes made to the meta data

property meta_signal
model_changed(model, prop_name, info)

This method notifies the parent state about changes made to the state element

property parent

Getter for the parent state model of the state element

Returns:

None if parent is not defined, else the model of the parent state

Return type:

rafcon.gui.models.abstract_state.AbstractState

prepare_destruction()

Prepares the model for destruction

Unregisters the model from observing itself.

set_observable_destruction_signal(value)
set_observable_meta_signal(value)
update_hash(obj_hash)

Should be implemented by derived classes to update the hash with their data fields

Parameters:

obj_hash – The hash object (see Python hashlib)

TransitionModel (in transition)

class rafcon.gui.models.transition.TransitionModel(transition, parent, meta=None)

Bases: StateElementModel

This model class manages a Transition

Parameters:
property core_element

Return the core element represented by this model

Returns:

core element of the model

Return type:

rafcon.core.state_elements.state_element.StateElement

get_observable_transition()
model_changed(model, prop_name, info)

This method notifies the parent state about changes made to the state element

prepare_destruction()

Prepares the model for destruction

Unregisters the model from observing itself.

set_observable_transition(value)
property transition
rafcon.gui.models.transition.mirror_waypoints(vividict)

DataFlowModel (in data_flow)

class rafcon.gui.models.data_flow.DataFlowModel(data_flow, parent, meta=None)

Bases: StateElementModel

This model class manages a DataFlow

Parameters:
property core_element

Return the core element represented by this model

Returns:

core element of the model

Return type:

rafcon.core.state_elements.state_element.StateElement

property data_flow
get_observable_data_flow()
model_changed(model, prop_name, info)

This method notifies the parent state about changes made to the state element

prepare_destruction()

Prepares the model for destruction

Unregisters the model from observing itself.

set_observable_data_flow(value)

DataPortModel (in data_port)

class rafcon.gui.models.data_port.DataPortModel(data_port, parent, meta=None)

Bases: StateElementModel

This model class manages a DataPort

Parameters:
property core_element

Return the core element represented by this model

Returns:

core element of the model

Return type:

rafcon.core.state_elements.state_element.StateElement

property data_port
get_observable_data_port()
model_changed(model, prop_name, info)

This method notifies the parent state about changes made to the state element

prepare_destruction()

Prepares the model for destruction

Unregisters the model from observing itself.

set_observable_data_port(value)

ScopedVariableModel (in scoped_variable)

class rafcon.gui.models.scoped_variable.ScopedVariableModel(scoped_variable, parent, meta=None)

Bases: StateElementModel

This model class manages a ScopedVariable

Parameters:
property core_element

Return the core element represented by this model

Returns:

core element of the model

Return type:

rafcon.core.state_elements.state_element.StateElement

get_observable_scoped_variable()
model_changed(model, prop_name, info)

This method notifies the parent state about changes made to the state element

prepare_destruction()

Prepares the model for destruction

Unregisters the model from observing itself.

property scoped_variable
set_observable_scoped_variable(value)

Selection (in selection)

class rafcon.gui.models.selection.Selection(parent_signal=None)

Bases: ModelMT

This class contains the selected models of a state_machine

add(*args, **kwargs)

Check for changes in the selection

If the selection is changed by the decorated method, the internal core element lists are updated and a signal is emitted with the old and new selection as well as the name of the method that caused the change..

clear(*args, **kwargs)

Check for changes in the selection

If the selection is changed by the decorated method, the internal core element lists are updated and a signal is emitted with the old and new selection as well as the name of the method that caused the change..

property data_flows

Returns all selected data flows

Returns:

Subset of the selection, only containing data flows

Return type:

set

property focus

Returns the currently focused element

property focus_signal
get_all()

Return a copy of the selection

Returns:

Copy of the set of selected elements

Return type:

set

get_observable_focus_signal()
get_observable_selection_changed_signal()
get_selected_elements_of_core_class(core_element_type)

Returns all selected elements having the specified core_element_type as state element class

Returns:

Subset of the selection, only containing elements having core_element_type as state element class

Return type:

set

get_selected_state()

Return the first state within the selection

Returns:

First state within the selection or None if there is none

Return type:

AbstractStateModel

handle_new_selection(*args, **kwargs)

Check for changes in the selection

If the selection is changed by the decorated method, the internal core element lists are updated and a signal is emitted with the old and new selection as well as the name of the method that caused the change..

handle_prepared_selection_of_core_class_elements(*args, **kwargs)

Check for changes in the selection

If the selection is changed by the decorated method, the internal core element lists are updated and a signal is emitted with the old and new selection as well as the name of the method that caused the change..

property income

Alias for incomes()

property incomes

Returns all selected incomes

Returns:

Subset of the selection, only containing incomes

Return type:

set

property input_data_ports

Returns all selected input data ports

Returns:

Subset of the selection, only containing input data ports

Return type:

set

is_selected(model)

Checks whether the given model is selected

Parameters:

model

Returns:

True if the model is within the selection, False else

Return type:

bool

on_model_destruct(destructed_model, signal, info)

Deselect models that are being destroyed

property outcomes

Returns all selected outcomes

Returns:

Subset of the selection, only containing outcomes

Return type:

set

property output_data_ports

Returns all selected output data ports

Returns:

Subset of the selection, only containing output data ports

Return type:

set

remove(*args, **kwargs)

Check for changes in the selection

If the selection is changed by the decorated method, the internal core element lists are updated and a signal is emitted with the old and new selection as well as the name of the method that caused the change..

property scoped_variables

Returns all selected scoped variables

Returns:

Subset of the selection, only containing scoped variables

Return type:

set

property selection_changed_signal
set(*args, **kwargs)

Check for changes in the selection

If the selection is changed by the decorated method, the internal core element lists are updated and a signal is emitted with the old and new selection as well as the name of the method that caused the change..

set_observable_focus_signal(value)
set_observable_selection_changed_signal(value)
property states

Returns all selected states

Returns:

Subset of the selection, only containing states

Return type:

set

property transitions

Returns all selected transitions

Returns:

Subset of the selection, only containing transitions

Return type:

set

update_core_element_lists()

Maintains inner lists of selected elements with a specific core element class

rafcon.gui.models.selection.extend_selection()

Checks is the selection is to be extended

The selection is to be extended, if a special modifier key (typically <Ctrl>) is being pressed.

Returns:

If to extend the selection

Return type:

True

rafcon.gui.models.selection.reduce_to_parent_states(models)

Remove all state models that also have their parents in the list

The function filters the list of models, so that for no model in the list, one of it (grand-)parents is also in the list. E.g. if the input models consists of a hierarchy state with two of its child states, the resulting list only contains the hierarchy state.

Parameters:

models (set) – The set of selected models

Returns:

The reduced set of selected models

Return type:

set

rafcon.gui.models.selection.updates_selection(update_selection)

Decorator indicating that the decorated method could change the selection

LogicalPortModel (in logical_port)

class rafcon.gui.models.logical_port.IncomeModel(income, parent, meta=None)

Bases: LogicalPortModel

This model class manages an Income

Parameters:
property core_element

Return the core element represented by this model

Returns:

core element of the model

Return type:

rafcon.core.state_elements.state_element.StateElement

get_observable_income()
property income
model_changed(model, prop_name, info)

This method notifies the parent state about changes made to the state element

set_observable_income(value)
class rafcon.gui.models.logical_port.LogicalPortModel(parent, meta=None)

Bases: StateElementModel

This model class serves as base class for all logical ports

class rafcon.gui.models.logical_port.OutcomeModel(outcome, parent, meta=None)

Bases: LogicalPortModel

This model class manages an Outcome

Parameters:
property core_element

Return the core element represented by this model

Returns:

core element of the model

Return type:

rafcon.core.state_elements.state_element.StateElement

get_observable_outcome()
model_changed(model, prop_name, info)

This method notifies the parent state about changes made to the state element

property outcome
prepare_destruction()

Prepares the model for destruction

Unregisters the model from observing itself.

set_observable_outcome(value)

StateMachineModel (in state_machine)

class rafcon.gui.models.state_machine.ComplexActionObserver(model)

Bases: Observer

This Observer observes the and structures the information of complex actions and separates those observations from the StateMachineModel to avoid to mix these with the root state observation of the state machine model.

  • In ongoing_complex_actions dictionary all active actions and there properties are hold

  • Only once at the end of an complex action the ongoing_complex_actions dictionary is empty and the nested_action_already_in list has elements in to secure accessibility of action properties in the pattern

  • The nested_action_already_in list is cleaned after the ongoing_complex_actions dictionary was cleared observable

action_signal(model, prop_name, info)
property ongoing_complex_actions
state_action_signal(model, prop_name, info)
class rafcon.gui.models.state_machine.StateMachineModel(**kwargs)

Bases: MetaModel, Hashable

This model class manages a rafcon.core.state_machine.StateMachine

The model class is part of the MVC architecture. It holds the data to be shown (in this case a state machine).

Parameters:

state_machine (StateMachine) – The state machine to be controlled and modified

property action_signal
action_signal_triggered(model, prop_name, info)

When the action was performed, we have to set the dirty flag, as the changes are unsaved

change_root_state_type(model, prop_name, info)
property core_element
destroy()
property destruction_signal
get_observable_action_signal()
get_observable_destruction_signal()
get_observable_meta_signal()
get_observable_ongoing_complex_actions()
get_observable_root_state()
get_observable_sm_selection_changed_signal()
get_observable_state_action_signal()
get_observable_state_machine()
get_observable_state_meta_signal()
get_state_model_by_path(path)

Returns the StateModel for the given path

Searches a StateModel in the state machine, who’s path is given by path.

Parameters:

path (str) – Path of the searched state

Returns:

The state with that path

Return type:

StateModel

Raises:

ValueError, if path is invalid/not existing with this state machine

load_meta_data(path=None, recursively=True)

Load meta data of state machine model from the file system

The meta data of the state machine model is loaded from the file system and stored in the meta property of the model. Existing meta data is removed. Also the meta data of root state and children is loaded.

Parameters:

path (str) – Optional path to the meta data file. If not given, the path will be derived from the state machine’s path on the filesystem

meta = None
meta_changed(model, prop_name, info)

When the meta was changed, we have to set the dirty flag, as the changes are unsaved

property meta_signal
property ongoing_complex_actions
prepare_destruction()

Prepares the model for destruction

Unregister itself as observer from the state machine and the root state

property root_state
root_state_assign(model, prop_name, info)
root_state_model_after_change(model, prop_name, info)
root_state_model_before_change(model, prop_name, info)
selection = None
set_observable_action_signal(value)
set_observable_destruction_signal(value)
set_observable_meta_signal(value)
set_observable_ongoing_complex_actions(value)
set_observable_root_state(value)
set_observable_sm_selection_changed_signal(value)
set_observable_state_action_signal(value)
set_observable_state_machine(value)
set_observable_state_meta_signal(value)
property sm_selection_changed_signal
property state_action_signal
property state_machine
state_machine_model_after_change(model, prop_name, info)
property state_meta_signal
store_meta_data(copy_path=None)

Save meta data of the state machine model to the file system

This method generates a dictionary of the meta data of the state machine and stores it on the filesystem.

Parameters:

copy_path (str) – Optional, if the path is specified, it will be used instead of the file system path

suppress_new_root_state_model_one_time = False
update_hash(obj_hash)

Should be implemented by derived classes to update the hash with their data fields

Parameters:

obj_hash – The hash object (see Python hashlib)

update_meta_data_hash(obj_hash)

Should be implemented by derived classes to update the hash with their meta data fields

Parameters:

obj_hash – The hash object (see Python hashlib)

ModificationsHistoryModel (in modification_history)

The History-Class provides the observation functionalities to register and identify all core or gui (graphical) edit actions that are a actual change to the state machine. Those changes are stored as Action-Objects in the ModificationsHistory-Class.

The HistoryChanges-Class provides the functionalities to organize and access all actions of the edit process. Hereby the branching of the edit process is stored and should be accessible, too.

class rafcon.gui.models.modification_history.HistoryTreeElement(prev_id, action=None, next_id=None)

Bases: object

property history_id
property next_id
property old_next_ids
prepare_destruction()
property prev_id
class rafcon.gui.models.modification_history.ModificationsHistory

Bases: Observable

The Class holds a all time history and a trail history. The trail history holds directly all modifications made since the last reset until the actual last active change and the undone modifications of this branch of modifications. So the all time history holds a list of all modifications ordered by time whereby the list elements are TreeElements that know respective previous action’s list id and the possible next action list ids (multiple branches). Hereby a fast search from a actual active branch (trail history) to specific history_id (some branch) can be performed and all recovery steps collected. Additionally there will be implemented functionalities that never forget a single change that was insert for debugging reasons. - the pointer are pointing on the next undo … so redo is pointer + 1 - all_actions is a type of a tree # prev_id, action, next_id, old_next_ids

property current_history_element
get_current_branch_history_ids()
get_element_for_history_id(history_id)
get_executed_history_ids()
get_history_path_from_current_to_target_history_id(target_history_id)
get_next_element(for_history_element=None)
get_previous_element(for_history_element=None)
go_to_history_element(target_history_id)
insert_action(**kwargs)
is_redo_possible()
is_undo_possible()
prepare_destruction()
redo(**kwargs)
reset(**kwargs)
undo(**kwargs)
class rafcon.gui.models.modification_history.ModificationsHistoryModel(state_machine_model)

Bases: ModelMT

action_signal_after_complex_action(model, prop_name, info)
property active_action
after_count()
assign_notification_root_state_after(model, prop_name, info)

This method is called, when any state, transition, data flow, etc. within the state machine modifications. This then typically requires a redraw of the graphical editor, to display these modifications immediately. :param model: The state machine model :param prop_name: The property that was changed :param info: Information about the change

assign_notification_root_state_before(model, prop_name, info)
assign_notification_states_after(model, prop_name, info)

This method is called, when any state, transition, data flow, etc. within the state machine modifications. This then typically requires a redraw of the graphical editor, to display these modifications immediately. :param model: The state machine model :param prop_name: The property that was changed :param info: Information about the change

assign_notification_states_before(model, prop_name, info)
before_count()
property change_count
finish_new_action(overview)
get_observable_change_count()
get_observable_modifications()
get_root_state_element_meta()
get_state_element_meta_from_internal_tmp_storage(state_path)
meta_changed_notify_after(changed_model, prop_name, info)
property modifications
prepare_destruction()

Prepares the model for destruction

Un-registers itself as observer from the state machine and the root state

re_initiate_meta_data()
redo()
reset_to_history_id(target_history_id)

Recovers a specific target_history_id of the _full_history element by doing several undos and redos.

Parameters:

target_history_id – the id of the list element which is to recover

Returns:

set_observable_change_count(value)
set_observable_modifications(value)
start_new_action(overview)
start_new_action_old(overview)
state_action_signal(model, prop_name, info)
state_machine_model = None
synchronized_redo()
synchronized_undo()
property tmp_meta_storage
undo()
update_internal_tmp_storage()

AutoBackupModel (in auto_backup)

class rafcon.gui.models.auto_backup.AutoBackupModel(state_machine_model)

Bases: ModelMT

Class provides auto backup functionality for a state-machine.

The Class AutoBackupModel requests a threading.Lock object named storage_lock in the StateMachineModel handed to it to avoid inconsistencies if storing in the middle of a modification by API or e.g. ModificationHistory. The auto-backup class can be initiated but be disabled by TIMED_TEMPORARY_STORAGE_ENABLED in the gui_config.yaml. There are two mode to run this class – with fix interval checks for backup or by dynamical auto backup by setting the flag ONLY_FIX_FORCED_TEMPORARY_STORAGE_INTERVAL in the gui_config.yaml. The forced interval FORCED_TEMPORARY_STORAGE_INTERVAL is used for the fix auto backup interval and as the forced time interval for the dynamic auto backup. The dynamic auto backup will backup additionally if the user was not doing any modifications till a time horizon of TIMED_TEMPORARY_STORAGE_INTERVAL. The flag AUTO_RECOVERY_CHECK enables the check on not cleanly closed instances and state machines what only can be performed if the AUTO_RECOVERY_LOCK_ENABLED is set True to write respective lock files into the backup folders. If the lock file is not cleaned up the state machine and the RAFCON instance was not closed cleanly.

cancel_timed_thread()
change_in_state_machine_notification(model, prop_name, info)
check_for_auto_backup(force=False)

The method implements the checks for possible auto backup of the state-machine according duration till the last change together with the private method _check_for_dyn_timed_auto_backup.

If the only_fix_interval is True this function is called ones in the beginning and is called by a timed- threads in a fix interval.

Parameters:

force – is a flag that force the temporary backup of the state-machine to the tmp-folder

Returns:

check_lock_file()
clean_lock_file(final=False)
destroy()
perform_temp_storage()
prepare_destruction()

Prepares the model for destruction

Unregister itself as observer from the state machine and the root state

set_timed_thread(duration, func, *args)
update_last_backup_meta_data()

Update the auto backup meta data with internal recovery information

update_last_sm_origin_meta_data()

Update the auto backup meta data with information of the state machine origin

update_tmp_storage_path()
write_backup_meta_data()

Write the auto backup meta data into the current tmp-storage path

rafcon.gui.models.auto_backup.check_for_crashed_rafcon_instances()
rafcon.gui.models.auto_backup.check_path_for_correct_dirty_lock_file(sm_path, path)
rafcon.gui.models.auto_backup.find_dirty_lock_file_for_state_machine_path(sm_path)
rafcon.gui.models.auto_backup.generate_rafcon_instance_lock_file()
rafcon.gui.models.auto_backup.move_dirty_lock_file(dirty_lock_file, sm_path)

Move the dirt_lock file to the sm_path and thereby is not found by auto recovery of backup anymore

rafcon.gui.models.auto_backup.recover_state_machine_from_backup(sm_path, pid=None, full_path_dirty_lock=None)
rafcon.gui.models.auto_backup.remove_rafcon_instance_lock_file()

StateMachineManagerModel (in state_machine_manager)

GlobalVariableManagerModel (in global_variable_manager)

LibraryManagerModel (in library_manager)

StateMachineExecutionEngineModel (in state_machine_execution_engine)