Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ccdWsInternal.h

Go to the documentation of this file.
00001 /*************************************************************************
00002 * E.S.O. - VLT project
00003 *
00004 * "@(#) $Id: ccdWsInternal.h,v 4.1 2003/10/30 15:32:47 vltsccm Exp $"
00005 *
00006 * who       when      what
00007 * --------  --------  ----------------------------------------------
00008 * alongino  12/08/94  created
00009 * alongino  24/07/95  commands moved to ccd.h
00010 *                     removed IMREADY. Obsolete
00011 * alongino  14/08/95  added definition of ccdPARAM
00012 * alongino  17/08/95  changed structure of ccdENVVAR to include ccdCAMERA
00013 * alongino  29/01/96  ccdPARAM replaced with cmdPARAM_LIST
00014 * alongino  15/11/96  added ccdMidasCmd and ccdObjGetMidasProc prototypes
00015 * pduhoux   31/01/97  added param <revision> to ccdLog functions
00016 * pduhoux   31/01/97  fixed DB/dataType mismatch in ccdFITSHIERARCH_WS
00017 * pduhoux   01/07/97  <id> set to vltBYTES32 in ccdFITSHIERARCH_WS to match DIC
00018 */
00019 
00020 /*************************************************************************
00021 *  This file contains the definitions for the WS part of the CCD sw.
00022 *  Common file Used by all WS CCD modules
00023 *************************************************************************/
00024 
00025 #ifndef CCDWSINTERNAL_H
00026 #define CCDWSINTERNAL_H
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 /*
00033  * System header files
00034  */
00035 #include <stdlib.h>
00036 #include <unistd.h>
00037 
00038 /*
00039  * CCD include files
00040  */
00041 #include "ccdInternal.h"               /* common definitions for WS and LCU */
00042 
00043  /*
00044  * Constants
00045  */
00046 #define ccdTIMEOUT_DEFAULT 25000      /* default timeout for replies 25 sec  */
00047                                       /* AL941214 10 sec not enough for wipe */
00048 #define ccdSETUP_VERS_PAR "VERSION"   /* keyword in setup file for version   */
00049 #define ccdMAX_LINE        80         /* maximum size of a setup line        */
00050 #define ccdMAX_PARAM       10         /* maximum number of command parameters*/
00051 
00052 #define ccdMAX_UTC_DELTA   5.0        /* Max UTC difference WS vs LCU        */
00053 
00054 /* commands */
00055 /* command ccdCMD_VERS */
00056 #define ccdPAR_START_MODE   "imageSave"    /* image save parameter name     */
00057 
00058 /*
00059  * database paths for common attributes 
00060  */
00061 
00062 /*
00063  * New types definitions
00064  */
00065 /*
00066  * operational states of CCD WS part
00067  */
00068 typedef enum {                     /* possible states of CCD DCS WS part   */
00069     ccdWsOFF         = ccdOFF,         /* terminating                      */
00070     ccdWsLOADED      = ccdLOADED,      /* need to be initialised           */
00071     ccdWsSTANDBY     = ccdSTANDBY,     /* stand-by                         */
00072     ccdWsONLINE      = ccdONLINE       /* ready for commands               */
00073 } ccdWsSTATE;
00074 
00075 /*
00076  * FITS for CCD WS part
00077  */
00078 typedef struct {                     /* basic FITS info                    */
00079     ccdFITSBASIC    lcu;             /* basic info from LCU                */
00080     vltBYTES16      dateFile;        /* date the file has been written     */
00081 } ccdFITSBASIC_WS;
00082 
00083 typedef struct {                     /* cryostat FITS info                 */
00084     vltBYTES16      description;     /* type                               */
00085     vltUINT8        esoNumber;       /* eso sequencial number              */
00086 } ccdFITSCRYO_WS;
00087 
00088 typedef struct {                     /* FITS info on camera shutter        */
00089     vltBYTES16      type;            /* shutter type                       */
00090     vltBYTES16      description;     /* unique identifier                  */
00091 } ccdFITSSHUT_WS;
00092 
00093 typedef struct {                     /* FITS info on tempepature sources   */
00094     vltBYTES16      id;              /* id as from manufacturer            */
00095     vltBYTES16      description;     /* unique identifier                  */
00096 } ccdFITSTEMP_WS;
00097 
00098 typedef struct {                     /* FITS info on telemetry sensors     */
00099     vltBYTES16      id;              /* id as from manufacturer            */
00100     vltBYTES16      description;     /* unique identifier                  */
00101 } ccdFITSTELE_WS;
00102 
00103 typedef struct {                     /* FITS info on chips in the mosaic   */
00104     vltBYTES16      id;              /* chip description                   */
00105     vltBYTES16      description;     /* chip identifier                    */
00106     vltBYTES16      date;            /* chip installation date             */
00107     vltDOUBLE       xGap;            /* right gap to next chip [um]        */
00108     vltDOUBLE       yGap;            /* top   gap to next chip [um]        */
00109 } ccdFITSCHIP_WS;
00110 
00111 typedef struct {                     /* FITS info on outputs               */
00112     vltBYTES16      id;              /* id as from manufacturer            */
00113     vltBYTES16      description;     /* name of the output                 */
00114 } ccdFITSOUTP_WS;
00115 
00116 typedef struct {                     /* FITS info on chip mosaic           */
00117     vltBYTES16      description;     /* chip type                          */
00118 } ccdFITSMOSAIC_WS;
00119 
00120 typedef struct {                     /* hierarchical FITS info             */
00121     ccdFITSHIERARCH    lcu;                 /* info from LCU               */
00122     vltBYTES32         id;                  /* software version identifier */
00123     vltBYTES32         name;                /* name of detector system     */
00124     vltBYTES16         date;                /* detector commissioning date */
00125     vltBYTES32         installed;           /* software installation date  */
00126     vltBYTES32         did;                 /* dictionary identifier       */
00127     vltDOUBLE          tranTime;            /* transfer time [s]           */
00128     vltDOUBLE          xPixSize;            /* pixel size in X [um]        */
00129     vltDOUBLE          yPixSize;            /* pixel size in Y [um]        */
00130     vltINT32           dumdit;              /* # dummy rdt / exposure      */
00131     ccdFITSCRYO_WS     cryo;                /* cryostat info               */
00132     ccdFITSSHUT_WS     shut;                /* shutter  info               */
00133     ccdFITSTEMP_WS     temp[ccdMAXTMPSRC];  /* temp. sensor info           */
00134     ccdFITSTELE_WS     tele[ccdMAXTELSRC];  /* telemetry info              */
00135     ccdFITSCHIP_WS     chip[ccdMAXCHIPS];   /* chip info                   */
00136     ccdFITSOUTP_WS     outp[ccdMAXOUTPUT];  /* output info                 */
00137     ccdFITSMOSAIC_WS   mosaic;              /* mosaic info                 */
00138 } ccdFITSHIERARCH_WS;
00139 
00140 typedef struct {                     /* complete DCS FITS info             */
00141     ccdFITSBASIC_WS    basic;        /* basic info                         */
00142     ccdFITSHIERARCH_WS hierarch;     /* hierarchical info                  */
00143 } ccdFITS_WS;
00144 
00145 typedef struct {                              /* Environment information   */
00146     ccdCAMERA         camera;                 /* camera info               */  
00147     ccsPROCNUM        myProcId;               /* my process ID             */
00148     ccsPROCNAME       myProcName;             /* my process name           */
00149     ccsPROCNAME       destProcName;           /* destination process name  */
00150     ccsENVNAME        destEnv;                /* destination CCS enviroment*/
00151     dbSYMADDRESS      myRootPoint;            /* name of my DB root point  */
00152     dbSYMADDRESS      destRootPoint;          /* name of dest. DB root point */
00153     ccdCONFIG         config;                 /* configuration information */
00154     slxDICTIONARY     dictionary;             /* dictionary name           */
00155     logMASK           logMask;                /* FITS log mask             */
00156 } ccdENVVAR;
00157 
00158 typedef struct {                  /* information associated to any message */
00159     vltUINT8          type;                   /* type of message           */
00160     msgCMD            name;                   /* name                      */
00161     msgCMDID          id;                     /* ID                        */
00162     msgPROCESSID      orgId;                  /* originator of message     */
00163     ccsPROCNAME       proc;                   /* destination process name  */
00164     ccsENVNAME        env;                    /* destination CCS enviroment*/
00165     char              body[msgMAXLEN];        /* body of message           */
00166     msgLENGTH         length;                 /* length of message body    */
00167     cmdPARAM_LIST     param;                  /* parameters structure      */
00168     msgTIMEOUT        timeout;                /* timeout to wait for reply */
00169     msgCHECKFLAG      check;                  /* check flag                */
00170     vltLOGICAL        sendReply;              /* reply must be sent        */
00171     vltLOGICAL        lastReply;              /* flag for last reply       */
00172     ccsERROR          error;                  /* error returned in reply   */
00173 } ccdMSG;
00174 
00175 typedef struct ccdMsgLst *ccdMSGLSTPTR;       /* pointer to ccdMSGLST      */
00176 /* 
00177    Note: better to define variables as (ccdMSGLST *) rather than ccdMSGLSTPTR
00178    because some debugger, e.g. gdb, shows the contents of the structure only
00179    in the former case 
00180 */
00181 
00182 typedef struct ccdMsgLst{ /* list of msg whose execution must be completed */
00183     ccdMSG            msg;                    /* message info              */
00184     ccdMSGLSTPTR      orgCmd;                 /* entry of original command */
00185     ccdMSGLSTPTR      prev;                   /* previous entry in the list*/
00186     ccdMSGLSTPTR      next;                   /* next entry in the list    */
00187 } ccdMSGLST;
00188 
00189 /* 
00190  * Macros 
00191  */
00192 
00193 /*
00194  * function prototypes
00195  */
00196 
00197 /* log that a CCD program started */
00198 void ccdLogStart( 
00199     IN  ccsPROCNAME  procName,              /* process name               */
00200     IN  const char  *revision);             /* RCS code revision string   */
00201 
00202 /* log that a CCD program terminated */
00203 void ccdLogTerminate( 
00204     IN  ccsPROCNAME  procName,              /* process name               */
00205     IN  const char  *revision);             /* RCS code revision string   */
00206 
00207 /* log that a CCD program runs in a certain operational mode */
00208 void ccdLogOpMode( 
00209     IN  const char  *opModeDescr);        /* operational mode description */
00210 
00211 /* add error to stack, print error info on stdout and close stack */
00212 void ccdPrintErr( 
00213     IN    ccsPROCNAME   procName,            /* process name              */
00214     IN    char          *reason,             /* reason for error          */
00215     IN    ccsERROR      *error);             /* error structure           */
00216 
00217 /* do startup actions for any WS CCD program */
00218 ccsCOMPL_STAT ccdProcStart( 
00219     IN  int argc,                         /* number of runtime parameters */
00220     IN  char *argv[],                     /* runtime parameters           */
00221     IN  const ccsPROCNAME destProc,       /* name of commands destination */
00222     IN  const char        *revision,      /* RCS code revision string     */
00223     OUT ccdENVVAR *envInfo);              /* pointer to env. var. values  */
00224 
00225 /* terminate CCD process */
00226 void ccdProcTerminate( 
00227     IN    ccsPROCNAME   procName,            /* process name              */
00228     IN    const char   *revision,            /* RCS code revision string   */
00229     IN    vltLOGICAL    ccsRegistered,       /* registered already to CCS */
00230     IN    const char   *reason,              /* reason for error          */
00231     IN    ccsERROR     *error);              /* error structure           */
00232 
00233 /* check operational mode */
00234 ccsCOMPL_STAT ccdCheckOpMode( 
00235     IN  ccdOPMODE opMode,                    /* operational mode          */
00236     OUT ccsERROR  *error);                   /* error structure           */
00237 
00238 /* receive and parse next message */
00239 ccsCOMPL_STAT ccdRecvMsg( 
00240     INOUT ccdMSGLST         **msg,           /* pointer to message entry  */
00241     OUT   vltLOGICAL        *logErr,         /* log the error             */
00242     INOUT ccsERROR          *error);         /* error structure           */
00243 
00244 /* Send command to other process and add expected reply to message list */
00245 ccsCOMPL_STAT ccdSendCmd(
00246     INOUT ccdMSGLST    **msg,             /* entry to list                */
00247     IN    ccdMSG       *cmd,              /* command info                 */
00248     IN    vltLOGICAL   link,              /* link to associated command   */
00249     OUT   ccsERROR     *error);           /* error structure              */
00250 
00251 /* send all pending replies in the pending messages list */
00252 ccsCOMPL_STAT ccdSendReply( 
00253     INOUT ccdMSGLST    **msg,             /* pointer to message entry     */
00254     OUT   vltLOGICAL   *exit,             /* last reply to EXIT sent      */
00255     INOUT ccsERROR     *error);           /* error structure              */
00256 
00257 /* add suffux to file name */
00258 void ccdFileNameAddSuffix( 
00259     IN     char       *header,         /* header of original pathname */
00260     IN     char       *suffix,         /* suffix of original pathname */
00261     IN     int        index,           /* index to be added as suffix */
00262     OUT    char       *path);          /* new pathname                */
00263 
00264 /* separate suffix from header in a file name */
00265 void ccdFileNameSepSuffix( 
00266     IN     char       *path,           /* original pathname           */
00267     OUT    char       *header,         /* file name header            */
00268     OUT    char       *suffix);        /* file name suffix            */
00269 
00270 /* get env. information needed by any CCD WS program */
00271 ccsCOMPL_STAT ccdGetEnv( 
00272     INOUT ccdENVVAR    *envInfo,           /* pointer to env. var. values */
00273     OUT   ccdOPMODE    *opMode,            /* operational mode            */
00274     OUT   ccsERROR     *error);            /* error structure             */
00275 
00276 /* get CCD sw operational mode */
00277 ccsCOMPL_STAT ccdGetOpMode (
00278     OUT ccdOPMODE     *opMode,             /* operational mode            */
00279     OUT ccsERROR      *error);             /* error structure             */
00280 
00281 /* convert operational mode from code to string */
00282 char *ccdOpModeEnumToStr(
00283     IN ccdOPMODE      opMode);             /* operational mode            */
00284 
00285 void ccdHandleBreak(             
00286     IN  int           sigNum);             /* signal Number               */
00287 
00288 /* add new entry in the list of pending messages for any CCD WS program */
00289 ccsCOMPL_STAT ccdMsgLstAdd(
00290     INOUT ccdMSGLST    **msg,              /* pointer to new entry in list */
00291     OUT   ccsERROR     *error);            /* error structure              */
00292 
00293 /* fill in a command entry in the list of pending messages */
00294 ccsCOMPL_STAT ccdMsgLstCmdAdd(
00295     INOUT ccdMSGLST    **msg,              /* pointer to entry in list     */
00296     IN    msgCMD       *cmdName,           /* command name                 */
00297     IN    msgCMDID     cmdId,              /* command ID                   */
00298     IN    msgPROCESSID *orgId,             /* originator ID                */
00299     IN    const char   *body,              /* command body                 */
00300     IN    msgLENGTH    length,             /* command body length          */
00301     OUT   ccsERROR     *error);            /* error structure              */
00302 
00303 /* fill in a command entry in the list of pending messages */
00304 ccsCOMPL_STAT ccdMsgLstRplyAdd(
00305     INOUT ccdMSGLST    **msg,              /* entry to list                */
00306     IN    vltLOGICAL   link,               /* link to associated command   */
00307     IN    ccdMSG       *cmd,               /* command info                 */
00308     OUT   ccsERROR     *error);            /* error structure              */
00309 
00310 /* fill in a reply entry in the list of pending messages */
00311 ccsCOMPL_STAT ccdMsgLstRplyFill(
00312     IN    ccdMSGLST    *rply,              /* reply entry in list          */
00313     IN    vltUINT8     type,               /* reply type                   */
00314     IN    const char   *command,           /* associated command           */
00315     IN    msgPROCESSID *orgId,             /* reply originator ID          */
00316     IN    const char   *body,              /* pointer to reply body        */
00317     IN    msgLENGTH    length,             /* command length               */
00318     IN    vltLOGICAL   last,               /* last reply                   */
00319     IN    ccsERROR     *error);            /* reply error                  */
00320 
00321 /* delete one entry in the list of pending messages for CCD WS program*/
00322 ccsCOMPL_STAT ccdMsgLstDel(
00323     INOUT ccdMSGLST    **msg,              /* pointer to next entry in list*/
00324     OUT   ccsERROR     *error);            /* error structure              */
00325 
00326 /* query list of pending messages for CCD WS program */
00327 ccsCOMPL_STAT ccdMsgLstSearch(
00328     INOUT ccdMSGLST    **msg,              /* pointer to new entry in list */
00329     IN    vltUINT8     type,               /* message type                 */
00330     IN    msgCMD       *cmdName,           /* command name                 */
00331     IN    msgCMDID     cmdId,              /* command ID                   */
00332     IN    msgPROCESSID *orgId,             /* originator ID                */
00333     OUT   vltLOGICAL   *logErr,            /* if TRUE, log error           */
00334     OUT   ccsERROR     *error);            /* error structure              */
00335 
00336 /* add reply information for pending command */
00337 void ccdMsgLstRplyBuild(
00338     IN    ccdMSGLST    *cmd,               /* entry to command associated  */ 
00339     IN    const char    *reply,             /* reply body                   */
00340     IN    msgLENGTH    length,             /* reply length                 */
00341     IN    vltLOGICAL   last,               /* last reply                   */
00342     IN    ccsERROR     *error);            /* error reply                  */
00343 
00344 /* Delete all links to a command in the pending messages list */
00345 void ccdMsgLstCmdLinkDel(
00346     IN    ccdMSGLST    *cmd);              /* entry to command associated  */ 
00347 
00348 /* Check if there are links to a command in the pending messages list */
00349 vltLOGICAL ccdMsgLstCmdLinkCheck(
00350     IN    ccdMSGLST    *cmd);              /* entry to command associated  */ 
00351 
00352 /* Check if there are pending commands ready for reply */
00353 vltLOGICAL ccdMsgLstCmdReady(
00354     INOUT    ccdMSGLST   **cmd);           /* pointer to entry to command  */
00355 
00356 /* Return timeout value for next message receive and associated message */
00357 void ccdMsgLstTimeout(
00358     OUT      msgTIMEOUT   *timeout,        /* timeout value               */
00359     INOUT    ccdMSGLST    **msg);          /* pointer to message entry    */
00360 
00361 /* Initialise message structure */
00362 void ccdMsgInit(
00363     INOUT ccdMSG       *msg);              /* message structure to init   */ 
00364 
00365 /* Add one value to the message body */
00366 void ccdMsgAddValue(
00367     INOUT ccdMSG       *msg,               /* message structure            */ 
00368     IN    cmdPARAM_TYPE type,              /* parameter type               */ 
00369     IN    const void   *value,             /* parameter value              */ 
00370     IN    vltLOGICAL   newPar);            /* first value of new parameter */ 
00371 
00372 /* Get the status of an exposure */
00373 ccsCOMPL_STAT ccdGetExpStatus( 
00374     INOUT vltINT32 *expId,          /* ID of exposure                        */
00375     OUT   vltINT32 *expStatus,      /* status of exposure                    */
00376     OUT   ccsERROR *error);         /* error structure                       */
00377 
00378 /* Set the status of an exposure */
00379 ccsCOMPL_STAT ccdSetExpStatus( 
00380     INOUT vltINT32 *expId,          /* ID of exposure                        */
00381     IN    vltINT32 *expStatus,      /* status of exposure                    */
00382     OUT   ccsERROR *error);         /* error structure                       */
00383 
00384 /* Write in database new operational state for CCD WS sw */
00385 ccsCOMPL_STAT ccdSetOpState(
00386     IN    ccdWsSTATE   opState,      /* operational state code           */
00387     OUT   ccsERROR     *error);      /* error structure                  */
00388 
00389 /* Get ID of last exposure started */
00390 ccsCOMPL_STAT ccdGetLastExpId(
00391     OUT vltINT32      *expId,              /* exposure ID                    */
00392     OUT ccsERROR      *error);             /* error structure                */
00393 
00394 /* get name of this program */
00395 void ccdGetProgName( 
00396     IN  const char   *argv0,                 /* runtime parameters        */
00397     OUT ccsPROCNAME   progName);             /* pointer program name      */
00398 
00399 /* get name of CCD process */
00400 void ccdGetProcName( 
00401     IN  const ccdCAMERANAME cameraName,      /* name of the camera used   */
00402     IN  const ccsPROCNAME   progName,        /* name of the program       */
00403     OUT       ccsPROCNAME   procName);       /* pointer to process name   */
00404 
00405 /* Send a command to Midas and return its reply */
00406 ccsCOMPL_STAT ccdMidasCmd(
00407     IN  char *midasId,            /* midas Unit ID string                  */
00408     IN  char *midasHost,          /* host where Midas is running           */
00409     IN  char *midasCmd,           /* Command for Midas                     */
00410     OUT msgLENGTH *rplyLen,       /* length of last reply from Midas       */
00411     OUT char **rplyBody,          /* pointer to Midas reply body           */
00412     OUT ccsERROR *error);         /* error structure                       */
00413 
00414 /* Get path for midas procedure usable from within Midas and image directory */
00415 ccsCOMPL_STAT ccdObjGetMidasProc(
00416     IN  char  *imgPath,           /* image file full path                 */
00417     IN  char  *procName,          /* name of Midas procedure              */
00418     OUT char  **imgDir,           /* image directory name                 */
00419     OUT char  **imgFile,          /* image file name                      */
00420     OUT char  *procPath,          /* path of procedure found              */
00421     OUT ccsERROR *error);         /* error structure                      */
00422 
00423 /* execute command DEBUG */
00424 ccsCOMPL_STAT ccdDebug( 
00425     IN  const ccdMSG   *inpCmd,     /* received command structure            */
00426     OUT ccdMSG         *destMsg,    /* destination message structure         */
00427     OUT ccsERROR       *error);      /* error structure                      */
00428 
00429 #ifdef __cplusplus
00430 }
00431 #endif
00432 
00433 #endif /* ! CCDWSINTERNAL_H */

Generated on Wed Dec 3 14:52:12 2003 for ATCS API by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001