areaDetector 1-8
/home/epics/devel/areaDetector/ADApp/andorSrc/andorCCD.h
Go to the documentation of this file.
00001 
00012 #ifndef ANDORCCD_H
00013 #define ANDORCCD_H
00014 
00015 #include <stddef.h>
00016 #include <stdlib.h>
00017 #include <stdarg.h>
00018 #include <math.h>
00019 #include <stdio.h>
00020 #include <errno.h>
00021 #include <string.h>
00022 #include <ctype.h>
00023 #include <fcntl.h>
00024 #include <sys/stat.h>
00025 
00026 #include <string>
00027 
00028 #include <epicsTime.h>
00029 #include <epicsThread.h>
00030 #include <epicsEvent.h>
00031 #include <epicsMutex.h>
00032 #include <epicsString.h>
00033 #include <epicsStdio.h>
00034 #include <cantProceed.h>
00035 
00036 #include <asynOctetSyncIO.h>
00037 
00038 #include "ADDriver.h"
00039 
00040 #ifdef _WIN32
00041 #include "ATMCD32D.h"
00042 #else
00043 #include "atmcdLXd.h"
00044 #endif
00045 
00046 #define MAX_ENUM_STRING_SIZE 26
00047 #define MAX_ADC_SPEEDS 16
00048 #define MAX_PREAMP_GAINS 16
00049 
00050 #define AndorCoolerParamString             "ANDOR_COOLER"
00051 #define AndorTempStatusMessageString       "ANDOR_TEMP_STAT"
00052 #define AndorMessageString                 "ANDOR_MESSAGE"
00053 #define AndorShutterModeString             "ANDOR_SHUTTER_MODE"
00054 #define AndorShutterExTTLString            "ANDOR_SHUTTER_EXTTL"
00055 #define AndorPalFileNameString             "ANDOR_PAL_FILE_PATH"
00056 #define AndorAccumulatePeriodString        "ANDOR_ACCUMULATE_PERIOD"
00057 #define AndorPreAmpGainString              "ANDOR_PREAMP_GAIN"
00058 #define AndorAdcSpeedString                "ANDOR_ADC_SPEED"
00059 
00060 typedef struct {
00061   int ADCIndex;
00062   int AmpIndex;
00063   int HSSpeedIndex;
00064   float HSSpeed;
00065   int BitDepth;
00066   char *EnumString;
00067   int EnumValue;
00068 } AndorADCSpeed_t;
00069 
00070 typedef struct {
00071   float Gain;
00072   char *EnumString;
00073   int EnumValue;
00074 } AndorPreAmpGain_t;
00075 
00080 class AndorCCD : public ADDriver {
00081  public:
00082   AndorCCD(const char *portName, int maxBuffers, size_t maxMemory, 
00083            const char *installPath, int priority, int stackSize);
00084   virtual ~AndorCCD();
00085 
00086   /* These are the methods that we override from ADDriver */
00087   virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
00088   virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
00089   virtual void report(FILE *fp, int details);
00090   virtual asynStatus readEnum(asynUser *pasynUser, char *strings[], int values[], int severities[], 
00091                               size_t nElements, size_t *nIn);
00092 
00093   // Should be private, but are called from C so must be public
00094   void statusTask(void);
00095   void dataTask(void);
00096 
00097  protected:
00098   int AndorCoolerParam;
00099   #define FIRST_ANDOR_PARAM AndorCoolerParam
00100   int AndorTempStatusMessage;
00101   int AndorMessage;
00102   int AndorShutterMode;
00103   int AndorShutterExTTL;
00104   int AndorPalFileName;
00105   int AndorAccumulatePeriod;
00106   int AndorPreAmpGain;
00107   int AndorAdcSpeed;
00108   #define LAST_ANDOR_PARAM AndorAdcSpeed
00109 
00110  private:
00111 
00112   unsigned int checkStatus(unsigned int returnStatus);
00113   asynStatus setupAcquisition();
00114   asynStatus setupShutter(int command);
00115   void saveDataFrame(int frameNumber);
00116   void setupADCSpeeds();
00117   void setupPreAmpGains();
00121    static const epicsInt32 AImageFastKinetics;
00122 
00126   static const epicsUInt32 AASingle;
00127   static const epicsUInt32 AAAccumulate;
00128   static const epicsUInt32 AAKinetics;
00129   static const epicsUInt32 AAFastKinetics;
00130   static const epicsUInt32 AARunTillAbort;
00131   static const epicsUInt32 AATimeDelayedInt;
00132 
00136   static const epicsUInt32 ATInternal;
00137   static const epicsUInt32 ATExternal;
00138   static const epicsUInt32 ATExternalStart;
00139   static const epicsUInt32 ATExternalExposure;
00140   static const epicsUInt32 ATExternalFVB;
00141   static const epicsUInt32 ATSoftware;
00142 
00146   static const epicsUInt32 ASIdle;
00147   static const epicsUInt32 ASTempCycle;
00148   static const epicsUInt32 ASAcquiring;
00149   static const epicsUInt32 ASAccumTimeNotMet;
00150   static const epicsUInt32 ASKineticTimeNotMet;
00151   static const epicsUInt32 ASErrorAck;
00152   static const epicsUInt32 ASAcqBuffer;
00153   static const epicsUInt32 ASSpoolError;
00154 
00158   static const epicsInt32 ARFullVerticalBinning;
00159   static const epicsInt32 ARMultiTrack;
00160   static const epicsInt32 ARRandomTrack;
00161   static const epicsInt32 ARSingleTrack;
00162   static const epicsInt32 ARImage;
00163 
00167   static const epicsInt32 AShutterAuto;
00168   static const epicsInt32 AShutterOpen;
00169   static const epicsInt32 AShutterClose;
00170 
00174   static const epicsInt32 AFFTIFF;
00175   static const epicsInt32 AFFBMP;
00176   static const epicsInt32 AFFSIF;
00177   static const epicsInt32 AFFEDF;
00178   static const epicsInt32 AFFRAW;
00179   static const epicsInt32 AFFFITS;
00180 
00181   epicsEventId statusEvent;
00182   epicsEventId dataEvent;
00183   double mPollingPeriod;
00184   double mFastPollingPeriod;
00185   unsigned int mAcquiringData;
00186   char *mInstallPath;
00187   
00191   int mNumAmps;
00192   int mNumADCs;
00193   int mNumADCSpeeds;
00194   AndorADCSpeed_t mADCSpeeds[MAX_ADC_SPEEDS];
00195   int mTotalPreAmpGains;
00196   int mNumPreAmpGains;
00197   AndorPreAmpGain_t mPreAmpGains[MAX_PREAMP_GAINS];
00198 
00199   //Shutter control parameters
00200   float mAcquireTime;
00201   float mAcquirePeriod;
00202   float mAccumulatePeriod;
00203 
00204 };
00205 
00206 #define NUM_ANDOR_DET_PARAMS (&LAST_ANDOR_PARAM - &FIRST_ANDOR_PARAM + 1)
00207 
00208 static const char *driverName = "andorCCDDetector";
00209 
00210 #endif //ANDORCCD_H
00211