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

ccdLcuInternal.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * E.S.O. - VLT Project
00003  *
00004  * "@(#) $Id: ccdLcuInternal.h,v 4.1 2003/10/30 15:32:26 vltsccm Exp $"
00005  *
00006  * who         when     what
00007  * --------- -------- ---------------------------------------------------
00008  * P.Duhoux  16/02/96 first implementation
00009  *                         - contains part of previous ccdcon.h which was
00010  *                           common to all sub-systems
00011  * P.Duhoux  13/03/96 Added setupResult structure in ccdDESCRIPTION
00012  * P.Duhoux  22/05/96 Added parameter <errReply> in fct ccdconWaitReply()
00013  * P.Duhoux  31/05/96 Added functions ccdconSet/ResetFailureLcu()
00014  * alongino  12/07/96 ccdconTASK_NAME_ACT_FMT moved to ccdInternal.h
00015  * P.Duhoux  16/07/96 changed type of ccdDesc->failure to vltUINT32
00016  * P.Duhoux  17/07/96 renamed fct ccdconEnvVarXxx to ccdEnvVarXxx   
00017  * P.Duhoux  06/08/96 moved ccdcon*Fis*.c, ccdconStoreTime.c from ccdcon
00018  * P.Duhoux  08/08/96 moved ccdconSendCmd*.c, ccdconWaitReply.c from ccdcon
00019  *                    moved ccdKill.c, ccd*Ace.c from ccdcon
00020  * P.Duhoux  08/08/96 ccdconSTATE replaced by ccdSTATE
00021  *                    ccdONLINE = ccdOPERATING
00022  * P.Duhoux  09/08/96 Added parameter <reply> in fct ccdWaitReply()
00023  *                    Added parameter <reply> in fct ccdSendCmd()
00024  * P.Duhoux  21/08/96 Moved fct ccdcon*ImBuf() from ccdcon
00025  * P.Duhoux  22/08/96 Added fct ccdFindImBuf() & ccdLoadImBuf()
00026  *                    Added parameter <storageType> in fct ccdAllocImBuf()
00027  *                    Added parameter <force> in fct ccdFreeImBuf()
00028  * P.Duhoux  22/08/96 Added fct ccd*Fits*.c and type ccdFITS for FITS file op
00029  * P.Duhoux  18/10/96 Added macros for IP file names & format (ccdFRAME_xxx)
00030  * P.Duhoux  27/01/97 Added times in ccdTIMES structure
00031  * P.Duhoux  12/02/97 Added <timer> data structure in ccdDESCRIPTION structure
00032  * P.Duhoux  12/03/97 Added <teleOn> and <tempOn> in ccdDESCRIPTION structure
00033  * P.Duhoux  02/04/97 Added ccdTELESTAT & ccdTEMPSTAT data structures
00034  *                    Added <teleStat> and <tempStat> in ccdDESCRIPTION
00035  * P.Duhoux  08/04/97 Indexed TMP sensor formats for symetry with TEL
00036  * pduhoux   06/05/97 moved ccdPROG_TEC/SCI to ccdInternal.h
00037  * pduhoux   01/07/97 extended ccdTIMES with <shiftStart>, <shiftTime> & 
00038  *                    <stepNum> for multiple exposures
00039  * pduhoux   02/07/97 permutated task prio TIME (now 35) 
00040  *                    with READ/SHUT (now 30)
00041  * alongino  09/05/98 changed priorities according to SPR 980215 
00042  * pduhoux   25/05/98 changed ccdCITASK_REGISTER() to set task priority
00043  *
00044  */
00045  
00046 /*
00047  ****************************************************************************
00048  * This header file belongs to the CCD LCU software. It contains global data
00049  * which is needed commonly by all CCD LCU modules.
00050  ****************************************************************************
00051  */
00052 
00053 #ifndef CCD_LCU_INTERNAL_H
00054 #define CCD_LCU_INTERNAL_H
00055 
00056 #ifdef __cplusplus
00057 extern "C" {
00058 #endif
00059 
00060 /*
00061  ****************************************************************************
00062  * Includes
00063  ****************************************************************************
00064  */
00065  
00066 /* 
00067  * System Includes 
00068  */
00069 #include "vxWorks.h"
00070 #include "envLib.h"
00071 #include "ioLib.h"
00072 #include "math.h"
00073 #include "semLib.h"
00074 #include "stdio.h"
00075 #include "stdlib.h"
00076 #include "string.h"
00077 #include "sysLib.h"
00078 #include "taskLib.h"
00079 #include "tickLib.h"
00080 #include "vxLib.h"
00081 #include "ctype.h"
00082 #include "usrLib.h"
00083 #include "errnoLib.h"
00084 
00085 /* 
00086  * CCD include files 
00087  */
00088 #include "ccdInternal.h"
00089 #include "too.h"
00090 
00091 #ifdef MEM_TRACE
00092 #include "lccMemoryTrace.h"
00093 #endif
00094 #include "lccTaskLib.h"
00095 
00096 /*
00097  ****************************************************************************
00098  * Data Types and Literals
00099  ****************************************************************************
00100  */
00101 #define ccdACE_B016_DRV  "/bxvi00"
00102 #define ccdACE_ARC0_DRV  "/arcdrv0"
00103 #define ccdACE_ARC1_DRV  "/arcdrv1"
00104 
00105 #define ccdTASK_FLAGS     (VX_FP_TASK)
00106 
00107 /* stack size */
00108 #define ccdTASK_STACK_30K  30000
00109 #define ccdTASK_STACK_40K  40000
00110 #define ccdTASK_STACK_50K  50000
00111 #define ccdTASK_STACK_80K  80000
00112 
00113 #define ccdTASK_STACK_SRV    ccdTASK_STACK_50K
00114 
00115 #define ccdTASK_STACK_SML    ccdTASK_STACK_30K
00116 #define ccdTASK_STACK_ACT    ccdTASK_STACK_40K
00117 #define ccdTASK_STACK_BIG    ccdTASK_STACK_50K
00118 #define ccdTASK_STACK_XXL    ccdTASK_STACK_80K
00119 
00120 #define ccdTASK_STACK_TIME   ccdTASK_STACK_SML
00121 #define ccdTASK_STACK_CTRL   ccdTASK_STACK_BIG
00122 #define ccdTASK_STACK_READ   ccdTASK_STACK_ACT
00123 #define ccdTASK_STACK_WIPE   ccdTASK_STACK_SML
00124 #define ccdTASK_STACK_SHUT   ccdTASK_STACK_ACT
00125 #define ccdTASK_STACK_TRAN   ccdTASK_STACK_XXL
00126 #define ccdTASK_STACK_PROC   ccdTASK_STACK_ACT
00127 #define ccdTASK_STACK_TELE   ccdTASK_STACK_SML
00128 #define ccdTASK_STACK_TEMP   ccdTASK_STACK_SML
00129 
00130 #define ccdMOD_NAME_CON      "ccdcon"
00131 #define ccdMOD_NAME_IT       "ccdit"
00132 #define ccdMOD_NAME_IP       "ccdip"
00133 #define ccdMOD_NAME_RDT      "ccdrdt"
00134 #define ccdMOD_NAME_SHT      "ccdsht"
00135 #define ccdMOD_NAME_TEL      "ccdtel"
00136 #define ccdMOD_NAME_TMP      "ccdtmp"
00137 #define ccdMOD_NAME_AUX      "ccdaux"
00138 
00139 typedef enum
00140     {
00141     ccdMOD_INDEX_CON = 0,
00142     ccdMOD_INDEX_IT,
00143     ccdMOD_INDEX_IP,
00144     ccdMOD_INDEX_RDT,
00145     ccdMOD_INDEX_SHT,
00146     ccdMOD_INDEX_TEL,
00147     ccdMOD_INDEX_TMP,
00148     ccdMOD_INDEX_AUX,
00149     ccdMAXSUBSYS
00150     }
00151 ccdMOD_INDEX;
00152 
00153 extern vltBYTES32 ccdDoFitsConfLog;
00154 extern vltINT32   ccdDebugLevel;
00155 extern int        ccdCmdInitTimeout;
00156 
00157 #define ccdFUNC_MAIN_FMT     "_%sMainTask"
00158 #define ccdFUNC_NAME_SRV_FMT "_%sStartServer"
00159 
00160 #define ccdTASK_NAME_SRV_FMT "%s_%s"                /* "%sSrv_%s" */
00161 /* AL960712 moved to ccdInternal.h in ws part: needed by ccditWs for dxf JUN96 
00162 #define ccdTASK_NAME_ACT_FMT "%sAct_%s"
00163 */
00164 #define ccdTASK_NAME_TIM_FMT "ccdTim_%s"
00165 #define ccdTASK_NAME_WIP_FMT "%sWip_%s"
00166 #define ccdTASK_NAME_MON_FMT "%sMon_%s"
00167 
00168 #define ccdCITASK_REGISTER(brkHdlr,kilHdlr,priority) \
00169   {                                           \
00170   char        vxProcName[7];                  \
00171   ccsPROCNAME ccsProcName;                    \
00172                                               \
00173   taskPrioritySet(taskIdSelf(),priority);     \
00174   /*                                          \
00175    * get first 7 chars of vx procname and     \
00176    * mangle with taskId to get unique         \
00177    * ccs proc name                            \
00178    */                                         \
00179   strncpy(vxProcName,taskName(taskIdSelf()),7);                        \
00180   vxProcName[7] = 0;                                                   \
00181   sprintf(ccsProcName,"%s%x",vxProcName,taskIdSelf());                 \
00182   if (ccsInit(ccsProcName,0,brkHdlr,kilHdlr,error) != SUCCESS)         \
00183     { errAdd(error,ccdMODULE,ccdERR_LCC_CALL,__FILE__,"%s","ccsInit"); \
00184       return FAILURE; }                                                \
00185   }
00186 
00187 /* timeouts */
00188 #define ccdSTARTUP_TIMEOUT   6000   /* 60 seconds for sub_system startup  */
00189 #define ccdSYNC_TIMEOUT       500   /*  5 seconds for task synchonization */
00190 
00191 /* conversions */
00192 #define ccdUS_TO_TICKS(m)    ((m) / 10000)
00193 #define ccdMS_TO_TICKS(m)    ((m) / 10)
00194 #define ccdTICKS_TO_MS(t)    ((t) * 10)
00195   
00196 /* environment variables */
00197 #define ccdENV_CPU        "CPU"
00198 #define ccdENV_CCDNAME    "CCDNAME"
00199 #define ccdENV_LOCALENV   "LOCALENV"
00200 #define ccdENV_INSROOT    "INS_ROOT"
00201 #define ccdENV_INSHOST    "INS_HOST"
00202 #define ccdENV_INSUSER    "INS_USER"
00203 
00204 /* host directory paths */
00205 #define ccdDIR_CONFIG_FMT  "%s/%s/COMMON/CONFIGFILES"  /* $INS_ROOT/$INS_USER */
00206 #define ccdDIR_BINARY_FMT  "vw/bin/%s/%s"
00207 
00208 /* macros for STATUS command handling */
00209 #define ccdSTATUS_FMT      "opMode %d,opState %d,status %d"
00210 
00211 /* macros for DBCFG file handling */
00212 #define ccdDBCFG_FMT       "%s.dbcfg"
00213 #define ccdDBCFG_CWP_FMT   "%s=@%s<alias>%s"
00214 #define ccdDBCFG_DCS_FIXED "ccdDcsFixed"
00215 #define ccdDBCFG_CWP       "<CWP>: "
00216 
00217 /* macro for LCC timer overhead correction [us] */ 
00218 #define ccdTIMER_SLEEP_OVERHEAD  200
00219 
00220 /* macro defining the limit of expTime [us] */ 
00221 #define ccdONE_SECOND_EXPTIME   1000000
00222 
00223 /*
00224  * base file names for IP auxilliary images
00225  * -> read from <images.imageDirectory>/<ccdFRAME_BASEtype>_<ccdName>.fits
00226  *    eg "bias_ccdTEC.fits"
00227  */ 
00228 #define ccdFRAME_BASEBIAS   "bias"
00229 #define ccdFRAME_BASEDARK   "dark"
00230 #define ccdFRAME_BASEFLAT   "flat"
00231 
00232 #define ccdFRAME_FITSFMT    "%s/%s_%s.fits"
00233 
00234 /* Julian Day constants */
00235 #define ccdJDToSec(jd)       ((vltDOUBLE)(jd) * 86400.0)
00236 #define ccdSecToJD(s)        ((vltDOUBLE)(s)  / 86400.0)
00237 
00238 #define ccdUTCtoSec(utc) \
00239     (vltDOUBLE)((double)((utc)->tv_sec) + (double)((utc)->tv_usec) / 1e6)
00240 #define ccdUTCtoUSec(utc) \
00241     (vltINT32)(1000000 * (utc)->tv_sec + (utc)->tv_usec)
00242 #define ccdSecToUTC(sec,utc) \
00243     (utc)->tv_sec = (int)(sec); \
00244     (utc)->tv_usec = (int)(((sec) - (utc)->tv_sec) * 1e6)
00245 #define ccdAddSecToUTC(sec,utc) \
00246     { int s,us; s = (int)(sec); us = ((sec) - s) * 1000000; \
00247       (utc)->tv_sec += s; (utc)->tv_usec += us;     \
00248       while ((utc)->tv_usec >= 1000000)              \
00249         { (utc)->tv_usec -= 1000000; (utc)->tv_sec++; }}
00250 #define ccdSubSecFromUTC(sec,utc) \
00251     { int s,us; s = (int)(sec); us = ((sec) - s) * 1000000; \
00252       (utc)->tv_sec -= s; (utc)->tv_usec -= us;     \
00253       while ((utc)->tv_usec < 0)                    \
00254         { (utc)->tv_usec += 1000000; (utc)->tv_sec--; }}
00255 
00256 
00257 /* macros for Telemetry sensors */
00258 #define ccdTEL_CLOCK_FMT        "CLOCK_%d_%c"
00259 #define ccdTEL_CLOCK_LOW        'L'
00260 #define ccdTEL_CLOCK_HIGH       'H'
00261 
00262 #define ccdTEL_BIAS_FMT         "BIAS_%d"
00263 
00264 /* macros for Temperature sensors */
00265 #define ccdTMP_CHIP_FMT         "CHIP_%d"
00266 #define ccdTMP_HOUSE_FMT        "HOUSE_%d"
00267 
00268 /* exposure events */
00269 #define ccdEVT_EXPIRED     1
00270 #define ccdEVT_ENDED       2
00271 #define ccdEVT_ABORTED     4
00272 #define ccdEVT_PAUSED      8
00273 #define ccdEVT_CONTINUED  16
00274 #define ccdEVT_ERROR      32
00275 #define ccdEVT_STOP      256
00276 
00277 /* database symbolic access */
00278 #define ccdDB_RETRY_COUNT    1    /* retry count for failed db access  */
00279 #define ccdDB_RETRY_DELAY    0    /* retry delay for failed db access  */
00280 
00281 /* database attributes index for direct access CCD */
00282 #define ccdDB_OPSTATE        0
00283 #define ccdDB_FAILURE        1
00284 #define ccdDB_INITDONE       2
00285 #define ccdDB_IMG_LST        3
00286 #define ccdDB_IMG_DIR        4
00287 
00288 /* command wait mode */
00289 #define ccdCMD_WAIT_NONE     1    /* Do not wait for reply              */
00290 #define ccdCMD_WAIT_ONCE     2    /* Wait for first reply               */
00291 #define ccdCMD_WAIT_LAST     3    /* Wait for last reply                */
00292 
00293 /* CCD types : Scientific / Technical */
00294 typedef enum
00295     {
00296     ccdCCD_SCI = 0,
00297     ccdCCD_TEC
00298     } ccdCCD_TYPE;
00299 
00300 /* fast Intertask communication Service routines */
00301 typedef struct
00302     {
00303     vltINT32 id;                /* FIS Id = structure address */
00304     vltINT32 timeout;           /* semaphore timeout in ticks */
00305     vltINT32 cmd;               /* command                    */
00306     SEM_ID   cmdSem;            /* command semaphore          */
00307     vltINT32 reply;             /* reply                      */
00308     SEM_ID   replySem;          /* reply semaphore            */
00309     } ccdFIS;
00310   
00311 /* camera HW description */
00312 typedef struct
00313     {
00314     ccdCCD_TYPE     type;        /* CCD system type [ccdCCD_TEC/SCI]       */
00315     vltBYTES32      link;        /* HW device name                         */
00316     vltINT32        tout;        /* HW device timeout [ms]                 */
00317     vltBYTES32      prog;        /* HW program name (embedded SW)          */
00318     } ccdHWDESC;
00319 
00320 /* sub-system description */
00321 typedef struct
00322     {
00323     vltINT32        avail;       /* Sub-system availability flag           */
00324     ccsPROCNAME     server;      /* Sub-system Server process name         */
00325     char           *desc;        /* Sub-system descriptor                  */
00326     } ccdSUBSYS;
00327 
00328 /* Telemetry statistics */
00329 typedef struct
00330     {
00331     vltINT32  numSrc;
00332     vltINT32  period;
00333     vltDOUBLE start[ccdMAXTELSRC];
00334     vltDOUBLE stop[ccdMAXTELSRC];
00335     vltINT32  numVal;
00336     vltDOUBLE valSum[ccdMAXTELSRC];
00337     vltDOUBLE valSum2[ccdMAXTELSRC];
00338     } ccdTELESTAT;
00339 
00340 /* Temperature statistics */
00341 typedef struct
00342     {
00343     vltINT32  numSns;
00344     vltINT32  period;
00345     vltDOUBLE start[ccdMAXTMPSRC];
00346     vltDOUBLE stop[ccdMAXTMPSRC];
00347     vltINT32  numVal;
00348     vltDOUBLE valSum[ccdMAXTMPSRC];
00349     vltDOUBLE valSum2[ccdMAXTMPSRC];
00350     } ccdTEMPSTAT;
00351 
00352 /* structure, containing various times         */ 
00353 /* All times are UTC, durations are in seconds */
00354 #define ccdProtectTimes(desc)   semTake(desc->times.updateSem,2)
00355 #define ccdUnProtectTimes(desc) semGive(desc->times.updateSem)
00356 typedef struct
00357     {
00358     SEM_ID     updateSem;         /* critical section protection semaphore  */
00359     ccdEXPTYPE expType;           /* exposure type                          */
00360     ccsTIMEVAL wipeStart;         /* wipe start time                        */
00361     vltDOUBLE  wipeTime;          /* wipe time                              */
00362     ccsTIMEVAL wipeEnd;           /* wipe end time                          */
00363     ccsTIMEVAL shiftStart[ccdMAXINTEGR]; /* shift start time                */
00364     vltDOUBLE  shiftTime;         /* shift time                             */
00365     ccsTIMEVAL darkStart;         /* start of dark current integration time */
00366     vltDOUBLE  darkTime;          /* total dark time during integration     */
00367     ccsTIMEVAL cycleStart;        /* start of cycle integration time        */
00368     vltDOUBLE  cycleEla;          /* elapsed cycle integration time         */
00369     ccsTIMEVAL cycleEnd;          /* cycle end time                         */
00370     vltINT32   stepNum;           /* step num for Multiple exposure         */
00371     vltDOUBLE  stepDef;           /* defined step integration time          */
00372     vltDOUBLE  stepDefMulti[ccdMAXINTEGR];
00373     vltDOUBLE  stepEla;           /* elapsed step integration time          */
00374     vltDOUBLE  stepElaMulti[ccdMAXINTEGR];
00375     vltDOUBLE  stepRem;           /* remaining step integration time        */
00376     ccsTIMEVAL readStart;         /* readout  start time                    */
00377     vltDOUBLE  readDuration;      /* readout  duration                      */
00378     ccsTIMEVAL procStart;         /* process  start time                    */
00379     vltDOUBLE  procDuration;      /* process  duration                      */
00380     ccsTIMEVAL tranStart;         /* transfer start time                    */
00381     vltDOUBLE  tranDuration;      /* transfer duration                      */
00382     ccsTIMEVAL shutOpenStart;     /* shutter  open  start time              */
00383     vltDOUBLE  shutOpenDuration;  /* shutter  open  duration                */
00384     ccsTIMEVAL shutCloseStart;    /* shutter  close strat time              */
00385     vltDOUBLE  shutCloseDuration; /* shutter  close duration                */
00386     } ccdTIMES;
00387     
00388 typedef struct
00389     {
00390     vltINT32        id;           /* Timer Request Id = address  */
00391     vltLOGICAL      upd;          /* Timer is being Updated      */
00392     vltLOGICAL      del;          /* Timer shall be Cancelled    */
00393     ccsTIMEVAL      utc;          /* UTC when timer is Due       */
00394     ccsTIMEVAL      per;          /* Interval for periodic timer */
00395     vltINT32        cnt;          /* Repetition count            */
00396     vltUINT8        num;          /* Associated timer number 1-4 */
00397     timerTIMER_MODE tmm;          /* Timer mode                  */
00398     SEM_ID          sem;          /* Associated semaphore        */
00399     vltINT32        rid;          /* Timer Request Id            */
00400     } ccdTIMRQST;
00401 
00402 /* Timer handling */
00403 typedef struct
00404     {
00405     timsMODE        timsMode;     /* TIM operation mode                  */
00406     timerSTATE      tmrState[5];  /* State of timers                     */
00407     ccdTIMRQST      tmrQLst[32];  /* List of timer requests              */
00408     SEM_ID          semTask;      /* Activation of Timer Task            */
00409     SEM_ID          semSync;      /* Request Synchronization             */
00410     SEM_ID          semProt;      /* Protection of Critical Zone         */
00411     int             tmrTid;       /* Timer Task Id                       */
00412     int             tmrTcb;       /* Timer Task TCB                      */
00413     int             tmrStart;     /* ReqId of timer for START at utc,per */
00414     int             tmrExpose;    /* ReqId of timer for Exposure Time    */
00415     int             tmrPause;     /* ReqId of timer for PAUSE at utc     */
00416     int             tmrCont;      /* ReqId of timer for CONT  at utc     */
00417     int             tmrOpen;      /* ReqId of timer for OPEN  at utc,exp */
00418     int             tmrClose;     /* ReqId of timer for CLOSE at utc     */
00419     ccsTIMEVAL      timExpose;    /* exposure time                       */
00420     ccsTIMEVAL      utcStart;     /* UTC for START                       */
00421     ccsTIMEVAL      utcPause;     /* UTC for PAUSE                       */
00422     ccsTIMEVAL      utcCont;      /* UTC for CONT                        */
00423     } ccdTIMDESC;
00424 
00425 /* camera descriptor */
00426 typedef struct
00427     {
00428     vltBYTES20   camera;       /* camera name                            */
00429     vltBYTES8    logMask;      /* FITS log mask                          */
00430     dbSYMADDRESS dbRoot;       /* camera's database root point           */
00431     ccdOPMODE    opMode;       /* camera operational mode                */
00432     ccdSTATE     opState;      /* camera operational state               */
00433     vltLOGICAL   initDone;     /* camera initialization status           */
00434     ccdCONFIG   *config;       /* CCD configuration data structure       */
00435     vltINT32     timeout;      /* CCD system timeout [ms]                */
00436     vltLOGICAL   wipeOn;       /* Wipe is active                         */
00437     vltLOGICAL   teleOn;       /* Telemetry   Monitoring is active       */
00438     vltLOGICAL   tempOn;       /* Temperature Monitoring is active       */
00439     ccdHWDESC    hwDesc;       /* CCD HW Description                     */
00440     char        *ccdAttr;      /* table of DB attr direct addresses      */
00441     ccdSUBSYS    subSys[ccdMAXSUBSYS];   /* Sub-system descriptions      */
00442     ccdTIMES     times;                  /* CCD exposure related times   */
00443     ccdTIMDESC   timDesc;                /* Timer handling               */
00444     ccdTELESTAT  teleStat;               /* Telemetry   statistics       */
00445     ccdTEMPSTAT  tempStat;               /* Temperature statistics       */
00446     ccdSETUP     setup[ccdMAXEXP+1];     /* CCD exposure related setup   */
00447     ccdSETUPRES  setupResult;            /* Setup result (Readout Time)  */
00448     vltBYTES32   fileNameSimu; /* Simulated image for LCU_SIM RDT        */
00449     vltINT32     imageIdSimu;  /* Associated image Id when loaded        */
00450     } ccdDESCRIPTION;
00451 
00452 /* image acquisition type */
00453 typedef enum
00454     {
00455     ccdFRM_ACQ_NORM = 0,                      /* Detector raw image          */
00456     ccdFRM_ACQ_FILE,                          /* Image read from WS file     */
00457     ccdFRM_ACQ_SIMU                           /* Simulated image (LCU/ACE)   */
00458     } ccdFRM_ACQ_TYPE;
00459 
00460 /* image storage type */
00461 typedef enum
00462     {
00463     ccdFRM_STO_NORM = ccdFRM_NORMAL,          /* Detector raw image          */
00464     ccdFRM_STO_BIAS = ccdFRM_BIAS,            /* Bias image                  */
00465     ccdFRM_STO_DARK = ccdFRM_DARK,            /* Dark image                  */
00466     ccdFRM_STO_FLAT = ccdFRM_FLAT,            /* FlatField image             */
00467     ccdFRM_STO_TEMP,                          /* Temporary image (IP result) */
00468     ccdFRM_STO_SIMU,                          /* Simulation image (LCU Sim)  */
00469     ccdMAXFRMSTOTYPE
00470     } ccdFRM_STO_TYPE;
00471 
00472 /* image list (map of DB attribute images.frame) */
00473 typedef struct
00474     {
00475     vltINT32   imageId;
00476     vltINT32   startAddr;
00477     vltINT32   allocSize;
00478     vltINT32   xSize,ySize;
00479     vltINT32   expId;
00480     vltINT32   acqType;          /* see ccdFRM_ACQ_TYPE */
00481     vltINT32   stoType;          /* see ccdFRM_STO_TYPE */
00482     vltINT32   dtaType;          /* see ccdIMAGE_REP    */
00483     } ccdIMAGELIST;
00484 
00485 /* image quality for FIS */
00486 #define ccdEVT_IMAGE_OK   0x01
00487 #define ccdEVT_IMAGE_ERR  0x02
00488 #define ccdEVT_IMAGE_LAST 0x04
00489 
00490 /* image buffer */
00491 typedef struct ccdImageBuffer
00492     {
00493     /* Internal section */
00494     vltINT32 id;                      /* identification label                */
00495     vltINT32 winNum;                  /* associated window number            */
00496     vltINT32 listIndex;               /* index in image list                 */
00497     vltINT32 imageSize;               /* image size in bytes (data area size)*/
00498     vltINT32 lineSize;                /* size of one image line in bytes     */
00499     vltINT32 bytesAvail;              /* data bytes available in buffer      */
00500     ccdFIS   ipcProc;                 /* process  FIS structure              */
00501     ccdFIS   ipcTran;                 /* transfer FIS structure              */
00502     char    *fillUp;                  /* ptr for filling buffer upwards      */
00503     char    *fillDown;                /* ptr for filling buffer downwards    */
00504     
00505     /* FITS parameter section */
00506     ccdFITSBASIC    fbHeader;         /* FITS basic header                   */
00507     ccdFITSHIERARCH feHeader;         /* FITS extended header                */
00508     /* TBD */                         /* FITS trailer                        */
00509     
00510     /* Image data section */
00511     vltUINT8       *data;             /* first data byte                     */
00512               /* (buffer dynamically allocated)      */
00513     struct ccdImageBuffer *next;
00514     } ccdIMAGEBUFFER;
00515 
00516 /* NFS FITS IMAGE descriptor */
00517 typedef struct
00518     {
00519     vltBYTES256     file;             /* file name (absolute)                */
00520     int             df;               /* file descriptor                     */
00521     ccdIMAGEBUFFER *image;            /* Image description including FITS    */
00522     ccdIMAGELIST   *entry;            /* Entry in DB image list              */
00523     } ccdNFSFITSIMAGE;
00524 
00525 /*
00526  ****************************************************************************
00527  * Function Prototypes
00528  ****************************************************************************
00529  */ 
00530 /* CCD version function */
00531 void          ccdVersion          ( void );
00532 void          ccdCompiledDate     ( const char *date, const char *time, 
00533             char *comp );
00534 void          ccdModuleVersion    ( const char *rev, const char *mod,
00535             const char *txt, const char *cmp,
00536             char *version );
00537 void          ccdModuleVersionDCL ( const char *prefix );
00538 
00539 /* CCD startup function */
00540 ccsCOMPL_STAT ccdconStartupCamera ( char *parStr );
00541 
00542 /* CCD tool functions */
00543 STATUS        ccdKill           ( char *taskNamePart );
00544 void          ccdShowSetup      ( ccdSETUP *setup );
00545 void          ccdPrintConfig    ( const char *camera , const ccdCONFIG *config );
00546 
00547 /* ACE tool functions */
00548 ccsCOMPL_STAT ccdSwitchAce      ( char mode );
00549 ccsCOMPL_STAT ccdTestAce        ( void );
00550 ccsCOMPL_STAT ccdCheckAceDriver ( char *channel, ccsERROR *error );
00551 ccsCOMPL_STAT ccdCheckLcuAceCom ( char *channel, ccsERROR *error );
00552 
00553 /* CCD internal functions */
00554 ccsCOMPL_STAT ccdCheckId        ( vltINT32 id );
00555 ccsCOMPL_STAT ccdSetOpState     ( ccdDESCRIPTION *ccdDesc, vltINT32 opState,
00556                                   ccsERROR *error );
00557 
00558 /* CCD installation/startup functions */
00559 ccsCOMPL_STAT ccdInstall        ( char *parStr, ccdDESCRIPTION **pccdDesc,
00560           ccsERROR *error);
00561 ccsCOMPL_STAT ccdDeinstall      ( ccdDESCRIPTION *ccdDesc, ccsERROR *error);
00562 
00563 ccsCOMPL_STAT ccdStartSystem    ( ccdDESCRIPTION *ccdDesc, char *module,
00564                                   ccsERROR *error );
00565 ccsCOMPL_STAT ccdStartServer    ( ccdDESCRIPTION *ccdDesc, int module,
00566                                   vltINT32 priority, ccsERROR *error );
00567 void          ccdParseRunString ( char *runStr, char *ccdName, 
00568           char *insHost, char *insRoot, char *insUser ); 
00569 ccsCOMPL_STAT ccdShutdown       ( ccdDESCRIPTION *ccdDesc, char *module,
00570                                   ccsERROR *error );
00571 
00572 /* DB Symbolic access functions */
00573 ccsCOMPL_STAT ccdReadAttr       ( char *ccdName, const dbSYMADDRESS attrName, 
00574           void *buffer, ccsERROR *error );
00575 ccsCOMPL_STAT ccdWriteAttr      ( char *ccdName, const dbSYMADDRESS attrName, 
00576                                   void *buffer, ccsERROR *error );
00577 ccsCOMPL_STAT ccdInitDb         ( vltBYTES20 camera, vltBYTES20 lcu,
00578                                   ccsERROR *error );
00579 
00580 /* MEM allocation functions */
00581 ccsCOMPL_STAT ccdCreaImBuf      ( ccdDESCRIPTION *ccdDesc, ccdSETUP *setup,  
00582           vltINT32 expId, vltINT32 dataType,
00583           vltINT32 storageType, vltINT32 *imageId, 
00584           ccsERROR *error);
00585 ccsCOMPL_STAT ccdDumpImBuf      ( ccdDESCRIPTION  *ccdDesc, vltINT32 imageId,
00586           char *fileName, ccsERROR *error );
00587 ccsCOMPL_STAT ccdFindImBuf      ( ccdDESCRIPTION  *ccdDesc, vltINT32 expId, 
00588           vltINT32 dataType, vltINT32 storageType, 
00589           vltINT32 *imageId, ccsERROR *error );
00590 ccsCOMPL_STAT ccdFreeImBuf      ( ccdDESCRIPTION *ccdDesc, vltINT32 imageId, 
00591           vltLOGICAL force, ccsERROR *error );
00592 ccsCOMPL_STAT ccdListImBuf      ( ccdDESCRIPTION  *ccdDesc, vltINT32 dataType, 
00593           vltINT32 storageType, ccdIMAGELIST **imgList,
00594           ccsERROR *error );
00595 ccsCOMPL_STAT ccdLoadImBuf      ( ccdDESCRIPTION  *ccdDesc, char *fileName, 
00596           vltINT32 storageType, vltINT32 *imageId, 
00597           ccsERROR *error );
00598 
00599 /* NFS FITS functions */
00600 ccsCOMPL_STAT ccdOpenFits        ( ccdNFSFITSIMAGE *desc, ccsERROR *error );
00601 ccsCOMPL_STAT ccdCreaFits        ( ccdNFSFITSIMAGE *desc, ccsERROR *error );
00602 
00603 ccsCOMPL_STAT ccdReadFitsHeader  ( ccdNFSFITSIMAGE *desc, ccsERROR *error );
00604 ccsCOMPL_STAT ccdReadFitsData    ( ccdNFSFITSIMAGE *desc, ccsERROR *error );
00605 ccsCOMPL_STAT ccdReadFitsTrailer ( ccdNFSFITSIMAGE *desc, ccsERROR *error );
00606 
00607 ccsCOMPL_STAT ccdWriteFitsHeader ( ccdNFSFITSIMAGE *desc, ccsERROR *error );
00608 ccsCOMPL_STAT ccdWriteFitsData   ( ccdNFSFITSIMAGE *desc, ccsERROR *error );
00609 ccsCOMPL_STAT ccdWriteFitsTrailer( ccdNFSFITSIMAGE *desc, ccsERROR *error );
00610 
00611 ccsCOMPL_STAT ccdWriteFitsDataBlock ( ccdNFSFITSIMAGE *desc, void *pData, 
00612               int len, ccsERROR *error );
00613 
00614 ccsCOMPL_STAT ccdCloseFits       ( ccdNFSFITSIMAGE *desc, ccsERROR *error );
00615 
00616 /* ERR handling functions */
00617 ccsCOMPL_STAT ccdSetFailure     ( ccdDESCRIPTION  *ccdDesc,  ccsERROR *error );
00618 ccsCOMPL_STAT ccdResetFailure   ( ccdDESCRIPTION  *ccdDesc,  ccsERROR *error );
00619 
00620 /* ENV handling functions */
00621 ccsCOMPL_STAT ccdEnvVarChk      ( char            *camera,   ccsERROR *error );
00622 ccsCOMPL_STAT ccdEnvVarDel      ( ccdDESCRIPTION  *ccdDesc,  ccsERROR *error );
00623 ccsCOMPL_STAT ccdEnvVarGet      ( ccdDESCRIPTION **pccdDesc, ccsERROR *error );
00624 ccsCOMPL_STAT ccdEnvVarSet      ( ccdDESCRIPTION  *ccdDesc,  ccsERROR *error );
00625 ccsCOMPL_STAT ccdGetDescriptor  ( const char      *camera, 
00626           ccdDESCRIPTION **pCcdDesc, ccsERROR *error );
00627 ccsCOMPL_STAT ccdCheckDescriptor( ccdDESCRIPTION  *ccdDesc,  ccsERROR *error );
00628 
00629 /* FIS handling functions */
00630 ccsCOMPL_STAT ccdCreaFis        ( ccdFIS *fis, vltINT32 timeout,
00631           ccsERROR *error );
00632 ccsCOMPL_STAT ccdCheckFisCmd    ( ccdFIS *fis, vltINT32 cmd,
00633           vltLOGICAL wait, vltLOGICAL *got, 
00634           ccsERROR *error );
00635 ccsCOMPL_STAT ccdFreeFis        ( ccdFIS *fis, ccsERROR *error);
00636 ccsCOMPL_STAT ccdResetFis       ( ccdFIS *fis, ccsERROR *error );
00637 ccsCOMPL_STAT ccdSendFisCmd     ( ccdFIS *fis, vltINT32 cmd,
00638           vltLOGICAL wait, ccsERROR *error );
00639 ccsCOMPL_STAT ccdSendFisReply   ( ccdFIS *fis, vltINT32 reply,
00640           ccsERROR *error );
00641 ccsCOMPL_STAT ccdSetFisTimeout  ( ccdFIS *fis, vltINT32 timeout,
00642           ccsERROR *error );
00643 ccsCOMPL_STAT ccdWaitFisReply   ( ccdFIS *fis, ccsERROR *error );
00644 
00645 /* TIM handling function */
00646 ccsCOMPL_STAT ccdStoreTime      ( char *attrTable, int attrIndex, 
00647           ccsTIMEVAL *startTime, vltDOUBLE *duration,
00648           ccsERROR *error );
00649 
00650 /* MSG handling functions */
00651 ccsCOMPL_STAT ccdSendCmdAck     ( msgMSG *msg, ccsERROR *error );
00652 ccsCOMPL_STAT ccdSendCmdAll     ( const msgCMD command, const char *params,
00653                                   ccdDESCRIPTION *ccdDesc, ccsERROR *error );
00654 ccsCOMPL_STAT ccdSendCmd        ( ccsPROCNAME dest, const msgCMD command,
00655                                   const char *params, char *reply, 
00656           ccdDESCRIPTION *ccdDesc, vltINT32 waitMode,
00657                                   ccsERROR *error );
00658 ccsCOMPL_STAT ccdWaitReply      ( ccsPROCNAME dest, vltINT32 timeout,
00659           char *reply, vltLOGICAL *lastReply, 
00660           vltLOGICAL *errReply, ccsERROR *error );
00661 
00662 /* Build next/prev exposure ID from the current exposure Index and ID */
00663 vltINT32 ccdGetNextExpId  ( vltINT32 expId , vltINT32 expIndex );
00664 vltINT32 ccdGetPrevExpId  ( vltINT32 expId , vltINT32 expIndex );
00665 
00666 /* TIMER handling functions */
00667 ccsCOMPL_STAT ccdTimerSleep     ( vltINT32 us, ccsERROR *error ); 
00668 ccsCOMPL_STAT ccdStartTimerTask ( ccdDESCRIPTION *ccdDesc, ccsERROR *error );
00669 ccsCOMPL_STAT ccdStopTimerTask  ( ccdDESCRIPTION *ccdDesc, ccsERROR *error );
00670 ccsCOMPL_STAT ccdTimerReqActive ( ccdDESCRIPTION *ccdDesc, 
00671           vltINT32 rid, ccsERROR *error );
00672 ccsCOMPL_STAT ccdTimerReqCreate ( ccdDESCRIPTION *ccdDesc, ccsTIMEVAL *utc, 
00673           ccsTIMEVAL *per, vltINT32 cnt, 
00674           vltINT32 *rid, ccsERROR *error );
00675 ccsCOMPL_STAT ccdTimerReqDelete ( ccdDESCRIPTION *ccdDesc, 
00676           vltINT32 rid, ccsERROR *error );
00677 ccsCOMPL_STAT ccdTimerReqUpdate ( ccdDESCRIPTION *ccdDesc, vltINT32 rid, 
00678           ccsTIMEVAL *utc, ccsTIMEVAL *per,
00679           vltINT32 cnt, ccsERROR *error );
00680 ccsCOMPL_STAT ccdWaitTimerDue   ( ccdDESCRIPTION *ccdDesc, vltINT32 rid,
00681           ccsERROR *error );
00682 ccsCOMPL_STAT ccdTimerReqRelease( ccdDESCRIPTION *ccdDesc, 
00683           vltINT32 rid, ccsERROR *error );
00684 void ccdPrintTimer ( ccdDESCRIPTION *ccdDesc );
00685 
00686 /* ISO8601 Time decoding function */
00687 ccsCOMPL_STAT ccdDecodeIsoTime  ( char *str, ccsTIMEVAL *utc, ccsERROR *err );
00688 
00689 void ccdDbAlign ( const char *type, vltLOGICAL pack, void *s, char *b );
00690 
00691 #define ccdDBPACK(t,s,b) ccdDbAlign(t,ccsTRUE, s,b)
00692 #define ccdUNPACK(t,b,s) ccdDbAlign(t,ccsFALSE,s,b)
00693 
00694 /*
00695  * Error handling macros
00696  */
00697 #ifndef __FILE_LINE__
00698 #define _ccd_tostr(a) #a
00699 #define _ccd_tostr_pass2(a) _ccd_tostr(a)
00700 
00701 #define __FILE_LINE__  __FILE__ ":" _ccd_tostr_pass2(__LINE__)
00702 #endif
00703 
00704 #define ccdERR_ADD(errNum,params...) \
00705     errAdd(error,ccdMODULE,errNum,__FILE_LINE__,"",##params)       
00706 #define ccdERR_RETURN(errNum,params...) \
00707     { \
00708     errAdd(error,ccdMODULE,errNum,__FILE_LINE__,"",##params); \
00709     return FAILURE; \
00710     }                                                             
00711 
00712 #ifdef __cplusplus
00713 }
00714 #endif
00715 
00716 #endif  /* ! CCD_LCU_INTERNAL_H */
00717 
00718 /************************************************************************/
00719 
00720 /*___o0o___*/

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