State machine shorthand: transitions

From Tekkotsu Wiki

Jump to: navigation, search
Abbreviation Meaning
=C=> Completion of all source nodes
=C(n)=> Completion of at least n source nodes
=T(t)=> Timeout after t milliseconds
=N=> Null transition (fires as soon as the node's doStart returns)
=RND=> Random transition: selects one target node at random
=B=> Any button event
=B(b)=> Button event signaling activation of button b, e.g., GreenBut
=B(b,t)=> Button event of type t (e.g., deactivateETID) for button b
=TM(s)=> Text message event matching string s
=TM=> Any unmatched text message event (can serve as default case)
=S<t>=> Signal of data type t (any value)
=S<t>(v)=> Signal of data type t with value v
=E(g)=> Any event from generator g, e.g., buttonEGID
=E(g,s)=> Any event from generator g with source s (e.g., green button)
=E(g,s,t)=> Any event from generator g with source s of type t (e.g., activateETID)
=S=> Success transition
=F=> Failure transition
=PILOT=> Pilot request completed
=PILOT(v)=> Pilot event with value v
=MAP=> MapBuilder request completed
=GRASP=> Grasper request completed
=GRASP(v)=> Grasper event with value v

The full syntax for the abbreviated notation is:

=label:ABBREV`(args)[inits]=>
  • There can be no spaces between the initial = and the terminal =>.
  • label must begin with a lowercase letter and end with a colon
  • ABBREV is the abbreviation for the transition, e.g., C for CompletionTrans
  • The optional backquote character, if present, indicates that the transition should speak its name when it fires (for debugging)
  • args is a list of constructor arguments; only used if the transition's constructor accepts arguments
  • inits (rarely used) is a sequence of intializer expressions, separated by semicolons, to be executed when constructing the transition, e.g., [setSound("ping.wav");]

Long Form Transition Syntax

The abbreviated transitions described above expand into a long form syntax that can also be employed directly if there is no abbreviated form for the transition you wish to use. The full long form syntax is:

>== label : TransitionClassName ` (args) [inits] ==>
  • Spaces between these elements are optional.
  • If an argument list is supplied, the first element should be $ to supply the name of the transition (the label) as a string argument, and the second element should be $$ to supply the address of the target node. If the argument list is omitted, a default argument list of ($,$$) is supplied automatically.

Examples: the abbreviated transitions on the left expand into the long forms shown on the right:

=C=>                     >==CompletionTrans==>

=T(500)=>                >== TimeoutTrans($,$$,500) ==>

=confirm:TM("yes")=>     >==confirm: TextMsgTrans($,$$,"yes")==>