00001 /*************************************************************************
00002 * E.S.O. - VLT project
00003 *
00004 * "@(#) $Id: ccdInternal.h,v 4.1 2003/10/30 15:32:47 vltsccm Exp $"
00005 *
00006 * who when what
00007 * -------- -------- ----------------------------------------------
00008 * alongino 31/08/94 created
00009 * alongino 22/05/95 new definitions added
00010 * ccumani 10/07/95 updated after reordering of DB
00011 * ccdMPPMODE and ccdREAD_CLOCK added
00012 * ccumani 17/07/95 ccdREAD_WIN1_FIR_X definition added
00013 * ccdREAD_WIN1_LST_X definition added
00014 * ccdREAD_WIN2_FIR_X definition added
00015 * ccdREAD_WIN2_LST_X definition added
00016 * ccdREAD_WIN1_FIR_Y definition added
00017 * ccdREAD_WIN1_LST_Y definition added
00018 * ccdREAD_WIN2_FIR_Y definition added
00019 * ccdREAD_WIN2_LST_Y definition added
00020 * ccumani 19/07/95 ccdREAD_WIN1_LST_X -> ccdREAD_WIN1_DIM_X
00021 * ccdREAD_WIN2_LST_X -> ccdREAD_WIN2_DIM_X
00022 * ccdREAD_WIN1_LST_Y -> ccdREAD_WIN1_DIM_Y
00023 * ccdREAD_WIN2_LST_Y -> ccdREAD_WIN2_DIM_Y
00024 * alongino 24/07/95 definitions used by external modules moved to ccd.h
00025 * commands common to WS moved to ccd.h
00026 * alongino 04/08/95 added expId to FITSBASIC
00027 * alongino 10/08/95 deleted ccdVERSION (replaced by cmm $Revision: 4.1 $)
00028 * alongino 17/08/95 ccdCAMERANAME and ccdCAMERANAME_LEN moved to ccd.h
00029 * alongino 18/08/95 SET parameters moved to ccd.h
00030 * alongino 24/08/95 added prototypes for ccdconNumPixels and
00031 * ccdconGetImageDim
00032 * literal for commands modified (prefix CMD_ added)
00033 * alongino 04/09/95 ccdconGetIndexFromId changed to ccdGetIndexFromId
00034 * alongino 04/09/95 ccdGetIndexFromId moved to ccd.h
00035 * ccdconNumPixels changed to ccdNumPixels
00036 * alongino 12/09/95 ccdMODULE renamed ccdMOD_WS (conflicts with ccdsht.h)
00037 * alongino 29/09/95 added ccdDatabase.h (taken out from ccd.h)
00038 * ccumani 09/10/95 ccdPID_ILLEGAL added
00039 * alongino 17/10/95 added ccdLAST_IMAGE_ID
00040 * pduhoux 16/11/95 added ccdSENSOR & ccdPARAMETER data structures
00041 * alongino 30/01/96 added definitions for command parameters
00042 * alongino 02/02/96 ccdMOD_WS removed (errors have been unified)
00043 * alongino 05/02/96 In ccdFITSBASIC display replaced with frameId
00044 * pduhoux 04/03/96 added fct prototype ccdGetImageXYDim
00045 * pduhoux 07/03/96 modified fct prototype ccdGetImageXYDim ccdGetImageDim
00046 * -> removed 'const'
00047 * alongino 12/07/96 ccdconTASK_NAME_ACT_FMT moved from ccdLcuInternal.h
00048 * ccditMODULE moved from ccdit/lcu/ccdit.h
00049 * alongino 24/07/96 ccdrdtSTATE moved from ccdrdt module
00050 * pduhoux 06/08/96 ccdconTASK_NAME_ACT_FMT renamed to ccdTASK_NAME_ACT_FMT
00051 * pduhoux 21/01/97 added prototypes for ccdPack/UnpackFitsHeader/Trailer
00052 * pduhoux 12/03/97 added Window Enabled Flag <on> in ccdFITSWIND
00053 * alongino 01/04/97 slx.h removed: not used on LCU
00054 * pduhoux 29/04/97 added <gainIdx>/<gainFct> replacing <gain> in ccdFITSOUTP
00055 * pduhoux 06/05/97 moved ccdPROG_TEC/SCI from ccdLcuInternal.h
00056 * alongino 22/05/97 added ccdCMD_DEBUG and ccdDEBUG_XXX defines
00057 * alongino 05/02/02 added CCD_SWAP_INT* macros
00058 */
00059
00060 /*************************************************************************
00061 * This file contains all definitions used by WS AND LCU CCD sw modules.
00062 *************************************************************************/
00063
00064 #ifndef CCDINTERNAL_H
00065 #define CCDINTERNAL_H
00066
00067 #ifdef __cplusplus
00068 extern "C" {
00069 #endif
00070
00071 /*
00072 * VLT header files
00073 */
00074 #include "dxf.h"
00075 #include "slx.h"
00076
00077 /*
00078 * CCD main header file
00079 */
00080 #include "ccd.h"
00081
00082 /*
00083 * CCD database header file
00084 */
00085 #include "ccdDatabase.h"
00086
00087 /*
00088 * CCD version header file
00089 */
00090 #include "ccdintDefines.h"
00091
00092 /*
00093 * CCDLIB Version
00094 */
00095 #define ccdlibVERSION "$Revision: 4.1 $"
00096
00097 /*
00098 * Constants
00099 */
00100 #define IN
00101 #define OUT
00102 #define INOUT
00103
00104 #define ILLEGAL 0 /* illegal value for most type enum */
00105 #define NO_ERROR 0
00106 #define FD_INVALID -1 /* invalid file descriptor number */
00107 #define ccdPID_ILLEGAL 0 /* invalid process id */
00108
00109 #define ccdCAMERANAME_LEN 8 /* maximum lenght of camera name */
00110 #define ccdMAXFILELEN 64 /* maximum lenght of image file name */
00111 #define ccdMAXPATHLEN 256 /* maximum lenght of full path name */
00112 #define ccdLAST_IMAGE_ID -1 /* Id of last image read */
00113
00114 #define ccdTASK_NAME_ACT_FMT "%sAct_%s" /* format for LCU action task name*/
00115 #define ccditMODULE "ccdit" /* name of ccdit module */
00116
00117 /* ID for logging system */
00118 #define ccdLOG_ID 130
00119
00120 #if defined(i386) || defined(__i386)
00121 #define CCD_SWAP_INT16(v) v = CCS_SWAP_INT16(v)
00122 #define CCD_SWAP_INT32(v) v = CCS_SWAP_INT32(v)
00123 #define CCD_SWAP_FLOAT(v) {vltINT32 *i1; i1=(vltINT32 *)&(v); *i1 = CCS_SWAP_INT32(*i1);}
00124 #define CCD_SWAP_DOUBLE(v) {vltINT32 *i1,*i2; i1=(vltINT32 *)&(v); i2=i1+1;CCS_SWAP_2INT32(i1,i2);}
00125 #else
00126 #define CCD_SWAP_INT16(v)
00127 #define CCD_SWAP_INT32(v)
00128 #define CCD_SWAP_FLOAT(v)
00129 #define CCD_SWAP_DOUBLE(v)
00130 #endif
00131
00132 /* log IDs */
00133 enum ccdLogId {
00134 ccdLOG_START = logAUTO_RANGE + 1,
00135 ccdLOG_OPMODE,
00136 ccdLOG_SIGNAL,
00137 ccdLOG_SETUP_SAVE,
00138 ccdLOG_SETUP_RESTORE,
00139 ccdLOG_STOP_LOG_REPLY_ERROR,
00140 ccdLOG_END
00141 };
00142
00143 /*
00144 * image transfer completion status
00145 */
00146 typedef enum
00147 {
00148 ccditNONE = 1, /* no transfer completed yet */
00149 ccditSUCCESS, /* last transfer completed successfully */
00150 ccditFAILURE, /* last transfer stopped with error */
00151 ccditABORTED, /* last transfer aborted by command */
00152 } ccditCOMPSTATUS;
00153
00154 /*
00155 * state of readout sub-system
00156 */
00157 typedef enum
00158 {
00159 ccdrdtOFF = ccdOFF,
00160 ccdrdtLOADED = ccdLOADED,
00161 ccdrdtSTANDBY = ccdSTANDBY,
00162 ccdrdtONLINE_IDLE = ccdONLINE, /* on-line but nothing to do */
00163 ccdrdtONLINE_WIPE, /* chip wiping active */
00164 ccdrdtONLINE_READY, /* read-out ready */
00165 ccdrdtONLINE_READ /* read-out active */
00166 } ccdrdtSTATE;
00167
00168 /*
00169 * Test commands
00170 */
00171 #define ccdCMD_DEBUG "DEBUG"
00172 #define ccdPAR_DEBUG_LEVEL "level"
00173
00174 /* debug levels definitions (bitfield)
00175 * The following convention is used on ranges to be used:
00176 * general functionality (e.g. messages, database): 0x00000000-0x0000000f
00177 * ccdcon : 0x00000010-0x000000f0
00178 * ccdit : 0x00000100-0x00000f00
00179 * ccdrdt : 0x00001000-0x0000f000
00180 * ccdsht : 0x00010000-0x000f0000
00181 * ccdip : 0x00100000-0x00f00000
00182 * ccdtel : 0x01000000-0x0f000000
00183 * ccdtem : 0x10000000-0xf0000000
00184 */
00185 #define ccdDEBUG_NONE 0x00000000 /* no debug */
00186 #define ccdDEBUG_MSG 0x00000001 /* commands/replies WS <-> LCU */
00187 #define ccdDEBUG_FIS 0x00000002 /* FIS control */
00188 #define ccdDEBUG_ACE 0x00000004 /* ACE control */
00189 #define ccdDEBUG_TIM 0x00000008 /* TIM control */
00190
00191 #define ccdDEBUG_STARTUP 0x00000010 /* startup info */
00192 #define ccdDEBUG_SETUP 0x00000020 /* setup info */
00193 #define ccdDEBUG_COORD 0x00000040 /* exposure coordination info */
00194 #define ccdDEBUG_STATUS 0x00000080 /* exposure status info */
00195
00196 #define ccdDEBUG_IT_MSG 0x00000100 /* image receive MSG flow */
00197 #define ccdDEBUG_IT_FIS 0x00000200 /* image receive FIS sync */
00198 #define ccdDEBUG_IT_DXF 0x00000400 /* image receive DXF info */
00199 #define ccdDEBUG_IT_RECV 0x00000800 /* image receive info */
00200
00201 #define ccdDEBUG_RD_MSG 0x00001000 /* image readout MSG flow */
00202 #define ccdDEBUG_RD_FIS 0x00002000 /* image readout FIS sync */
00203 #define ccdDEBUG_RD_ACE 0x00004000 /* image readout ACE info */
00204 #define ccdDEBUG_RD_READ 0x00008000 /* image readout info */
00205
00206 #define ccdDEBUG_SH_MSG 0x00010000 /* shutter control MSG flow */
00207 #define ccdDEBUG_SH_FIS 0x00020000 /* shutter control FIS sync */
00208 #define ccdDEBUG_SH_ACE 0x00040000 /* shutter control ACE info */
00209 #define ccdDEBUG_SH_SHUT 0x00080000 /* shutter info */
00210
00211 #define ccdDEBUG_IP_MSG 0x00100000 /* image processing MSG flow */
00212 #define ccdDEBUG_IP_FIS 0x00200000 /* image processing FIS sync */
00213 #define ccdDEBUG_IP_PROC 0x00400000 /* image processing PROC info */
00214 #define ccdDEBUG_IP_USER 0x00800000 /* image processing USER func info */
00215
00216 #define ccdDEBUG_TL_MSG 0x01000000 /* telemetry control MSG flow */
00217 #define ccdDEBUG_TL_FIS 0x02000000 /* telemetry control FIS sync */
00218 #define ccdDEBUG_TL_ACE 0x04000000 /* telemetry control ACE info */
00219 #define ccdDEBUG_TL_TELE 0x08000000 /* telemetry info */
00220
00221 #define ccdDEBUG_TM_MSG 0x10000000 /* temperature control MSG flow */
00222 #define ccdDEBUG_TM_FIS 0x20000000 /* temperature control FIS sync */
00223 #define ccdDEBUG_TM_ACE 0x40000000 /* temperature control ACE info */
00224 #define ccdDEBUG_TM_TEMP 0x80000000 /* temperature info */
00225
00226 /*
00227 * commands to LCU
00228 */
00229 #define ccdCMD_BREAK "BREAK"
00230 #define ccdCMD_KILL "KILL"
00231 #define ccdCMD_SET "SET"
00232
00233 /* command parameters */
00234
00235 /*
00236 * New types definitions
00237 */
00238
00239 /* Chip ability for line shifting */
00240 typedef enum
00241 {
00242 ccdLINE_SHIFT_NONE = 0, /* CCD does not support lineShift */
00243 ccdLINE_SHIFT_UP, /* only Shift Up supported */
00244 ccdLINE_SHIFT_DOWN, /* only Shift Down supported */
00245 ccdLINE_SHIFT_BOTH /* both Shift Up & Down supported */
00246 } ccdLINESHIFT_MODE;
00247
00248 /*
00249 * Note: the file name, although not modified by the LCU sw, better "follows"
00250 * the exposure path as all other setup parameters. If it stops at WS level,
00251 * problems of merging information coming from the same exposure between
00252 * LCU and WS, specially when more exposures are running simultaneously.
00253 */
00254 typedef struct { /* FITS info for each window */
00255 vltLOGICAL on; /* Window enabled */
00256 vltINT16 strx; /* X window start */
00257 vltINT16 stry; /* Y window start */
00258 vltINT16 nx; /* X window size */
00259 vltINT16 ny; /* Y window size */
00260 vltINT8 binx; /* X binning factor */
00261 vltINT8 biny; /* Y binning factor */
00262 } ccdFITSWIND;
00263
00264 typedef struct { /* FITS file header basic information */
00265 /* This part is used to build the FITS header(s) */
00266 vltINT32 bitPix; /* bits per pixel */
00267 vltINT32 windowN; /* number of windows used */
00268 ccdFITSWIND winInfo[ccdMAXWINDOW]; /* info for each used window */
00269 vltBYTES8 dateObs; /* date when exposure started */
00270 vltDOUBLE bscale; /* real = file * BSCALE + BZERO */
00271 vltDOUBLE bzero; /* real = file * BSCALE + BZERO */
00272 ccsTIMEVAL utcObs; /* UTC time of exposure start */
00273 vltDOUBLE expTime; /* actual exposure time */
00274
00275 /* This part is used by the WS part */
00276 vltINT32 expId; /* ID of associated exposure */
00277
00278 /* This part is used by the WS part for FITS */
00279 char fileUnc[ccdMAXFILELEN];/* name of file for image uncompressed*/
00280 vltINT32 diskSaveMethod; /* disk save method */
00281 vltINT32 overWrite; /* file overwrite flag */
00282
00283 /* This part is used by the WS part for RTD */
00284 vltINT32 frameId; /* real-time display frame ID */
00285 } ccdFITSBASIC;
00286
00287 typedef struct { /* FITS info for each output used */
00288 vltINT32 index; /* index of output on chip */
00289 vltFLOAT elAdu; /* conversion factor e- to ADU */
00290 vltFLOAT gainFct; /* gain factor */
00291 vltINT32 gainIdx; /* gain index */
00292 } ccdFITSOUTP;
00293
00294 typedef struct { /* FITS info for each integration */
00295 vltDOUBLE uit; /* defined by the user */
00296 vltDOUBLE dit; /* elapsed */
00297 } ccdFITSINTE;
00298
00299 typedef struct { /* info for each temper. sensor used */
00300 vltINT32 index; /* index of sensor */
00301 vltFLOAT start; /* temp. value at start of exposure */
00302 vltFLOAT stop; /* temp. value at end of exposure */
00303 #ifdef ccdONLY_FOR_OPS_LOG
00304 vltFLOAT mean; /* temp. average during exposure */
00305 vltFLOAT drift; /* temp. variance during exposure */
00306 #endif
00307 } ccdFITSTEMP;
00308
00309 typedef struct { /* info for each telem. source used */
00310 vltINT32 index; /* index of source */
00311 vltFLOAT start; /* tel. value at start of exposure */
00312 vltFLOAT stop; /* tel. value at end of exposure */
00313 #ifdef ccdONLY_FOR_OPS_LOG
00314 vltFLOAT mean; /* tel. average during exposure */
00315 vltFLOAT drift; /* tel. variance during exposure */
00316 #endif
00317 } ccdFITSTELE;
00318
00319 typedef struct { /* FITS hierarchical information */
00320 vltINT32 readPixelN; /* Times same pixel has been read */
00321 vltBYTES16 readMode; /* readout mode used */
00322 vltBYTES16 readSpeed; /* readout speed used */
00323 vltBYTES16 readClock; /* clock pattern used for readout */
00324 vltINT32 readPixTime; /* readout time / pixel [us] */
00325 vltINT32 readShiftType; /* line shift type */
00326 vltINT32 readShift[ccdMAXINTEGR];/* number of lines shifted / intgr */
00327 vltINT32 expType; /* type of exposure */
00328 vltINT32 outputN; /* number of outputs used */
00329 ccdFITSOUTP outInfo[ccdMAXOUTPUT]; /* info for each used output */
00330 vltINT32 outRef; /* refer. output (image orientation) */
00331 vltINT32 frmId; /* image sequential number */
00332 vltINT32 frmType; /* type of frame */
00333 vltINT32 frmNaver; /* number of frames averaged */
00334 vltLOGICAL frmBias; /* bias substraction done */
00335 vltLOGICAL frmFlatf; /* flatF division done */
00336 vltINT32 integrN; /* number of integrations */
00337 ccdFITSINTE intTime[ccdMAXINTEGR]; /* integration time information */
00338 vltDOUBLE startReadTime; /* mjd when readout has started */
00339 vltDOUBLE readTime; /* image readout time [s] */
00340 vltDOUBLE startProcTime; /* mjd when process has started */
00341 vltDOUBLE procTime; /* image processing time [s] */
00342 vltDOUBLE startTranTime; /* mjd when transfer has started */
00343 vltDOUBLE tranTime; /* image transfer time [s] */
00344 vltDOUBLE stopWipeTime; /* mjd last wipe done before readout */
00345 vltDOUBLE darkTime; /* total dark time [s] */
00346 vltDOUBLE shutOpenTime; /* shutter open time [s] */
00347 vltDOUBLE shutCloseTime; /* shutter close time [s] */
00348 #ifdef ccdONLY_FOR_OPS_LOG
00349 vltINT32 tmpPeriod; /* sampling period [s] */
00350 #endif
00351 vltINT32 tmpSnsN; /* number of temp. sensors enabled */
00352 ccdFITSTEMP tmpSns[ccdMAXTMPSRC]; /* info on enabled temp. sensors */
00353 #ifdef ccdONLY_FOR_OPS_LOG
00354 vltINT32 telPeriod; /* sampling period [s] */
00355 vltINT32 telSrcN; /* number of tel. sources enabled */
00356 ccdFITSTELE telSrc[ccdMAXTELSRC]; /* info on enabled tel. sources */
00357 #endif
00358 } ccdFITSHIERARCH;
00359
00360 /* data structure for sensors (telemetry & temperature) */
00361 typedef struct { /* Mapping of DB sensor table */
00362 vltLOGICAL readOnly; /* Parameter is Read Only */
00363 vltLOGICAL available; /* Signal is available */
00364 vltLOGICAL enabled; /* */
00365 vltLOGICAL reserved; /* Reserved for align / future use */
00366 vltBYTES16 description; /* Sensor type description */
00367 vltBYTES16 id; /* Sensor Id */
00368 vltBYTES8 unit; /* Unit of physical value */
00369 vltDOUBLE low; /* Lowest tolerated value */
00370 vltDOUBLE high; /* Highest tolerated value */
00371 vltDOUBLE reference; /* Reference value */
00372 } ccdSENSOR;
00373
00374 /* data structure for sensors parameters (telemetry & temperature) */
00375 typedef struct {
00376 vltBYTES8 parName; /* Parameter name */
00377 vltDOUBLE parValue; /* Parameter value */
00378 } ccdPARAMETER;
00379
00380 /*
00381 * Macros
00382 */
00383 /* CCD ACE Program names Scientific/Technical */
00384 #define ccdPROG_SCI "acesci"
00385 #define ccdPROG_SCI_TRA "acesci.btl"
00386 #define ccdPROG_TEC "acetec"
00387 #define ccdPROG_TEC_TRA "acetec.btl"
00388 #define ccdPROG_TEC_PCI "acetec.pci"
00389
00390 /*
00391 * function prototypes
00392 */
00393 /* Build a full DB path from <prefix>_<index>.<attribute> */
00394 ccsCOMPL_STAT ccdSetIndexAttr(
00395 IN const dbSYMADDRESS attrPath, /* path (rel. or abs.) before index */
00396 IN vltINT32 index, /* index */
00397 IN const dbSYMADDRESS attrName, /* attribute name */
00398 OUT dbSYMADDRESS attrFullName); /* returned full path */
00399
00400 /* returns number of pixels taking into account binning factor */
00401 vltINT32 ccdNumPixels(
00402 IN vltINT32 dim, /* dimension in pixels */
00403 IN vltINT32 binning); /* binning factor */
00404
00405 /* calculate total number of pixels selected windows */
00406 ccsCOMPL_STAT ccdGetImageDim (
00407 IN ccdCONFIG *config, /* configuration of camera used */
00408 IN ccdSETUP *setup, /* setup information */
00409 OUT vltINT32 *winDim, /* window dimension */
00410 OUT ccsERROR *error); /* error structure */
00411
00412 /* calculate number of pixels/direction selected windows */
00413 ccsCOMPL_STAT ccdGetImageXYDim (
00414 IN ccdCONFIG *config, /* configuration of camera used */
00415 IN ccdSETUP *setup, /* setup information */
00416 OUT vltINT32 *winXDim, /* window X dimension */
00417 OUT vltINT32 *winYDim, /* window Y dimension */
00418 OUT ccsERROR *error); /* error structure */
00419
00420 /* FITS header/trailer Pack/Unpack functions */
00421 ccsCOMPL_STAT ccdPackFitsHeader (
00422 IN ccdFITSBASIC *header, /* FITS header to pack to byte stream */
00423 OUT char *buffer, /* packed FITS header */
00424 OUT ccsERROR *error ); /* error structure */
00425 ccsCOMPL_STAT ccdUnpackFitsHeader (
00426 IN char *buffer, /* byte stream containing the packed hdr */
00427 OUT ccdFITSBASIC *header, /* unpacked FITS header */
00428 OUT ccsERROR *error ); /* error structure */
00429 ccsCOMPL_STAT ccdPackFitsTrailer (
00430 IN ccdFITSHIERARCH *trailer, /* FITS trailer to pack to byte stream */
00431 OUT char *buffer, /* packed FITS trailer */
00432 OUT ccsERROR *error ); /* error structure */
00433 ccsCOMPL_STAT ccdUnpackFitsTrailer (
00434 IN char *buffer, /* byte stream containing the packed trl */
00435 OUT ccdFITSHIERARCH *trailer, /* unpacked FITS trailer */
00436 OUT ccsERROR *error ); /* error structure */
00437 /* Set new debugging level */
00438 void ccdDebugSet(
00439 IN vltINT32 level); /* new debug level to be set */
00440 /* Get current debugging level */
00441 vltINT32 ccdDebugGet( void );
00442 /* Compare current debugging level with passed one */
00443 vltLOGICAL ccdDebugCheck(
00444 IN vltINT32 level); /* debug level to be compared with */
00445
00446 /* FITS Logging functions */
00447 ccsCOMPL_STAT ccdLogFitsComment ( const char *msg );
00448 ccsCOMPL_STAT ccdLogFitsAction ( const logFITS_KEY sub,
00449 const logFITS_KEY key,
00450 const logACTION act );
00451 ccsCOMPL_STAT ccdLogFitsParameter ( const logFITS_KEY sub,
00452 const logFITS_KEY key,
00453 const logFITS_KEY par,
00454 const void *val );
00455 ccsCOMPL_STAT ccdLogFitsUnforeseen ( const char *msg );
00456 ccsCOMPL_STAT ccdLogFitsRecovery ( const char *msg );
00457
00458 #ifdef __cplusplus
00459 }
00460 #endif
00461
00462 #endif /* ! CCDINTERNAL_H */
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001