swscomp
[options] files
The default <prefix> is 'SWData'.
Without -A
, four files are generated:
.h
.tmc
_col.tmc
.cmd
With -A
, either <prefix> or <prefix>.tma
is generated.
There is a well-established convention in tmcalgo programs of using software status telemetry variables to control instrument operations. Unlike most telemetry variables, software status variables do not report the state of physical sensors. Instead, they are set under program or interactive control. Using this approach, it is possible to provide operators with very high-level control.
Setting up an instrument for this type of configuration involves:
.tma
).tmc
).tmc
, .cmd
).h
).cmd
).tma
)As you can see, many different input files are involved, but only the first item listed here involves truly original coding. Setting up and modifying all the other files has been a tedious process of duplicating the established convention. This is what motivated the effort to create a compiler to offload the busy work and
centralize the necessary definitions. With swscomp
the steps required now include:
.tma
).sws
)As you can see, the aim of the .sws
file is to succinctly encapsulate
selected syntaxes from several different languages into one file. There are three
basic types of input lines:
SW_Variable:
[ < ctype,tmtype > ] name [cmd_prefix]
This defines a variable with the specified name that can be set using the specified cmd_prefix. If the cmd_prefix is omitted, the variable's name is used instead. If the type specifications are omitted, the default is <unsigned char,UCHAR>
. Both C and TMC type definitions are required
because the variable will be used in both C and TMC contexts.
If no SW_Variable
statement is found, the following default is used:
SW_Variable: <unisgned char,UCHAR> SWStat SW Status
It remains the responsibility of the programmer to ensure that appropriate type definitions are in place for the ctype and tmtype.
SWS_
mnemonic value cmd_text:
action
Value/Action Mappings cram a lot of details onto a single line (although the action portion can
extend onto subsequent lines as well.) The easiest way to think of these lines is as a C case statement
within the tmcalgo program. Everything before the colon is replaced with case SWS_
mnemonic:, and everything after the colon gets copied directly. Subsequent lines that are not identified as one of
the recognized sws syntax elements are also copied as part of this case statement body.
In addition to tmcalgo commands, this line includes information that goes into a header file
(#define SWS_
mnemonic value) and into a .cmd
file (
:
cmd_prefix cmd_text { $0 =
value; }
)
The following restrictions apply:
break;
statement.cmdgen
definitionsSometimes we need software status variables that serve a different purpose within the algorithm
or need to communicate data that is not easily reduced to a fixed number of integer values.
Since swscomp
has already set up the interprocess communication required, it is
handy to allow these other variable types to be supported, even though they don't have exactly
the same implementation on the algorithm side.
Any line where the first non-space character is a colon is interpreted as a line from a cmdgen
specification for the right hand side expansion for the value of the current SW_Variable
.
The basic structure is:
:
cmd_text{ $0 =
value; }
but more complex cmdgen
syntax is also possible. To specify a float
value, for example:
: Set Point %f { $0 = $3; }
Note that the full command syntax will include the SW_Variable
's cmd_prefix.
.sws
files should be listed in the .spec
file using the
swsbase
syntax:
swsbase = ToF.sws
In addition, .sws
files also need to be listed explicitly as inputs
to any algorithms that they reference.
Both specifications are required because although the command syntax definitions and the variable name and types definitions are global, it is entirely possible for an instrument to have more than one algorithm with independent functionality. This might be true for example when more than one physical instrument is controlled by a single processor.
The following example is taken verbatim from the Wennberg Group's Time of Flight instrument:
SW_Variable: SWStat SW Status SWS_FLOWSTATE_OFF 1 Flow State Off: Validate Flows_OFF; break; SWS_TURBOS_ON 90 Turbo Pumps On: Validate TPA_On; Validate TPB_On; break; SWS_TURBOS_OFF 91 Turbo Pumps Off: Validate TPA_Off; Validate TPB_Off; break; SWS_PUMPS_ON 96 Pumps On: Validate pumps_on; break; SWS_PUMPS_OFF 97 Pumps Off: Validate pumps_off; break; SWS_INLET_PCTRL 100 Inlet Pressure Control: Validate Inlet_PControl; break; SWS_INLET_IDLE 101 Inlet Close: Validate Inlet_Close; break; SWS_INLET_LAB 102 Inlet Lab: Validate Inlet_Lab; break; SWS_TOF_START 110 ToF Start: Validate ToF_start; break; SWS_TOF_STOP 111 ToF Stop: Validate ToF_stop; break; SWS_DATA_LOOP 115 Data loop start: Validate data_loop; break; SWS_DATA_STOP 116 Data loop stop: Validate data_idle; break; SWS_QUICK_SHUTDOWN 254 Shutdown Quick: Validate Quick_Shutdown; break; SWS_SHUTDOWN 255 Shutdown Full: Validate Shutdown; break; SW_Variable: SWFlow SW Flow State : Transitioning { $0 = 0; } : Off { $0 = SWS_FLOWSTATE_OFF; } SW_Variable: <float,SWStatf> InP_Pgain Inlet Pgain : %f (Enter Proportional Gain) { $0 = $1; } SW_Variable: <float,SWStatf> InP_igain Inlet Igain : %f (Enter Integral Gain) { $0 = $1; } SW_Variable: <signed short,V100torr_t> InPset Inlet Pressure Setpoint : %f (Enter Inlet Pressure Setpoint in mbar) { $0 = $1*32768/133.33; }
Return to Manuals Guide. Written by Norton T. Allen
last updated: Wed Aug 8 11:15 EDT 2012 | webmaster@huarp.harvard.edu |
Copyright 2012 by the President and Fellows of Harvard College |