| Package-private script parser.
Note that, at this time, the scripting language is rather
limited. Future enhancements will include variables,
conditionals, loops, math, etc.
Expects lines of text:
- Empty lines are ignored
- Lines starting with "#" are ignored
- Lines starting with "label " are goto labels, and require
a name (e.g. "label X").
- Lines starting with "goto " are goto commands, and require
a name (e.g. "goto X"). They may branch forward or
backwards in the script, but the label name must be
contained in the script.
- Lines starting with "move " are mobility step commands,
and are detailed below.
"move" commands, also called "step"s, look like:
(example)
move ActorAgent, ^0:30, +1:20, MobileAgent, OrigNode, DestNode, true
and require 7 comma-separated parameters:
- actor
The agent that should run the step. If an empty value is
specified then the script runner's agent is assumed.
- [+^@]pauseTime with ":" time dividers
The pause time before starting the move. See the notes
below on time formats.
If no value or a negative value is specified, then there
will be zero pause.
- [+^@]timeoutTime with ":" time dividers
The timeout time for the move, relative to before the
above (optional) pause time. See the notes below on
time formats.
If no value or a negative value is specified, then there
will be no timeout.
- mobileAgent
Agent that should be moved, or the script runner's agent
if an empty value is specified.
- origNode
Node that the mobile agent should be on when the move
is started, or an empty value if any node is allowed.
- destNode
Node that the mobile agent should be on when the move
has completed, or an empty value if the agent should
move to its current node. See the "forceRestart"
option below.
- forceRestart
Specify "true" if the mobile agent should be fully
restarted, even if the destination node is the same
as that agent's starting node.
Time is formatted as [+^@]time, where the
time is further separated with :
and .characters:
- If + is specified then the time is relative
to the runtime start of the current step. This can
be used to create a sequence of moves where you're
not counting the time to do the agent move.
- If ^ is specified then the time is relative
to the runtime start of the prior step excluding the
pause time (same as + on the first step). This can
be used to create a sequence of moves where you want
to count the move as part of the pause time.
- If @ is specified then the time is relative
to the start time of first step in the script (same as
+ on the first step)
- If no [+^@] modifier is used an absolute
system time in millseconds since Jan 1st 1970 is assumed.
- If no ":" or "." is present in the time, then
milliseconds is assumed.
- If one ":" is present and no ".", then the time is
the addition of the value before the ":" as minutes, and
the value after the ":" as milliseconds, i.e.:
(v[1] + 1000 * (v[0]))
- If one ":" and one "." is present, then the formula
yields minutes:seconds.millis
(v[3] + 1000 * (v[1] * 60 * (v[0])))
Ugly example script:
# my comment
# pause until it's 20 seconds after the script launch
# move agent A from node X to node Y
# no timeout for this move
move , @0:20, , A, X, Y,
# pause until it's 60 seconds after script launch
# move agent A from whichever node it happens to be to node Z
# timeout if the move doesn't complete within
# 30 seconds (which is equivalent to @(60+30) == @90
move , @0:60, +:30, A, , Z,
# pause until at least 50 seconds have passed since the
# prior move was started (excluding the above 60 second
# pause). If the above agent move took 10 seconds, this
# would be equivalent to @(60+50-10) == @100
# have agent B request that agent A move to node X
# timeout if the move doesn't complete before it's
# 1 minute 5 seconds 100 milliseconds after the script
# launch
move B, ^0:50, @1:5.1, A, , X,
# pause for 30 seconds
# move A to X
# no timeout for this move
# force a restart even if agent A is already on node X
move , +:30, , A, , X, true
# begin an infinite loop
label foo
# pause for 30 seconds
# move B from X to Y
# timeout after 60 seconds
move , +:30, +:60, B, X, Y,
# pause until it's 1 minute 20 seconds after the prior
# started its move (after its 30 second pause)
# move B back
# timeout after 1 minute
move , ^1:20, +1:, B, Y, X,
# note that we can't use "@" times in a loop
# keep moving B back and forth forever
goto foo
# never reach here!
|