TMC: The Telemetry Compiler

Contents

0.0: Invocation

    tmc [options] [files]
        -c             Generate collection rules
        -C             Print information on Conversions
        -d             Print Data Definitions
        -D filename    Create dac file
        -i             Print Steps in compilation progress
        -k             Keep output file (.c) even on error
        -m             Do not generate main() function
        -o filename    Send C output to file
        -p             Print PCM (TM Format) Definition
        -v             Produce very verbose output (-Cdps)
        -V filename    Redirect verbose output to file
        -q             Show this help message
        -s             Print frame statistics
        -w             Give error return on warnings

A.0: Syntax

program
  : [ progitem ... ]

progitem
  : TM rate declaration ;
  : STATE ( <NAME> [ , <NAME> ... ] );
  : TM SYNCHRONOUS;
  : TM SYNCHRONOUS TOLERANCE = <INTEGER-CONST> ;
  : TM MAXCOLS = <INTEGER-CONST> ;
  : TM <STRING-LITERAL> <NAME> <INTEGER-CONST> ;
  : COLLECT <NAME> block
  : COLLECT <NAME> = expression ;
  : GROUP <NAME> ( grouplist ) block
  : ADDRESS <NAME> <INTEGER-CONST> ;
  : CALIBRATION ( <TYPE-NAME> , <TYPE-NAME> ) { pairs }
  : nontm-decl
  : tl-statement

nontm-decl
  : declaration ;
  : TYPEDEF declaration ;
  : TM TYPEDEF declaration tmtyperules

grouplist
  : <NAME> [ , <NAME> ... ]

tl-statement
  : opt-expr ;
  : block
  : DO statement WHILE ( expression );
  : IF ( expression ) statement [ ELSE statement ]
  : SWITCH ( expression ) statement
  : WHILE ( expression ) statement
  : FOR ( opt-expr ; opt-expr ; opt-expr ) statement
  : RETURN opt-expr ;
  : DEPENDING ON ( namelist ) statement [ ELSE statement ]
  : validator <NAME> ;
  : DISPLAY ( constant , constant , constant , <NAME> ) ;

statement
  : tl-statement
  : <NAME> : statement
  : CASE expression : statement
  : DEFAULT : statement

validator
  : VALIDATE
  : INVALIDATE

block
  : { declarations statements }

statements
  : [ statement ... ]

namelist
  : depname
  : namelist , depname
  : rate
  : namelist , rate

depname
  : <NAME> [ ONCE ]

opt-expr
  : [ expression ]

expression
  : expr-piece
  : expression expr-piece
  : expression ? expression : expression

expr-piece
  : constant
  : reference
  : oper-punc
  : ( opt-expr )

reference
  : <NAME>
  : <NAME> . ADDRESS
  : CONVERT ( <NAME> )
  : ICONVERT ( <NAME> )
  : TEXT ( <NAME> )
  : <NAME> derefs

derefs
  : deref [ deref ... ]

deref
  : . <NAME>
  : -> <NAME>

