next up previous contents
Next: Adding new elements to Up: The xtract macro language Previous: Internal design   Contents

Subsections


Programming with the xtract library

The process of compilation and execution of the xtract macro described above is done via a stand-alone library. This section describes the Application Programming Interface (API) of this library.

The C/C++ interface of this library is defined in fmt.h, which must be included in the code and linked to libjump.a, in addition to all other GMRT Off-line libraries (liboff.a, libregex.a, libkum.a).

Interpretation and compilation of the format string

The xtract macros are interpreted via the following function call:

      int interpret(char *fmtString, struct fftmac *fm,
                    Parameters *Params, SymbType *Inst)
The first argument is the macro as a NULL terminated string. Second argument is the sanjay/Offline/gstruct">fftmac (Bhatnagar1997a) structure which holds the various mappings for the LTA database (e.g., sampler to the MAC mapping, etc.). This structure must be filled using services provided by the sanjay/Offline/ltaobj">GMRT Offline Library (getFFTMac method). The third argument is a pointer to the structure of the type Parameters. This structure holds the various parameters which the library uses while executing the macro. Various fields of this structure are described in Section B.4.3. The value of some of the fields of this structure are defined by the user, while others are to be extracted from the LTA database. The fourth argument is a pointer to a structure of type SymbType. This is the table of elements mentioned earlier and must be initialized to NULL before being passed to this routine. A return value of less than EOF ($ -1$), indicates a syntax error in the macro.

Compilation of the macro string is done via a call to:

      int Compile(SymbType *Inst,struct fftmac *fm,
                  struct AntCoord *Tab, Parameters *Params)
The first argument is the symbol table returned by a call to interpret. It now points to the head of a linked list of nodes of type SymbType. The last node of this list is NULL. The second argument is the fftmac structure. The third argument is the table of antenna co-ordinates. This can be retrieved from the LTA database via the services provided by the sanjay/Offline/ltaobj">GMRT Offline Library (getFFTMac method). The fourth argument is a pointer to the Parameters structure. A return value of less than EOF($ -1$) indicates error in compilation of the macro. On successful compilation, it returns the size of the compiled symbol table in units of the size of the structure SymbType.

Execution of the compiled macro

If the interpretation and compilation of the macro was successful, the compiled macro can be executed via calls to a user-supplied function of signature

int Exec(FILE *fd, SymbType *Inst, float *Buf, int ProgSize) fd refers to the output file already opened for writing. Inst is the symbol table returned by interpret. In case the output data is not to be written to any file, the user can write versions of this routine which will fill the data in the buffer Buf. ProgSize is the value returned by Compile.

The data field of the Parameters structure (see section B.4.3) must be made to point to the buffer in which the LTA-data buffers are read. To generate a regular stream of output, corresponding to each input data record, this function must be called every time a new LTA-data record is read.

Few types of Exec functions are provided in the library. These include:

To generate any other functionality, the programmers need to write their versions of this function. The recommended route for writing a new function is to modify Execute or ExecuteDef functions.


The Parameters structure

The Parameters structure is of the following type:

            typedef struct StructParamType{
               int Norm;
               int *BList, *SList, *AList, *CList;
               int  NBase,  NScans, NAnt,   NChan;
               int dBNBase, dBNChan, dBNAnt;
               int dBStartChan;
               int TimeOff, ParOff,DataOff;

               float Lambda;
               float sd,cd, TUnits;
               char *data;
            } Parameters;
Various fields and their use is as follows:


next up previous contents
Next: Adding new elements to Up: The xtract macro language Previous: Internal design   Contents
Sanjay Bhatnagar 2005-07-07