Highslide JS
Click to Enlarge

Communications Protocol State Machine

The state machine for the COACH was implemented using the guidelines put forth by the Communications Committee. On the Mississippi Queen, we chose to implement this using a three level state machine. While the structure of the code is similar to that given by the state chart template – we did not feel the complexity of this state machine warranted full use of this template, and the entire state machine was instead handled in one module. 

 

The Master State Machine is the only function run by the program main. This level consists of three states: Start-up, Paired, and Not Paired. Upon turning on the COACH, the state machine will enter the Paired state if command of the Mississippi Queen can be asserted within 5 seconds, otherwise, the Not Paired state is entered and any TOWRP can be commanded once available. 

Paired: The ‘Paired’ state has two sub-levels. The first sub-level has two states, a ‘Normal Operations’ state which performs general actions during control of a TOWRP, and a ‘Mutnious Crew’ state which is entered when the user must suppress a mutiny to retain command of the TOWRP. During ‘Normal Operations’, velocity commands are sent every 0.5s, morale status is updated, and free analog or digital commands are sent on request. Upon reaching a mutiny, the ‘Mutinous Crew’ state is entered, which in turn has two sublevels. First, the COACH waits for the user to perform the special action required to suppress a mutiny, then waits for the TOWRP to respond. If the mutiny is suppressed successfully, ‘Normal Operations’ are resumed, otherwise, the COACH enters a ‘Not Paired’ master state since it will not have received an updated morale status from the TOWRP.

Not-Paired: The ‘Not-Paired’ state also has two sub-levels. The COACH first waits for an ‘I am Available’ message from a marauding TOWRP, and then assert command over that TOWRP. With the ‘Assertion of Command’ state, there is a further sub-level, in which the TOWRP first waits for the assertion of command action to be performed by the user, and then waits for a positive result from the TOWRP. If this is completed successfully, the ‘Paired’ master state is entered, otherwise, various timers and guards prevent a COACH from trying to assert command over a TOWRP that has already been commanded, or may be broken.