* roi structure expanded to have ymin and ymax

* compile with 'detector roi'

* wip

* wip, rx_roi, rx_clearroi

* wip rxroi

* rxroi wip

* wip rxroi

* merge fix

* wip

* rx_roi works, impl wip, test

* tests in, impl left

* wip, rxroi impl

* wip, rxroi impl

* wip

* setrx_Roi works, getrx_roi, wip

* rx_roi impl done

* wip, rxroi

* wip, getrx_roi rxr ports

* fix ports

* wip

* wip

* fix positions on server side

* wip

* numports wip

* wip

* jungfrau top inner interface row increment

* x, y detpos, wip

* removed eiger row indices flipping in gui (bottom flipping maintained)

* wip

* wip, jungfrau numinterfaces2

* jungfrau virtual works

* eiger, jungfrau, g2 virtual server works

* eiger positions fix, wip

* binaries in

* minor printout

* binaries in

* merge fix

* merge fix

* removing getposition

* setrxroi wip

* set upto port

* get messed, wip

* roi multi to module works, wip

* wip

* roi dont return -1

* added rxroi metadata in master file

* added rxroifromshm, not yet in detector

* rx roi in gui with box, also for gap pixels (gappixels for jungfrau mess)

* fix for segfault in gui with detaching roi box in gui

* wip

* m3 gui: slave timing modes should be discarded when squashing

* fixed m3 virtual data, and fixed counters in gui asthetics

* m3 roi works

* wip, g2

* wip

* handling g225um boards, and showing roi for gainplot as well

* udpate python functions

* fix for 1d and a2d roi written

* fixed actual roi written to file

* no virtual hdf5 when handling rx roi

* test

* minor

* binarie in
This commit is contained in:
Dhanya Thattil
2022-05-16 12:35:06 +02:00
committed by GitHub
parent 9808376207
commit fcc7f7aef8
53 changed files with 1713 additions and 859 deletions

View File

