mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-07 02:20:42 +02:00
handling get data rxr callback exceptions
This commit is contained in:
parent
a36a294515
commit
918f3f3fde
@ -24,18 +24,18 @@ const std::string DataProcessor::TypeName = "DataProcessor";
|
|||||||
|
|
||||||
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo *f,
|
DataProcessor::DataProcessor(int ind, detectorType dtype, Fifo *f,
|
||||||
fileFormat *ftype, bool fwenable, bool *mfwenable,
|
fileFormat *ftype, bool fwenable, bool *mfwenable,
|
||||||
bool *dsEnable, uint32_t *freq,
|
bool *dsEnable, uint32_t *freq, uint32_t *timer,
|
||||||
uint32_t *timer, uint32_t *sfnum, bool *fp,
|
uint32_t *sfnum, bool *fp, bool *act,
|
||||||
bool *act, bool *depaden, bool *sm,
|
bool *depaden, bool *sm, std::vector<int> *cdl,
|
||||||
std::vector<int> *cdl, int *cdo, int *cad)
|
int *cdo, int *cad)
|
||||||
: ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype),
|
: ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype),
|
||||||
dataStreamEnable(dsEnable), fileFormatType(ftype),
|
dataStreamEnable(dsEnable), fileFormatType(ftype),
|
||||||
fileWriteEnable(fwenable), masterFileWriteEnable(mfwenable),
|
fileWriteEnable(fwenable), masterFileWriteEnable(mfwenable),
|
||||||
streamingFrequency(freq), streamingTimerInMs(timer),
|
streamingFrequency(freq), streamingTimerInMs(timer),
|
||||||
streamingStartFnum(sfnum), activated(act),
|
streamingStartFnum(sfnum), activated(act),
|
||||||
deactivatedPaddingEnable(depaden), silentMode(sm),
|
deactivatedPaddingEnable(depaden), silentMode(sm), framePadding(fp),
|
||||||
framePadding(fp), ctbDbitList(cdl), ctbDbitOffset(cdo),
|
ctbDbitList(cdl), ctbDbitOffset(cdo), ctbAnalogDataBytes(cad),
|
||||||
ctbAnalogDataBytes(cad), firstStreamerFrame(false) {
|
firstStreamerFrame(false) {
|
||||||
LOG(logDEBUG) << "DataProcessor " << ind << " created";
|
LOG(logDEBUG) << "DataProcessor " << ind << " created";
|
||||||
memset((void *)&timerBegin, 0, sizeof(timespec));
|
memset((void *)&timerBegin, 0, sizeof(timespec));
|
||||||
}
|
}
|
||||||
@ -185,12 +185,17 @@ void DataProcessor::ThreadExecution() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t fnum = ProcessAnImage(buffer);
|
uint64_t fnum = 0;
|
||||||
|
try {
|
||||||
|
fnum = ProcessAnImage(buffer);
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
fifo->FreeAddress(buffer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// stream (if time/freq to stream) or free
|
// stream (if time/freq to stream) or free
|
||||||
if (*dataStreamEnable && SendToStreamer()) {
|
if (*dataStreamEnable && SendToStreamer()) {
|
||||||
// if first frame to stream, add frame index to fifo header (might not
|
// if first frame to stream, add frame index to fifo header (might
|
||||||
// be the first)
|
// not be the first)
|
||||||
if (firstStreamerFrame) {
|
if (firstStreamerFrame) {
|
||||||
firstStreamerFrame = false;
|
firstStreamerFrame = false;
|
||||||
(*((uint32_t *)(buffer + FIFO_DATASIZE_NUMBYTES))) =
|
(*((uint32_t *)(buffer + FIFO_DATASIZE_NUMBYTES))) =
|
||||||
@ -256,22 +261,27 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
|
|||||||
RearrangeDbitData(buf);
|
RearrangeDbitData(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// normal call back
|
try {
|
||||||
if (rawDataReadyCallBack != nullptr) {
|
// normal call back
|
||||||
rawDataReadyCallBack((char *)rheader,
|
if (rawDataReadyCallBack != nullptr) {
|
||||||
buf + FIFO_HEADER_NUMBYTES +
|
rawDataReadyCallBack((char *)rheader,
|
||||||
sizeof(sls_receiver_header),
|
buf + FIFO_HEADER_NUMBYTES +
|
||||||
(uint32_t)(*((uint32_t *)buf)), pRawDataReady);
|
sizeof(sls_receiver_header),
|
||||||
}
|
(uint32_t)(*((uint32_t *)buf)), pRawDataReady);
|
||||||
|
}
|
||||||
|
|
||||||
// call back with modified size
|
// call back with modified size
|
||||||
else if (rawDataModifyReadyCallBack != nullptr) {
|
else if (rawDataModifyReadyCallBack != nullptr) {
|
||||||
auto revsize = (uint32_t)(*((uint32_t *)buf));
|
auto revsize = (uint32_t)(*((uint32_t *)buf));
|
||||||
rawDataModifyReadyCallBack((char *)rheader,
|
rawDataModifyReadyCallBack((char *)rheader,
|
||||||
buf + FIFO_HEADER_NUMBYTES +
|
buf + FIFO_HEADER_NUMBYTES +
|
||||||
sizeof(sls_receiver_header),
|
sizeof(sls_receiver_header),
|
||||||
revsize, pRawDataReady);
|
revsize, pRawDataReady);
|
||||||
(*((uint32_t *)buf)) = revsize;
|
(*((uint32_t *)buf)) = revsize;
|
||||||
|
}
|
||||||
|
} catch (const std::exception &e) {
|
||||||
|
throw sls::RuntimeError("Get Data Callback Error: " +
|
||||||
|
std::string(e.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// write to file
|
// write to file
|
||||||
@ -284,8 +294,8 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
|
|||||||
// from previous call back
|
// from previous call back
|
||||||
fnum - firstIndex, nump);
|
fnum - firstIndex, nump);
|
||||||
} catch (const sls::RuntimeError &e) {
|
} catch (const sls::RuntimeError &e) {
|
||||||
; // ignore write exception for now (TODO: send error message via
|
; // ignore write exception for now (TODO: send error message
|
||||||
// stopReceiver tcp)
|
// via stopReceiver tcp)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return fnum;
|
return fnum;
|
||||||
@ -385,8 +395,8 @@ void DataProcessor::PadMissingPackets(char *buf) {
|
|||||||
|
|
||||||
// missing packet
|
// missing packet
|
||||||
switch (myDetectorType) {
|
switch (myDetectorType) {
|
||||||
// for gotthard, 1st packet: 4 bytes fnum, CACA +
|
// for gotthard, 1st packet: 4 bytes fnum, CACA + CACA, 639*2 bytes
|
||||||
// CACA, 639*2 bytes data
|
// data
|
||||||
// 2nd packet: 4 bytes fnum, previous 1*2 bytes data +
|
// 2nd packet: 4 bytes fnum, previous 1*2 bytes data +
|
||||||
// 640*2 bytes data !!
|
// 640*2 bytes data !!
|
||||||
case GOTTHARD:
|
case GOTTHARD:
|
||||||
|
@ -41,8 +41,8 @@ int StartAcq(std::string filepath, std::string filename, uint64_t fileindex,
|
|||||||
void AcquisitionFinished(uint64_t frames, void *p) {
|
void AcquisitionFinished(uint64_t frames, void *p) {
|
||||||
std::cout << "#### AcquisitionFinished: frames:" << frames << " ####";
|
std::cout << "#### AcquisitionFinished: frames:" << frames << " ####";
|
||||||
|
|
||||||
throw std::runtime_error(
|
/*throw std::runtime_error(
|
||||||
"Throwing exception from acquisition finished call back");
|
"Throwing exception from acquisition finished call back");*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,6 +75,10 @@ void GetData(char *metadata, char *datapointer, uint32_t datasize, void *p) {
|
|||||||
<< "\t\tfirstbytedata: " << std::hex << "0x"
|
<< "\t\tfirstbytedata: " << std::hex << "0x"
|
||||||
<< ((uint8_t)(*((uint8_t *)(datapointer))))
|
<< ((uint8_t)(*((uint8_t *)(datapointer))))
|
||||||
<< "\t\tdatsize: " << datasize << "\n\n";
|
<< "\t\tdatsize: " << datasize << "\n\n";
|
||||||
|
|
||||||
|
if (detectorHeader.frameNumber % 2 == 0) {
|
||||||
|
throw std::runtime_error("Throwing exception from Get Data call back");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user