PyHadesStateMachine
pyhades.PyHadesStateMachine
(name, **kwargs)Class used to define custom state machines.
This class is used to define custom machines, by defining parameters, states, transitions and by defining methods state behaviour can de defined.
Parameters:
- name (str): state machine name.
Attributes
- tag_engine (CVTEngine Object)
- logger_engine (DataLoggerEngine Object)
get_state
(self)Gets current state of the state machine
Returns
- state: (str) current state of the state machine
get_states
(self)Gets a list of state machine's names
Returns
- (list)
Usage
>>> machine = app.get_machine(name)
>>> states = machine.get_states()
get_state_interval
(self)Gets current state interval
Returns
- (float)
Usage
>>> machine = app.get_machine(name)
>>> current_interval = machine.get_state_interval()
get_interval
(self)Gets overall state machine interval
Returns
- (float)
Usage
>>> machine = app.get_machine(name)
>>> interval = machine.get_interval()
set_interval
(self, interval)Sets overall machine interval
Parameters
- interval: (float) overal machine interval in seconds
Usage
>>> machine = app.get_machine(name)
>>> machine.set_interval(0.5)
get_attributes
()_get_active_transitions
(self)Gets allowed transitions based on the current state
Returns
- (list)
get_transitions_name
(self)Get all transitions name define in the state machine
Returns
- (list) of string
serialize
(self)Gets state machine attributes serialized
loop
(self)Starts state machine thread and it allows to execute the correct while_ method in the state machine loop execution
info
(self)Gets general information of the state machine
Returns
- (str)
Usage
>>> machine = app.get_machine(name)
>>> info = machine.info()