Module sm
[frames] | no frames]

Module sm

Classes for representing and combining state machines.

Classes
  SM
Generic superclass representing state machines.
  Cascade
Cascade composition of two state machines.
  Parallel
Takes a single inp and feeds it to two machines in parallel.
  Feedback
Take the output of m and feed it back to its input.
  Feedback2
Like previous Feedback, but takes a machine with two inps and one output at initialization time.
  FeedbackAdd
Takes two machines, m1 and m2.
  FeedbackSubtract
Takes two machines, m1 and m2.
  Parallel2
Like Parallel, but takes two inps.
  ParallelAdd
Like Parallel, but output is the sum of the outputs of the two machines.
  If
Given a condition (function from inps to boolean) and two state machines, make a new machine.
  Switch
Given a condition (function from inps to boolean) and two state machines, make a new machine.
  Mux
Like Switch, but updates both machines no matter whether the condition is true or false.
  Sequence
Given a list of state machines, make a new machine that will execute the first until it is done, then execute the second, etc.
  Repeat
Given a terminating state machine, generate a new one that will execute it n times.
  RepeatUntil
Given a terminating state machine and a condition on the input, generate a new one that will run the machine until the condition becomes true.
  Until
Execute SM until it terminates or the condition becomes true.
  DebugParams
Housekeeping stuff
  Constant
Machine whose output is a constant, independent of the input
  R
Machine whose output is the input, but delayed by one time step.
  Delay
Delay is another name for the class R, for backward compatibility
  Gain
Machine whose output is the input, but multiplied by k.
  Wire
Machine whose output is the input
  Select
Machine whose input is a structure list and whose output is the kth element of that list.
  PureFunction
Machine whose output is produced by applying a specified Python function to its input.
Functions
 
coupledMachine(m1, m2)
Couple two machines together.
 
splitValue(v, n=2)
If v is a list of n elements, return it; if it is 'undefined', return a list of n 'undefined' values; else generate an error
 
isDefined(v)
 
allDefined(struct)
 
safe(f)
 
safeAdd(a1, a2)
 
safeMul(a1, a2)
 
safeSub(a1, a2)
Variables
  __package__ = None
Function Details

coupledMachine(m1, m2)

 

Couple two machines together.

Parameters:
  • m1 - SM
  • m2 - SM
Returns:
New machine with no input, in which the output of m1 is the input to m2 and vice versa.