From 6b60c8c07d8887311308e8c809434b8e8ffe0b71 Mon Sep 17 00:00:00 2001 From: Benjamin Bradnick Date: Mon, 17 Feb 2020 16:38:31 +0000 Subject: [PATCH] Temperature parameter is set on startup to current temperature. Invalid temperatures no longer update the parameter. --- andorApp/src/andorCCD.cpp | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/andorApp/src/andorCCD.cpp b/andorApp/src/andorCCD.cpp index 7efb253..ac26317 100755 --- a/andorApp/src/andorCCD.cpp +++ b/andorApp/src/andorCCD.cpp @@ -241,6 +241,13 @@ AndorCCD::AndorCCD(const char *portName, const char *installPath, int cameraSeri checkStatus(GetFastestRecommendedVSSpeed(&mVSIndex, &mVSPeriod)); mCapabilities.ulSize = sizeof(mCapabilities); checkStatus(GetCapabilities(&mCapabilities)); + + /* Get current temperature */ + float temperature; + checkStatus(GetTemperatureF(&temperature)); + printf("%s:%s: current temperature is %f\n", driverName, functionName, temperature); + setDoubleParam(ADTemperature, temperature); + callParamCallbacks(); } catch (const std::string &e) { asynPrint(pasynUserSelf, ASYN_TRACE_ERROR, @@ -766,6 +773,10 @@ asynStatus AndorCCD::writeFloat64(asynUser *pasynUser, epicsFloat64 value) int minTemp = 0; int maxTemp = 0; + /* Store the old value */ + epicsFloat64 oldValue; + getDoubleParam(function, &oldValue); + /* Set the parameter and readback in the parameter library. */ status = setDoubleParam(function, value); @@ -786,16 +797,21 @@ asynStatus AndorCCD::writeFloat64(asynUser *pasynUser, epicsFloat64 value) "%s:%s:, Setting temperature value %f\n", driverName, functionName, value); try { + /* Check requested temperature is within our range */ + checkStatus(GetTemperatureRange(&minTemp, &maxTemp)); asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "%s:%s:, CCD Min Temp: %d, Max Temp %d\n", driverName, functionName, minTemp, maxTemp); - checkStatus(GetTemperatureRange(&minTemp, &maxTemp)); - if ((static_cast(value) > minTemp) & (static_cast(value) < maxTemp)) { + if ((static_cast(value) >= minTemp) & (static_cast(value) <= maxTemp)) { asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, "%s:%s:, SetTemperature(%d)\n", driverName, functionName, static_cast(value)); checkStatus(SetTemperature(static_cast(value))); } else { + /* Requested temperature is out of range */ + status = setDoubleParam(function, oldValue); + asynPrint(this->pasynUserSelf, ASYN_TRACE_FLOW, + "Requested temperature out of range\n"); setStringParam(AndorMessage, "Temperature is out of range."); callParamCallbacks(); status = asynError; @@ -811,24 +827,24 @@ asynStatus AndorCCD::writeFloat64(asynUser *pasynUser, epicsFloat64 value) (function == ADShutterCloseDelay)) { status = setupShutter(-1); } - else { status = ADDriver::writeFloat64(pasynUser, value); } - //For a successful write, clear the error message. - setStringParam(AndorMessage, " "); - /* Do callbacks so higher layers see any changes */ callParamCallbacks(); - if (status) + if (status) { asynPrint(pasynUser, ASYN_TRACE_ERROR, "%s:%s: error, status=%d function=%d, value=%f\n", driverName, functionName, status, function, value); - else + } + else { asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: function=%d, value=%f\n", driverName, functionName, function, value); + /* For a successful write, clear the error message. */ + setStringParam(AndorMessage, " "); + } return status; } @@ -1479,7 +1495,7 @@ void AndorCCD::dataTask(void) epicsTimeStamp startTime; NDArray *pArray; int autoSave; - int readOutMode; + int readOutMode; static const char *functionName = "dataTask"; printf("%s:%s: Data thread started...\n", driverName, functionName); @@ -1579,8 +1595,8 @@ void AndorCCD::dataTask(void) dims[0] = sizeX; dims[1] = sizeY; pArray = this->pNDArrayPool->alloc(nDims, dims, dataType, 0, NULL); - if (readOutMode == ARRandomTrack) - mMultiTrack.storeTrackAttributes(pArray->pAttributeList); + if (readOutMode == ARRandomTrack) + mMultiTrack.storeTrackAttributes(pArray->pAttributeList); // Read the oldest array // Is there still an image available? status = GetNumberNewImages(&firstImage, &lastImage);