959 lines
34 KiB
C++
959 lines
34 KiB
C++
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <wchar.h>
|
|
#include <stdarg.h>
|
|
|
|
#include <epicsEvent.h>
|
|
#include <epicsTime.h>
|
|
#include <epicsThread.h>
|
|
#include <iocsh.h>
|
|
#include <epicsString.h>
|
|
#include <epicsExit.h>
|
|
#include <epicsExport.h>
|
|
|
|
#include "hama.h"
|
|
// --- includes from DCMAPI ----
|
|
#include "dcamprop.h"
|
|
//
|
|
|
|
|
|
#define NUM_HAMA_PARAMS ((int)(&LAST_HAMA_PARAM - &FIRST_HAMA_PARAM + 1))
|
|
|
|
static const char *driverName="drvHama";
|
|
|
|
static void c_imagetask(void *arg) {
|
|
Hama *p = (Hama *)arg;
|
|
p->imageTask();
|
|
}
|
|
|
|
static void c_temperaturetask(void *arg) {
|
|
Hama *p = (Hama *)arg;
|
|
p->temperatureTask();
|
|
}
|
|
|
|
|
|
//============================================================================
|
|
Hama::Hama(const char* portName, int cameraId, int maxBuffers, size_t maxMemory,
|
|
int priority, int stackSize, int maxFrames)
|
|
: ADDriver(portName, 1, NUM_HAMA_PARAMS, maxBuffers, maxMemory,
|
|
asynEnumMask, asynEnumMask,
|
|
ASYN_CANBLOCK, /* ASYN_CANBLOCK=1 ASYN_MULTIDEVICE=0 */
|
|
1, /* autoConnect=1 */
|
|
priority, stackSize),
|
|
m_hdcam(NULL), m_id(0){
|
|
|
|
printf("[DEBUG] === Constructor ADHama ===\n");
|
|
printf("[DEBUG] driverName: %s\n", driverName);
|
|
|
|
stopThread = 0;
|
|
//General
|
|
|
|
createParam( HamaName, asynParamOctet, &hHamaName);
|
|
createParam( hVendorString, asynParamOctet, &hVendor);
|
|
createParam( hModelString, asynParamOctet, &hModel);
|
|
createParam( hCameraIDString, asynParamOctet, &hCameraID);
|
|
createParam( hBusString, asynParamOctet, &hBus);
|
|
createParam( hCameraVersionString, asynParamOctet, &hCameraVersion);
|
|
createParam( hDriverVersionString, asynParamOctet, &hDriverVersion);
|
|
createParam( hModuleVersionString, asynParamOctet, &hModuleVersion);
|
|
createParam( hDcamApiVersionString, asynParamOctet, &hDcamApiVersion);
|
|
|
|
//Sensor Mode and Speed
|
|
createParam( hSensorModeString, asynParamInt32, &hSensorMode);
|
|
createParam( hReadoutSpeedString, asynParamInt32, &hReadoutSpeed);
|
|
createParam( hReadoutDirectionString, asynParamInt32, &hReadoutDirection);
|
|
|
|
//Trigger
|
|
createParam( hTriggerModeString, asynParamInt32, &hTriggerMode);
|
|
createParam( hTriggerSourceString, asynParamInt32, &hTriggerSource);
|
|
createParam( hTriggerActiveString, asynParamInt32, &hTriggerActive);
|
|
createParam( hTriggerGlobalExposureString, asynParamInt32, &hTriggerGlobalExposure);
|
|
createParam( hTriggerPolarityString, asynParamInt32, &hTriggerPolarity);
|
|
createParam( hTriggerConnectorString, asynParamInt32, &hTriggerConnector);
|
|
createParam( hTriggerTimesString, asynParamInt32, &hTriggerTimes);
|
|
createParam( hTriggerDelayString, asynParamFloat64, &hTriggerDelay);
|
|
createParam( hInternalTriggerHandlingString, asynParamInt32, &hInternalTriggerHandling);
|
|
|
|
//Sensor cooler
|
|
createParam( hSensorTemperatureString, asynParamFloat64, &hSensorTemperature);
|
|
createParam( hSensorCoolerString, asynParamInt32, &hSensorCooler);
|
|
createParam( hSensorCoolerStatusString, asynParamInt32, &hSensorCoolerStatus);
|
|
|
|
//Binning and ROI
|
|
createParam( hBinningString, asynParamInt32, &hBinning);
|
|
createParam( hSubarrayHPosString, asynParamInt32, &hSubarrayHPos);
|
|
createParam( hSubarrayHSizeString, asynParamInt32, &hSubarrayHSize);
|
|
createParam( hSubarrayVPosString, asynParamInt32, &hSubarrayVPos);
|
|
createParam( hSubarrayVSizeString, asynParamInt32, &hSubarrayVSize);
|
|
createParam( hSubarrayModeString, asynParamInt32, &hSubarrayMode);
|
|
|
|
//Feature
|
|
createParam( hExposureTimeString, asynParamFloat64, &hExposureTime);
|
|
|
|
//ALU
|
|
createParam( hDefectCorrectModeString, asynParamInt32, &hDefectCorrectMode);
|
|
createParam( hHotPixelCorrectLevelString, asynParamInt32, &hHotPixelCorrectLevel);
|
|
createParam( hIntensityLutModeString, asynParamInt32, &hIntensityLutMode);
|
|
createParam( hIntensityLutPageString, asynParamInt32, &hIntensityLutPage);
|
|
createParam( hExtractionModeString, asynParamInt32, &hExtractionMode);
|
|
|
|
//output trigger
|
|
createParam( hNrOutputTriggerConnectorsString, asynParamInt32, &hNrOutputTriggerConnectors);
|
|
createParam( hOutputTriggerSource0String, asynParamInt32, &hOutputTriggerSource0),
|
|
createParam( hOutputTriggerSource1String, asynParamInt32, &hOutputTriggerSource1);
|
|
createParam( hOutputTriggerSource2String, asynParamInt32, &hOutputTriggerSource2);
|
|
createParam( hOutputTriggerPolarity0String, asynParamInt32, &hOutputTriggerPolarity0);
|
|
createParam( hOutputTriggerPolarity1String, asynParamInt32, &hOutputTriggerPolarity1);
|
|
createParam( hOutputTriggerPolarity2String, asynParamInt32, &hOutputTriggerPolarity2);
|
|
createParam( hOutputTriggerActive0String, asynParamInt32, &hOutputTriggerActive0);
|
|
createParam( hOutputTriggerActive1String, asynParamInt32, &hOutputTriggerActive1);
|
|
createParam( hOutputTriggerActive2String, asynParamInt32, &hOutputTriggerActive2);
|
|
createParam( hOutputTriggerDelay0String, asynParamFloat64, &hOutputTriggerDelay0);
|
|
createParam( hOutputTriggerDelay1String, asynParamFloat64, &hOutputTriggerDelay1);
|
|
createParam( hOutputTriggerDelay2String, asynParamFloat64, &hOutputTriggerDelay2);
|
|
createParam( hOutputTriggerPeriod0String, asynParamFloat64, &hOutputTriggerPeriod0);
|
|
createParam( hOutputTriggerPeriod1String, asynParamFloat64, &hOutputTriggerPeriod1);
|
|
createParam( hOutputTriggerPeriod2String, asynParamFloat64, &hOutputTriggerPeriod2);
|
|
createParam( hOutputTriggerKind0String, asynParamInt32, &hOutputTriggerKind0);
|
|
createParam( hOutputTriggerKind1String, asynParamInt32, &hOutputTriggerKind1);
|
|
createParam( hOutputTriggerKind2String, asynParamInt32, &hOutputTriggerKind2);
|
|
createParam( hOutputTriggerBaseSensor0String, asynParamInt32, &hOutputTriggerBaseSensor0);
|
|
createParam( hOutputTriggerBaseSensor1String, asynParamInt32, &hOutputTriggerBaseSensor1);
|
|
createParam( hOutputTriggerBaseSensor2String, asynParamInt32, &hOutputTriggerBaseSensor2);
|
|
createParam( hOutTriggerPreHsyncCountString, asynParamInt32, &hOutTriggerPreHsyncCount);
|
|
|
|
//Master Puls
|
|
createParam( hMasterPulseModeString, asynParamInt32, &hMasterPulseMode);
|
|
createParam( hMasterPulseTriggerSourceString, asynParamInt32, &hMasterPulseTriggerSource);
|
|
createParam( hMasterPulseIntervalString, asynParamFloat64, &hMasterPulseInterval);
|
|
createParam( hMasterPulseBurstTimesString, asynParamInt32, &hMasterPulseBurstTimes);
|
|
|
|
//Synchronious Timing
|
|
createParam( hTimingReadoutTimeString, asynParamFloat64, &hTimingReadoutTime);
|
|
createParam( hTimingCyclicTriggerPeriodString, asynParamFloat64, &hTimingCyclicTriggerPeriod);
|
|
createParam( hTimingMinTriggerBlankingString, asynParamFloat64, &hTimingMinTriggerBlanking);
|
|
createParam( hTimingMinTriggerIntervalString, asynParamFloat64, &hTimingMinTriggerInterval);
|
|
createParam( hTimingGlobalExposureDelayString, asynParamFloat64, &hTimingGlobalExposureDelay);
|
|
createParam( hTimingExposureString, asynParamInt32, &hTimingExposure);
|
|
createParam( hTimingInvalidExposurePeriodString, asynParamFloat64, &hTimingInvalidExposurePeriod);
|
|
createParam( hInternalFrameRateString, asynParamFloat64, &hInternalFrameRate);
|
|
createParam( hInternalFrameIntervalString, asynParamFloat64, &hInternalFrameInterval);
|
|
createParam( hInternalLineSpeedString, asynParamFloat64, &hInternalLineSpeed);
|
|
createParam( hInternalLineIntervalString, asynParamFloat64, &hInternalLineInterval);
|
|
|
|
//System Information
|
|
createParam( hColorTypeString, asynParamInt32, &hColorType);
|
|
createParam( hBitPerChannelString, asynParamInt32, &hBitPerChannel);
|
|
createParam( hImageWidthString, asynParamInt32, &hImageWidth);
|
|
createParam( hImageHeightString, asynParamInt32, &hImageHeight);
|
|
createParam( hImageRowBytesString, asynParamInt32, &hImageRowbytes);
|
|
createParam( hImageFrameBytesString, asynParamInt32, &hImageFramebytes);
|
|
createParam( hImageTopOffsetBytesString, asynParamInt32, &hImageTopOffsetBytes);
|
|
createParam( hImagePixelTypeString, asynParamInt32, &hImagePixelType);
|
|
createParam( hBufferRowbytesString, asynParamInt32, &hBufferRowbytes);
|
|
createParam( hBufferFramebytesString, asynParamInt32, &hBufferFramebytes);
|
|
createParam( hBufferTopOffsetBytesString, asynParamInt32, &hBufferTopOffsetBytes);
|
|
createParam( hBufferPixelTypeString, asynParamInt32, &hBufferPixelType);
|
|
createParam( hRecordFixedBytesPerFileString, asynParamInt32, &hRecordFixedBytesPerFile);
|
|
createParam( hRecordFixedBytesPerSessionString, asynParamInt32, &hRecordFixedBytesPerSession);
|
|
createParam( hRecordFixedBytesPerFrameString, asynParamInt32, &hRecordFixedBytesPerFrame);
|
|
createParam( hSystemAliveString, asynParamInt32, &hSystemAlive);
|
|
createParam( hConversionFactorCoeffString, asynParamFloat64, &hConversionFactorCoeff);
|
|
createParam( hConversionFactorOffsetString, asynParamFloat64, &hConversionFactorOffset);
|
|
createParam( hNumberOfViewString, asynParamInt32, &hNumberOfView);
|
|
createParam( hImageDetectorPixelWidthString, asynParamFloat64, &hImageDetectorPixelWidth);
|
|
createParam( hImageDetectorPixelHeightString, asynParamFloat64, &hImageDetectorPixelHeight);
|
|
createParam( hImageDetectorPixelNumHorzString, asynParamInt32, &hImageDetectorPixelNumHorz);
|
|
createParam( hImageDetectorPixelNumVertString, asynParamInt32, &hImageDetectorPixelNumVert);
|
|
createParam( hTimeStampProducerString, asynParamInt32, &hTimeStampProducer);
|
|
createParam( hFrameStampProducerString, asynParamInt32, &hFrameStampProducer);
|
|
|
|
|
|
|
|
connectCamera();
|
|
|
|
int err = 0;
|
|
|
|
/*
|
|
err |= getParameter(DCAM_IDPROP_SENSORMODE);
|
|
err |= getParameter(DCAM_IDPROP_READOUTSPEED);
|
|
err |= getParameter(DCAM_IDPROP_READOUT_DIRECTION);
|
|
err |= getParameter(DCAM_IDPROP_TRIGGERSOURCE);
|
|
err |= getParameter(DCAM_IDPROP_TRIGGER_MODE);
|
|
err |= getParameter(DCAM_IDPROP_TRIGGERACTIVE);
|
|
err |= getParameter(DCAM_IDPROP_TRIGGER_GLOBALEXPOSURE);
|
|
err |= getParameter(DCAM_IDPROP_TRIGGERPOLARITY);
|
|
err |= getParameter(DCAM_IDPROP_TRIGGER_CONNECTOR);
|
|
err |= getParameter(DCAM_IDPROP_TRIGGERTIMES);
|
|
err |= getParameter(DCAM_IDPROP_TRIGGERDELAY);
|
|
err |= getParameter(DCAM_IDPROP_INTERNALTRIGGER_HANDLING);
|
|
*/
|
|
|
|
|
|
err |= getParameterStr(DCAM_IDSTR_VENDOR);
|
|
err |= getParameterStr(DCAM_IDSTR_MODEL);
|
|
err |= getParameterStr(DCAM_IDSTR_CAMERAID);
|
|
err |= getParameterStr(DCAM_IDSTR_BUS);
|
|
err |= getParameterStr(DCAM_IDSTR_CAMERAVERSION);
|
|
err |= getParameterStr(DCAM_IDSTR_DRIVERVERSION);
|
|
err |= getParameterStr(DCAM_IDSTR_MODULEVERSION);
|
|
err |= getParameterStr(DCAM_IDSTR_DCAMAPIVERSION);
|
|
|
|
if(err){
|
|
printf("[DEBUG] Error = %d\n", err);
|
|
}
|
|
|
|
/* launch image read task */
|
|
epicsThreadCreate("HamaImageTask",
|
|
epicsThreadPriorityMedium,
|
|
epicsThreadGetStackSize(epicsThreadStackMedium),
|
|
c_imagetask, this);
|
|
|
|
/* launch temp read task */
|
|
epicsThreadCreate("HamaTemperatureTask",
|
|
epicsThreadPriorityMedium,
|
|
epicsThreadGetStackSize(epicsThreadStackMedium),
|
|
c_temperaturetask, this);
|
|
|
|
/* shutdown on exit */
|
|
//epicsAtExit(c_shutdown, this);
|
|
|
|
printf("[DEBUG] === END Constructor ADHama ===\n");
|
|
}
|
|
//============================================================================
|
|
//Hama::~Hama(){
|
|
// // not sure if the destructor has to be define here...
|
|
// printf("[DEBUG] === Destructor ADHama ===\n");
|
|
//}
|
|
|
|
//============================================================================
|
|
int Hama::getParameterStr(int propertyID){
|
|
|
|
asynStatus status = asynSuccess;
|
|
|
|
char text[256];
|
|
DCAMDEV_STRING param;
|
|
memset( ¶m, 0, sizeof(param) );
|
|
param.size = sizeof(param);
|
|
param.text = text;
|
|
param.textbytes = sizeof(text);
|
|
param.iString = propertyID;
|
|
|
|
switch (propertyID){
|
|
case DCAM_IDSTR_VENDOR:
|
|
dcamdev_getstring(m_hdcam, ¶m);
|
|
status = setStringParam(hVendor, text);
|
|
printf("[DEBUG]::VENDOR %s\n", text);
|
|
break;
|
|
case DCAM_IDSTR_MODEL:
|
|
dcamdev_getstring(m_hdcam, ¶m);
|
|
status = setStringParam(hModel, text);
|
|
printf("[DEBUG]::MODEL %s\n", text);
|
|
break;
|
|
case DCAM_IDSTR_CAMERAID:
|
|
dcamdev_getstring(m_hdcam, ¶m);
|
|
status = setStringParam(hCameraID, text);
|
|
printf("[DEBUG]::CAMERAID %s\n", text);
|
|
break;
|
|
case DCAM_IDSTR_BUS:
|
|
dcamdev_getstring(m_hdcam, ¶m);
|
|
status = setStringParam(hBus, text);
|
|
printf("[DEBUG]::BUS %s\n", text);
|
|
break;
|
|
case DCAM_IDSTR_CAMERAVERSION:
|
|
dcamdev_getstring(m_hdcam, ¶m);
|
|
status = setStringParam(hCameraVersion, text);
|
|
printf("[DEBUG]::CAMERAVERSION %s\n", text);
|
|
break;
|
|
case DCAM_IDSTR_DRIVERVERSION:
|
|
dcamdev_getstring(m_hdcam, ¶m);
|
|
status = setStringParam(hDriverVersion, text);
|
|
printf("[DEBUG]::DRIVERVERSION %s\n", text);
|
|
break;
|
|
case DCAM_IDSTR_MODULEVERSION:
|
|
dcamdev_getstring(m_hdcam, ¶m);
|
|
status = setStringParam(hModuleVersion, text);
|
|
printf("[DEBUG]::MODULEVERSION %s\n", text);
|
|
break;
|
|
case DCAM_IDSTR_DCAMAPIVERSION:
|
|
dcamdev_getstring(m_hdcam, ¶m);
|
|
status = setStringParam(hDcamApiVersion, text);
|
|
printf("[DEBUG]::DCAMPVERSION %s\n", text);
|
|
break;
|
|
default:
|
|
printf("[DEBUG]::NOT SUPPORTED\n");
|
|
break;
|
|
|
|
}
|
|
|
|
/* Do callbacks so higher layers see any changes */
|
|
status = (asynStatus) callParamCallbacks();
|
|
|
|
// asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: port=%s, value=%d, status=%d\n",
|
|
// driverName, functionName, this->portName, value, (int)status);
|
|
return int(status);
|
|
}
|
|
//============================================================================
|
|
int Hama::getParameter(int propertyID){
|
|
printf("\n[DEBUG] Function:getProperty\n");
|
|
|
|
double value = 0;
|
|
dcamprop_getvalue(m_hdcam, propertyID, &value);
|
|
|
|
switch (propertyID){
|
|
case DCAM_IDPROP_SENSORMODE:
|
|
printf("The SENSOR MODE = %f\n", value);
|
|
break;
|
|
|
|
case DCAM_IDPROP_READOUTSPEED:
|
|
printf("The READOUT SPEED = %f\n", value);
|
|
break;
|
|
|
|
case DCAM_IDPROP_READOUT_DIRECTION:
|
|
printf("The READOUT DIRECTION = %f\n", value);
|
|
break;
|
|
|
|
case DCAM_IDPROP_TRIGGERSOURCE:
|
|
printf("The = TRIGGER SOURCE = %f\n", value);
|
|
break;
|
|
|
|
case DCAM_IDPROP_TRIGGER_MODE:
|
|
printf("The TRIGGER MODE = %f\n", value);
|
|
break;
|
|
|
|
case DCAM_IDPROP_TRIGGERACTIVE:
|
|
printf("The TRIGGER ACTIVE = %f\n", value);
|
|
break;
|
|
|
|
case DCAM_IDPROP_TRIGGER_GLOBALEXPOSURE:
|
|
printf("The TRIGGER GLOBAL EXPOSURE = %f\n", value);
|
|
break;
|
|
|
|
case DCAM_IDPROP_TRIGGERPOLARITY:
|
|
printf("The TRIGGER POLARITY = %f\n", value);
|
|
break;
|
|
|
|
case DCAM_IDPROP_TRIGGER_CONNECTOR:
|
|
printf("The TRIGGER CONNECTOR = %f\n", value);
|
|
break;
|
|
|
|
case DCAM_IDPROP_TRIGGERTIMES:
|
|
printf("The TRIGGER TIMES = %f\n", value);
|
|
break;
|
|
|
|
case DCAM_IDPROP_TRIGGERDELAY:
|
|
printf("The TRIGGER DELAY = %f\n", value);
|
|
break;
|
|
|
|
case DCAM_IDPROP_INTERNALTRIGGER_HANDLING:
|
|
printf("The INTERNAL TRIGGE HANDLING = %f\n", value);
|
|
break;
|
|
|
|
default:
|
|
printf("The = %f\n", value);
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
//============================================================================
|
|
int Hama::setParameter(int paramIndex){
|
|
/*
|
|
setIntegerParam(ADBinY, 2048);
|
|
setIntegerParam(ADBinX, 2048);
|
|
setIntegerParam(NDNDimensions, 1);
|
|
setIntegerParam(NDArrayCounter, 1);
|
|
setIntegerParam(NDDataType, NDUInt16);
|
|
setIntegerParam(NDColorMode, NDColorModeMono);
|
|
setIntegerParam(NDArraySizeZ, 0);
|
|
setIntegerParam(NDArraySize, 5000000);
|
|
setStringParam(ADStringToServer, "<not used by driver>");
|
|
setStringParam(ADStringFromServer, "<not used by driver>");
|
|
setStringParam(ADManufacturer, "Hamamatsu");
|
|
*/
|
|
|
|
|
|
return 0;
|
|
}
|
|
|
|
//============================================================================
|
|
int Hama::getProperties(){
|
|
printf("\n[DEBUG] Function:getProperties\n");
|
|
|
|
int32 iProp = 0; // property IDs
|
|
|
|
double value = 50;
|
|
dcamprop_getvalue(m_hdcam, DCAM_IDPROP_SENSORTEMPERATURE, &value);
|
|
printf("The SENSOR TEMPERATURE = %f\n", value);
|
|
|
|
DCAMERR err;
|
|
err = dcamprop_getnextid( m_hdcam, &iProp, DCAMPROP_OPTION_SUPPORT );
|
|
if( failed(err) ) {
|
|
printError( m_hdcam, err, "dcamprop_getnextid()", "IDPROP:0x%08x, OPTION:SUPPORT", 0 );
|
|
return err;
|
|
}
|
|
|
|
do{
|
|
// get property name
|
|
char text[ 64 ];
|
|
err = dcamprop_getname( m_hdcam, iProp, text, sizeof(text) );
|
|
if( failed(err) ) {
|
|
printError( m_hdcam, err, "dcamprop_getname()", "IDPROP:0x%08x", iProp );
|
|
return err;
|
|
}
|
|
|
|
printf( "0x%08x: %s\n", iProp, text );
|
|
|
|
// get property attribute
|
|
DCAMPROP_ATTR basepropattr;
|
|
memset( &basepropattr, 0, sizeof(basepropattr) );
|
|
basepropattr.cbSize = sizeof(basepropattr);
|
|
basepropattr.iProp = iProp;
|
|
|
|
err = dcamprop_getattr( m_hdcam, &basepropattr );
|
|
if( !failed(err) ) {
|
|
|
|
#if SHOW_PROPERTY_ATTRIBUTE
|
|
// show property attribute
|
|
//dcamcon_show_propertyattr( basepropattr );
|
|
#endif
|
|
|
|
#if SHOW_PROPERTY_MODEVALUELIST
|
|
// show mode value list of property
|
|
//if( (basepropattr.attribute & DCAMPROP_TYPE_MASK) == DCAMPROP_TYPE_MODE )
|
|
// dcamcon_show_supportmodevalues( m_hdcam, iProp, basepropattr.valuemin );
|
|
#endif
|
|
|
|
#if SHOW_PROPERTY_ARRAYELEMENT
|
|
// show array element
|
|
//if( basepropattr.attribute2 & DCAMPROP_ATTR2_ARRAYBASE )
|
|
// dcamcon_show_arrayelement( m_hdcam, basepropattr );
|
|
#endif
|
|
}
|
|
|
|
// get next property id
|
|
err = dcamprop_getnextid( m_hdcam, &iProp, DCAMPROP_OPTION_SUPPORT );
|
|
if( failed(err) ) {
|
|
// no more supported property id
|
|
return err;
|
|
}
|
|
|
|
} while( iProp != 0 );
|
|
|
|
return 0;
|
|
}
|
|
//============================================================================
|
|
void Hama::imageTask(){
|
|
|
|
|
|
}
|
|
//============================================================================
|
|
void Hama::temperatureTask(){
|
|
static const char *functionName = "tempTask";
|
|
asynStatus status = asynSuccess;
|
|
double value = 0;
|
|
|
|
while( !stopThread ) {
|
|
m_err = dcamprop_getvalue(m_hdcam, DCAM_IDPROP_SENSORTEMPERATURE, &value);
|
|
|
|
if(m_err != DCAMERR_SUCCESS){
|
|
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
|
|
"%s:%s: temperature read error = %d\n",
|
|
driverName, functionName, m_err);
|
|
}
|
|
else{
|
|
setDoubleParam(hSensorTemperature, value);
|
|
//printf("Temperature = %f\n",value);
|
|
}
|
|
|
|
status = (asynStatus) callParamCallbacks();
|
|
epicsThreadSleep(1.0);
|
|
|
|
}
|
|
|
|
}
|
|
//============================================================================
|
|
|
|
asynStatus Hama::writeInt32(asynUser *pasynUser, epicsInt32 value){
|
|
|
|
printf("[DEBUG]::writeInt32\t");
|
|
asynStatus status = asynSuccess;
|
|
const char* functionName = "writeInt32";
|
|
const char* paramName;
|
|
|
|
int index = pasynUser->reason;
|
|
|
|
getParamName(index, ¶mName);
|
|
|
|
double value_d = 0;
|
|
//getIntegerParam(index, &value);
|
|
|
|
if (index == ADAcquire) {
|
|
printf("function ADAcquire\n");
|
|
}
|
|
else if (index == ADImageMode) {
|
|
printf("function ADImageMode\n");
|
|
}
|
|
else if (index == ADNumExposures) {
|
|
printf("function ADNumExposures\n");
|
|
}
|
|
else if (index == ADMinX) {
|
|
printf("function ADMinX\n");
|
|
}
|
|
else if (index == ADMinY) {
|
|
printf("function ADMinY\n");
|
|
}
|
|
else if (index == ADSizeX) {
|
|
printf("function ADSizeX\n");
|
|
}
|
|
else if (index == ADSizeY) {
|
|
printf("function ADSizeY\n");
|
|
}
|
|
else if (index == ADReadStatus) {
|
|
printf("function ADReadStatus\n");
|
|
}
|
|
else if (index == hSensorMode) {
|
|
setIntegerParam(index, value);
|
|
printf("function SensorMode\n");
|
|
}
|
|
else if (index == hReadoutSpeed) {
|
|
printf("function ReadoutSpeed\n");
|
|
|
|
}
|
|
else if (index == hReadoutDirection) {
|
|
printf("function ReadoutDirection\n");
|
|
}
|
|
else if (index == hColorType) {
|
|
printf("function ColorType\n");
|
|
}
|
|
else if (index == hBitPerChannel) {
|
|
printf("function BitPerChannel\n");
|
|
}
|
|
else if (index == hTriggerSource) {
|
|
dcamprop_setvalue(m_hdcam, DCAM_IDPROP_TRIGGERSOURCE, value);
|
|
dcamprop_getvalue(m_hdcam, DCAM_IDPROP_TRIGGERSOURCE, &value_d);
|
|
}
|
|
else if (index == hTriggerMode) {
|
|
dcamprop_setvalue(m_hdcam, DCAM_IDPROP_TRIGGER_MODE, value);
|
|
dcamprop_getvalue(m_hdcam, DCAM_IDPROP_TRIGGER_MODE, &value_d);
|
|
}
|
|
else if (index == hTriggerActive) {
|
|
dcamprop_setvalue(m_hdcam, DCAM_IDPROP_TRIGGERACTIVE, value);
|
|
dcamprop_getvalue(m_hdcam, DCAM_IDPROP_TRIGGERACTIVE, &value_d);
|
|
}
|
|
else if (index == hTriggerGlobalExposure) {
|
|
dcamprop_setvalue(m_hdcam, DCAM_IDPROP_TRIGGER_GLOBALEXPOSURE, value);
|
|
dcamprop_getvalue(m_hdcam, DCAM_IDPROP_TRIGGER_GLOBALEXPOSURE, &value_d);
|
|
}
|
|
else if (index == hTriggerPolarity) {
|
|
dcamprop_setvalue(m_hdcam, DCAM_IDPROP_TRIGGERPOLARITY, value);
|
|
dcamprop_getvalue(m_hdcam, DCAM_IDPROP_TRIGGERPOLARITY, &value_d);
|
|
}
|
|
else if (index == hTriggerConnector) {
|
|
dcamprop_setvalue(m_hdcam, DCAM_IDPROP_TRIGGER_CONNECTOR, value);
|
|
dcamprop_getvalue(m_hdcam, DCAM_IDPROP_TRIGGER_CONNECTOR, &value_d);
|
|
}
|
|
else if (index == hTriggerTimes) {
|
|
dcamprop_setvalue(m_hdcam, DCAM_IDPROP_TRIGGERTIMES, value);
|
|
dcamprop_getvalue(m_hdcam, DCAM_IDPROP_TRIGGERTIMES, &value_d);
|
|
}
|
|
else if (index == hInternalTriggerHandling) {
|
|
dcamprop_setvalue(m_hdcam, DCAM_IDPROP_INTERNALTRIGGER_HANDLING, value);
|
|
dcamprop_getvalue(m_hdcam, DCAM_IDPROP_INTERNALTRIGGER_HANDLING, &value_d);
|
|
}
|
|
else{
|
|
printf("function ELSE.... \n");
|
|
|
|
}
|
|
|
|
setIntegerParam(index, value_d);
|
|
|
|
/* Do callbacks so higher layers see any changes */
|
|
status = (asynStatus) callParamCallbacks();
|
|
|
|
if (status)
|
|
asynPrint(pasynUser, ASYN_TRACE_ERROR,
|
|
"%s:%s: error, status=%d function=%d, paramName=%s, value=%d\n",
|
|
driverName, functionName, status, index, paramName, value);
|
|
else
|
|
asynPrint(pasynUser, ASYN_TRACEIO_DRIVER,
|
|
"%s:%s: function=%d, paramName=%s, value=%d\n",
|
|
driverName, functionName, index, paramName, value);
|
|
|
|
return status;
|
|
}
|
|
|
|
//============================================================================
|
|
|
|
asynStatus Hama::writeFloat64(asynUser *pasynUser, epicsFloat64 value){
|
|
|
|
// printf("[DEBUG]::writeFloat64\t");
|
|
asynStatus status = asynSuccess;
|
|
const char* functionName = "writeFloat64";
|
|
const char* paramName;
|
|
|
|
int function = pasynUser->reason;
|
|
|
|
|
|
getParamName(function, ¶mName);
|
|
|
|
setDoubleParam(function, value);
|
|
|
|
status = (asynStatus) callParamCallbacks();
|
|
|
|
if (status)
|
|
asynPrint(pasynUser, ASYN_TRACE_ERROR,
|
|
"%s:%s: error, status=%d function=%d, paramName=%s, value=%f\n",
|
|
driverName, functionName, status, function, paramName, value);
|
|
else
|
|
asynPrint(pasynUser, ASYN_TRACEIO_DRIVER,
|
|
"%s:%s: function=%d, paramName=%s, value=%f\n",
|
|
driverName, functionName, function, paramName, value);
|
|
|
|
|
|
|
|
return(asynSuccess);
|
|
}
|
|
|
|
//============================================================================
|
|
/*
|
|
asynStatus Hama::readEnum(asynUser *pasynUser, char *strings[], int values[],
|
|
int severities[], size_t nElements, size_t *nIn){
|
|
|
|
printf("[DEBUG]::readEnum\t");
|
|
const char* functionName = "readEnum";
|
|
const char *paramName;
|
|
|
|
int function = pasynUser->reason;
|
|
asynStatus status = asynSuccess;
|
|
|
|
|
|
getParamName(function, ¶mName);
|
|
|
|
|
|
double value = 0;
|
|
dcamprop_getvalue(m_hdcam, function, &value);
|
|
|
|
// dcamprop_setvalue(m_hdcam, function, value);
|
|
|
|
if (function == hSensorMode) {
|
|
printf("function Sensor Mode\n");
|
|
}
|
|
else if (function == hReadoutDirection) {
|
|
printf("function Readout Direction\n");
|
|
}
|
|
else if (function == hTriggerSource) {
|
|
printf("function Trigger Source\n");
|
|
dcamprop_getvalue(m_hdcam, DCAM_IDPROP_TRIGGERSOURCE, &value);
|
|
setIntegerParam(function, value);
|
|
|
|
}
|
|
else if (function == hTriggerMode) {
|
|
printf("function Trigger Mode\n");
|
|
}
|
|
else if (function == hTriggerActive) {
|
|
printf("function Trigger Active\n");
|
|
}
|
|
else if (function == hTriggerGlobalExposure) {
|
|
printf("function Trigger Global Exposure\n");
|
|
}
|
|
else if (function == hTriggerPolarity) {
|
|
printf("function Trigger Polarity\n");
|
|
}
|
|
else if (function == hTriggerConnector) {
|
|
printf("function TriggerConnector\n");
|
|
}
|
|
else if (function == hInternalTriggerHandling) {
|
|
printf("function Internal Trigger Handling\n");
|
|
}
|
|
else if (function == hSensorCooler) {
|
|
printf("function Sensor Cooler\n");
|
|
}
|
|
else if (function == hSensorCoolerStatus){
|
|
printf("function Sensor Cooler Status\n");
|
|
}
|
|
///////////////////////////////////////////////////////////////////
|
|
else if (function == hColorType) {
|
|
printf("function Color Type\n");
|
|
}
|
|
else if (function == hImagePixelType) {
|
|
printf("function Image Pixel Type\n");
|
|
}
|
|
else if (function == hBufferPixelType) {
|
|
printf("function Buffer Pixel Type\n");
|
|
}
|
|
else if (function == hSystemAlive) {
|
|
printf("function System Alive\n");
|
|
}
|
|
else if (function == hTimeStampProducer) {
|
|
printf("function Time Stamp Producer\n");
|
|
}
|
|
else if (function == hFrameStampProducer) {
|
|
printf("function Frame Stamp producer\n");
|
|
}
|
|
// else if (function == ) {
|
|
// printf("function \n");
|
|
// }
|
|
// else if (function == ) {
|
|
// printf("function \n");
|
|
// }
|
|
// else if (function == ) {
|
|
// printf("function \n");
|
|
// }
|
|
else {
|
|
printf("function ELSE....\n");
|
|
}
|
|
*nIn = 0;
|
|
|
|
status = (asynStatus) callParamCallbacks();
|
|
|
|
asynPrint(pasynUserSelf, ASYN_TRACEIO_DRIVER,
|
|
"%s:%s: entry, function=%d, string=%s\n", driverName, functionName, function, strings[0]);
|
|
|
|
return(asynSuccess);
|
|
}
|
|
*/
|
|
//============================================================================
|
|
|
|
void Hama::report(FILE *fp, int details){
|
|
|
|
printf("[DEBUG]::report\n");
|
|
}
|
|
|
|
//============================================================================
|
|
int Hama::connectCamera(void){
|
|
|
|
static const char *functionName = "connectCamera";
|
|
int nDevices = 0;
|
|
int iDevice = 0;
|
|
/* disconnect any connected camera first */
|
|
disconnectCamera();
|
|
|
|
/* initialize api */
|
|
memset(&m_apiInit, 0, sizeof(m_apiInit));
|
|
m_apiInit.size = sizeof(m_apiInit);
|
|
|
|
asynPrint(pasynUserSelf, ASYN_TRACE_FLOW,
|
|
"%s:%s: connecting camera %d\n",
|
|
driverName, functionName, m_id);
|
|
|
|
m_err = dcamapi_init( &m_apiInit);
|
|
if( failed(m_err) ){
|
|
printError( m_hdcam, m_err, "dcamapi_init()", NULL );
|
|
} else {
|
|
nDevices = m_apiInit.iDeviceCount;
|
|
printf("dcamapi_init() found %d device(s). \n", nDevices);
|
|
printf("camera with index 0 will be used\n");
|
|
iDevice = 0;
|
|
}
|
|
|
|
/* open handle to camera */
|
|
memset( &m_devOpen, 0, sizeof(m_devOpen) );
|
|
m_devOpen.size = sizeof(m_devOpen);
|
|
m_devOpen.index = iDevice;
|
|
m_err = dcamdev_open( &m_devOpen );
|
|
|
|
if( failed(m_err) ){
|
|
printError( m_hdcam, m_err, "dcamapi_init()" );
|
|
|
|
} else {
|
|
m_hdcam = m_devOpen.hdcam;
|
|
printInfo( m_hdcam );
|
|
}
|
|
|
|
// if(status != AT_SUCCESS) {
|
|
// asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
|
|
// "%s:%s: unable to open camera %d\n",
|
|
// driverName, functionName, m_id);
|
|
// return status;
|
|
// }
|
|
|
|
int ferr = allocateBuffers(10);
|
|
if( ferr ){
|
|
printError( m_hdcam, m_err, "dcambuf_alloc()" );
|
|
// return = 1;
|
|
}
|
|
|
|
/* close api */ //- it should be here??????????????
|
|
// dcamapi_uninit();
|
|
// return status;
|
|
return 0;
|
|
}
|
|
|
|
//============================================================================
|
|
int Hama::disconnectCamera(void){
|
|
|
|
static const char *functionName = "disconnectCamera";
|
|
|
|
int status = 0;
|
|
|
|
|
|
if(m_hdcam == NULL) {
|
|
return status;
|
|
}
|
|
|
|
asynPrint(pasynUserSelf, ASYN_TRACE_FLOW,
|
|
"%s:%s: disconnecting camera %d\n",
|
|
driverName, functionName, m_id);
|
|
|
|
// status = AT_GetBool(handle_, L"CameraAcquiring", &acquiring);
|
|
// if(status == AT_SUCCESS && acquiring) {
|
|
// status |= AT_Command(handle_, L"Acquisition Stop");
|
|
// }
|
|
|
|
// status |= freeBuffers();
|
|
dcamdev_close( m_hdcam );
|
|
|
|
if(status) {
|
|
asynPrint(pasynUserSelf, ASYN_TRACE_ERROR,
|
|
"%s:%s: error closing camera %d\n",
|
|
driverName, functionName, m_id);
|
|
}
|
|
|
|
m_hdcam = NULL;
|
|
return status;
|
|
|
|
|
|
}
|
|
//============================================================================
|
|
int Hama::allocateBuffers(unsigned int nBuffers){
|
|
|
|
m_err = dcambuf_alloc( m_hdcam, nBuffers );
|
|
if( failed(m_err) )
|
|
return 1;
|
|
|
|
return 0;
|
|
}
|
|
|
|
//============================================================================
|
|
int Hama::freeBuffers(){
|
|
m_err = dcambuf_release( m_hdcam );
|
|
if( failed(m_err) )
|
|
printError( m_hdcam, m_err, "dcambuf_release()" );
|
|
|
|
return 0;
|
|
}
|
|
//============================================================================
|
|
void Hama::printError(HDCAM hdcam, DCAMERR errid, const char* apiname, const char* fmt, ...){
|
|
|
|
char errtext[ 256 ];
|
|
|
|
DCAMERR err;
|
|
dcamdev_string( err, hdcam, errid, errtext, sizeof(errtext) );
|
|
|
|
printf( "-[ERROR]- (DCAMERR) 0x%08X %s @ %s", errid, errtext, apiname );
|
|
|
|
if( fmt != NULL ) {
|
|
printf( " : " );
|
|
|
|
va_list arg;
|
|
va_start(arg,fmt);
|
|
vprintf( fmt, arg );
|
|
va_end(arg);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
//============================================================================
|
|
|
|
void Hama::printInfo(HDCAM hdcam){
|
|
|
|
char model[ 256 ];
|
|
char cameraid[ 64 ];
|
|
char bus[ 64 ];
|
|
|
|
DCAMERR err;
|
|
if( ! dcamdev_string( err, hdcam, DCAM_IDSTR_MODEL, model, sizeof(model) ) ) {
|
|
printError( hdcam, err, "dcamdev_getstring(DCAM_IDSTR_MODEL)\n" );
|
|
}
|
|
else if( ! dcamdev_string( err, hdcam, DCAM_IDSTR_CAMERAID, cameraid, sizeof(cameraid)) ) {
|
|
printError( hdcam, err, "dcamdev_getstring(DCAM_IDSTR_CAMERAID)\n" );
|
|
}
|
|
else if( ! dcamdev_string( err, hdcam, DCAM_IDSTR_BUS, bus, sizeof(bus) ) ) {
|
|
printError( hdcam, err, "dcamdev_getstring(DCAM_IDSTR_BUS)\n" );
|
|
}
|
|
else {
|
|
printf( "%s (%s) on %s\n", model, cameraid, bus );
|
|
}
|
|
|
|
}
|
|
|
|
|
|
//============================================================================
|
|
|
|
int Hama::dcamdev_string( DCAMERR& err, HDCAM hdcam, int32 idStr, char* text, int32 textbytes ) {
|
|
|
|
DCAMDEV_STRING param;
|
|
memset( ¶m, 0, sizeof(param) );
|
|
param.size = sizeof(param);
|
|
param.text = text;
|
|
param.textbytes = textbytes;
|
|
param.iString = idStr;
|
|
|
|
err = dcamdev_getstring( hdcam, ¶m );
|
|
return ! failed( err );
|
|
}
|
|
|
|
//============================================================================
|
|
//============================================================================
|
|
/* Code for iocsh registration */
|
|
|
|
|
|
|
|
extern "C" int HamaConfig(const char *portName, int cameraId, int maxBuffers,
|
|
size_t maxMemory, int priority, int stackSize,
|
|
int maxFrames) {
|
|
new Hama(portName, cameraId, maxBuffers, maxMemory, priority, stackSize,
|
|
maxFrames);
|
|
|
|
return(asynSuccess);
|
|
}
|
|
|
|
//============================================================================
|
|
static const iocshArg HamaConfigArg0 = {"Port name", iocshArgString};
|
|
static const iocshArg HamaConfigArg1 = {"CameraId", iocshArgInt};
|
|
static const iocshArg HamaConfigArg2 = {"maxBuffers", iocshArgInt};
|
|
static const iocshArg HamaConfigArg3 = {"maxMemory", iocshArgInt};
|
|
static const iocshArg HamaConfigArg4 = {"priority", iocshArgInt};
|
|
static const iocshArg HamaConfigArg5 = {"stackSize", iocshArgInt};
|
|
static const iocshArg HamaConfigArg6 = {"maxFrames", iocshArgInt};
|
|
static const iocshArg * const HamaConfigArgs[] = { &HamaConfigArg0,
|
|
&HamaConfigArg1,
|
|
&HamaConfigArg2,
|
|
&HamaConfigArg3,
|
|
&HamaConfigArg4,
|
|
&HamaConfigArg5,
|
|
&HamaConfigArg6 };
|
|
//============================================================================
|
|
static const iocshFuncDef confighama = {"devHamamatsuConfig", 7, HamaConfigArgs};
|
|
|
|
//============================================================================
|
|
static void confighamaCallFunc(const iocshArgBuf *args) {
|
|
HamaConfig(args[0].sval, args[1].ival, args[2].ival, args[3].ival,
|
|
args[4].ival, args[5].ival, args[6].ival);
|
|
}
|
|
|
|
//============================================================================
|
|
static void hamaRegister(void) {
|
|
|
|
iocshRegister(&confighama, confighamaCallFunc);
|
|
}
|
|
|
|
//============================================================================
|
|
extern "C" {
|
|
|
|
epicsExportRegistrar(hamaRegister);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|