Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38218b883e | ||
|
|
77b5441d23 | ||
|
|
7ee6421657 | ||
|
|
def770e2f8 | ||
|
|
cceb18989b | ||
|
|
e2d6d48cde | ||
|
|
62065f7f44 | ||
|
|
00cb454e8c | ||
|
|
66cbff0ca4 | ||
|
|
934ce7afd0 | ||
|
|
47a2b8435f | ||
|
|
eaebcece9d | ||
|
|
994242e524 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -14,3 +14,6 @@ ecdc-kafka-ca.crt
|
||||
.pre-commit-config.yaml
|
||||
.clang-format
|
||||
.iocsh_history
|
||||
build
|
||||
build.sh
|
||||
|
||||
|
||||
@@ -109,6 +109,14 @@ record("*", "$(P)$(R)AcquirePeriod_RBV") {
|
||||
field(FLNK, "$(P)$(R)#EVRAcquireTime-S.PROC PP MS")
|
||||
}
|
||||
|
||||
record("*", "$(P)$(R)AcquireTime") {
|
||||
field(VAL, "0.9")
|
||||
}
|
||||
|
||||
record("*", "$(P)$(R)AcquirePeriod") {
|
||||
field(VAL, "1")
|
||||
}
|
||||
|
||||
record(calcout, "$(P)$(R)#EVRAcquireTime-S") {
|
||||
field(DESC, "Set EVR acquire time in seconds")
|
||||
field(CALC, "A=0?B:A*B")
|
||||
|
||||
@@ -834,12 +834,15 @@ void Orca::imageTask() {
|
||||
uint64_t prevAcquisitionCount = 0;
|
||||
DCAMCAP_TRANSFERINFO captransferinfo;
|
||||
epicsTimeStamp prevAcqTime, currentAcqTime;
|
||||
epicsTimeStamp acqTimestamp;
|
||||
epicsTimeStamp prev_trigger_time, current_trigger_time;
|
||||
double elapsedTime;
|
||||
int evr_counts = 0;
|
||||
double exposure_time, readout_time;
|
||||
double maxAcqusitionTime, acqusitionRate;
|
||||
int triggerMode = DCAMPROP_TRIGGERSOURCE__INTERNAL;
|
||||
int triggerActive;
|
||||
char buf[256];
|
||||
|
||||
lock();
|
||||
while (1) {
|
||||
@@ -874,7 +877,7 @@ void Orca::imageTask() {
|
||||
|
||||
// get image transfer status.
|
||||
unlock();
|
||||
imageTransferStatus(m_hdcam, captransferinfo);
|
||||
imageTransferStatus(m_hdcam, captransferinfo, buf);
|
||||
lock();
|
||||
|
||||
if (prevAcquisitionCount < (uint64_t)captransferinfo.nFrameCount) {
|
||||
@@ -910,39 +913,48 @@ void Orca::imageTask() {
|
||||
double timestamp;
|
||||
|
||||
getIntegerParam(hTriggerSource, &triggerMode);
|
||||
|
||||
if (triggerMode == DCAMPROP_TRIGGERSOURCE__EXTERNAL) {
|
||||
getIntegerParam(evrCounts, &evr_counts);
|
||||
|
||||
// Count events
|
||||
evr_counts_since_last_start = evr_counts - initial_evr_counters;
|
||||
evr_trigger_dropped =
|
||||
evr_counts_since_last_start - captransferinfo.nFrameCount;
|
||||
FLOW_ARGS("EVR event count: %d\n", evr_counts);
|
||||
FLOW_ARGS("evr_counts_since_last_start: %d\n",
|
||||
evr_counts_since_last_start);
|
||||
|
||||
// Update asyn parameters
|
||||
setIntegerParam(evrCountsSinceAcqStart, evr_counts_since_last_start);
|
||||
setIntegerParam(evrTriggerDropped, evr_trigger_dropped);
|
||||
char buf[256];
|
||||
getStringParam(evrTimeStamp, 256, buf);
|
||||
|
||||
// remember parsed timestamp values
|
||||
sscanf(buf, "%u.%u", &mTimeStampSec, &mTimeStampNsec);
|
||||
timestamp = mTimeStampSec + mTimeStampNsec / 1.e9;
|
||||
FLOW_ARGS("mTimeStampSec: %u - mTimeStampNsec: %u\n", mTimeStampSec,
|
||||
mTimeStampNsec);
|
||||
sscanf(buf, "%u.%u", &acqTimestamp.secPastEpoch, &acqTimestamp.nsec);
|
||||
acqTimestamp.secPastEpoch -= POSIX_TIME_AT_EPICS_EPOCH;
|
||||
|
||||
timestamp = acqTimestamp.secPastEpoch + acqTimestamp.nsec / 1.e9;
|
||||
FLOW_ARGS("acqTimestamp.secPastEpoch: %u - acqTimestamp.nsec: %u\n", acqTimestamp.secPastEpoch,
|
||||
acqTimestamp.nsec);
|
||||
FLOW_ARGS("Timestamp from evr: %f\n", timestamp);
|
||||
|
||||
|
||||
} else {
|
||||
updateTimeStamp(&acqTimestamp);
|
||||
timestamp =
|
||||
(ts_sec + ts_microsec / 1.0e6) - (exposure_time + readout_time);
|
||||
FLOW_ARGS("Timestamp from camera: %f\n", timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
FLOW_ARGS("readout_time: %f - exposure_time: %f\n", readout_time,
|
||||
exposure_time);
|
||||
|
||||
// calculate time since previous frame and update framerate.
|
||||
epicsTimeGetCurrent(¤tAcqTime);
|
||||
elapsedTime = epicsTimeDiffInSeconds(¤tAcqTime, &prevAcqTime);
|
||||
prevAcqTime = currentAcqTime;
|
||||
|
||||
status = setDoubleParam(hFrameRate, (double)(1 / elapsedTime));
|
||||
|
||||
|
||||
getIntegerParam(NDArrayCallbacks, &callback);
|
||||
if (callback) {
|
||||
NDArray* pImage;
|
||||
@@ -958,7 +970,7 @@ void Orca::imageTask() {
|
||||
if (pImage) {
|
||||
pImage->uniqueId = count;
|
||||
pImage->timeStamp = timestamp;
|
||||
updateTimeStamp(&pImage->epicsTS);
|
||||
pImage->epicsTS = acqTimestamp;
|
||||
|
||||
memcpy(pImage->pData, (epicsUInt16*)image, pImage->dataSize);
|
||||
|
||||
@@ -973,6 +985,7 @@ void Orca::imageTask() {
|
||||
|
||||
setIntegerParam(ADNumImagesCounter, captransferinfo.nFrameCount);
|
||||
|
||||
// Check if evr count number has been updated and update parameters.
|
||||
getIntegerParam(evrCounts, &evr_counts);
|
||||
evr_counts_since_last_start = evr_counts - initial_evr_counters;
|
||||
if (evr_counts_since_last_start != evr_counts_since_last_start_previous) {
|
||||
@@ -980,23 +993,35 @@ void Orca::imageTask() {
|
||||
epicsTimeGetCurrent(&prev_trigger_time);
|
||||
evr_counts_since_last_start_previous = evr_counts_since_last_start;
|
||||
}
|
||||
|
||||
getIntegerParam(hTriggerActive, &triggerActive);
|
||||
|
||||
getDoubleParam(ADAcquirePeriod, &acqusitionRate);
|
||||
getIntegerParam(ADStatus, &acqStatus);
|
||||
maxAcqusitionTime = acqusitionRate * 2;
|
||||
epicsTimeGetCurrent(¤tAcqTime);
|
||||
if ((epicsTimeDiffInSeconds(¤tAcqTime, &prevAcqTime) >
|
||||
maxAcqusitionTime) &&
|
||||
acqStatus != ADStatusAborted) {
|
||||
FLOW_ARGS("maxAcqusitionTime %f\n", maxAcqusitionTime);
|
||||
setShutter(0);
|
||||
stopAcquire();
|
||||
setIntegerParam(ADAcquire, 0);
|
||||
setIntegerParam(hAcqControl, 0);
|
||||
setIntegerParam(ADStatus, ADStatusError);
|
||||
setStringParam(ADStatusMessage, "Acquisition timeout");
|
||||
if (triggerActive == DCAMPROP_TRIGGERACTIVE__SYNCREADOUT) {
|
||||
|
||||
} else if (triggerActive == DCAMPROP_TRIGGERACTIVE__LEVEL) {
|
||||
|
||||
} else {
|
||||
// Checks if the elapsed time since last frame is longer than the exposure,
|
||||
// stop waiting for image and put in timeout status.
|
||||
getDoubleParam(ADAcquirePeriod, &acqusitionRate);
|
||||
getIntegerParam(ADStatus, &acqStatus);
|
||||
maxAcqusitionTime = acqusitionRate * 2; // arbitrary time longer than the acqusiontime.
|
||||
epicsTimeGetCurrent(¤tAcqTime);
|
||||
if ((epicsTimeDiffInSeconds(¤tAcqTime, &prevAcqTime) >
|
||||
maxAcqusitionTime) &&
|
||||
acqStatus != ADStatusAborted) {
|
||||
FLOW_ARGS("maxAcqusitionTime %f\n", maxAcqusitionTime);
|
||||
setShutter(0);
|
||||
stopAcquire();
|
||||
setIntegerParam(ADAcquire, 0);
|
||||
setIntegerParam(hAcqControl, 0);
|
||||
setIntegerParam(ADStatus, ADStatusError);
|
||||
setStringParam(ADStatusMessage, "Acquisition timeout");
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the camera has failed a trigger from the evr. Updates the
|
||||
// amount dropped evr triggers.
|
||||
epicsTimeGetCurrent(¤t_trigger_time);
|
||||
if (epicsTimeDiffInSeconds(¤t_trigger_time, &prev_trigger_time) >
|
||||
(exposure_time + readout_time)) {
|
||||
@@ -1007,6 +1032,7 @@ void Orca::imageTask() {
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the acqusition is done (support single and multiple exposure)
|
||||
if ((imageMode == ADImageMultiple &&
|
||||
totalImages == captransferinfo.nFrameCount) ||
|
||||
(imageMode == ADImageSingle && captransferinfo.nFrameCount == 1)) {
|
||||
@@ -1078,7 +1104,7 @@ asynStatus Orca::writeInt32(asynUser* pasynUser, epicsInt32 value) {
|
||||
} else if (!value &&
|
||||
(adstatus == ADStatusAcquire || adstatus == ADStatusError ||
|
||||
adstatus == ADStatusWaiting)) {
|
||||
/* This was a command to stop acquisition */
|
||||
/* This was a command to stop acquisition */ //But not anymore?
|
||||
setIntegerParam(ADStatus, ADStatusAborted);
|
||||
setIntegerParam(hAcqControl, 0);
|
||||
setStringParam(ADStatusMessage, "Acquisition aborted by user");
|
||||
@@ -1719,7 +1745,7 @@ void Orca::getImageInformation(HDCAM hdcam, int32& pixeltype, int32& width,
|
||||
}
|
||||
|
||||
asynStatus Orca::imageTransferStatus(HDCAM hdcam,
|
||||
DCAMCAP_TRANSFERINFO& captransferinfo) {
|
||||
DCAMCAP_TRANSFERINFO& captransferinfo, char *buf) {
|
||||
DCAMERR err;
|
||||
const char* functionName = "imageTransferStatus";
|
||||
memset(&captransferinfo, 0, sizeof(captransferinfo));
|
||||
@@ -1727,6 +1753,7 @@ asynStatus Orca::imageTransferStatus(HDCAM hdcam,
|
||||
|
||||
// get number of captured image
|
||||
err = dcamcap_transferinfo(m_hdcam, &captransferinfo);
|
||||
getStringParam(evrTimeStamp, 256, buf);
|
||||
if (failed(err)) {
|
||||
ERR_ARGS("DCAMERR: 0x%08X [%s]", m_err, "dcamcap_transferinfo");
|
||||
return asynError;
|
||||
|
||||
@@ -189,9 +189,6 @@ class epicsShareClass Orca : public ADDriver {
|
||||
int readParameter(int propertyID, bool processPV = true);
|
||||
int readParameterStr(int paramIndex);
|
||||
|
||||
epicsUInt32 mTimeStampSec;
|
||||
epicsUInt32 mTimeStampNsec;
|
||||
|
||||
void imageTask();
|
||||
void temperatureTask();
|
||||
|
||||
@@ -333,7 +330,7 @@ class epicsShareClass Orca : public ADDriver {
|
||||
int32 rowbytes, int32 cx, int32 cy,
|
||||
epicsUInt32& ts_sec, epicsUInt32& ts_microsec);
|
||||
asynStatus imageTransferStatus(HDCAM hdcam,
|
||||
DCAMCAP_TRANSFERINFO& captransferinfo);
|
||||
DCAMCAP_TRANSFERINFO& captransferinfo, char *buf);
|
||||
|
||||
// wrapper functions for dcamapi
|
||||
int allocateBuffers(unsigned int);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
require adorca
|
||||
require ndpluginschemas
|
||||
require adpluginkafka
|
||||
|
||||
epicsEnvSet("PREFIX", "YMIR-Det1:")
|
||||
@@ -34,6 +35,9 @@ NDPvaConfigure("PVA1", $(QSIZE), 0, "$(PORT)", 0, "$(PREFIX)Pva1:Image", 0, 0, 0
|
||||
dbLoadRecords("$(adcore_DIR)/db/NDPva.template", "P=$(PREFIX),R=Pva1:, PORT=PVA1,ADDR=0,TIMEOUT=1,NDARRAY_PORT=$(PORT)")
|
||||
#
|
||||
|
||||
NDSchemasConfigure("Schemas1", "$(QSIZE)", 0, "$(PORT)", 0, 0, 0, "test-orca-lab", 0)
|
||||
dbLoadRecords("$(ndpluginschemas_DB)/NDPluginSchemas.template", "P=$(PREFIX), R=schemas:, PORT=Schemas1, ADDR=0, TIMEOUT=1, NDARRAY_PORT=$(PORT)")
|
||||
|
||||
# Create a standard arrays plugin, set it to get data from orca driver.
|
||||
NDStdArraysConfigure("Image1", "$(QSIZE)", 0, "$(PORT)", 0, 0)
|
||||
dbLoadRecords("NDStdArrays.template", "P=$(PREFIX),R=image1:,PORT=Image1,ADDR=0,TIMEOUT=1,NDARRAY_PORT=$(PORT),TYPE=Int32,FTVL=LONG,NELEMENTS=$(NELEMENTS)")
|
||||
@@ -44,8 +48,8 @@ epicsEnvSet("KFK_TOPIC", "ymir_camera")
|
||||
# Kafka plugin
|
||||
#epicsEnvSet("KFK_CONFIG_FILE_PATH", "/etc/kafka/kafka.conf")
|
||||
|
||||
#KafkaPluginConfigure("KFK1", 3, 1, "$(PORT)", 0, -1, "$(KFK_TOPIC)", "hama_kfk1","$(KFK_CONFIG_FILE_PATH)")
|
||||
#dbLoadRecords("$(adpluginkafka_DIR)db/adpluginkafka.db", "P=$(PREFIX), R=Kfk1:, PORT=KFK1, ADDR=0, TIMEOUT=1, NDARRAY_PORT=$(PORT)")
|
||||
KafkaPluginConfigure("Kafka1", 3, 1, "Schemas1", 0, -1, "$(KFK_TOPIC)","$(KFK_CONFIG_FILE_PATH)")
|
||||
dbLoadRecords("$(adpluginkafka_DB)/adpluginkafka.db", "P=$(PREFIX), R=Kfk1:, PORT=Kafka1, ADDR=0, TIMEOUT=1, NDARRAY_PORT=Schemas1")
|
||||
|
||||
# startPVAServer
|
||||
iocInit()
|
||||
|
||||
Reference in New Issue
Block a user