oper-punc
  : <OPER-PUNC>
  : ]
  : [
  : ,
  : /
  : =
  : -
  : +

constant
  : <INTEGER-CONST>
  : <REAL-CONST>
  : <CHAR-CONST>
  : <STRING-LITERAL>

tmtyperules
  : ;
  : { [ tmtyperule ... ] }

tmtyperule
  : COLLECT <NAME> { declarations statements }
  : COLLECT <NAME> = expression ;
  : CONVERT <TYPE-NAME> [ cvtfunc ] ;
  : TEXT <STRING-LITERAL> [ cvtfunc ] ;

cvtfunc
  : <NAME>()
  : <NAME>[]
  : ()

rate
  : rational SAMPLE[S] / time-unit
  : rational HZ
  : rational time-unit / SAMPLE[S]

time-unit
  : SECOND[S]
  : MINUTE[S]
  : HOUR[S]

rational
  : <INTEGER-CONST> [ / <INTEGER-CONST> ]

declarations
  : [ declaration ; ... ]

declaration
  : declarators

declarators
  : typeparts declarator [ , declarator ... ]

declarator
  : <NAME> array-decorations

array-decorations
  :
  : array-decorations [ <INTEGER-CONST> ]

typeparts
  : integertypes
  : FLOAT
  : DOUBLE
  : <TYPE-NAME>
  : struct-union { declarations }

struct-union
  : STRUCT
  : UNION

integertypes
  : integertype [ integertype ... ]

integertype
  : CHAR
  : INT
  : LONG
  : SHORT
  : SIGNED
  : UNSIGNED

pairs
  : pair-num , pair-num [ , pair-num , pair-num ... ]

pair-num
  : <INTEGER-CONST>
  : <REAL-CONST>
  : - pair-num
  : + pair-num

B.0: Changes

Changes from V1R3 to V1R4

Changes have been made to how TMC supports Calibrations and conversions between types and to text.

Output text format is now specified in the source type, not the destination. A side effect is that we should require fewer "dummy" output types. For example, in ClONO2 we have VOLTS2 and VOLTS4 which both represent volts, but one with a %4.2lf format and the other with a %6.4lf format. We convert AD8's to VOLTS2 and AD12's to VOLTS4. Now we can specify a single VOLTS type and specify AD8 { convert VOLTS; text "%4.2lf"; } and AD12 { convert VOLTS; text "%6.4lf"; } and it is quite reasonable to compare VOLTS to VOLTS regardless of which type they originated from.

Calibrations and conversions can be inherited. This allows for more flexible sub-typing. For example, a sub-type can be created for individual thermistors. Each thermistor will inherit the generic calibration from the parent, but if a better calibration is made, that can be added later. If the thermistor-specific calibrations are placed in a separate file, a display program which doesn't require a precise calibration could simply use the generic calibration whereas an extraction program could use the individual calibrations.

iconvert() is a new syntax for to augment and improve the semantics of the convert() syntax. By and large, iconvert() behaves the way the old convert() syntax did and convert() now behaves the way you might have expected it to all along. convert() now produces converted floating point values which are scaled correctly. iconvert() produces converted integer values which have been scaled to preserve the precision of fixed-point formats. For example, if the output format of AD8 is "%4.2lf" and x is of type AD8, convert(x) will produce VOLTS and iconvert(x) will produce VOLTS*100.

When in doubt, use convert() and stay away from iconvert().

A side-effect of this change is that basic extraction into spreadsheets via simple .edf definitions will now produce properly scaled output (without any .1* kluges in the .edf file).

Support for text conversion of floating point types including %e format for scientific notation. Previously any fixed-point values had to be stored as integers for display, and true floating-point output was virtually impossible.

Support for text conversion of data using a supplied explicit conversion function. An earlier release supported explicit convert() and text() functions to augment the calibration facility, but if you provided a convert() function, you had to provide a text() function also, which was a real pain. Now TMC will generate a text() function for you using your custom convert().

C.0: Upgrading from V1R3

Check all TM typedefs for appropriate text formats. The text format now belongs with the source type and reflects how the data should be scaled/displayed after conversion. May be able to collapse redundant destination types (VOLTS2 & VOLTS4, for example)

Check all instances of convert() to make sure they are appropriate. Replace with iconvert() if desired.

Remove any explicit scaling from .edf files where it is no longer required.

Add the following to your .spec file:

    %%
    TMCREV=tmcV1R4beta
(If you already have a %% line, don't add another.)

D.0: Changes in V1R10 (QNX6)

TM “Receive” <NAME> <INTEGER-CONST> ;

The TM “Receive” functionality has been made a little easier to implement with QNX6. Each such statement causes collection to create a new device named /dev/huarp/TM/$Experiment/data/<NAME>. Any data written into that device is copied into the variable <NAME>.

The INTEGER-CONST must be either 0 or 1. If it is 1, writes to the device are synchronized with the telemetry frame. A DG_data object named <NAME>_obj is defined, and it is the developer's responsibility to ensure the <NAME>_obj->synch() is called after the data is processed. A more detailed example is required, but in the mean time, you can refer to existing source code for the TILDE instrument for synchronized writes using blocking I/O and the idx64 driver for synchronized writes using non-blocking I/O and ionotify().

TM INITFUNC <statement>

Adds the specified statement to a list of statements executed just prior to starting operation. May be called multiple times.

Return to Manuals Guide. Written by Norton T. Allen



last updated: Fri Jan 28 09:16:16 2011 webmaster@huarp.harvard.edu
Copyright 2008 by the President and Fellows of Harvard College