Package sparked :: Module application :: Class StateMachine
[hide private]
[frames] | no frames]

Class StateMachine

source code

object --+
         |
        StateMachine

A simple state machine.

This machine is linked to a parent class, on which it calls enter_<state> and exit_<state> methods on state change. Also provided is a mechanism for timed state changes.

Instance Methods [hide private]
 
__init__(self, parent)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
set(self, newstate)
Sets a new state.
source code
 
setAfter(self, newstate, after)
Make a state transition after a specified amount of time.
source code
 
bumpAfter(self, after=None)
Change the state-changer timer to the specified nr of seconds.
source code
 
_call(self, cb, *arg) source code
 
addListener(self, l) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  _state = None
hash(x)
  _statechanger = None
hash(x)
  _listeners = None
hash(x)
Instance Variables [hide private]
  nextStateAfter = None
nr of seconds after which the next state change is triggered.
Properties [hide private]
  get
Get the current state.

Inherited from object: __class__

Method Details [hide private]

__init__(self, parent)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

set(self, newstate)

source code 

Sets a new state. Calls parent's state transition functions, if they exist.

bumpAfter(self, after=None)

source code 

Change the state-changer timer to the specified nr of seconds. If none given, resets the timer to the initial delay, 'bumping' it.


Instance Variable Details [hide private]

nextStateAfter

nr of seconds after which the next state change is triggered. If None, the timer is not active.
Value:
None

Property Details [hide private]

get

Get the current state.

Get Method:
unreachable.get(self) - Get the current state.