diff --git a/ADHamaApp/Db/hama.template b/ADHamaApp/Db/hama.template index 1db9f4e..e4deaf2 100644 --- a/ADHamaApp/Db/hama.template +++ b/ADHamaApp/Db/hama.template @@ -109,6 +109,15 @@ record(calc, "$(P)$(R)EVRTime-R") { field(INPB, "$(P)$(R)#EVRTimeProc") } +record(ai, "$(P)$(R)TimeStamp-RB") { + field(DESC, "DCAM Timestamp when trigger received") + field(DTYP, "asynFloat64") + field(INP, "@asyn($(PORT),$(ADDR),$(TIMEOUT))H_TIMESTAMP") + field(PREC, "3") + field(SCAN, "I/O Intr") + field(PINI, "YES") +} + ########################################################################## # General properties # ########################################################################## diff --git a/ADHamaApp/src/hama.cpp b/ADHamaApp/src/hama.cpp index ccbfa43..d216d21 100644 --- a/ADHamaApp/src/hama.cpp +++ b/ADHamaApp/src/hama.cpp @@ -181,6 +181,7 @@ Hama::Hama(const char* portName, int cameraId, int maxBuffers, size_t maxMemory, createParam( hImageDetectorPixelNumVertString, asynParamInt32, &hImageDetectorPixelNumVert); createParam( hTimeStampProducerString, asynParamInt32, &hTimeStampProducer); createParam( hFrameStampProducerString, asynParamInt32, &hFrameStampProducer); + createParam( hTimeStampString, asynParamFloat64, &hTimeStamp); setIntegerParam(NDArrayCallbacks, 1); @@ -672,7 +673,15 @@ void Hama::imageTask(){ accessCapturedImage(m_hdcam, captransferinfo.nNewestFrameIndex, image, width * 2, width, height, ts_sec, ts_microsec); - // printf("Timestamp from camera: %d\n", ts_sec + ts_microsec); + double exposure_time, readout_time, timestamp; + dcamprop_getvalue(m_hdcam, DCAM_IDPROP_TIMING_READOUTTIME, &readout_time); + dcamprop_getvalue(m_hdcam, DCAM_IDPROP_EXPOSURETIME, &exposure_time); + timestamp = (ts_sec + ts_microsec / 1.0e6) - (exposure_time + readout_time); + status = setDoubleParam(hTimeStamp, timestamp); + + //printf("Timestamp from camera: %f\n", (ts_sec + ts_microsec / 1.0e6)); + //printf("Timestamp from camera with correction: %f\n", timestamp); + getIntegerParam(NDArrayCallbacks, &callback); if(callback) { diff --git a/ADHamaApp/src/hama.h b/ADHamaApp/src/hama.h index 3ce2ee9..a5b09a5 100644 --- a/ADHamaApp/src/hama.h +++ b/ADHamaApp/src/hama.h @@ -128,6 +128,7 @@ #define hImageDetectorPixelNumVertString "H_IMAGE_DETECTOR_PIXEL_NUM_VERT" /* asynInt32 ro */ #define hTimeStampProducerString "H_TIMESTAMP_PRODUCER" /* asynInt32 ro */ #define hFrameStampProducerString "H_FRAMESTAMP_PRODUCER" /* asynInt32 ro */ +#define hTimeStampString "H_TIMESTAMP" /* asynFloat64 ro */ // For some reason these two addresses are not defined in the dcamapi4 neither in dcamprop.h #define DETECTOR_PIXEL_NUM_HORZ 0x00420830 @@ -249,7 +250,8 @@ protected: int hImageDetectorPixelNumVert; int hTimeStampProducer; int hFrameStampProducer; - #define LAST_HAMA_PARAM hFrameStampProducer + int hTimeStamp; + #define LAST_HAMA_PARAM hTimeStamp private: