00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef PERKINELMER_H
00014 #define PERKINELMER_H
00015
00016 #include <sys/stat.h>
00017
00018 #include <stddef.h>
00019 #include <stdlib.h>
00020 #include <stdarg.h>
00021 #include <math.h>
00022 #include <stdio.h>
00023 #include <errno.h>
00024 #include <string.h>
00025
00026 #include <epicsTime.h>
00027 #include <epicsThread.h>
00028 #include <epicsEvent.h>
00029 #include <epicsMutex.h>
00030 #include <epicsString.h>
00031 #include <epicsStdio.h>
00032 #include <epicsMutex.h>
00033 #include <cantProceed.h>
00034
00035 #include "asynNDArrayDriver.h"
00036 #include "NDArray.h"
00037 #include "ADDriver.h"
00038
00039 #include "drvPerkinElmer.h"
00040
00041 #include <windows.h>
00042 #include "Acq.h"
00043
00044
00045
00046 static const char *driverName = "drvPerkinElmer";
00047
00048
00049
00050
00051
00052 typedef enum {
00053 PE_SystemID = ADLastStdParam,
00054 PE_Initialize,
00055 PE_StatusRBV,
00056 PE_AcquireOffset,
00057 PE_NumOffsetFrames,
00058 PE_UseOffset,
00059 PE_OffsetAvailable,
00060 PE_AcquireGain,
00061 PE_NumGainFrames,
00062 PE_UseGain,
00063 PE_GainAvailable,
00064 PE_PixelCorrectionAvailable,
00065 PE_Gain,
00066 PE_GainRBV,
00067 PE_DwellTime,
00068 PE_DwellTimeRBV,
00069 PE_NumFrameBuffers,
00070 PE_NumFrameBuffersRBV,
00071 PE_SyncMode,
00072 PE_SyncModeRBV,
00073 PE_Trigger,
00074 PE_SyncTime,
00075 PE_SyncTimeRBV,
00076 PE_UsePixelCorrection,
00077 PE_LoadCorrectionFiles,
00078 PE_SaveCorrectionFiles,
00079 PE_PixelCorrectionFile,
00080 PE_PixelCorrectionFileRBV,
00081 PE_CorrectionsDirectory,
00082 PE_FrameBufferIndex,
00083 PE_ImageNumber,
00084 PE_FastCollectMode,
00085 ADLastDriverParam
00086 } PerkinElmerParam_t;
00087
00088
00089
00090 static asynParamString_t PerkinElmerParamString[] = {
00091 {PE_SystemID, "PE_SYSTEMID"},
00092 {PE_Initialize, "PE_INITIALIZE"},
00093 {PE_StatusRBV, "PE_STATUS_RBV"},
00094 {PE_AcquireOffset, "PE_ACQUIRE_OFFSET"},
00095 {PE_NumOffsetFrames, "PE_NUM_OFFSET_FRAMES"},
00096 {PE_UseOffset, "PE_USE_OFFSET"},
00097 {PE_OffsetAvailable, "PE_OFFSET_AVAILABLE"},
00098 {PE_AcquireGain, "PE_ACQUIRE_GAIN"},
00099 {PE_NumGainFrames, "PE_NUM_GAIN_FRAMES"},
00100 {PE_UseGain, "PE_USE_GAIN"},
00101 {PE_GainAvailable, "PE_GAIN_AVAILABLE"},
00102 {PE_PixelCorrectionAvailable, "PE_PIXEL_CORRECTION_AVAILABLE"},
00103 {PE_Gain, "PE_GAIN"},
00104 {PE_GainRBV, "PE_GAIN_RBV"},
00105 {PE_DwellTime, "PE_DWELL_TIME"},
00106 {PE_DwellTimeRBV, "PE_DWELL_TIME_RBV"},
00107 {PE_NumFrameBuffers, "PE_NUM_FRAME_BUFFERS"},
00108 {PE_NumFrameBuffersRBV, "PE_NUM_FRAME_BUFFERS_RBV"},
00109 {PE_SyncMode, "PE_SYNC_MODE"},
00110 {PE_SyncModeRBV, "PE_SYNC_MODE_RBV"},
00111 {PE_Trigger, "PE_TRIGGER"},
00112 {PE_SyncTime, "PE_SYNC_TIME"},
00113 {PE_SyncTimeRBV, "PE_SYNC_TIME_RBV"},
00114 {PE_UsePixelCorrection, "PE_USE_PIXEL_CORRECTION"},
00115 {PE_LoadCorrectionFiles, "PE_LOAD_CORRECTION_FILES"},
00116 {PE_SaveCorrectionFiles, "PE_SAVE_CORRECTION_FILES"},
00117 {PE_PixelCorrectionFile, "PE_PIXEL_CORRECTION_FILE"},
00118 {PE_PixelCorrectionFileRBV, "PE_PIXEL_CORRECTION_FILE_RBV"},
00119 {PE_CorrectionsDirectory, "PE_CORRECTIONS_DIRECTORY"},
00120 {PE_FrameBufferIndex, "PE_FRAME_BUFFER_INDEX"},
00121 {PE_ImageNumber, "PE_IMAGE_NUMBER"},
00122 {PE_FastCollectMode, "PE_FAST_COLLECT_MODE"},
00123
00124 };
00125
00126 #define NUM_PERKIN_ELMER_PARAMS (sizeof(PerkinElmerParamString)/sizeof(PerkinElmerParamString[0]))
00127
00128 typedef enum
00129 {
00130 PE_ACQUIRE_ACQUISITION,
00131 PE_ACQUIRE_OFFSET,
00132 PE_ACQUIRE_GAIN
00133 } PEAcquisitionMode_t;
00134
00135 typedef enum
00136 {
00137 PE_INTERNAL_TRIGGER,
00138 PE_EXTERNAL_TRIGGER,
00139 PE_FREE_RUNNING,
00140 PE_SOFT_TRIGGER
00141 } PETimingMode_t;
00142
00143 #define TIME0 0
00144 #define TIME0_STR "66.5ms"
00145 #define TIME1 1
00146 #define TIME1_STR "79.9ms"
00147 #define TIME2 2
00148 #define TIME2_STR "99.8ms"
00149 #define TIME3 3
00150 #define TIME3_STR "133.2ms"
00151 #define TIME4 4
00152 #define TIME4_STR "199.9ms"
00153 #define TIME5 5
00154 #define TIME5_STR "400.0ms"
00155 #define TIME6 6
00156 #define TIME6_STR "999.8ms"
00157 #define TIME7 7
00158 #define TIME7_STR "1999.8ms"
00159
00160
00161 #define GAIN0 0
00162 #define GAIN0_STR "0.25pF"
00163 #define GAIN1 1
00164 #define GAIN1_STR "0.5pF"
00165 #define GAIN2 2
00166 #define GAIN2_STR "1pF"
00167 #define GAIN3 3
00168 #define GAIN3_STR "2pF"
00169 #define GAIN4 4
00170 #define GAIN4_STR "4pF"
00171 #define GAIN5 5
00172 #define GAIN5_STR "8pF"
00173
00174 typedef enum
00175 {
00176 PE_STATUS_OK,
00177 PE_STATUS_INITIALIZING,
00178 PE_STATUS_RUNNING_OFFSET,
00179 PE_STATUS_RUNNING_GAIN,
00180 PE_STATUS_ERROR
00181 } PEStatus_t;
00182
00183 typedef enum
00184 {
00185 NOT_AVAILABLE,
00186 AVAILABLE
00187 } Avalability_t;
00188
00189 typedef enum
00190 {
00191 NO,
00192 YES
00193 } YesNo_t;
00194
00195
00196
00197 class PerkinElmer;
00198
00199
00202 typedef struct {
00203 unsigned short *pDataBuffer,
00204 *pOffsetBuffer;
00205 DWORD *pGainBuffer;
00206 unsigned int uiRows,
00207 uiColumns,
00208 numBufferFrames;
00209 int iAcqMode,
00210 iUseOffset,
00211 iUseGain,
00212 iUsePixelCorrections,
00213 *pPixelCorrectionList;
00214 short iFastCollectMode;
00215 PerkinElmer *pPerkinElmer;
00216 } AcqData_t;
00217
00218
00221 class PerkinElmer : public ADDriver
00222 {
00223 public:
00224 int imagesRemaining;
00225 epicsEventId startAcquisitionEventId;
00226 epicsEventId stopAcquisitionEventId;
00227 NDArray *pRaw;
00228
00229 PerkinElmer(const char *portName, int maxSizeX, int maxSizeY, NDDataType_t dataType, int maxBuffers, size_t maxMemory,
00230 int priority, int stackSize);
00231
00232
00233 virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
00234 virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
00235 virtual asynStatus drvUserCreate(asynUser *pasynUser, const char *drvInfo, const char **pptypeName, size_t *psize);
00236 void report(FILE *fp, int details);
00237
00238 void acquireTask ();
00239
00240 void frameCallback (unsigned int buffFrame);
00241 void offsetCallback ();
00242 void gainCallback ();
00243
00244 ~PerkinElmer ();
00245
00246 private:
00247 HACQDESC hAcqDesc;
00248 unsigned short *pAcqBuffer,
00249 *pOffsetBuffer,
00250 *pBadPixelMap;
00251 DWORD *pGainBuffer;
00252 DWORD dwBoardType,
00253 dwAcqType,
00254 dwSystemID,
00255 dwSyncMode,
00256 dwHwAccess;
00257 int abortAcq,
00258 iChannelNum,
00259 *pPixelCorrectionList;
00260 BOOL bEnableIRQ,
00261 bSelfInit,
00262 bInitAlways,
00263 bAcquiringOffset,
00264 bAcquiringGain;
00265 UINT uiRows,
00266 uiColumns,
00267 uiDataType,
00268 uiSortFlags,
00269 uiNumSensors,
00270 uiChannelType,
00271 uiPEResult,
00272 uiNumFrameBuffers;
00273 double acqTimeReq,
00274 acqTimeAct;
00275 int trigModeReq,
00276 trigModeAct;
00277
00278 AcqData_t dataAcqStruct;
00279
00280 template <typename epicsType> void computeArray(int maxSizeX, int maxSizeY, unsigned int buffFrame);
00281
00282 int allocateBuffer(void);
00283 int computeImage(unsigned int buffFrame);
00284
00285 void enumSensors (void);
00286 BOOL initializeDetector (void);
00287
00288 void acquireImage (void);
00289 void acquireOffsetImage (void);
00290 void acquireGainImage (void);
00291
00292 void saveCorrectionFiles (void);
00293 void loadCorrectionFiles (void);
00294
00295 void readPixelCorrectionFile (char *pixel_correction_file);
00296
00297 };
00298
00299
00300
00301 #endif