Execution: execution

base_execution_history

class rafcon.core.execution.base_execution_history.BaseExecutionHistory(initial_prev=None, root_state_name='', consumer_manager=None)

Bases: object

A class for the history of a state machine execution

Variables

initial_prev – optional link to a previous element for the first element pushed into this history of type rafcon.core.execution.execution_history.HistoryItem

destroy()

Destroy the consumer manager and reset all variables

feed_consumers(execution_history_item)

Add execution history item to the dedicated queue of all consumers and notify their condition variables

Parameters

execution_history_item – the execution history item

get_last_history_item()

Returns the history item that was added last

Returns

History item added last

Return type

rafcon.core.execution.execution_history_items.HistoryItem

push_call_history_item(state, call_type, state_for_scoped_data, input_data=None, link_and_feed_item_to_consumers=True)

Adds a new call-history-item to the history item list

A call history items stores information about the point in time where a method (entry, execute, exit) of a certain state was called.

Parameters
  • state – the state that was called

  • call_type – the call type of the execution step, i.e. if it refers to a container state or an execution state

  • state_for_scoped_data – the state of which the scoped data needs to be saved for further usages (e.g. backward stepping)

  • link_and_feed_item_to_consumers – if the history item should be feed to all other consumers

push_concurrency_history_item(state, number_concurrent_threads, link_and_feed_item_to_consumers=True)

Adds a new concurrency-history-item to the history item list

A concurrent history item stores information about the point in time where a certain number of states is launched concurrently (e.g. in a barrier concurrency state).

Parameters
  • state – the state that launches the state group

  • number_concurrent_threads – the number of states that are launched

  • link_and_feed_item_to_consumers – if the history item should be feed to all other consumers

push_return_history_item(state, call_type, state_for_scoped_data, output_data=None, link_and_feed_item_to_consumers=True)

Adds a new return-history-item to the history item list

A return history items stores information about the point in time where a method (entry, execute, exit) of a certain state returned.

Parameters
  • state – the state that returned

  • call_type – the call type of the execution step, i.e. if it refers to a container state or an execution state

  • state_for_scoped_data – the state of which the scoped data needs to be saved for further usages (e.g. backward stepping)

push_state_machine_start_history_item(state_machine, run_id, feed_item_to_consumers=True)

Adds a new state-machine-start-history-item to the history item list

A state machine starts history item stores information about the point in time where a state machine started to run

Parameters
  • state_machine – the state machine that started

  • run_id – the run id

  • feed_item_to_consumers – if the history item should be feed to all other consumers

shutdown()

Destroy the consumer manager and reset all variables

consumer_manager

class rafcon.core.execution.consumer_manager.ExecutionHistoryConsumerManager(root_state_name)

Bases: object

A class for managing all consumers including the consumer plugins

FILE_SYSTEM_CONSUMER_NAME = 'file_system_consumer'
add_history_item_to_queue(execution_history_item)

Add execution history item to the dedicated queue of all consumers and notify their condition variables

Parameters

execution_history_item – the execution history item

property consumers_exist
property file_system_consumer_exists

Check if the file system consumer is activated

get_file_system_consumer_file_name()

Get the filename of the shelve

register_consumer(consumer_name, consumer)

Register a specific consumer

Parameters
  • consumer_name – the consumer name

  • consumer – an instance of the consumer

stop_consumers()

Stop the working thread and unregister all consumers

stop_worker_thread()

Stop the working thread by setting interrupt to true

unregister_consumer(consumer)

Unegister a specific consumer

Parameters

consumer – an instance of the consumer

state_machine_execution_engine

execution_history_factory

class rafcon.core.execution.execution_history_factory.ExecutionHistoryFactory

Bases: object

A factory class for creating an instance of BaseExecutionHistory or InMemoryExecutionHistory

static get_execution_history(initial_prev=None, root_state_name='', consumer_manager=None)

Create an instance of a InMemoryExecutionHistory or BaseExecutionHistory

Parameters
  • initial_prev – the initial previous history item

  • root_state_name – the root state name

  • consumer_manager – the consumer manager

Returns

an instance of BaseExecutionHistory or InMemoryExecutionHistory

execution_history_items

class rafcon.core.execution.execution_history_items.CallItem(state, call_type, state_for_scoped_data, input_data, run_id)

Bases: rafcon.core.execution.execution_history_items.ScopedDataItem

A history item to represent a state call

to_dict(pickled=True)
rafcon.core.execution.execution_history_items.CallType

alias of rafcon.core.execution.execution_history_items.METHOD_NAME

class rafcon.core.execution.execution_history_items.ConcurrencyItem(container_state, number_concurrent_threads, run_id, consumer_manager)

Bases: rafcon.core.execution.execution_history_items.HistoryItem

A class to hold all the data for an invocation of several concurrent threads.

destroy()
to_dict(pickled=True)
class rafcon.core.execution.execution_history_items.HistoryItem(state, run_id)

Bases: object

Class representing an entry within the history

An abstract class that serves as a data structure to hold all important information of a certain point in time during the execution of a state machine. A history item is an element in a doubly linked history item list.

Variables
  • state_reference – a reference to the state performing a certain action that is going to be saved

  • path – the state path

  • timestamp – the time of the call/return

  • prev – the previous history item

  • next – the next history item

destroy()
property next

Property for the next field

property prev

Property for the prev field

