StateElements: state_elements
¶
Contents
DataFlow¶
- class rafcon.core.state_elements.data_flow.DataFlow(from_state=None, from_key=None, to_state=None, to_key=None, data_flow_id=None, parent=None, safe_init=True)¶
Bases:
rafcon.core.state_elements.state_element.StateElement
A class for representing a data flow connection in the state machine
It inherits from Observable to make a change of its fields observable.
- Variables
DataFlow.from_state (str) – the id of the source state of the data flow connection
DataFlow.to_state (str) – the id of the target state of the data flow connection
DataFlow.from_key (int) – the id of the data port / scoped variable of the source state
DataFlow.to_key (int) – the id of the data port /scoped variable of the target state
DataFlow.data_flow_id (int) – the id of the data port, must be unique for the parent state
StateElement.parent (rafcon.core.states.container_state.ContainerState) – reference to the parent state
- property data_flow_id¶
Property for the _data_flow_id field
- classmethod from_dict(dictionary)¶
Abstract method
This method must be implemented by the deriving classes. It must return an object of type cls, created from the parameters defined in dictionary. The type of cls is the type of the class the method is called on.
- Parameters
dictionary (dict) – A Python dict with all parameters needed for creating an object of type cls
- Returns
An instance of cls
- Return type
cls
- property from_key¶
Property for the _from_key field
- property from_state¶
Property for the _from_state field
- modify_origin(**kwargs)¶
- modify_target(**kwargs)¶
- property state_element_id¶
Returns the id of the state element
- static state_element_to_dict(state_element)¶
- property to_key¶
Property for the _to_key field
- property to_state¶
Property for the _to_state field
DataPorts¶
- class rafcon.core.state_elements.data_port.DataPort(name=None, data_type=None, default_value=None, data_port_id=None, parent=None, force_type=False, init_without_default_value_type_exceptions=False, safe_init=True)¶
Bases:
rafcon.core.state_elements.state_element.StateElement
A class for representing a data ports in a state
- Variables
DataPort.name (str) – the name of the data port
DataPort.data_type (type) – the value type of the data port can be handed as convertible
str
tooDataPort.default_value – the default value of the data port
data_port_id (int) – the id of the data port, must be unique for the parent state
StateElement.parent (rafcon.core.states.state.State) – reference to the parent state
DataPort.force_type (bool) – if true the DataPort type exception is not raised while initiation (backward compatibility)
DataPort.init_without_default_value_type_exceptions (bool) – if true it is allowed to initiate with any default value type used to load not matching default value data types and correct them using the GUI.
- change_data_type(**kwargs)¶
- check_default_value(default_value, data_type=None)¶
Check whether the passed default value suits to the passed data type. If no data type is passed, the data type of the data port is used. If the default value does not fit, an exception is thrown. If the default value is of type string, it is tried to convert that value to the data type.
- Parameters
default_value – The default value to check
data_type – The data type to use
- Raises
exceptions.AttributeError – if check fails
- Returns
The converted default value
- property data_port_id¶
Property for the _data_port_id field
- property data_type¶
Property for the _data_type field
- property default_value¶
Property for the _default_value field
- classmethod from_dict(dictionary)¶
Abstract method
This method must be implemented by the deriving classes. It must return an object of type cls, created from the parameters defined in dictionary. The type of cls is the type of the class the method is called on.
- Parameters
dictionary (dict) – A Python dict with all parameters needed for creating an object of type cls
- Returns
An instance of cls
- Return type
cls
- property name¶
Property for the _name field
- property state_element_id¶
Returns the id of the state element
- static state_element_to_dict(state_element)¶
- class rafcon.core.state_elements.data_port.InputDataPort(name=None, data_type=None, default_value=None, data_port_id=None, parent=None, force_type=False, init_without_default_value_type_exceptions=False, safe_init=True)¶
- class rafcon.core.state_elements.data_port.OutputDataPort(name=None, data_type=None, default_value=None, data_port_id=None, parent=None, force_type=False, init_without_default_value_type_exceptions=False, safe_init=True)¶
Logical Ports¶
- class rafcon.core.state_elements.logical_port.Income(parent=None, safe_init=True)¶
Bases:
rafcon.core.state_elements.logical_port.LogicalPort
A class for representing an income of a state
There can only be one Income within a state, which is why no income_id is required.
- Variables
StateElement.parent (rafcon.core.states.state.State) – reference to the parent state
- classmethod from_dict(dictionary)¶
Abstract method
This method must be implemented by the deriving classes. It must return an object of type cls, created from the parameters defined in dictionary. The type of cls is the type of the class the method is called on.
- Parameters
dictionary (dict) – A Python dict with all parameters needed for creating an object of type cls
- Returns
An instance of cls
- Return type
cls
- property state_element_id¶
Always returns 0
Only required for consistent handling of all state elements.
- Returns
0
- static state_element_to_dict(state_element)¶
- class rafcon.core.state_elements.logical_port.LogicalPort(parent=None, safe_init=True)¶
Bases:
rafcon.core.state_elements.state_element.StateElement
Base class for the logical ports
- class rafcon.core.state_elements.logical_port.Outcome(outcome_id=None, name=None, parent=None, safe_init=True)¶
Bases:
rafcon.core.state_elements.logical_port.LogicalPort
A class for representing an outcome of a state
As the name of an outcome can be changes without modifying the transitions the primary key of an outcome is its id and not its name.
- Variables
Outcome.outcome_id (int) – the id of the outcome, must be unique on one hierarchy level
Outcome.name (str) – the human readable name of the outcome
StateElement.parent (rafcon.core.states.state.State) – reference to the parent state
- classmethod from_dict(dictionary)¶
Abstract method
This method must be implemented by the deriving classes. It must return an object of type cls, created from the parameters defined in dictionary. The type of cls is the type of the class the method is called on.
- Parameters
dictionary (dict) – A Python dict with all parameters needed for creating an object of type cls
- Returns
An instance of cls
- Return type
cls
- property name¶
Returns the Outcome’s name
- property outcome_id¶
Returns the outcome_id
- property state_element_id¶
Returns the id of the state element
- static state_element_to_dict(state_element)¶
Scope (State Element)¶
- class rafcon.core.state_elements.scope.ScopedData(name, value, value_type, from_state, data_port_type, parent=None, safe_init=True)¶
Bases:
rafcon.core.state_elements.state_element.StateElement
A class for representing scoped data of a container state
It inherits from Observable to make a change of its fields observable.
- Variables
ScopedData.name (str) – the name of the scoped data
ScopedData.from_state (str) – the state_id of the state that wrote to the scoped data last
value_type (type) – specifies the type of self._value; the setter of __value will only allow assignments that satisfies the data_type constraint
value – the current value of the scoped data
data_port_type – the type of the data port that wrote to the scoped data last
timestamp (str) – the timestamp when the scoped data was written to last
- property data_port_type¶
Property for the _data_port_type field
- classmethod from_dict(dictionary)¶
Abstract method
This method must be implemented by the deriving classes. It must return an object of type cls, created from the parameters defined in dictionary. The type of cls is the type of the class the method is called on.
- Parameters
dictionary (dict) – A Python dict with all parameters needed for creating an object of type cls
- Returns
An instance of cls
- Return type
cls
- property from_state¶
Property for the _from_state field
- property name¶
Property for the _name field
- property state_element_id¶
Returns the id of the state element
- static state_element_to_dict(state_element)¶
- property timestamp¶
Property for the _timestamp field
- property value¶
Property for the _value field
- property value_type¶
Property for the _value_type field
- class rafcon.core.state_elements.scope.ScopedVariable(name=None, data_type=None, default_value=None, scoped_variable_id=None, parent=None, safe_init=True)¶
Bases:
rafcon.core.state_elements.data_port.DataPort
A class for representing a scoped variable in a container state
It inherits from the DataPort class as it needs exactly the same class fields. It inherits from Observable to make a change of its fields observable.
- Variables
DataPort.name (str) – the name of the scoped variable
DataPort.data_type (type) – specifies the type of the scoped variable (data port); the setter of _value will only allow assignments that satisfies the type constraint
DataPort.default_value – specifies the default value of the scoped variable (data port)
scoped_variable_id (int) – the id of the scoped variable (see DataPort.data_port_id), must be unique for the parent state
StateElement.parent (rafcon.core.states.container_state.ContainerState) – reference to the parent state
- classmethod from_dict(dictionary)¶
Abstract method
This method must be implemented by the deriving classes. It must return an object of type cls, created from the parameters defined in dictionary. The type of cls is the type of the class the method is called on.
- Parameters
dictionary (dict) – A Python dict with all parameters needed for creating an object of type cls
- Returns
An instance of cls
- Return type
cls
- static state_element_to_dict(state_element)¶
- rafcon.core.state_elements.scope.generate_time_stamp()¶
Generate a time stamp for the current time as integer in micro. :return:
Transition¶
- class rafcon.core.state_elements.transition.Transition(from_state, from_outcome, to_state, to_outcome, transition_id, parent=None, safe_init=True)¶
Bases:
rafcon.core.state_elements.state_element.StateElement
A class for representing a transition in the state machine
It inherits from Observable to make a change of its fields observable.
Raises an exceptions.TypeError if the transition_id is not of type int.
- Variables
transition_id (int) – the id of the transition, must be unique for the parent state
Transition.from_state (str) – the source state of the transition
Transition.from_outcome (int) – the outcome of the source state
Transition.to_state (str) – the target state of the transition
Transition.to_outcome (int) – the outcome of the target state
StateElement.parent (rafcon.core.states.container_state.ContainerState) – reference to the parent state
- classmethod from_dict(dictionary)¶
Abstract method
This method must be implemented by the deriving classes. It must return an object of type cls, created from the parameters defined in dictionary. The type of cls is the type of the class the method is called on.
- Parameters
dictionary (dict) – A Python dict with all parameters needed for creating an object of type cls
- Returns
An instance of cls
- Return type
cls
- property from_outcome¶
Property for the _from_outcome field
- property from_state¶
Property for the _from_state field
- modify_origin(**kwargs)¶
- modify_target(**kwargs)¶
- property state_element_id¶
Returns the id of the state element
- static state_element_to_dict(state_element)¶
- property to_outcome¶
Property for the to_outcome field
- property to_state¶
Property for the _to_state field
- property transition_id¶
Property for the _transition_id field
StateElement¶
- class rafcon.core.state_elements.state_element.StateElement(parent=None, safe_init=True)¶
Bases:
rafcon.design_patterns.observer.observable.Observable
,yaml.YAMLObject
,jsonconversion.jsonobject.JSONObject
,rafcon.utils.hashable.Hashable
A abstract base class for all elements of a state (ports, connections)
It inherits from Observable to make a change of its fields observable. It also inherits from YAMLObject, in order to store/load it as YAML file.
It raises an exceptions.NotImplementedError if the type of the class instance is type(self).
- Variables
StateElement.parent (rafcon.core.states.state.State) – Parent state of the state element
- property core_element_id¶
Returns the id of the state element
- classmethod from_dict(dictionary)¶
Abstract method
This method must be implemented by the deriving classes. It must return an object of type cls, created from the parameters defined in dictionary. The type of cls is the type of the class the method is called on.
- Parameters
dictionary (dict) – A Python dict with all parameters needed for creating an object of type cls
- Returns
An instance of cls
- Return type
cls
- property parent¶
Getter for the parent state of the state element
- Returns
None if parent is not defined, else the parent state
- Return type
- property state_element_id¶
Returns the id of the state element
- static state_element_to_dict(state_element)¶
- to_dict()¶
Abstract method
This method must be implemented by the deriving classes. It must return a Python dict with all parameters of self, which are needed to create a copy of self.
- Returns
A Python dict with all needed parameters of self
- Return type
- 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)