mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-04-19 18:40:01 +02:00
parent
62418c1316
commit
e9dc3d8c38
@ -19,6 +19,7 @@ Checks: '*,
|
|||||||
-google-readability-braces-around-statements,
|
-google-readability-braces-around-statements,
|
||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
-readability-isolate-declaration,
|
-readability-isolate-declaration,
|
||||||
|
-readability-implicit-bool-conversion,
|
||||||
-llvmlibc-*'
|
-llvmlibc-*'
|
||||||
|
|
||||||
HeaderFilterRegex: \.h
|
HeaderFilterRegex: \.h
|
||||||
|
@ -42,14 +42,10 @@ DataProcessor::DataProcessor(int index, detectorType detectorType, Fifo *fifo,
|
|||||||
ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false) {
|
ctbAnalogDataBytes_(ctbAnalogDataBytes), firstStreamerFrame_(false) {
|
||||||
|
|
||||||
LOG(logDEBUG) << "DataProcessor " << index << " created";
|
LOG(logDEBUG) << "DataProcessor " << index << " created";
|
||||||
|
|
||||||
memset((void *)&timerbegin_, 0, sizeof(timespec));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DataProcessor::~DataProcessor() { DeleteFiles(); }
|
DataProcessor::~DataProcessor() { DeleteFiles(); }
|
||||||
|
|
||||||
/** getters */
|
|
||||||
|
|
||||||
bool DataProcessor::GetStartedFlag() const { return startedFlag_; }
|
bool DataProcessor::GetStartedFlag() const { return startedFlag_; }
|
||||||
|
|
||||||
void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; }
|
void DataProcessor::SetFifo(Fifo *fifo) { fifo_ = fifo; }
|
||||||
@ -66,10 +62,8 @@ void DataProcessor::ResetParametersforNewAcquisition() {
|
|||||||
void DataProcessor::RecordFirstIndex(uint64_t fnum) {
|
void DataProcessor::RecordFirstIndex(uint64_t fnum) {
|
||||||
// listen to this fnum, later +1
|
// listen to this fnum, later +1
|
||||||
currentFrameIndex_ = fnum;
|
currentFrameIndex_ = fnum;
|
||||||
|
|
||||||
startedFlag_ = true;
|
startedFlag_ = true;
|
||||||
firstIndex_ = fnum;
|
firstIndex_ = fnum;
|
||||||
|
|
||||||
LOG(logDEBUG1) << index << " First Index:" << firstIndex_;
|
LOG(logDEBUG1) << index << " First Index:" << firstIndex_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,10 +78,8 @@ void DataProcessor::CloseFiles() {
|
|||||||
|
|
||||||
void DataProcessor::DeleteFiles() {
|
void DataProcessor::DeleteFiles() {
|
||||||
CloseFiles();
|
CloseFiles();
|
||||||
if (dataFile_) {
|
delete dataFile_;
|
||||||
delete dataFile_;
|
dataFile_ = nullptr;
|
||||||
dataFile_ = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void DataProcessor::SetupFileWriter(const bool filewriteEnable,
|
void DataProcessor::SetupFileWriter(const bool filewriteEnable,
|
||||||
const fileFormat fileFormatType,
|
const fileFormat fileFormatType,
|
||||||
@ -231,13 +223,11 @@ std::string DataProcessor::CreateMasterFile(
|
|||||||
void DataProcessor::ThreadExecution() {
|
void DataProcessor::ThreadExecution() {
|
||||||
char *buffer = nullptr;
|
char *buffer = nullptr;
|
||||||
fifo_->PopAddress(buffer);
|
fifo_->PopAddress(buffer);
|
||||||
LOG(logDEBUG5) << "DataProcessor " << index
|
LOG(logDEBUG5) << "DataProcessor " << index << ", " << std::hex
|
||||||
<< ", "
|
<< static_cast<void *>(buffer) << std::dec << ":" << buffer;
|
||||||
"pop 0x"
|
|
||||||
<< std::hex << (void *)(buffer) << std::dec << ":" << buffer;
|
|
||||||
|
|
||||||
// check dummy
|
// check dummy
|
||||||
auto numBytes = (uint32_t)(*((uint32_t *)buffer));
|
auto numBytes = *reinterpret_cast<uint32_t *>(buffer);
|
||||||
LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes;
|
LOG(logDEBUG1) << "DataProcessor " << index << ", Numbytes:" << numBytes;
|
||||||
if (numBytes == DUMMY_PACKET_VALUE) {
|
if (numBytes == DUMMY_PACKET_VALUE) {
|
||||||
StopProcessing(buffer);
|
StopProcessing(buffer);
|
||||||
@ -282,7 +272,7 @@ void DataProcessor::StopProcessing(char *buf) {
|
|||||||
|
|
||||||
uint64_t DataProcessor::ProcessAnImage(char *buf) {
|
uint64_t DataProcessor::ProcessAnImage(char *buf) {
|
||||||
|
|
||||||
auto *rheader = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES);
|
auto *rheader = reinterpret_cast<sls_receiver_header *>(buf + FIFO_HEADER_NUMBYTES);
|
||||||
sls_detector_header header = rheader->detHeader;
|
sls_detector_header header = rheader->detHeader;
|
||||||
uint64_t fnum = header.frameNumber;
|
uint64_t fnum = header.frameNumber;
|
||||||
currentFrameIndex_ = fnum;
|
currentFrameIndex_ = fnum;
|
||||||
@ -316,7 +306,7 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
|
|||||||
try {
|
try {
|
||||||
// normal call back
|
// normal call back
|
||||||
if (rawDataReadyCallBack != nullptr) {
|
if (rawDataReadyCallBack != nullptr) {
|
||||||
std::size_t dsize = *reinterpret_cast<uint32_t*>(buf);
|
std::size_t dsize = *reinterpret_cast<uint32_t *>(buf);
|
||||||
rawDataReadyCallBack(rheader,
|
rawDataReadyCallBack(rheader,
|
||||||
buf + FIFO_HEADER_NUMBYTES +
|
buf + FIFO_HEADER_NUMBYTES +
|
||||||
sizeof(sls_receiver_header),
|
sizeof(sls_receiver_header),
|
||||||
@ -325,7 +315,7 @@ uint64_t DataProcessor::ProcessAnImage(char *buf) {
|
|||||||
|
|
||||||
// call back with modified size
|
// call back with modified size
|
||||||
else if (rawDataModifyReadyCallBack != nullptr) {
|
else if (rawDataModifyReadyCallBack != nullptr) {
|
||||||
std::size_t revsize = *reinterpret_cast<uint32_t*>(buf);
|
std::size_t revsize = *reinterpret_cast<uint32_t *>(buf);
|
||||||
rawDataModifyReadyCallBack(rheader,
|
rawDataModifyReadyCallBack(rheader,
|
||||||
buf + FIFO_HEADER_NUMBYTES +
|
buf + FIFO_HEADER_NUMBYTES +
|
||||||
sizeof(sls_receiver_header),
|
sizeof(sls_receiver_header),
|
||||||
@ -370,14 +360,15 @@ bool DataProcessor::CheckTimer() {
|
|||||||
struct timespec end;
|
struct timespec end;
|
||||||
clock_gettime(CLOCK_REALTIME, &end);
|
clock_gettime(CLOCK_REALTIME, &end);
|
||||||
|
|
||||||
LOG(logDEBUG1) << index << " Timer elapsed time:"
|
auto elapsed_s = (end.tv_sec - timerbegin_.tv_sec) +
|
||||||
<< ((end.tv_sec - timerbegin_.tv_sec) +
|
(end.tv_nsec - timerbegin_.tv_nsec) / 1e9;
|
||||||
(end.tv_nsec - timerbegin_.tv_nsec) / 1000000000.0)
|
double timer_s = *streamingTimerInMs_ / 1e3;
|
||||||
|
|
||||||
|
LOG(logDEBUG1) << index << " Timer elapsed time:" << elapsed_s
|
||||||
<< " seconds";
|
<< " seconds";
|
||||||
|
|
||||||
// still less than streaming timer, keep waiting
|
// still less than streaming timer, keep waiting
|
||||||
if (((end.tv_sec - timerbegin_.tv_sec) +
|
if (elapsed_s < timer_s)
|
||||||
(end.tv_nsec - timerbegin_.tv_nsec) / 1000000000.0) <
|
|
||||||
((double)*streamingTimerInMs_ / 1000.00))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// restart timer
|
// restart timer
|
||||||
@ -410,7 +401,8 @@ void DataProcessor::PadMissingPackets(char *buf) {
|
|||||||
LOG(logDEBUG) << index << ": Padding Missing Packets";
|
LOG(logDEBUG) << index << ": Padding Missing Packets";
|
||||||
|
|
||||||
uint32_t pperFrame = generalData_->packetsPerFrame;
|
uint32_t pperFrame = generalData_->packetsPerFrame;
|
||||||
auto *header = (sls_receiver_header *)(buf + FIFO_HEADER_NUMBYTES);
|
auto *header =
|
||||||
|
reinterpret_cast<sls_receiver_header *>(buf + FIFO_HEADER_NUMBYTES);
|
||||||
uint32_t nmissing = pperFrame - header->detHeader.packetNumber;
|
uint32_t nmissing = pperFrame - header->detHeader.packetNumber;
|
||||||
sls_bitset pmask = header->packetsMask;
|
sls_bitset pmask = header->packetsMask;
|
||||||
|
|
||||||
@ -483,7 +475,7 @@ void DataProcessor::RearrangeDbitData(char *buf) {
|
|||||||
|
|
||||||
// ceil as numResult8Bits could be decimal
|
// ceil as numResult8Bits could be decimal
|
||||||
const int numResult8Bits =
|
const int numResult8Bits =
|
||||||
ceil((double)(numSamples * (*ctbDbitList_).size()) / 8.00);
|
ceil((numSamples * (*ctbDbitList_).size()) / 8.00);
|
||||||
std::vector<uint8_t> result(numResult8Bits);
|
std::vector<uint8_t> result(numResult8Bits);
|
||||||
uint8_t *dest = &result[0];
|
uint8_t *dest = &result[0];
|
||||||
|
|
||||||
@ -499,7 +491,7 @@ void DataProcessor::RearrangeDbitData(char *buf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// loop through the frame digital data
|
// loop through the frame digital data
|
||||||
for (auto ptr = source; ptr < (source + numSamples);) {
|
for (auto *ptr = source; ptr < (source + numSamples);) {
|
||||||
// get selected bit from each 8 bit
|
// get selected bit from each 8 bit
|
||||||
uint8_t bit = (*ptr++ >> bi) & 1;
|
uint8_t bit = (*ptr++ >> bi) & 1;
|
||||||
*dest |= bit << bitoffset;
|
*dest |= bit << bitoffset;
|
||||||
|
@ -155,7 +155,7 @@ class DataProcessor : private virtual slsDetectorDefs, public ThreadObject {
|
|||||||
uint32_t *streamingTimerInMs_;
|
uint32_t *streamingTimerInMs_;
|
||||||
uint32_t *streamingStartFnum_;
|
uint32_t *streamingStartFnum_;
|
||||||
uint32_t currentFreqCount_{0};
|
uint32_t currentFreqCount_{0};
|
||||||
struct timespec timerbegin_;
|
struct timespec timerbegin_{};
|
||||||
bool *framePadding_;
|
bool *framePadding_;
|
||||||
std::vector<int> *ctbDbitList_;
|
std::vector<int> *ctbDbitList_;
|
||||||
int *ctbDbitOffset_;
|
int *ctbDbitOffset_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user