Merge pull request #20 from hinxx/multiple_cameras

use device serial number to select the camera (0 for any camera)
This commit is contained in:
Mark Rivers
2018-12-19 17:39:11 -06:00
committed by GitHub
3 changed files with 41 additions and 19 deletions

View File

@@ -101,8 +101,7 @@ static void exitHandler(void *drvPvt);
* \param[in] installPath The path to the Andor directory containing the detector INI files, etc.
* This can be specified as an empty string ("") for new detectors that don't use the INI
* files on Windows, but must be a valid path on Linux.
* \param[in] cameraID The index number of the desired camera.
* 0 is the first camera in the system.
* \param[in] cameraSerial The serial number of the desired camera.
* \param[in] shamrockID The index number of the Shamrock spectrograph, if installed.
* 0 is the first Shamrock in the system. Ignored if there are no Shamrocks.
* \param[in] maxBuffers The maximum number of NDArray buffers that the NDArrayPool for this driver is
@@ -112,7 +111,7 @@ static void exitHandler(void *drvPvt);
* \param[in] priority The thread priority for the asyn port driver thread if ASYN_CANBLOCK is set in asynFlags.
* \param[in] stackSize The stack size for the asyn port driver thread if ASYN_CANBLOCK is set in asynFlags.
*/
AndorCCD::AndorCCD(const char *portName, const char *installPath, int cameraID, int shamrockID,
AndorCCD::AndorCCD(const char *portName, const char *installPath, int cameraSerial, int shamrockID,
int maxBuffers, size_t maxMemory, int priority, int stackSize)
: ADDriver(portName, 1, NUM_ANDOR_DET_PARAMS, maxBuffers, maxMemory,
@@ -195,18 +194,37 @@ AndorCCD::AndorCCD(const char *portName, const char *installPath, int cameraID,
try {
epicsInt32 numCameras;
checkStatus(GetAvailableCameras(&numCameras));
if (cameraID < numCameras) {
epicsInt32 cameraHandle;
checkStatus(GetCameraHandle(cameraID, &cameraHandle));
bool cameraFound = false;
for (i=0; i<numCameras; i++) {
epicsInt32 cameraHandle = -1;
checkStatus(GetCameraHandle(i, &cameraHandle));
checkStatus(SetCurrentCamera(cameraHandle));
} else {
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
"%s::%s error selecting camera %d, only %d cameras in system\n",
driverName, functionName, cameraID, numCameras);
printf("%s:%s: initializing camera with handle %d\n", driverName, functionName, cameraHandle);
unsigned long error = Initialize(mInstallPath);
if (error == DRV_NOT_AVAILABLE) {
// Is this the right way to detect if camera is used/busy/claimed?
printf("%s:%s: camera with handle %d not available (already claimed?)\n",
driverName, functionName, cameraHandle);
} else if (error == DRV_SUCCESS) {
checkStatus(GetCameraSerialNumber(&serialNumber));
if ((cameraSerial == serialNumber) ||
((cameraSerial == 0) && (serialNumber != 0))) {
cameraFound = true;
break;
}
} else {
printf("%s:%s: initialization error for camera handle %d: %ld\n",
driverName, functionName, cameraHandle, error);
}
ShutDown();
}
printf("%s:%s: initializing camera\n",
driverName, functionName);
checkStatus(Initialize(mInstallPath));
if (! cameraFound) {
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
"%s::%s camera not detected!\n", driverName, functionName);
return;
}
printf("%s:%s: found camera with serial %d\n", driverName, functionName, serialNumber);
setStringParam(AndorMessage, "Camera successfully initialized.");
checkStatus(GetDetector(&sizeX, &sizeY));
checkStatus(GetHeadModel(model));
@@ -1843,6 +1861,7 @@ static void andorDataTaskC(void *drvPvt)
* \param[in] portName The name of the asyn port driver to be created.
* \param[in] installPath The path to the Andor directory containing the detector INI files, etc.
* This can be specified as an empty string ("") for new detectors that don't use the INI
* \param[in] cameraSerial The serial number of the desired camera.
* \param[in] shamrockID The index number of the Shamrock spectrograph, if installed.
* 0 is the first Shamrock in the system. Ignored if there are no Shamrocks.
* \param[in] maxBuffers The maximum number of NDArray buffers that the NDArrayPool for this driver is
@@ -1854,11 +1873,11 @@ static void andorDataTaskC(void *drvPvt)
* \param[in] stackSize The stack size for the asyn port driver thread
*/
extern "C" {
int andorCCDConfig(const char *portName, const char *installPath, int cameraID, int shamrockID,
int andorCCDConfig(const char *portName, const char *installPath, int cameraSerial, int shamrockID,
int maxBuffers, size_t maxMemory, int priority, int stackSize)
{
/*Instantiate class.*/
new AndorCCD(portName, installPath, cameraID, shamrockID, maxBuffers, maxMemory, priority, stackSize);
new AndorCCD(portName, installPath, cameraSerial, shamrockID, maxBuffers, maxMemory, priority, stackSize);
return(asynSuccess);
}
@@ -1868,7 +1887,7 @@ int andorCCDConfig(const char *portName, const char *installPath, int cameraID,
/* andorCCDConfig */
static const iocshArg andorCCDConfigArg0 = {"Port name", iocshArgString};
static const iocshArg andorCCDConfigArg1 = {"installPath", iocshArgString};
static const iocshArg andorCCDConfigArg2 = {"cameraID", iocshArgInt};
static const iocshArg andorCCDConfigArg2 = {"cameraSerial", iocshArgInt};
static const iocshArg andorCCDConfigArg3 = {"shamrockID", iocshArgInt};
static const iocshArg andorCCDConfigArg4 = {"maxBuffers", iocshArgInt};
static const iocshArg andorCCDConfigArg5 = {"maxMemory", iocshArgInt};

View File

@@ -79,7 +79,7 @@ typedef struct {
*/
class AndorCCD : public ADDriver {
public:
AndorCCD(const char *portName, const char *installPath, int cameraID, int shamrockID,
AndorCCD(const char *portName, const char *installPath, int cameraSerial, int shamrockID,
int maxBuffers, size_t maxMemory, int priority, int stackSize);
virtual ~AndorCCD();

View File

@@ -15,10 +15,13 @@ epicsEnvSet("CBUFFS", "500")
# The search path for database files
epicsEnvSet("EPICS_DB_INCLUDE_PATH", "$(ADCORE)/db")
# andorCCDConfig(const char *portName, const char *installPath, int cameraID, int shamrockID,
# andorCCDConfig(const char *portName, const char *installPath, int cameraSerial, int shamrockID,
# int maxBuffers, size_t maxMemory, int priority, int stackSize)
#andorCCDConfig("$(PORT)", "/usr/local/etc/andor/", 0, 0, 0, 0, 0 ,0)
andorCCDConfig("$(PORT)", "", 0, 0, 0, 0, 0)
# select the camera with serial number 1370
#andorCCDConfig("$(PORT)", "", 1370, 0, 0, 0, 0, 0)
# select a camera with any serial number
andorCCDConfig("$(PORT)", "", 0, 0, 0, 0, 0, 0)
dbLoadRecords("$(ADANDOR)/db/andorCCD.template", "P=$(PREFIX),R=cam1:,PORT=$(PORT),ADDR=0,TIMEOUT=1")