property state_reference

Property for the state_reference field

to_dict(pickled=True)
class rafcon.core.execution.execution_history_items.ReturnItem(state, call_type, state_for_scoped_data, output_data, run_id)

Bases: rafcon.core.execution.execution_history_items.ScopedDataItem

A history item to represent the return of a root state call

to_dict(pickled=True)
class rafcon.core.execution.execution_history_items.ScopedDataItem(state, call_type, state_for_scoped_data, child_state_input_output_data, run_id)

Bases: rafcon.core.execution.execution_history_items.HistoryItem

A abstract class to represent history items which contains the scoped data of a state

Variables
  • call_type – the call type of the execution step, i.e. if it refers to a container state or an execution state

  • state_for_scoped_data – the state of which the scoped data will be stored as the context data that is necessary to re-execute the state

to_dict(pickled=True)
class rafcon.core.execution.execution_history_items.StateMachineStartItem(state_machine, run_id)

Bases: rafcon.core.execution.execution_history_items.HistoryItem

to_dict(pickled=True)

execution_status

class rafcon.core.execution.execution_status.CustomCondition(lock=None)

Bases: threading.Condition

A class which inherits from Condition but can tell the outside world on how many threads are currently waiting.

get_number_of_waiting_threads()

A getter for the number of waiting threads :return:

class rafcon.core.execution.execution_status.ExecutionStatus(execution_mode=None)

Bases: rafcon.design_patterns.observer.observable.Observable

A class for representing the state machine status

It inherits from Observable to make a change of its fields observable.

Variables

execution_mode – the execution mode of the state machine (i.e. running, paused, stopped, stepping)

property execution_mode

Property for the _execution_mode field

rafcon.core.execution.execution_status.StateMachineExecutionStatus

alias of rafcon.core.execution.execution_status.STATE_MACHINE_EXECUTION_STATUS

in_memory_execution_history

class rafcon.core.execution.in_memory_execution_history.InMemoryExecutionHistory(initial_prev=None, root_state_name='', consumer_manager=None)

Bases: rafcon.core.execution.base_execution_history.BaseExecutionHistory, rafcon.design_patterns.observer.observable.Observable, collections.abc.Iterable, collections.abc.Sized

A class for the history of a state machine execution

It stores all history elements in a stack wise fashion.

Variables

initial_prev – optional link to a previous element for the first element pushed into this history of type rafcon.core.execution.execution_history.HistoryItem

destroy()

Destroy the consumer and reset all variables

get_last_history_item()

Returns the history item that was added last

Returns

History item added last

Return type

rafcon.core.execution.execution_history_items.HistoryItem

pop_last_item(**kwargs)
push_call_history_item(**kwargs)

Adds a new call-history-item to the history item list

A call history items stores information about the point in time where a method (entry, execute, exit) of a certain state was called.

Parameters
  • state – the state that was called

  • call_type – the call type of the execution step, i.e. if it refers to a container state or an execution state

  • state_for_scoped_data – the state of which the scoped data needs to be saved for further usages (e.g. backward stepping)

  • link_and_feed_item_to_consumers – if the history item should be feed to all other consumers

push_concurrency_history_item(**kwargs)

Adds a new concurrency-history-item to the history item list

A concurrent history item stores information about the point in time where a certain number of states is launched concurrently (e.g. in a barrier concurrency state).

Parameters
  • state – the state that launches the state group

  • number_concurrent_threads – the number of states that are launched

  • link_and_feed_item_to_consumers – if the history item should be feed to all other consumers

push_return_history_item(**kwargs)

Adds a new return-history-item to the history item list

A return history items stores information about the point in time where a method (entry, execute, exit) of a certain state returned.

Parameters
  • state – the state that returned

  • call_type – the call type of the execution step, i.e. if it refers to a container state or an execution state

  • state_for_scoped_data – the state of which the scoped data needs to be saved for further usages (e.g. backward stepping)

push_state_machine_start_history_item(**kwargs)

Adds a new state-machine-start-history-item to the history item list

A state machine starts history item stores information about the point in time where a state machine started to run

Parameters
  • state_machine – the state machine that started

  • run_id – the run id

  • feed_item_to_consumers – if the history item should be feed to all other consumers

shutdown()

Stop all consumers including consumer plugins

abstract_execution_history_consumer

class rafcon.core.execution.consumers.abstract_execution_history_consumer.AbstractExecutionHistoryConsumer

Bases: object

A class that should be the base for every defined consumer

consume(execution_history_item)

Override the register for the consumer to run the required procedures when a consumer wants to consume an execution history item

enqueue(execution_history_item)

Add the execution history item to the local consumer queue

Parameters

execution_history_item – the execution history item

register()

Override the register for the consumer to run the required procedures when a consumer starts

stop()

Stop the consumer thread

unregister()

Override the register for the consumer to run the required procedures when a consumer stops

worker()

Consume the available execution history item until the thread stops

file_system_consumer

class rafcon.core.execution.consumers.file_system_consumer.FileSystemConsumer(root_state_name)

Bases: rafcon.core.execution.consumers.abstract_execution_history_consumer.AbstractExecutionHistoryConsumer

A class that consumes an execution history event and writes it onto the file system.

consume(execution_history_item)

Write to the store variable corresponding to a shelve file

register()

Open the shelve file

unregister()

Flush & close the shelve file