Revision 7.10
2/28/2012
Appendix C. Quick Guide to Authoring Dock Server Scripts
This appendix presents a short primer on authoring Dock Server Scripts. These scripts
run within the Dock Server application. A Dock Server script operates similar to Expect
on Unix or Linux. A script monitors the character input stream on a serial port for
specific patterns of characters. When one of these patterns is detected, the script
writes a preprogrammed character sequence to the serial port. In this fashion, glider
output read on a serial port triggers a script to write glider commands to the glider. In
turn, the glider responds with more output which triggers the writing of additional
commands. This cycle repeats until the script terminates.
To be a little more formal, a Dock Server script represents a finite state machine. A
script is composed of states. Each state is composed of transitions. Each transition
specifies a condition, an action, and a state. A condition is a regular expression (see
Appendix H. Java 1.4.2 Regular Expression Syntax
). This expression is continuously
matched against glider output. If a match is found, the condition becomes true. As long
as no match is found, the condition is false.
When a transition’s condition becomes true, its action is performed. For Dock Server
scripts, a transition’s action is to send a given command to a glider. Thus, when a
transition’s condition is true, its action (i.e., glider command) is sent to the glider. In
addition, this transition’s state becomes the “active” state of the script. That is, the
conditions of this new state’s transitions are now matched against glider output. This
matching glider output against the conditions of a state’s transitions continues until a
special state called the final state is reached. The script terminates when the final state
is reached.
While many glider associated tasks can be automated using scripts, they have
limitations. The following list identifies the most prominent Dock Server script
limitations.
1. No arithmetic. Quantities can not be manipulated mathematically – no addition,
subtraction, etc… Thus, no loop counters.
2. No variables. Quantities can not be saved and then referred to later.
Page 196 of 228