this logic is no longer needed if(is_before_boundary && (frame_timestamp > boundary_time)) { need to be careful and make sure that boundary_time hasn't overflowed the 28 bits do this by checking whether timestamp isn't very large AND boundary_time isn't very small TODO a better way to catch rollovers? if(!((boundary_time < dune::PennMicroSlice::ROLLOVER_LOW_VALUE) && (timestamp > dune::PennMicroSlice::ROLLOVER_HIGH_VALUE))) { remaining_size = (buffer_ + pl_size) - pl_ptr; remaining_data_ptr = pl_ptr; is_before_boundary = false; is_before_overlap = false; is_in_overlap = false;
if(overlap_size) { overlap_size -= remaining_size; //take off the bytes after the overlap started, and after the end of the current millislice } } else {
I need to use "loval" and "highval" in the cet::exception statement, otherwise debug builds will fail
'else' is to make sure we don't have data in both the 'overlap' and 'remaining' buffers else if(is_before_overlap && (timestamp > overlap_time)) {
need to be careful and make sure that boundary_time hasn't overflowed the 28 bits do this by checking whether timestamp isn't very large AND boundary_time isn't very small TODO a better way to catch rollovers? if(!((overlap_time < dune::PennMicroSlice::ROLLOVER_LOW_VALUE) && (timestamp > dune::PennMicroSlice::ROLLOVER_HIGH_VALUE))) { overlap_size = (buffer_ + pl_size) - pl_ptr; overlap_data_ptr = pl_ptr; is_in_overlap = true; is_before_overlap = false; } else {
I need to use "loval" and "highval" in the cet::exception statement, otherwise debug builds will fail
530 n_words_b = n_counter_words_b = n_trigger_words_b = n_timestamp_words_b = n_selftest_words_b = n_checksum_words_b = 0;
532 n_words_a = n_counter_words_a = n_trigger_words_a = n_timestamp_words_a = n_selftest_words_a = n_checksum_words_a = 0;
535 overlap_size = remaining_size = 0;
537 uint8_t* remaining_data_ptr =
nullptr;
538 overlap_data_ptr =
nullptr;
539 bool is_before_boundary =
true, is_before_overlap =
true, is_in_overlap =
false;
546 if(override_uslice_size) {
548 pl_size = override_uslice_size -
sizeof(Header);
551 pl_ptr =
buffer_ +
sizeof(Header);
555 #ifdef __DEBUG_sampleTimeSplitAndCountTwice__ 556 mf::LogInfo(
"PennMicroSlice") <<
"Dumping the received microslice with " << pl_size <<
" bytes.";
560 uint8_t* aux_ptr = pl_ptr;
565 mf::LogError(
"PennMicroSlice") <<
"Last word in the microslice is not a checksum :" << std::bitset<3>(payload_header->
data_packet_type);
575 uint64_t microslice_boundary = pl_ts->nova_timestamp;
577 uint64_t frame_timestamp = 0;
580 while(pl_ptr < (
buffer_ + pl_size)) {
581 #ifdef __DEBUG_sampleTimeSplitAndCountTwice__ 583 mf::LogInfo(
"PennMicroSlice") <<
"PennMicroSlice::sampleTimeSplitAndCountTwice DEBUG microslice_boundary = " << microslice_boundary;
584 mf::LogInfo(
"PennMicroSlice") <<
"PennMicroSlice::sampleTimeSplitAndCountTwice DEBUG pointers." 585 <<
" Payload " << (
unsigned int*)pl_ptr
586 <<
"\tOverlap " << (
unsigned int*)overlap_data_ptr
587 <<
"\tRemaining " << (
unsigned int*)remaining_data_ptr;
591 if(swap_payload_header_bytes) {
592 *((uint32_t*)pl_ptr) = ntohl(*((uint32_t*)pl_ptr));
604 }
else if ((microslice_boundary & 0x7FFFFFF) == timestamp) {
605 frame_timestamp = microslice_boundary;
606 }
else if ((microslice_boundary & 0x7FFFFFF) > timestamp) {
607 frame_timestamp = microslice_boundary - ((microslice_boundary & 0x7FFFFFF) - timestamp);
611 frame_timestamp = microslice_boundary - ((microslice_boundary & 0x7FFFFFF) + (0x7FFFFFF - timestamp));
614 #ifdef __DEBUG_sampleTimeSplitAndCountTwice__ 615 mf::LogInfo(
"PennMicroSlice") <<
"PennMicroSlice::sampleTimeSplitAndCountTwice DEBUG >> frame_timestamp : " << frame_timestamp <<
" type " << std::bitset<3>(
type);
623 mf::LogInfo(
"PennMicroSlice") <<
"Sample type: counter : [" << std::bitset<3>(
type) <<
"]";
629 mf::LogInfo(
"PennMicroSlice") <<
"Sample type: trigger : [" << std::bitset<3>(
type) <<
"]";
635 mf::LogInfo(
"PennMicroSlice") <<
"Sample type: checksum : [" << std::bitset<3>(
type) <<
"]";
638 mf::LogInfo(
"PennMicroSlice") <<
"Sample type: timestamp : [" << std::bitset<3>(
type) <<
"]";
644 mf::LogInfo(
"PennMicroSlice") <<
"Sample type: WARNING : [" << std::bitset<3>(
type) <<
"]";
650 mf::LogError(
"PennMicroSlice") <<
"Unexpected header type...something is going to fail [" << std::bitset<3>(
type) <<
"]";
662 if (is_before_boundary && (frame_timestamp > boundary_time)) {
663 remaining_size = (
buffer_ + pl_size) - pl_ptr;
664 remaining_data_ptr = pl_ptr;
665 is_before_boundary =
false;
666 is_before_overlap =
false;
667 is_in_overlap =
false;
671 overlap_size -= remaining_size;
673 }
else if (is_before_overlap & (frame_timestamp > overlap_time)) {
674 overlap_size = (
buffer_ + pl_size) - pl_ptr;
675 overlap_data_ptr = pl_ptr;
676 is_in_overlap =
true;
677 is_before_overlap =
false;
747 if(is_before_boundary)
756 if(is_before_boundary)
765 if(is_before_boundary)
766 n_timestamp_words_b++;
768 n_timestamp_words_a++;
770 n_timestamp_words_o++;
782 mf::LogWarning(
"PennMicroSlice") <<
"The DMA timed out. Possible data loss after this point.";
break;
784 mf::LogWarning(
"PennMicroSlice") <<
"Unknown data type received.";
break;
786 mf::LogWarning(
"PennMicroSlice") <<
"FIFO reached half full state. Stop run recommended.";
789 mf::LogError(
"PennMicroSlice") <<
"FIFO reached full state. Data after this point is unreliable.";
794 if(is_before_boundary)
795 n_selftest_words_b++;
797 n_selftest_words_a++;
799 n_selftest_words_o++;
804 if(is_before_boundary)
805 n_checksum_words_b++;
807 n_checksum_words_a++;
809 n_checksum_words_o++;
816 checksum = *(
reinterpret_cast<uint16_t*
>(pl_ptr) );
824 std::cerr <<
"Unknown data packet type found 0x" <<
std::hex << (
unsigned int)type
830 n_words_b = n_counter_words_b + n_trigger_words_b + n_timestamp_words_b + n_selftest_words_b + n_checksum_words_b;
831 n_words_a = n_counter_words_a + n_trigger_words_a + n_timestamp_words_a + n_selftest_words_a + n_checksum_words_a;
832 n_words_o = n_counter_words_o + n_trigger_words_o + n_timestamp_words_o + n_selftest_words_o + n_checksum_words_o;
833 #ifdef __DEBUG_sampleTimeSplitAndCountTwice__ 834 mf::LogInfo(
"PennMicroSlice") <<
"PennMicroSlice::sampleTimeSplitAndCountTwice DEBUG returning with:" 835 <<
" remaining size " << remaining_size <<
" for boundary_time " << boundary_time
836 <<
" overlap size " << overlap_size <<
" for overlap_time " << overlap_time;
838 mf::LogInfo(
"PennMicroSlice") <<
"PennMicroSlice::sampleTimeSplitAndCountTwice DEBUG returning with: " 839 <<
" Payloads before " << n_words_b <<
" = " << n_counter_words_b <<
" + " << n_trigger_words_b
840 <<
" + " << n_timestamp_words_b <<
" + " << n_selftest_words_b <<
" + " << n_checksum_words_b
841 <<
" Payloads after " << n_words_a <<
" = " << n_counter_words_a <<
" + " << n_trigger_words_a
842 <<
" + " << n_timestamp_words_a <<
" + " << n_selftest_words_a <<
" + " << n_checksum_words_a
843 <<
" Overlap payloads " << n_words_o <<
" = " << n_counter_words_o <<
" + " << n_trigger_words_o
844 <<
" + " << n_timestamp_words_o <<
" + " << n_selftest_words_o <<
" + " << n_checksum_words_o ;
846 return remaining_data_ptr;
static microslice_size_t const payload_size_trigger
static microslice_size_t const payload_size_timestamp
static const Warning_Word::warning_type_t WarnFIFOHalfFull
static const Payload_Header::data_packet_type_t DataTypeWarning
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
static microslice_size_t const payload_size_checksum
QTextStream & hex(QTextStream &s)
void display_bits(void *memstart, size_t nbytes, std::string sourcename)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
static const Payload_Header::data_packet_type_t DataTypeTimestamp
static microslice_size_t const payload_size_counter
static const Warning_Word::warning_type_t WarnUnknownDataType
dune::PennMicroSlice::microslice_size_t size() const
static const Payload_Header::data_packet_type_t DataTypeChecksum
warning_type_t warning_type
QTextStream & dec(QTextStream &s)
static const Payload_Header::data_packet_type_t DataTypeTrigger
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
static const Warning_Word::warning_type_t WarnTimeout
static const Warning_Word::warning_type_t WarnFIFOFull
static microslice_size_t const payload_size_warning
static const Payload_Header::data_packet_type_t DataTypeCounter
QTextStream & endl(QTextStream &s)