00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef PVCAMSRC_H
00012 #define PVCAMSRC_H
00013
00014 #include <stddef.h>
00015 #include <stdlib.h>
00016 #include <stdarg.h>
00017 #include <math.h>
00018 #include <stdio.h>
00019 #include <errno.h>
00020 #include <string.h>
00021
00022 #include <epicsTime.h>
00023 #include <epicsThread.h>
00024 #include <epicsEvent.h>
00025 #include <epicsMutex.h>
00026 #include <epicsString.h>
00027 #include <epicsStdio.h>
00028 #include <epicsMutex.h>
00029 #include <cantProceed.h>
00030
00031 #include "ADDriver.h"
00032
00033 #include "drvPVCam.h"
00034
00035
00036 #include "master.h"
00037 #include "pvcam.h"
00038
00039
00040
00041 static const char *driverName = "drvPVCam";
00042
00043
00044
00046 #define POLL_TIME 0.01
00047
00048 #define NUM_PV_CAM_PARAMS (sizeof(PVCamParamString)/sizeof(PVCamParamString[0]))
00049
00050 #define MAX_DETECTORS_SUPPORTED 3
00051 #define MAX_SPEEDS_SUPPORTED 5
00052
00053
00054
00055
00056
00057 typedef enum {
00058 PVCamInitDetector
00059 = ADLastStdParam,
00060 PVCamSlot1Cam,
00061 PVCamSlot2Cam,
00062 PVCamSlot3Cam,
00063 PVCamDetectorSelected,
00064 PVCamChipNameRBV,
00065 PVCamNumParallelPixelsRBV,
00066 PVCamNumSerialPixelsRBV,
00067 PVCamPixelParallelSizeRBV,
00068 PVCamPixelSerialSizeRBV,
00069 PVCamChipHeightMMRBV,
00070 PVCamChipWidthMMRBV,
00071 PVCamPixelParallelDistRBV,
00072 PVCamPixelSerialDistRBV,
00073 PVCamPostMaskRBV,
00074 PVCamPreMaskRBV,
00075 PVCamPostScanRBV,
00076 PVCamPreScanRBV,
00077 PVCamNumPortsRBV,
00078 PVCamFullWellCapacityRBV,
00079 PVCamFrameTransferCapableRBV,
00080 PVCamNumSpeedTableEntriesRBV,
00081 PVCamSpeedTableIndex,
00082 PVCamSpeedTableIndexRBV,
00083 PVCamBitDepthRBV,
00084 PVCamPixelTimeRBV,
00085 PVCamGainIndex,
00086 PVCamGainIndexRBV,
00087 PVCamMaxGainIndexRBV,
00088 PVCamMinShutterOpenDelayRBV,
00089 PVCamMaxShutterOpenDelayRBV,
00090 PVCamMinShutterCloseDelayRBV,
00091 PVCamMaxShutterCloseDelayRBV,
00092 PVCamShutterOpenDelay,
00093 PVCamShutterOpenDelayRBV,
00094 PVCamShutterCloseDelay,
00095 PVCamShutterCloseDelayRBV,
00096 PVCamMeasuredTemperatureRBV,
00097 PVCamMinTemperatureRBV,
00098 PVCamMaxTemperatureRBV,
00099 PVCamSetTemperature,
00100 PVCamSetTemperatureRBV,
00101 PVCamDetectorMode,
00102 PVCamDetectorModeRBV,
00103 PVCamTriggerMode,
00104 PVCamTriggerModeRBV,
00105 PVCamTriggerEdge,
00106 PVCamTriggerEdgeRBV,
00107 ADLastDriverParam
00108 } PVCamParam_t;
00109
00110
00111
00112 static asynParamString_t PVCamParamString[] = {
00113 {PVCamInitDetector, "PVCAM_INITIALIZE_DETECTOR"},
00114 {PVCamSlot1Cam, "PVCAM_SLOT1"},
00115 {PVCamSlot2Cam, "PVCAM_SLOT2"},
00116 {PVCamSlot3Cam, "PVCAM_SLOT3"},
00117 {PVCamDetectorSelected, "PVCAM_DETECTORSELECTED"},
00118 {PVCamChipNameRBV, "PVCAM_CHIPNAME"},
00119 {PVCamNumParallelPixelsRBV, "PVCAM_NUMPARALLELPIXELS"},
00120 {PVCamNumSerialPixelsRBV, "PVCAM_NUMSERIALPIXELS"},
00121 {PVCamPixelParallelSizeRBV, "PVCAM_PIXELPARALLELSIZE"},
00122 {PVCamPixelSerialSizeRBV, "PVCAM_PIXELSERIALSIZE"},
00123 {PVCamChipHeightMMRBV, "PVCAM_CHIPHEIGHT"},
00124 {PVCamChipWidthMMRBV, "PVCAM_CHIPWIDTH"},
00125 {PVCamPixelParallelDistRBV, "PVCAM_PIXELPARALLELDIST"},
00126 {PVCamPixelSerialDistRBV, "PVCAM_PIXELSERIALDIST"},
00127 {PVCamPostMaskRBV, "PVCAM_POSTMASK"},
00128 {PVCamPreMaskRBV, "PVCAM_PREMASK"},
00129 {PVCamPostScanRBV, "PVCAM_POSTSCAN"},
00130 {PVCamPreScanRBV, "PVCAM_PRESCAN"},
00131 {PVCamNumPortsRBV, "PVCAM_NUMPORTS"},
00132 {PVCamFullWellCapacityRBV, "PVCAM_FULLWELLCAPACITY"},
00133 {PVCamFrameTransferCapableRBV, "PVCAM_FRAMETRANSFERCAPABLE"},
00134 {PVCamNumSpeedTableEntriesRBV, "PVCAM_NUMSPEEDTABLEENTRIES"},
00135 {PVCamSpeedTableIndex, "PVCAM_SPEEDTABLEINDEX"},
00136 {PVCamSpeedTableIndexRBV, "PVCAM_SPEEDTABLEINDEX_RBV"},
00137 {PVCamBitDepthRBV, "PVCAM_BITDEPTH"},
00138 {PVCamPixelTimeRBV, "PVCAM_PIXELTIME"},
00139 {PVCamGainIndex, "PVCAM_GAININDEX"},
00140 {PVCamGainIndexRBV, "PVCAM_GAININDEX_RBV"},
00141 {PVCamMaxGainIndexRBV, "PVCAM_MAXGAININDEX"},
00142 {PVCamMinShutterOpenDelayRBV, "PVCAM_MINSHUTTEROPENDELAY"},
00143 {PVCamMaxShutterOpenDelayRBV, "PVCAM_MAXSHUTTEROPENDELAY"},
00144 {PVCamMinShutterCloseDelayRBV, "PVCAM_MINSHUTTERCLOSEDELAY"},
00145 {PVCamMaxShutterCloseDelayRBV, "PVCAM_MAXSHUTTERCLOSEDELAY"},
00146 {PVCamShutterOpenDelay, "PVCAM_SHUTTEROPENDELAY"},
00147 {PVCamShutterOpenDelayRBV, "PVCAM_SHUTTEROPENDELAY_RBV"},
00148 {PVCamShutterCloseDelay, "PVCAM_SHUTTERCLOSEDELAY"},
00149 {PVCamShutterCloseDelayRBV, "PVCAM_SHUTTERCLOSEDELAY_RBV"},
00150 {PVCamMeasuredTemperatureRBV, "PVCAM_MEASUREDTEMPERATURE"},
00151 {PVCamMinTemperatureRBV, "PVCAM_MINTEMPERATURE"},
00152 {PVCamMaxTemperatureRBV, "PVCAM_MAXTEMPERATURE"},
00153 {PVCamSetTemperature, "PVCAM_SETTEMPERATURE"},
00154 {PVCamSetTemperatureRBV, "PVCAM_SETTEMPERATURE_RBV"},
00155 {PVCamDetectorMode, "PVCAM_DETECTORMODE"},
00156 {PVCamDetectorModeRBV, "PVCAM_DETECTORMODE_RBV"},
00157 {PVCamTriggerMode, "PVCAM_TRIGGERMODE"},
00158 {PVCamTriggerModeRBV, "PVCAM_TRIGGERMODE_RBV"},
00159 {PVCamTriggerEdge, "PVCAM_TRIGGEREDGE"},
00160 {PVCamTriggerEdgeRBV, "PVCAM_TRIGGEREDGE_RBV"},
00161 };
00162
00163
00164
00165 class pvCam : public ADDriver
00166 {
00167 public:
00168 int imagesRemaining;
00169 epicsEventId startEventId,
00170 stopEventId;
00171 NDArray *pRaw;
00172
00173 pvCam(const char *portName, int maxSizeX, int maxSizeY, NDDataType_t dataType,
00174 int maxBuffers, size_t maxMemory, int priority, int stackSize);
00175
00176
00177 virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value);
00178 virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value);
00179 virtual asynStatus drvUserCreate(asynUser *pasynUser, const char *drvInfo, const char **pptypeName, size_t *psize);
00180 void report(FILE *fp, int details);
00181
00182
00183 template <typename epicsType> int computeArray(int maxSizeX, int maxSizeY);
00184
00185 int allocateBuffer();
00186 int computeImage();
00187
00188 void pvCamAcquisitionTask();
00189 void pvCamMonitorTask();
00190
00191 ~pvCam ();
00192
00193 private:
00194 int16 numDetectorsInstalled,
00195 detectorSelected,
00196 detectorHandle;
00197
00198 char *detectorList[5];
00199
00200 unsigned short *rawData;
00201
00202 void outputErrorMessage (const char *functionName, char *appMessage);
00203
00204 void initializeDetectorInterface (void);
00205 void selectDetector (int selectedDetector);
00206
00207 void queryCurrentSettings (void);
00208
00209 void initializeDetector (void);
00210
00211 int getAcquireStatus (void);
00212
00213 };
00214
00215
00216
00217 #endif