Interpolation Extension¶
PREVIEW
- Extension introduced in 5.0.6.
- Interpolation in descriptions (
"""...""") is fully handled by the TethysL tooling (there's no LRAUV counterpart because such descriptions are not translated). - Interpolation in string literals and ids requires the corresponding support in the LRAUV software (see the note below).
Syntax¶
Within descriptions ("""...""") and string literals ("..."), $ names
(constants and macro variables) are replaced by their values:
mission Example {
"""
Survey with $NUM_LEGS legs, and up to $MAX_CARTRIDGES cartridges.
"""
const $NUM_LEGS = 4
const $MAX_CARTRIDGES = 60
arguments {
NumSamplers = 1 count
"""
Total number of ESP cartridges (Maximum $MAX_CARTRIDGES)
"""
}
macro $j = 1..$NUM_LEGS {
aggregate Leg$j {
"""
Leg $j of $NUM_LEGS.
"""
run in sequence
syslog important "Starting leg $j of $NUM_LEGS"
}
}
}
Here, the argument's description reads "Total number of ESP cartridges (Maximum 60)" wherever it is shown: the generated mission, the TethysDash mission view, the generated documentation, and the hover information in the VS Code extension. Each expanded aggregate gets its own description ("Leg 1 of 4.", "Leg 2 of 4.", ...), and its own syslog message ("Starting leg 1 of 4", ...).
$NAMEis replaced by the value of the constant or the macro variable with that name.${NAME}can be used when the name is immediately followed by letters, digits or_, e.g.,"Leg${j}A".- Only the names defined at that point (a constant, or an enclosing macro variable) are
replaced. Any other
$wordis kept as written, with a warning, so text like "costs $USD" continues to work while possible typos are still flagged. $$gives a literal$, e.g.,"$$USD"for "$USD" without the warning.- A constant can be used in the description of the mission (or aggregate file) itself,
even though that description comes before the
constdefinitions. - Within nested macros, all enclosing macro variables are available
(e.g.,
"leg $j, sample $k"). - For descriptions shown outside of the expanded mission (TethysDash, documentation, hover information), only constants are replaced: a macro variable has no single value there.
- VS Code extension: highlighting of the
$names within strings and descriptions; hover, go to definition, references and rename also for constants within them.
Where it applies¶
The replacement applies to descriptions, and to the string literals used as values:
- syslog strings (each
"..."piece on its own, so a$name never spans a+) - string values in expressions: behavior settings (e.g.,
set command = "..."),assign, argument and output defaults,redefineArgininsert, array elements
It also applies to the ids and the references to them:
id = "..."ofinsert,assign,behavior,call,readData,readDatum, e.g.,insert id="Labeled${j}A" ...call refId = "..."
(In aggregate names, e.g., aggregate Leg$j, the macro variable was already replaced.)
It does not apply to the other strings that name or locate something, which are kept as written:
the insert path, sendData destination = "...", customUri "...".
Note
The string literals and ids are used by the vehicle,
so their interpolation requires a version of the LRAUV software that supports it.
A vehicle with an older version would keep the $ names as written in those strings,
and, in ids, replace only the innermost macro variable.
(Descriptions are not used by the vehicle.)