Add frame rate and control to acquire period PV

This commit is contained in:
Douglas Araujo
2022-12-30 17:22:13 +01:00
committed by Iocuser
parent e15fafea4b
commit ee066ef720
3 changed files with 64 additions and 14 deletions
+12 -3
View File
@@ -118,6 +118,15 @@ record(ai, "$(P)$(R)TimeStamp-RB") {
field(PINI, "YES")
}
record(ai, "$(P)$(R)FrameRate-R") {
field(DESC, "Acquisition frame rate")
field(DTYP, "asynFloat64")
field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))H_FRAMERATE")
field(PREC, "2")
field(SCAN, "I/O Intr")
field(PINI, "YES")
}
##########################################################################
# General properties #
##########################################################################
@@ -1371,10 +1380,8 @@ record(mbbo, "$(P)$(R)MasterPulseMode-S") {
field(ONST, "Start")
field(TWVL, "3")
field(THST, "Burst")
# field(DRVL, "1")
# field(DRVH, "3")
field(OUT, "@asyn($(PORT),$(ADDR),$(TIMEOUT))H_MASTERPULSE_MODE")
field(VAL, "1")
field(VAL, "0")
}
record(mbbi, "$(P)$(R)MasterPulseMode-RB") {
@@ -1423,6 +1430,7 @@ record(ao, "$(P)$(R)MasterPulseInterval-S") {
field(DESC, "")
field(PINI, "YES")
field(DTYP, "asynFloat64")
field(PREC, "6")
field(DRVL, "0.00001")
field(DRVH, "10")
field(OUT, "@asyn($(PORT),$(ADDR),$(TIMEOUT))H_MASTERPULSE_INTERVAL")
@@ -1432,6 +1440,7 @@ record(ao, "$(P)$(R)MasterPulseInterval-S") {
record(ai, "$(P)$(R)MasterPulseInterval-RB") {
field(DESC, "")
field(DTYP, "asynFloat64")
field(PREC, "6")
field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))H_MASTERPULSE_INTERVAL")
field(SCAN, "I/O Intr")
}
+50 -9
View File
@@ -18,6 +18,8 @@
//
#include <unistd.h>
#include <iostream>
using namespace std;
//#define NUM_HAMA_PARAMS ((int)(&LAST_HAMA_PARAM - &FIRST_HAMA_PARAM + 1))
@@ -61,7 +63,7 @@ Hama::Hama(const char* portName, int cameraId, int maxBuffers, size_t maxMemory,
}
//General
createParam( hFrameRateString, asynParamOctet, &hFrameRate);
createParam( hFrameRateString, asynParamFloat64, &hFrameRate);
createParam( hHamaNameString, asynParamOctet, &hHamaName);
createParam( hVendorString, asynParamOctet, &hVendor);
createParam( hModelString, asynParamOctet, &hModel);
@@ -729,6 +731,8 @@ void Hama::imageTask(){
int totalImages=0;
uint64_t prevAcquisitionCount = 0;
DCAMCAP_TRANSFERINFO captransferinfo;
epicsTimeStamp prevAcqTime, currentAcqTime;
double elapsedTime;
//static const char *functionName = "imageTask";
@@ -749,6 +753,7 @@ void Hama::imageTask(){
setIntegerParam(ADStatus, ADStatusAcquire);
status = startAcquire();
epicsTimeGetCurrent(&prevAcqTime);
printf("Status: %d\n", status);
if (status != asynSuccess) {
//acquireStatusError = 1;
@@ -790,6 +795,7 @@ void Hama::imageTask(){
image = new unsigned char[width * 2 * height];
memset(image, 0, width * 2 * height);
getIntegerParam(NDArrayCounter, &count);
count++;
setIntegerParam(NDArrayCounter, count);
@@ -818,6 +824,12 @@ void Hama::imageTask(){
printf("Timestamp from camera: %f\n", (ts_sec + ts_microsec / 1.0e6));
//printf("Timestamp from camera with correction: %f\n", timestamp);
epicsTimeGetCurrent(&currentAcqTime);
elapsedTime = epicsTimeDiffInSeconds(&currentAcqTime, &prevAcqTime);
prevAcqTime = currentAcqTime;
status = setDoubleParam(hFrameRate, (double)(1 / elapsedTime));
getIntegerParam(NDArrayCallbacks, &callback);
if(callback) {
@@ -1482,12 +1494,43 @@ asynStatus Hama::writeFloat64(asynUser *pasynUser, epicsFloat64 value){
//-- Feature
if(index == ADAcquireTime) {
printf("[DEBUG]::function ADAcquireTime from camera: %f\n", value);
status = (asynStatus)setFeature(DCAM_IDPROP_EXPOSURETIME, value);
status = setFeature(DCAM_IDPROP_EXPOSURETIME, value);
m_err = dcamprop_setgetvalue(m_hdcam, DCAM_IDPROP_EXPOSURETIME, &dvalue);
if(failed(m_err)) {
printError(m_hdcam, m_err, "dcamprop_setgetvalue()", "IDPROP:0x%08x, VALUE:%f\n", index, dvalue);
}
double acquire_period = 0;
status = getDoubleParam(ADAcquirePeriod, &acquire_period);
if (value >= acquire_period) {
status = setDoubleParam(ADAcquirePeriod, 0);
status = setFeature(DCAM_IDPROP_TRIGGERSOURCE, DCAMPROP_TRIGGERSOURCE__INTERNAL);
status = setIntegerParam(hTriggerSource, DCAMPROP_TRIGGERSOURCE__INTERNAL);
callParamCallbacks();
}
}
if(index == ADAcquirePeriod) {
printf("[DEBUG]::function ADAcquirePeriod from camera: %f\n", value);
m_err = dcamprop_getvalue(m_hdcam, DCAM_IDPROP_EXPOSURETIME, &dvalue);
if (value <= dvalue) {
status = setFeature(DCAM_IDPROP_TRIGGERSOURCE, DCAMPROP_TRIGGERSOURCE__INTERNAL);
status = setIntegerParam(hTriggerSource, DCAMPROP_TRIGGERSOURCE__INTERNAL);
value = 0;
}
else {
status = setFeature(DCAM_IDPROP_TRIGGERSOURCE, DCAMPROP_TRIGGERSOURCE__MASTERPULSE);
status = setIntegerParam(hTriggerSource, DCAMPROP_TRIGGERSOURCE__MASTERPULSE);
status = setFeature(DCAM_IDPROP_MASTERPULSE_INTERVAL, value);
status = setDoubleParam(hMasterPulseInterval, value);
status = setFeature(DCAM_IDPROP_MASTERPULSE_MODE, DCAMPROP_MASTERPULSE_MODE__CONTINUOUS);
status = setIntegerParam(hMasterPulseMode, DCAMPROP_MASTERPULSE_MODE__CONTINUOUS);
}
}
//-- Trigger
else if (index == hTriggerDelay) {
printf("[DEBUG]::function TriggerDelay %f\n", value);
@@ -1595,6 +1638,8 @@ asynStatus Hama::writeFloat64(asynUser *pasynUser, epicsFloat64 value){
printError(m_hdcam, m_err, "dcamprop_setgetvalue()", "IDPROP:0x%08x, VALUE:%f\n", index, dvalue);
}
}*/
/* THESE PARAMETERS ARE READ ONLY
else if (index == hInternalFrameRate) {
int sensorMode = 0;
getIntegerParam(hSensorMode, &sensorMode);
@@ -1615,6 +1660,8 @@ asynStatus Hama::writeFloat64(asynUser *pasynUser, epicsFloat64 value){
printError(m_hdcam, m_err, "dcamprop_setgetvalue()", "IDPROP:0x%08x, VALUE:%f\n", index, dvalue);
}
}
*/
else if (index == hInternalLineSpeed) {
printf("[DEBUG]::function InternalLineSpeed %f\n", value);
m_err = dcamprop_setgetvalue(m_hdcam, DCAM_IDPROP_INTERNALLINESPEED, &dvalue);
@@ -2243,7 +2290,7 @@ return ! failed( err );
}
//============================================================================
int Hama::setFeature(int featureIndex, double value) {
asynStatus Hama::setFeature(int featureIndex, double value) {
DCAMERR err;
err = dcamprop_setvalue(m_hdcam, featureIndex, value);
if(failed(err)) {
@@ -2372,9 +2419,3 @@ extern "C" {
epicsExportRegistrar(hamaRegister);
}
+2 -2
View File
@@ -6,7 +6,7 @@
#define MAX_FEATURE_NAME_LEN 64
#define hFrameRateString "H_FRAME_RATE" /* asynOctet ro */
#define hFrameRateString "H_FRAMERATE"
#define hHamaNameString "H_HAMA_NAME" /* asynOctet ro */
#define hVendorString "H_VENDOR" /* asynOctet ro */
#define hModelString "H_MODEL" /* asynOctet ro */
@@ -303,7 +303,7 @@ private:
int setParameter(int paramIndex);
int getParameterStr(int paramIndex);
int getProperties();
int setFeature(int featureIndex, double value);
asynStatus setFeature(int featureIndex, double value);
};
#endif