@ -55,7 +55,8 @@ int64_t ClientInterface::getReceiverVersion() { return APIRECEIVER; }
/***callback functions***/
void ClientInterface::registerCallBackStartAcquisition(
int (*func)(const std::string &, const std::string &, uint64_t, size_t, void *),
int (*func)(const std::string &, const std::string &, uint64_t, size_t,
void *),
void *arg) {
startAcquisitionCallBack = func;
pStartAcquisition = arg;
@ -122,7 +123,7 @@ int ClientInterface::functionTable(){
flist[F_GET_LAST_RECEIVER_CLIENT_IP] = &ClientInterface::get_last_client_ip;
flist[F_GET_RECEIVER_VERSION] = &ClientInterface::get_version;
flist[F_SETUP_RECEIVER] = &ClientInterface::setup_receiver;
flist[F_RECEIVER_SET_ROI] = &ClientInterface::set_roi;
flist[F_RECEIVER_SET_DETECTOR_ROI] = &ClientInterface::set_detector_roi;
flist[F_RECEIVER_SET_NUM_FRAMES] = &ClientInterface::set_num_frames;
flist[F_SET_RECEIVER_NUM_TRIGGERS] = &ClientInterface::set_num_triggers;
flist[F_SET_RECEIVER_NUM_BURSTS] = &ClientInterface::set_num_bursts;
@ -217,6 +218,9 @@ int ClientInterface::functionTable(){
flist[F_RECEIVER_SET_DATASTREAM] = &ClientInterface::set_detector_datastream;
flist[F_GET_RECEIVER_ARPING] = &ClientInterface::get_arping;
flist[F_SET_RECEIVER_ARPING] = &ClientInterface::set_arping;
flist[F_RECEIVER_GET_RECEIVER_ROI] = &ClientInterface::get_receiver_roi;
flist[F_RECEIVER_SET_RECEIVER_ROI] = &ClientInterface::set_receiver_roi;
flist[F_RECEIVER_SET_RECEIVER_ROI_METADATA] = &ClientInterface::set_receiver_roi_metadata;
for (int i = NUM_DET_FUNCTIONS + 1; i < NUM_REC_FUNCTIONS ; i++) {
LOG(logDEBUG1) << "function fnum: " << i << " (" <<
@ -247,7 +251,7 @@ int ClientInterface::decodeFunction(Interface &socket) {
void ClientInterface::functionNotImplemented() {
std::ostringstream os;
os << "Function: " << getFunctionNameFromEnum((enum detFuncs)fnum)
<< ", is is not implemented for this detector";
<< " is not implemented for this detector";
throw RuntimeError(os.str());
}
@ -455,7 +459,7 @@ int ClientInterface::setup_receiver(Interface &socket) {
}
if (detType == GOTTHARD) {
try {
impl()->setROI(arg.roi);
impl()->setDetectorROI(arg.roi);
} catch (const RuntimeError &e) {
throw RuntimeError("Could not set ROI");
}
@ -497,8 +501,11 @@ void ClientInterface::setDetectorType(detectorType arg) {
detType = GENERIC;
receiver = sls::make_unique<Implementation>(arg);
detType = arg;
} catch (...) {
throw RuntimeError("Could not set detector type");
} catch (std::exception &e) {
std::ostringstream os;
os << "Could not set detector type in the receiver. ";
os << e.what();
throw RuntimeError(os.str());
}
// callbacks after (in setdetectortype, the object is reinitialized)
@ -518,16 +525,16 @@ void ClientInterface::setDetectorType(detectorType arg) {
impl()->setThreadIds(parentThreadId, tcpThreadId);
}
int ClientInterface::set_roi(Interface &socket) {
int ClientInterface::set_detector_roi(Interface &socket) {
auto arg = socket.Receive<ROI>();
LOG(logDEBUG1) << "Set ROI: [" << arg.xmin << ", " << arg.xmax << "]";
LOG(logDEBUG1) << "Set Detector ROI: " << sls::ToString(arg);
if (detType != GOTTHARD)
functionNotImplemented();
verifyIdle(socket);
try {
impl()->setROI(arg);
impl()->setDetectorROI(arg);
} catch (const RuntimeError &e) {
throw RuntimeError("Could not set ROI");
}
@ -1736,3 +1743,37 @@ int ClientInterface::set_arping(Interface &socket) {
impl()->setArping(value, udpips);
return socket.Send(OK);
}
int ClientInterface::get_receiver_roi(Interface &socket) {
auto retval = impl()->getReceiverROI();
LOG(logDEBUG1) << "Receiver roi retval:" << sls::ToString(retval);
return socket.sendResult(retval);
}
int ClientInterface::set_receiver_roi(Interface &socket) {
auto arg = socket.Receive<ROI>();
if (detType == CHIPTESTBOARD || detType == MOENCH)
functionNotImplemented();
LOG(logDEBUG1) << "Set Receiver ROI: " << sls::ToString(arg);
verifyIdle(socket);
try {
impl()->setReceiverROI(arg);
} catch (const RuntimeError &e) {
throw RuntimeError("Could not set ReceiverROI");
}
return socket.Send(OK);
}
int ClientInterface::set_receiver_roi_metadata(Interface &socket) {
auto arg = socket.Receive<ROI>();
if (detType == CHIPTESTBOARD || detType == MOENCH)
functionNotImplemented();
LOG(logDEBUG1) << "Set Receiver ROI Metadata: " << sls::ToString(arg);
verifyIdle(socket);
try {
impl()->setReceiverROIMetadata(arg);
} catch (const RuntimeError &e) {
throw RuntimeError("Could not set ReceiverROI metadata");
}
return socket.Send(OK);
}

View File

@ -66,7 +66,7 @@ class ClientInterface : private virtual slsDetectorDefs {
int get_version(sls::ServerInterface &socket);
int setup_receiver(sls::ServerInterface &socket);
void setDetectorType(detectorType arg);
int set_roi(sls::ServerInterface &socket);
int set_detector_roi(sls::ServerInterface &socket);
int set_num_frames(sls::ServerInterface &socket);
int set_num_triggers(sls::ServerInterface &socket);
int set_num_bursts(sls::ServerInterface &socket);
@ -164,6 +164,9 @@ class ClientInterface : private virtual slsDetectorDefs {
int set_detector_datastream(sls::ServerInterface &socket);
int get_arping(sls::ServerInterface &socket);
int set_arping(sls::ServerInterface &socket);
int get_receiver_roi(sls::ServerInterface &socket);
int set_receiver_roi(sls::ServerInterface &socket);
int set_receiver_roi_metadata(sls::ServerInterface &socket);
Implementation *impl() {
if (receiver != nullptr) {

View File

@ -27,19 +27,19 @@
const std::string DataProcessor::typeName_ = "DataProcessor";
DataProcessor::DataProcessor(int index, detectorType detectorType, Fifo *fifo,
bool *activated, bool *dataStreamEnable,
bool *dataStreamEnable,
uint32_t *streamingFrequency,
uint32_t *streamingTimerInMs,
uint32_t *streamingStartFnum, bool *framePadding,
std::vector<int> *ctbDbitList, int *ctbDbitOffset,
int *ctbAnalogDataBytes)
: ThreadObject(index, typeName_), fifo_(fifo), detectorType_(detectorType),
dataStreamEnable_(dataStreamEnable), activated_(activated),
dataStreamEnable_(dataStreamEnable),
streamingFrequency_(streamingFrequency),
streamingTimerInMs_(streamingTimerInMs),
streamingStartFnum_(streamingStartFnum), framePadding_(framePadding),
ctbDbitList_(ctbDbitList), ctbDbitOffset_(ctbDbitOffset),
ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false) {
ctbAnalogDataBytes_(ctbAnalogDataBytes) {
LOG(logDEBUG) << "DataProcessor " << index << " created";
}
@ -50,6 +50,13 @@ bool DataProcessor::GetStartedFlag() const { return startedFlag_; }
void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; }
void DataProcessor::SetActivate(bool enable) { activated_ = enable; }
void DataProcessor::SetReceiverROI(ROI roi) {
receiverRoi_ = roi;
receiverRoiEnabled_ = receiverRoi_.completeRoi() ? false : true;
}
void DataProcessor::ResetParametersforNewAcquisition() {
StopRunning();
startedFlag_ = false;
@ -57,6 +64,8 @@ void DataProcessor::ResetParametersforNewAcquisition() {
firstIndex_ = 0;
currentFrameIndex_ = 0;
firstStreamerFrame_ = true;
streamCurrentFrame_ = false;
completeImageToStreamBeforeCropping = sls::make_unique<char[]>(generalData_->imageSize);
}
void DataProcessor::RecordFirstIndex(uint64_t fnum) {
@ -115,18 +124,28 @@ void DataProcessor::CreateFirstFiles(
CloseFiles();
// deactivated (half module/ single port), dont write file
if ((!*activated_) || (!detectorDataStream)) {
if (!activated_ || !detectorDataStream) {
return;
}
#ifdef HDF5C
int nx = generalData_->nPixelsX;
int ny = generalData_->nPixelsY;
if (receiverRoiEnabled_) {
nx = receiverRoi_.xmax - receiverRoi_.xmin + 1;
ny = receiverRoi_.ymax - receiverRoi_.ymin + 1;
if (receiverRoi_.ymax == -1 || receiverRoi_.ymin == -1) {
ny = 1;
}
}
#endif
switch (dataFile_->GetFileFormat()) {
#ifdef HDF5C
case HDF5:
dataFile_->CreateFirstHDF5DataFile(
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
modulePos, numUnitsPerReadout, udpPortNumber, maxFramesPerFile,
numImages, generalData_->nPixelsX, generalData_->nPixelsY,
dynamicRange);
numImages, nx, ny, dynamicRange);
break;
#endif
case BINARY:
@ -156,6 +175,10 @@ std::array<std::string, 2> DataProcessor::CreateVirtualFile(
const int numModX, const int numModY, const uint32_t dynamicRange,
std::mutex *hdf5LibMutex) {
if (receiverRoiEnabled_) {
throw std::runtime_error("Skipping virtual hdf5 file since rx_roi is enabled.");
}
bool gotthard25um =
((detectorType_ == GOTTHARD || detectorType_ == GOTTHARD2) &&
(numModX * numModY) == 2);
@ -170,10 +193,10 @@ std::array<std::string, 2> DataProcessor::CreateVirtualFile(
// stop acquisition)
return masterFileUtility::CreateVirtualHDF5File(
filePath, fileNamePrefix, fileIndex, overWriteEnable, silentMode,
modulePos, numUnitsPerReadout, framesPerFile, numImages,
generalData_->nPixelsX, generalData_->nPixelsY, dynamicRange,
numFramesCaught_, numModX, numModY, dataFile_->GetPDataType(),
dataFile_->GetParameterNames(), dataFile_->GetParameterDataTypes(),
modulePos, numUnitsPerReadout, framesPerFile, numImages,
generalData_->nPixelsX, generalData_->nPixelsY, dynamicRange,
numFramesCaught_, numModX, numModY, dataFile_->GetPDataType(),
dataFile_->GetParameterNames(), dataFile_->GetParameterDataTypes(),
hdf5LibMutex, gotthard25um);
}
@ -182,6 +205,10 @@ void DataProcessor::LinkFileInMaster(const std::string &masterFileName,
const std::string &virtualDatasetName,
const bool silentMode,
std::mutex *hdf5LibMutex) {
if (receiverRoiEnabled_) {
throw std::runtime_error("Should not be here, roi with hdf5 virtual should throw.");
}
std::string fname{virtualFileName}, datasetName{virtualDatasetName};
// if no virtual file, link data file
if (virtualFileName.empty()) {
@ -234,21 +261,19 @@ void DataProcessor::ThreadExecution() {
return;
}
uint64_t fnum = 0;
try {
fnum = ProcessAnImage(buffer);
ProcessAnImage(buffer);
} catch (const std::exception &e) {
fifo_->FreeAddress(buffer);
return;
}
// stream (if time/freq to stream) or free
if (*dataStreamEnable_ && SendToStreamer()) {
// if first frame to stream, add frame index to fifo header (might
// not be the first)
if (firstStreamerFrame_) {
firstStreamerFrame_ = false;
(*((uint32_t *)(buffer + FIFO_DATASIZE_NUMBYTES))) =
(uint32_t)(fnum - firstIndex_);
if (streamCurrentFrame_) {
// copy the complete image back if roi enabled
if (receiverRoiEnabled_) {
(*((uint32_t *)buffer)) = generalData_->imageSize;
memcpy(buffer + generalData_->fifoBufferHeaderSize, &completeImageToStreamBeforeCropping[0], generalData_->imageSize);
}
fifo_->PushAddressToStream(buffer);
} else {
@ -270,9 +295,10 @@ void DataProcessor::StopProcessing(char *buf) {
LOG(logDEBUG1) << index << ": Processing Completed";
}
uint64_t DataProcessor::ProcessAnImage(char *buf) {
void DataProcessor::ProcessAnImage(char *buf) {
auto *rheader = reinterpret_cast<sls_receiver_header *>(buf + FIFO_HEADER_NUMBYTES);
auto *rheader =
reinterpret_cast<sls_receiver_header *>(buf + FIFO_HEADER_NUMBYTES);
sls_detector_header header = rheader->detHeader;
uint64_t fnum = header.frameNumber;
currentFrameIndex_ = fnum;
@ -295,7 +321,7 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
}
// frame padding
if (*activated_ && *framePadding_ && nump < generalData_->packetsPerFrame)
if (activated_ && *framePadding_ && nump < generalData_->packetsPerFrame)
PadMissingPackets(buf);
// rearrange ctb digital bits (if ctbDbitlist is not empty)
@ -303,6 +329,30 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
RearrangeDbitData(buf);
}
// 'stream Image' check has to be done here before crop image
// stream (if time/freq to stream) or free
if (*dataStreamEnable_ && SendToStreamer()) {
// if first frame to stream, add frame index to fifo header (might
// not be the first)
if (firstStreamerFrame_) {
firstStreamerFrame_ = false;
(*((uint32_t *)(buf + FIFO_DATASIZE_NUMBYTES))) =
(uint32_t)(fnum - firstIndex_);
}
streamCurrentFrame_ = true;
} else {
streamCurrentFrame_ = false;
}
if (receiverRoiEnabled_) {
// copy the complete image to stream before cropping
if (streamCurrentFrame_) {
memcpy(&completeImageToStreamBeforeCropping[0], buf + generalData_->fifoBufferHeaderSize, generalData_->imageSize);
}
CropImage(buf);
}
try {
// normal call back
if (rawDataReadyCallBack != nullptr) {
@ -341,7 +391,6 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
// via stopReceiver tcp)
}
}
return fnum;
}
bool DataProcessor::SendToStreamer() {
@ -508,3 +557,44 @@ void DataProcessor::RearrangeDbitData(char *buf) {
memcpy(buf + digOffset, result.data(), numResult8Bits * sizeof(uint8_t));
(*((uint32_t *)buf)) = numResult8Bits * sizeof(uint8_t);
}
void DataProcessor::CropImage(char *buf) {
LOG(logDEBUG) << "Cropping Image to ROI " << sls::ToString(receiverRoi_);
int nPixelsX = generalData_->nPixelsX;
int xmin = receiverRoi_.xmin;
int xmax = receiverRoi_.xmax;
int ymin = receiverRoi_.ymin;
int ymax = receiverRoi_.ymax;
int xwidth = xmax - xmin + 1;
int ywidth = ymax - ymin + 1;
if (ymin == -1 || ymax == -1) {
ywidth = 1;
ymin = 0;
}
// calculate total roi size
double bytesPerPixel = generalData_->dynamicRange / 8.00;
int startOffset = (int)((nPixelsX * ymin + xmin) * bytesPerPixel);
// write size into fifo buffer header
std::size_t roiImageSize = xwidth * ywidth * bytesPerPixel;
LOG(logDEBUG) << "roiImageSize:" << roiImageSize;
(*((uint32_t *)buf)) = roiImageSize;
// copy the roi to the beginning of the image
char *dstOffset = buf + generalData_->fifoBufferHeaderSize;
char *srcOffset = dstOffset + startOffset;
// entire width
if (xwidth == nPixelsX) {
memcpy(dstOffset, srcOffset, roiImageSize);
}
// width is cropped
else {
for (int y = 0; y != ywidth; ++y) {
memcpy(dstOffset, srcOffset, xwidth * bytesPerPixel);
dstOffset += (int)(xwidth * bytesPerPixel);
srcOffset += (int)(generalData_->nPixelsX * bytesPerPixel);
}
}
}

View File

@ -28,17 +28,18 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
public:
DataProcessor(int index, detectorType detectorType, Fifo *fifo,
bool *activated, bool *dataStreamEnable,
uint32_t *streamingFrequency, uint32_t *streamingTimerInMs,
uint32_t *streamingStartFnum, bool *framePadding,
std::vector<int> *ctbDbitList, int *ctbDbitOffset,
int *ctbAnalogDataBytes);
bool *dataStreamEnable, uint32_t *streamingFrequency,
uint32_t *streamingTimerInMs, uint32_t *streamingStartFnum,
bool *framePadding, std::vector<int> *ctbDbitList,
int *ctbDbitOffset, int *ctbAnalogDataBytes);
~DataProcessor() override;
bool GetStartedFlag() const;
void SetFifo(Fifo *f);
void SetActivate(bool enable);
void SetReceiverROI(ROI roi);
void ResetParametersforNewAcquisition();
void SetGeneralData(GeneralData *generalData);
@ -85,7 +86,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
char *, size_t, void *),
void *arg);
/** params: sls_receiver_header pointer, pointer to data, reference to image size */
/** params: sls_receiver_header pointer, pointer to data, reference to image
* size */
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
char *, size_t &,
void *),
@ -110,9 +112,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
/**
* Process an image popped from fifo,
* write to file if fw enabled & update parameters
* @returns frame number
*/
uint64_t ProcessAnImage(char *buf);
void ProcessAnImage(char *buf);
/**
* Calls CheckTimer and CheckCount for streaming frequency and timer
@ -143,19 +144,24 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
*/
void RearrangeDbitData(char *buf);
void CropImage(char *buf);
static const std::string typeName_;
const GeneralData *generalData_{nullptr};
Fifo *fifo_;
detectorType detectorType_;
bool *dataStreamEnable_;
bool *activated_;
bool activated_{false};
ROI receiverRoi_{};
bool receiverRoiEnabled_{false};
std::unique_ptr<char[]> completeImageToStreamBeforeCropping;
/** if 0, sending random images with a timer */
uint32_t *streamingFrequency_;
uint32_t *streamingTimerInMs_;
uint32_t *streamingStartFnum_;
uint32_t currentFreqCount_{0};
struct timespec timerbegin_{};
struct timespec timerbegin_ {};
bool *framePadding_;
std::vector<int> *ctbDbitList_;
int *ctbDbitOffset_;
@ -164,7 +170,6 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
std::atomic<uint64_t> firstIndex_{0};
// for statistics
/** Number of frames caught */
uint64_t numFramesCaught_{0};
/** Frame Number of latest processed frame number */
@ -173,6 +178,8 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
/** first streamer frame to add frame index in fifo header */
bool firstStreamerFrame_{false};
bool streamCurrentFrame_{false};
File *dataFile_{nullptr};
// call back

View File

@ -19,7 +19,7 @@ const std::string DataStreamer::TypeName = "DataStreamer";
DataStreamer::DataStreamer(int ind, Fifo *f, uint32_t *dr, ROI *r, uint64_t *fi,
bool fr, slsDetectorDefs::xy np, bool *qe,
uint64_t *tot)
: ThreadObject(ind, TypeName), fifo(f), dynamicRange(dr), roi(r),
: ThreadObject(ind, TypeName), fifo(f), dynamicRange(dr), detectorRoi(r),
fileIndex(fi), flipRows(fr), numPorts(np), quadEnable(qe),
totalNumFrames(tot) {
@ -43,8 +43,8 @@ void DataStreamer::ResetParametersforNewAcquisition(const std::string &fname) {
delete[] completeBuffer;
completeBuffer = nullptr;
}
if (generalData->myDetectorType == GOTTHARD && roi->xmin != -1) {
adcConfigured = generalData->GetAdcConfigured(index, *roi);
if (generalData->myDetectorType == GOTTHARD && detectorRoi->xmin != -1) {
adcConfigured = generalData->GetAdcConfigured(index, *detectorRoi);
completeBuffer = new char[generalData->imageSizeComplete];
memset(completeBuffer, 0, generalData->imageSizeComplete);
}
@ -114,7 +114,7 @@ void DataStreamer::ThreadExecution() {
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer;
// check dummy
uint32_t numBytes = (uint32_t)(*((uint32_t *)buffer));
auto numBytes = *reinterpret_cast<uint32_t *>(buffer);
LOG(logDEBUG1) << "DataStreamer " << index << ", Numbytes:" << numBytes;
if (numBytes == DUMMY_PACKET_VALUE) {
StopProcessing(buffer);
@ -153,6 +153,7 @@ void DataStreamer::ProcessAnImage(char *buf) {
if (!startedFlag) {
RecordFirstIndex(fnum, buf);
}
auto numBytes = *reinterpret_cast<uint32_t *>(buf);
// shortframe gotthard
if (completeBuffer) {
@ -170,7 +171,7 @@ void DataStreamer::ProcessAnImage(char *buf) {
}
memcpy(completeBuffer + ((generalData->imageSize) * adcConfigured),
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
(uint32_t)(*((uint32_t *)buf)));
numBytes);
if (!zmqSocket->SendData(completeBuffer,
generalData->imageSizeComplete)) {
@ -182,16 +183,15 @@ void DataStreamer::ProcessAnImage(char *buf) {
// normal
else {
if (!SendHeader(header, (uint32_t)(*((uint32_t *)buf)),
generalData->nPixelsX, generalData->nPixelsY,
if (!SendHeader(header, numBytes, generalData->nPixelsX,
generalData->nPixelsY,
false)) { // new size possibly from callback
LOG(logERROR) << "Could not send zmq header for fnum " << fnum
<< " and streamer " << index;
}
if (!zmqSocket->SendData(
buf + FIFO_HEADER_NUMBYTES + sizeof(sls_receiver_header),
(uint32_t)(*(
(uint32_t *)buf)))) { // new size possibly from callback
if (!zmqSocket->SendData(buf + FIFO_HEADER_NUMBYTES +
sizeof(sls_receiver_header),
numBytes)) { // new size possibly from callback
LOG(logERROR) << "Could not send zmq data for fnum " << fnum
<< " and streamer " << index;
}

View File

@ -30,7 +30,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
* @param ind self index
* @param f address of Fifo pointer
* @param dr pointer to dynamic range
* @param r roi
* @param r detectorRoi
* @param fi pointer to file index
* @param fr flip rows
* @param nm number of ports in each dimension
@ -64,15 +64,7 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
*/
void CreateZmqSockets(int *nunits, uint32_t port, const sls::IpAddr ip,
int hwm);
/**
* Shuts down and deletes Zmq Sockets
*/
void CloseZmqSocket();
/**
* Restream stop dummy packet
*/
void RestreamStop();
private:
@ -82,24 +74,17 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
* @param buf get frame index from buffer to calculate first index to record
*/
void RecordFirstIndex(uint64_t fnum, char *buf);
/**
* Thread Exeution for DataStreamer Class
* Stream an image via zmq
*/
void ThreadExecution();
/**
* Frees dummy buffer,
* reset running mask by calling StopRunning()
* @param buf address of pointer
*/
void StopProcessing(char *buf);
/**
* Process an image popped from fifo,
* write to file if fw enabled & update parameters
* @param buf address of pointer
*/
void ProcessAnImage(char *buf);
@ -120,11 +105,10 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
Fifo *fifo;
ZmqSocket *zmqSocket{nullptr};
uint32_t *dynamicRange;
ROI *roi;
ROI *detectorRoi;
int adcConfigured{-1};
uint64_t *fileIndex;
bool flipRows;
std::map<std::string, std::string> additionalJsonHeader;
/** Used by streamer thread to update local copy (reduce number of locks
@ -137,15 +121,10 @@ class DataStreamer : private virtual slsDetectorDefs, public ThreadObject {
/** local copy of additional json header (it can be update on the fly) */
std::map<std::string, std::string> localAdditionalJsonHeader;
/** Aquisition Started flag */
bool startedFlag{false};
/** Frame Number of First Frame */
uint64_t firstIndex{0};
std::string fileNametoStream;
/** Complete buffer used for roi, eg. shortGotthard */
/** Complete buffer used for detectorRoi, eg. shortGotthard */
char *completeBuffer{nullptr};
xy numPorts{1, 1};

View File

@ -72,7 +72,7 @@ class GeneralData {
void ThrowGenericError(std::string msg) const {
throw sls::RuntimeError(
msg + std::string("SetROI is a generic function that should be "
msg + std::string("This is a generic function that should be "
"overloaded by a derived class"));
}
@ -96,8 +96,8 @@ class GeneralData {
bunchId = -1;
}
virtual void SetROI(slsDetectorDefs::ROI i) {
ThrowGenericError("SetROI");
virtual void SetDetectorROI(slsDetectorDefs::ROI i) {
ThrowGenericError("SetDetectorROI");
};
/**@returns adc configured */
@ -248,7 +248,7 @@ class GotthardData : public GeneralData {
return oddStartingPacket;
};
void SetROI(slsDetectorDefs::ROI i) {
void SetDetectorROI(slsDetectorDefs::ROI i) {
roi = i;
UpdateImageSize();
};

View File

@ -165,7 +165,7 @@ void Implementation::setDetectorType(const detectorType d) {
readoutType = generalData->readoutType;
adcEnableMaskOneGiga = generalData->adcEnableMaskOneGiga;
adcEnableMaskTenGiga = generalData->adcEnableMaskTenGiga;
roi = generalData->roi;
detectorRoi = generalData->roi;
counterMask = generalData->counterMask;
SetLocalNetworkParameters();
@ -179,17 +179,16 @@ void Implementation::setDetectorType(const detectorType d) {
listener.push_back(sls::make_unique<Listener>(
i, detType, fifo_ptr, &status, &udpPortNum[i], &eth[i],
&udpSocketBufferSize, &actualUDPSocketBufferSize,
&framesPerFile, &frameDiscardMode, &activated,
&detectorDataStream[i], &silentMode));
&framesPerFile, &frameDiscardMode, &detectorDataStream[i],
&silentMode));
int ctbAnalogDataBytes = 0;
if (detType == CHIPTESTBOARD) {
ctbAnalogDataBytes = generalData->GetNumberOfAnalogDatabytes();
}
dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, detType, fifo_ptr, &activated, &dataStreamEnable,
&streamingFrequency, &streamingTimerInMs, &streamingStartFnum,
&framePadding, &ctbDbitList, &ctbDbitOffset,
&ctbAnalogDataBytes));
i, detType, fifo_ptr, &dataStreamEnable, &streamingFrequency,
&streamingTimerInMs, &streamingStartFnum, &framePadding,
&ctbDbitList, &ctbDbitOffset, &ctbAnalogDataBytes));
} catch (...) {
listener.clear();
dataProcessor.clear();
@ -200,10 +199,14 @@ void Implementation::setDetectorType(const detectorType d) {
}
// set up writer and callbacks
for (const auto &it : listener)
for (const auto &it : listener) {
it->SetGeneralData(generalData);
for (const auto &it : dataProcessor)
it->SetActivate(activated);
}
for (const auto &it : dataProcessor) {
it->SetGeneralData(generalData);
it->SetActivate(activated);
}
SetThreadPriorities();
LOG(logDEBUG) << " Detector type set to " << sls::ToString(d);
@ -213,7 +216,7 @@ slsDetectorDefs::xy Implementation::getDetectorSize() const {
return numModules;
}
slsDetectorDefs::xy Implementation::GetPortGeometry() {
const slsDetectorDefs::xy Implementation::GetPortGeometry() const {
xy portGeometry{1, 1};
if (detType == EIGER)
portGeometry.x = numUDPInterfaces;
@ -363,6 +366,91 @@ void Implementation::setArping(const bool i,
}
}
slsDetectorDefs::ROI Implementation::getReceiverROI() const {
return receiverRoi;
}
void Implementation::setReceiverROI(const slsDetectorDefs::ROI arg) {
receiverRoi = arg;
if (numUDPInterfaces == 1 || detType == slsDetectorDefs::GOTTHARD2) {
portRois[0] = arg;
} else {
slsDetectorDefs::xy nPortDim(generalData->nPixelsX,
generalData->nPixelsY);
for (int iPort = 0; iPort != numUDPInterfaces; ++iPort) {
// default init = complete roi
slsDetectorDefs::ROI portRoi{};
// no roi
if (arg.noRoi()) {
portRoi.setNoRoi();
}
// incomplete roi
else if (!arg.completeRoi()) {
// get port limits
slsDetectorDefs::ROI portFullRoi{0, nPortDim.x - 1, 0,
nPortDim.y - 1};
if (iPort == 1) {
// left right (eiger)
if (GetPortGeometry().x == 2) {
portFullRoi.xmin += nPortDim.x;
portFullRoi.xmax += nPortDim.x;
}
// top bottom (jungfrau)
else {
portFullRoi.ymin += nPortDim.y;
portFullRoi.ymax += nPortDim.y;
}
}
LOG(logDEBUG)
<< iPort << ": portfullroi:" << sls::ToString(portFullRoi);
// no roi
if (arg.xmin > portFullRoi.xmax ||
arg.xmax < portFullRoi.xmin ||
arg.ymin > portFullRoi.ymax ||
arg.ymax < portFullRoi.ymin) {
portRoi.setNoRoi();
}
// incomplete module roi
else if (arg.xmin > portFullRoi.xmin ||
arg.xmax < portFullRoi.xmax ||
arg.ymin > portFullRoi.ymin ||
arg.ymax < portFullRoi.ymax) {
portRoi.xmin = (arg.xmin <= portFullRoi.xmin)
? 0
: (arg.xmin % nPortDim.x);
portRoi.xmax = (arg.xmax >= portFullRoi.xmax)
? nPortDim.x - 1
: (arg.xmax % nPortDim.x);
portRoi.ymin = (arg.ymin <= portFullRoi.ymin)
? 0
: (arg.ymin % nPortDim.y);
portRoi.ymax = (arg.ymax >= portFullRoi.ymax)
? nPortDim.y - 1
: (arg.ymax % nPortDim.y);
}
}
portRois[iPort] = portRoi;
}
}
for (size_t i = 0; i != dataProcessor.size(); ++i)
dataProcessor[i]->SetReceiverROI(portRois[i]);
LOG(logINFO) << "receiver roi: " << sls::ToString(receiverRoi);
if (numUDPInterfaces == 2 && detType != slsDetectorDefs::GOTTHARD2) {
LOG(logINFO) << "port rois: " << sls::ToString(portRois);
}
}
void Implementation::setReceiverROIMetadata(const ROI arg) {
receiverRoiMetadata = arg;
LOG(logINFO) << "receiver roi Metadata: " << sls::ToString(receiverRoiMetadata);
}
/**************************************************
* *
* File Parameters *
@ -775,6 +863,8 @@ void Implementation::StartMasterWriter() {
masterAttributes.framePadding = framePadding;
masterAttributes.scanParams = scanParams;
masterAttributes.totalFrames = numberOfTotalFrames;
masterAttributes.receiverRoi =
receiverRoiMetadata;
masterAttributes.exptime = acquisitionTime;
masterAttributes.period = acquisitionPeriod;
masterAttributes.burstMode = burstMode;
@ -805,7 +895,7 @@ void Implementation::StartMasterWriter() {
for (auto &i : ctbDbitList) {
masterAttributes.dbitlist |= (1 << i);
}
masterAttributes.roi = roi;
masterAttributes.detectorRoi = detectorRoi;
masterAttributes.counterMask = counterMask;
masterAttributes.exptimeArray[0] = acquisitionTime1;
masterAttributes.exptimeArray[1] = acquisitionTime2;
@ -842,8 +932,9 @@ void Implementation::StartMasterWriter() {
}
}
#endif
} catch (...) {
; // ignore it and just print it
} catch (std::exception &e) {
// ignore it and just print it
LOG(logWARNING) << "Caught exception when handling virtual hdf5 file [" << e.what() << "]";
}
}
@ -895,6 +986,8 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
// fifo
udpSocketBufferSize = generalData->defaultUdpSocketBufferSize;
SetupFifoStructure();
// recalculate port rois
setReceiverROI(receiverRoi);
// create threads
for (int i = 0; i < numUDPInterfaces; ++i) {
@ -904,9 +997,10 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
listener.push_back(sls::make_unique<Listener>(
i, detType, fifo_ptr, &status, &udpPortNum[i], &eth[i],
&udpSocketBufferSize, &actualUDPSocketBufferSize,
&framesPerFile, &frameDiscardMode, &activated,
&detectorDataStream[i], &silentMode));
&framesPerFile, &frameDiscardMode, &detectorDataStream[i],
&silentMode));
listener[i]->SetGeneralData(generalData);
listener[i]->SetActivate(activated);
int ctbAnalogDataBytes = 0;
if (detType == CHIPTESTBOARD) {
@ -914,11 +1008,13 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
generalData->GetNumberOfAnalogDatabytes();
}
dataProcessor.push_back(sls::make_unique<DataProcessor>(
i, detType, fifo_ptr, &activated, &dataStreamEnable,
i, detType, fifo_ptr, &dataStreamEnable,
&streamingFrequency, &streamingTimerInMs,
&streamingStartFnum, &framePadding, &ctbDbitList,
&ctbDbitOffset, &ctbAnalogDataBytes));
dataProcessor[i]->SetGeneralData(generalData);
dataProcessor[i]->SetActivate(activated);
dataProcessor[i]->SetReceiverROI(portRois[i]);
} catch (...) {
listener.clear();
dataProcessor.clear();
@ -934,15 +1030,15 @@ void Implementation::setNumberofUDPInterfaces(const int n) {
flip = (i == 1 ? true : false);
}
dataStreamer.push_back(sls::make_unique<DataStreamer>(
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip,
numPorts, &quadEnable, &numberOfTotalFrames));
i, fifo[i].get(), &dynamicRange, &detectorRoi,
&fileIndex, flip, numPorts, &quadEnable,
&numberOfTotalFrames));
dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(
&numUDPInterfaces, streamingPort, streamingSrcIP,
streamingHwm);
dataStreamer[i]->SetAdditionalJsonHeader(
additionalJsonHeader);
} catch (...) {
if (dataStreamEnable) {
dataStreamer.clear();
@ -1061,8 +1157,9 @@ void Implementation::setDataStreamEnable(const bool enable) {
flip = (i == 1 ? true : false);
}
dataStreamer.push_back(sls::make_unique<DataStreamer>(
i, fifo[i].get(), &dynamicRange, &roi, &fileIndex, flip,
numPorts, &quadEnable, &numberOfTotalFrames));
i, fifo[i].get(), &dynamicRange, &detectorRoi,
&fileIndex, flip, numPorts, &quadEnable,
&numberOfTotalFrames));
dataStreamer[i]->SetGeneralData(generalData);
dataStreamer[i]->CreateZmqSockets(
&numUDPInterfaces, streamingPort, streamingSrcIP,
@ -1420,20 +1517,20 @@ void Implementation::setDynamicRange(const uint32_t i) {
LOG(logINFO) << "Dynamic Range: " << dynamicRange;
}
slsDetectorDefs::ROI Implementation::getROI() const { return roi; }
slsDetectorDefs::ROI Implementation::getROI() const { return detectorRoi; }
void Implementation::setROI(slsDetectorDefs::ROI arg) {
if (roi.xmin != arg.xmin || roi.xmax != arg.xmax) {
roi.xmin = arg.xmin;
roi.xmax = arg.xmax;
void Implementation::setDetectorROI(slsDetectorDefs::ROI arg) {
if (detectorRoi.xmin != arg.xmin || detectorRoi.xmax != arg.xmax) {
detectorRoi.xmin = arg.xmin;
detectorRoi.xmax = arg.xmax;
// only for gotthard
generalData->SetROI(arg);
generalData->SetDetectorROI(arg);
framesPerFile = generalData->maxFramesPerFile;
SetupFifoStructure();
}
LOG(logINFO) << "ROI: [" << roi.xmin << ", " << roi.xmax << "]";
LOG(logINFO) << "Detector ROI: " << sls::ToString(detectorRoi);
LOG(logINFO) << "Packets per Frame: " << (generalData->packetsPerFrame);
}
@ -1509,6 +1606,11 @@ bool Implementation::getActivate() const { return activated; }
void Implementation::setActivate(bool enable) {
activated = enable;
for (const auto &it : listener)
it->SetActivate(enable);
for (const auto &it : dataProcessor)
it->SetActivate(enable);
LOG(logINFO) << "Activation: " << (activated ? "enabled" : "disabled");
}

View File

@ -53,6 +53,9 @@ class Implementation : private virtual slsDetectorDefs {
bool getArping() const;
pid_t getArpingThreadId() const;
void setArping(const bool i, const std::vector<std::string> ips);
ROI getReceiverROI() const;
void setReceiverROI(const ROI arg);
void setReceiverROIMetadata(const ROI arg);
/**************************************************
* *
@ -204,7 +207,7 @@ class Implementation : private virtual slsDetectorDefs {
void setDynamicRange(const uint32_t i);
ROI getROI() const;
/* [Gotthard] */
void setROI(ROI arg);
void setDetectorROI(ROI arg);
bool getTenGigaEnable() const;
/* [Eiger][Ctb] */
void setTenGigaEnable(const bool b);
@ -253,7 +256,8 @@ class Implementation : private virtual slsDetectorDefs {
* *
* ************************************************/
/** params: file path, file name, file index, image size */
void registerCallBackStartAcquisition(int (*func)(const std::string &, const std::string &,
void registerCallBackStartAcquisition(int (*func)(const std::string &,
const std::string &,
uint64_t, size_t, void *),
void *arg);
/** params: total frames caught */
@ -263,7 +267,8 @@ class Implementation : private virtual slsDetectorDefs {
void registerCallBackRawDataReady(void (*func)(sls_receiver_header *,
char *, size_t, void *),
void *arg);
/** params: sls_receiver_header pointer, pointer to data, reference to image size */
/** params: sls_receiver_header pointer, pointer to data, reference to image
* size */
void registerCallBackRawDataModifyReady(void (*func)(sls_receiver_header *,
char *, size_t &,
void *),
@ -274,7 +279,7 @@ class Implementation : private virtual slsDetectorDefs {
void SetThreadPriorities();
void SetupFifoStructure();
xy GetPortGeometry();
const xy GetPortGeometry() const;
void ResetParametersforNewAcquisition();
void CreateUDPSockets();
void SetupWriter();
@ -299,6 +304,10 @@ class Implementation : private virtual slsDetectorDefs {
bool framePadding{true};
pid_t parentThreadId;
pid_t tcpThreadId;
ROI receiverRoi{};
std::array<ROI, 2> portRois{};
// receiver roi for complete detector for metadata
ROI receiverRoiMetadata{};
// file parameters
fileFormat fileFormatType{BINARY};
@ -356,13 +365,14 @@ class Implementation : private virtual slsDetectorDefs {
uint32_t numberOfDigitalSamples{0};
uint32_t counterMask{0};
uint32_t dynamicRange{16};
ROI roi{};
ROI detectorRoi{};
bool tengigaEnable{false};
bool flipRows{false};
bool quadEnable{false};
bool activated{true};
std::array<bool, 2> detectorDataStream = {{true, true}};
std::array<bool, 2> detectorDataStream10GbE = {{true, true}};
std::array<bool, 2> portStream = {{true, true}};
int readNRows{0};
int thresholdEnergyeV{-1};
std::array<int, 3> thresholdAllEnergyeV = {{-1, -1, -1}};
@ -374,8 +384,8 @@ class Implementation : private virtual slsDetectorDefs {
int ctbDbitOffset{0};
// callbacks
int (*startAcquisitionCallBack)(const std::string &, const std::string &, uint64_t, size_t,
void *){nullptr};
int (*startAcquisitionCallBack)(const std::string &, const std::string &,
uint64_t, size_t, void *){nullptr};
void *pStartAcquisition{nullptr};
void (*acquisitionFinishedCallBack)(uint64_t, void *){nullptr};
void *pAcquisitionFinished{nullptr};

View File

@ -24,11 +24,11 @@ const std::string Listener::TypeName = "Listener";
Listener::Listener(int ind, detectorType dtype, Fifo *f,
std::atomic<runStatus> *s, uint32_t *portno, std::string *e,
int *us, int *as, uint32_t *fpf, frameDiscardPolicy *fdp,
bool *act, bool *detds, bool *sm)
bool *detds, bool *sm)
: ThreadObject(ind, TypeName), fifo(f), myDetectorType(dtype), status(s),
udpPortNumber(portno), eth(e), udpSocketBufferSize(us),
actualUDPSocketBufferSize(as), framesPerFile(fpf), frameDiscardMode(fdp),
activated(act), detectorDataStream(detds), silentMode(sm) {
detectorDataStream(detds), silentMode(sm) {
LOG(logDEBUG) << "Listener " << ind << " created";
}
@ -115,8 +115,10 @@ void Listener::RecordFirstIndex(uint64_t fnum) {
void Listener::SetGeneralData(GeneralData *g) { generalData = g; }
void Listener::SetActivate(bool enable) { activated = enable; }
void Listener::CreateUDPSockets() {
if (!(*activated) || !(*detectorDataStream)) {
if (!activated || !(*detectorDataStream)) {
return;
}
@ -166,7 +168,7 @@ void Listener::CreateDummySocketForUDPSocketBufferSize(int s) {
LOG(logINFO) << "Testing UDP Socket Buffer size " << s << " with test port "
<< *udpPortNumber;
if (!(*activated) || !(*detectorDataStream)) {
if (!activated || !(*detectorDataStream)) {
*actualUDPSocketBufferSize = (s * 2);
return;
}
@ -225,8 +227,7 @@ void Listener::ThreadExecution() {
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer;
// udpsocket doesnt exist
if (*activated && *detectorDataStream && !udpSocketAlive &&
!carryOverFlag) {
if (activated && *detectorDataStream && !udpSocketAlive && !carryOverFlag) {
// LOG(logERROR) << "Listening_Thread " << index << ": UDP Socket not
// created or shut down earlier";
(*((uint32_t *)buffer)) = 0;
@ -236,7 +237,7 @@ void Listener::ThreadExecution() {
// get data
if ((*status != TRANSMITTING &&
(!(*activated) || !(*detectorDataStream) || udpSocketAlive)) ||
(!activated || !(*detectorDataStream) || udpSocketAlive)) ||
carryOverFlag) {
rc = ListenToAnImage(buffer);
}
@ -319,7 +320,7 @@ uint32_t Listener::ListenToAnImage(char *buf) {
return 0;
}
// deactivated (eiger)
if (!(*activated)) {
if (!activated) {
return 0;
}

View File

@ -37,13 +37,12 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
* @param as pointer to actual udp socket buffer size
* @param fpf pointer to frames per file
* @param fdp frame discard policy
* @param act pointer to activated
* @param detds pointer to detector data stream
* @param sm pointer to silent mode
*/
Listener(int ind, detectorType dtype, Fifo *f, std::atomic<runStatus> *s,
uint32_t *portno, std::string *e, int *us, int *as, uint32_t *fpf,
frameDiscardPolicy *fdp, bool *act, bool *detds, bool *sm);
frameDiscardPolicy *fdp, bool *detds, bool *sm);
/**
* Destructor
@ -63,6 +62,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
void SetFifo(Fifo *f);
void ResetParametersforNewAcquisition();
void SetGeneralData(GeneralData *g);
void SetActivate(bool enable);
void CreateUDPSockets();
void ShutDownUDPSocket();
@ -76,8 +76,8 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
/**
* Set hard coded (calculated but not from detector) row and column
* r is in row index if detector has not send them yet in firmware,
* c is in col index for jungfrau and eiger (for missing packets/deactivated
* eiger) c when used is in 2d
* c is in col index for jungfrau and eiger (for missing
* packets/deactivated) c when used is in 2d
*/
void SetHardCodedPosition(uint16_t r, uint16_t c);
@ -125,7 +125,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
int *actualUDPSocketBufferSize;
uint32_t *framesPerFile;
frameDiscardPolicy *frameDiscardMode;
bool *activated;
bool activated{false};
bool *detectorDataStream;
bool *silentMode;
@ -135,7 +135,7 @@ class Listener : private virtual slsDetectorDefs, public ThreadObject {
uint16_t row{0};
/** column hardcoded as 2D,
* deactivated eiger/missing packets (eiger/jungfrau sends 2d pos) **/
* deactivated/missing packets (eiger/jungfrau sends 2d pos) **/
uint16_t column{0};
// acquisition start

View File

@ -109,6 +109,17 @@ void MasterAttributes::GetCommonBinaryAttributes(
w->String(sls::ToString(scanParams).c_str());
w->Key("Total Frames");
w->Uint64(totalFrames);
w->Key("Receiver Roi");
w->StartObject();
w->Key("xmin");
w->Uint(receiverRoi.xmin);
w->Key("xmax");
w->Uint(receiverRoi.xmax);
w->Key("ymin");
w->Uint(receiverRoi.ymin);
w->Key("ymax");
w->Uint(receiverRoi.ymax);
w->EndObject();
}
void MasterAttributes::GetFinalBinaryAttributes(
@ -274,6 +285,34 @@ void MasterAttributes::WriteCommonHDF5Attributes(H5File *fd, Group *group) {
PredType::STD_U64LE, dataspace);
dataset.write(&totalFrames, PredType::STD_U64LE);
}
// Receiver Roi xmin
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("receiver roi xmin",
PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.xmin, PredType::NATIVE_INT);
}
// Receiver Roi xmax
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("receiver roi xmax",
PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.xmax, PredType::NATIVE_INT);
}
// Receiver Roi ymin
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("receiver roi ymin",
PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.ymin, PredType::NATIVE_INT);
}
// Receiver Roi ymax
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("receiver roi ymax",
PredType::NATIVE_INT, dataspace);
dataset.write(&receiverRoi.ymax, PredType::NATIVE_INT);
}
}
void MasterAttributes::WriteFinalHDF5Attributes(H5File *fd, Group *group) {
@ -343,14 +382,14 @@ void MasterAttributes::WriteHDF5ROI(H5File *fd, Group *group) {
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("roi xmin", PredType::NATIVE_INT, dataspace);
dataset.write(&roi.xmin, PredType::NATIVE_INT);
dataset.write(&detectorRoi.xmin, PredType::NATIVE_INT);
}
// Roi xmax
{
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset =
group->createDataSet("roi xmax", PredType::NATIVE_INT, dataspace);
dataset.write(&roi.xmax, PredType::NATIVE_INT);
dataset.write(&detectorRoi.xmax, PredType::NATIVE_INT);
}
}
@ -369,7 +408,7 @@ void MasterAttributes::WriteHDF5ReadNRows(H5File *fd, Group *group) {
}
void MasterAttributes::WriteHDF5ThresholdEnergy(H5File *fd, Group *group) {
char c[1024]{};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
DataSet dataset = group->createDataSet("Threshold Energy",
PredType::NATIVE_INT, dataspace);
@ -383,7 +422,7 @@ void MasterAttributes::WriteHDF5ThresholdEnergy(H5File *fd, Group *group) {
}
void MasterAttributes::WriteHDF5ThresholdEnergies(H5File *fd, Group *group) {
char c[1024]{};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 1024);
DataSet dataset =
@ -393,7 +432,7 @@ void MasterAttributes::WriteHDF5ThresholdEnergies(H5File *fd, Group *group) {
}
void MasterAttributes::WriteHDF5SubExpTime(H5File *fd, Group *group) {
char c[1024]{};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
@ -403,7 +442,7 @@ void MasterAttributes::WriteHDF5SubExpTime(H5File *fd, Group *group) {
}
void MasterAttributes::WriteHDF5SubPeriod(H5File *fd, Group *group) {
char c[1024]{};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
@ -420,7 +459,7 @@ void MasterAttributes::WriteHDF5SubQuad(H5File *fd, Group *group) {
}
void MasterAttributes::WriteHDF5RateCorrections(H5File *fd, Group *group) {
char c[1024]{};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 1024);
DataSet dataset =
@ -438,7 +477,7 @@ void MasterAttributes::WriteHDF5CounterMask(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5ExptimeArray(H5File *fd, Group *group) {
for (int i = 0; i != 3; ++i) {
char c[1024]{};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
@ -450,7 +489,7 @@ void MasterAttributes::WriteHDF5ExptimeArray(H5File *fd, Group *group) {
void MasterAttributes::WriteHDF5GateDelayArray(H5File *fd, Group *group) {
for (int i = 0; i != 3; ++i) {
char c[1024]{};
char c[1024]{};
DataSpace dataspace = DataSpace(H5S_SCALAR);
StrType strdatatype(PredType::C_S1, 256);
DataSet dataset =
@ -533,8 +572,13 @@ void MasterAttributes::GetGotthardBinaryAttributes(
w->String(sls::ToString(exptime).c_str());
w->Key("Period");
w->String(sls::ToString(period).c_str());
w->Key("Roi (xmin, xmax)");
w->String(sls::ToString(roi).c_str());
w->Key("Detector Roi");
w->StartObject();
w->Key("xmin");
w->Uint(detectorRoi.xmin);
w->Key("xmax");
w->Uint(detectorRoi.xmax);
w->EndObject();
};
#ifdef HDF5C

View File

@ -7,8 +7,8 @@
#include "sls/logger.h"
#include "sls/sls_detector_defs.h"
#include <rapidjson/stringbuffer.h>
#include <rapidjson/prettywriter.h>
#include <rapidjson/stringbuffer.h>
#ifdef HDF5C
#include "H5Cpp.h"
@ -54,7 +54,8 @@ class MasterAttributes {
uint32_t digitalSamples{0};
uint32_t dbitoffset{0};
uint64_t dbitlist{0};
slsDetectorDefs::ROI roi{};
slsDetectorDefs::ROI detectorRoi{};
slsDetectorDefs::ROI receiverRoi{};
uint32_t counterMask{0};
std::array<ns, 3> exptimeArray{};
std::array<ns, 3> gateDelayArray{};
@ -65,15 +66,16 @@ class MasterAttributes {
MasterAttributes() = default;
~MasterAttributes() = default;
void GetBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
void
GetBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteHDF5Attributes(H5File *fd, Group *group);
#endif
void
GetCommonBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
void
GetFinalBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
void GetCommonBinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
void GetFinalBinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteCommonHDF5Attributes(H5File *fd, Group *group);
void WriteFinalHDF5Attributes(H5File *fd, Group *group);
@ -104,43 +106,44 @@ class MasterAttributes {
void WriteHDF5DbitList(H5File *fd, Group *group);
#endif
void
GetGotthardBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
void GetGotthardBinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteGotthardHDF5Attributes(H5File *fd, Group *group);
#endif
void
GetJungfrauBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
void GetJungfrauBinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteJungfrauHDF5Attributes(H5File *fd, Group *group);
#endif
void
GetEigerBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
void GetEigerBinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteEigerHDF5Attributes(H5File *fd, Group *group);
#endif
void
GetMythen3BinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
void GetMythen3BinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMythen3HDF5Attributes(H5File *fd, Group *group);
#endif
void
GetGotthard2BinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
void GetGotthard2BinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteGotthard2HDF5Attributes(H5File *fd, Group *group);
#endif
void
GetMoenchBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
void GetMoenchBinaryAttributes(
rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteMoenchHDF5Attributes(H5File *fd, Group *group);
#endif
void GetCtbBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
void
GetCtbBinaryAttributes(rapidjson::PrettyWriter<rapidjson::StringBuffer> *w);
#ifdef HDF5C
void WriteCtbHDF5Attributes(H5File *fd, Group *group);
#endif

View File

@ -17,8 +17,8 @@
// files
// versions
#define HDF5_WRITER_VERSION (6.4) // 1 decimal places
#define BINARY_WRITER_VERSION (7.0) // 1 decimal places
#define HDF5_WRITER_VERSION (6.5) // 1 decimal places
#define BINARY_WRITER_VERSION (7.1) // 1 decimal places
#define MAX_FRAMES_PER_FILE 20000
#define SHORT_MAX_FRAMES_PER_FILE 100000