From 8bedd10ef536de0df1fb60d1c3922fb7302bae7c Mon Sep 17 00:00:00 2001 From: rivers Date: Thu, 10 May 2012 19:08:02 +0000 Subject: [PATCH] Improved handling ADC speed and pre-amp gain, using new asynEnum interface in asyn git-svn-id: https://subversion.xor.aps.anl.gov/synApps/areaDetector/trunk@14733 dc6c5ff5-0b8b-c028-a01f-ffb33f00fc8b --- ADApp/andorSrc/andorCCD.cpp | 168 ++++++++++++++++++++++++++++++++---- 1 file changed, 153 insertions(+), 15 deletions(-) diff --git a/ADApp/andorSrc/andorCCD.cpp b/ADApp/andorSrc/andorCCD.cpp index 4cc46c8..e8debfa 100755 --- a/ADApp/andorSrc/andorCCD.cpp +++ b/ADApp/andorSrc/andorCCD.cpp @@ -90,11 +90,13 @@ static void exitHandler(void *drvPvt); AndorCCD::AndorCCD(const char *portName, int maxBuffers, size_t maxMemory, const char *installPath, int priority, int stackSize) - : ADDriver(portName, 1, NUM_ANDOR_DET_PARAMS, maxBuffers, maxMemory, 0, 0, + : ADDriver(portName, 1, NUM_ANDOR_DET_PARAMS, maxBuffers, maxMemory, + asynEnumMask, asynEnumMask, ASYN_CANBLOCK, 1, priority, stackSize) { int status = asynSuccess; + int i; int binX=1, binY=1, minX=0, minY=0, sizeX, sizeY; char model[256]; const char *functionName = "AndorCCD::AndorCCD"; @@ -116,6 +118,7 @@ AndorCCD::AndorCCD(const char *portName, int maxBuffers, size_t maxMemory, createParam(AndorShutterExTTLString, asynParamInt32, &AndorShutterExTTL); createParam(AndorPalFileNameString, asynParamOctet, &AndorPalFileName); createParam(AndorAccumulatePeriodString, asynParamFloat64, &AndorAccumulatePeriod); + createParam(AndorPreAmpGainString, asynParamInt32, &AndorPreAmpGain); createParam(AndorAdcSpeedString, asynParamInt32, &AndorAdcSpeed); // Create the epicsEvent for signaling to the status task when parameters should have changed. @@ -148,6 +151,19 @@ AndorCCD::AndorCCD(const char *portName, int maxBuffers, size_t maxMemory, return; } + // Initialize ADC enums + for (i=0; iADCIndex, pSpeed->AmpIndex, pSpeed->HSSpeedIndex, + i, &isAvailable)); + if (isAvailable) { + checkStatus(GetPreAmpGain(i, &gain)); + epicsSnprintf(pGain->EnumString, MAX_ENUM_STRING_SIZE, "%.2f", gain); + pGain->EnumValue = i; + pGain->Gain = gain; + mNumPreAmpGains++; + if (mNumPreAmpGains >= MAX_PREAMP_GAINS) break; + pGain++; + } + } + for (i=0; ireason; + int i; + + if (function == AndorAdcSpeed) { + for (i=0; ((iADCIndex = i; + pSpeed->AmpIndex = j; + pSpeed->HSSpeedIndex = k; + pSpeed->BitDepth = bitDepth; + pSpeed->HSSpeed = HSSpeed; + epicsSnprintf(pSpeed->EnumString, MAX_ENUM_STRING_SIZE, + "%.2f MHz", HSSpeed); + mNumADCSpeeds++; + if (mNumADCSpeeds >= MAX_ADC_SPEEDS) return; + pSpeed++; + } + } + } +} + + + /** Report status of the driver. * Prints details about the detector in us if details>0. * It then calls the ADDriver::report() method. @@ -273,6 +393,7 @@ void AndorCCD::report(FILE *fp, int details) unsigned int uIntParam5; unsigned int uIntParam6; AndorCapabilities capabilities; + AndorADCSpeed_t *pSpeed; fprintf(fp, "Andor CCD port=%s\n", this->portName); if (details > 0) { @@ -295,16 +416,24 @@ void AndorCCD::report(FILE *fp, int details) getIntegerParam(ADMaxSizeY, &ysize); fprintf(fp, " X pixels: %d\n", xsize); fprintf(fp, " Y pixels: %d\n", ysize); - checkStatus(GetNumberAmp(¶m1)); - fprintf(fp, " Number of amplifier channels: %d\n", param1); - checkStatus(GetNumberADChannels(¶m1)); - fprintf(fp, " Number of ADC channels: %d\n", param1); - checkStatus(GetNumberPreAmpGains(¶m1)); - fprintf(fp, " Number of pre-amp gains: %d\n", param1); - for (i=0; iAmpIndex, pSpeed->ADCIndex, pSpeed->BitDepth, pSpeed->HSSpeedIndex, pSpeed->HSSpeed); + } + fprintf(fp, " Pre-amp gains available: %d\n", mNumPreAmpGains); + for (i=0; ipasynUserSelf, ASYN_TRACE_FLOW, "%s, SetTriggerMode(%d)\n", functionName, triggerMode); checkStatus(SetTriggerMode(triggerMode)); + asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, - "%s, SetADChannel(%d)\n", functionName, adcChannel); - checkStatus(SetADChannel(adcChannel)); - //Set fastest HS speed. + "%s, SetADChannel(%d)\n", functionName, pSpeed->ADCIndex); + checkStatus(SetADChannel(pSpeed->ADCIndex)); + asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, - "%s, SetHSSpeed(0, 0)\n", functionName); - checkStatus(SetHSSpeed(0, 0)); + "%s, SetOutputAmplifier(%d)\n", functionName, pSpeed->AmpIndex); + checkStatus(SetOutputAmplifier(pSpeed->AmpIndex)); + + asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, + "%s, SetHSSpeed(%d, %d)\n", functionName, pSpeed->AmpIndex, pSpeed->HSSpeedIndex); + checkStatus(SetHSSpeed(pSpeed->AmpIndex, pSpeed->HSSpeedIndex)); + asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "%s, SetImage(%d,%d,%d,%d,%d,%d)\n", functionName, binX, binY, minX+1, minX+sizeX, minY+1, minY+sizeY);