Goulib.statemachine module

state machines with graph representation

class Goulib.statemachine.StateDiagram(name=None, comment=None, filename=None, directory=None, format=None, engine=None, encoding=None, graph_attr=None, node_attr=None, edge_attr=None, body=None, strict=False)[source]

Bases: graphviz.dot.Digraph

helper to write State Diagrams graph in iPython notebook This library uses Graphviz that has to be installed separately (http://www.graphviz.org/)

state(number, descr, actions, transitions)[source]
Parameters:
  • number – the state number (int)
  • descr – a string describing the state
  • actions – a string describing the various actions. use <br/> to make a new line
  • transitions – a array of tuple (<new_state>,”condition”)
Goulib.statemachine.noPrint(*args)[source]
class Goulib.statemachine.Simulation[source]

Bases: object

all simulation should derive from this class that has some helper

__init__()[source]
setOutput(h1=<function noPrint>, h2=<function noPrint>, h3=<function noPrint>, h=<function noPrint>, hinfo=<function noPrint>, hsuccess=<function noPrint>, hwarning=<function noPrint>, herror=<function noPrint>, displayState=<function noPrint>, displayObj=<function noPrint>, displayPlot=<function noPrint>)[source]
class Goulib.statemachine.EventLog[source]

Bases: object

log(stateMachine)[source]
class Goulib.statemachine.StateChangeLog(newState)[source]

Bases: Goulib.statemachine.EventLog

__init__(newState)[source]
class Goulib.statemachine.WaitLog(untilTime, waitForWhat)[source]

Bases: Goulib.statemachine.EventLog

__init__(untilTime, waitForWhat)[source]
class Goulib.statemachine.TooLateLog(pastTime, missedWhat)[source]

Bases: Goulib.statemachine.EventLog

__init__(pastTime, missedWhat)[source]
class Goulib.statemachine.TimeMarker(name)[source]

Bases: object

__init__(name)[source]
set(time)[source]
__call__()[source]
__repr__()[source]
class Goulib.statemachine.StateMachine(simulation=None, name=None, background_color='#F5ECCE')[source]

Bases: object

__init__(simulation=None, name=None, background_color='#F5ECCE')[source]
reset()[source]

where all actuators should be declared and other variables

__reset__()[source]
parseDoc(state, f)[source]
__call__(time)[source]

find the state at time. time must be in seconds

displayGraph()[source]
checkOnTimeAndWait(time, what)[source]

checks that the self.time < time if this is not the case an error will be logged with the message

wait(time, cause='unknown cause')[source]
run(start=0, stops=[], startTime=None, maxSteps=100000, maxTime=<Quantity(1000, 'second')>)[source]

runs the behavioral simulation :params start: is the starting state of the simulation :params stops: a list of states that will stop the simulation (after having simulated this last state) :params startTime: a time to start this run if None takes self.time :params maxState: is the number of states being evaluated before the end of simulation :params maxTime: is the virtual time at which the simulation ends_in_comment_or_string :params displayStates: at every new state, display the state in Notebook as well as the time when entered :params displayMove: if True, every actuator.move displays the graph of the move

returns the time when run finishes

hinfo(*args)[source]
hsuccess(*args)[source]
hwarning(*args)[source]
herror(*args)[source]
lastExitTime(state)[source]
display(fromTime=None, toTime=None)[source]