Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch/fddaq v4.4.x #95

Merged
merged 11 commits into from
Jun 20, 2024
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
project(hdf5libs VERSION 2.8.2)
project(hdf5libs VERSION 2.8.4)

find_package(daq-cmake REQUIRED)

Expand Down
34 changes: 24 additions & 10 deletions scripts/hdf5_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,36 @@ def check_fragments(self, k_nrecords):
break
dset = self.h5file[i.header]
data_array = bytearray(dset[:])
(trh_version, ) = struct.unpack('<I', data_array[4:8])
if trh_version != TRIGGER_RECORD_HEADER_VERSION:
raise ValueError(f"Invalid TriggerRecord Header format version: expected {TRIGGER_RECORD_HEADER_VERSION} and found {trh_version}")
(h, j, k) = struct.unpack('<3Q', data_array[8:32])
(s, ) = struct.unpack('<H', data_array[42:44])
(s, ) = struct.unpack('<H', data_array[48:50])
nf = len(i.fragments)
report.append((h, s, k, nf, nf - k))
empty_frag_count = 0
for frag in i.fragments:
frag_dset = self.h5file[frag]
frag_data = bytearray(frag_dset[:])
(frag_version, ) = struct.unpack('<I', frag_data[4:8])
if frag_version != FRAGMENT_HEADER_VERSION:
raise ValueError(f"Invalid Fragment Header format version: expected {FRAGMENT_HEADER_VERSION} and found {frag_version}")
(frag_size, ) = struct.unpack('<Q', frag_data[8:16])
if frag_size <= 72:
empty_frag_count += 1
report.append((h, s, k, nf, nf - k, empty_frag_count))
n += 1
print("{:-^80}".format("Column Definitions"))
print("i: Trigger record number;")
print("s: Sequence number;")
print("N_frag_exp: expected no. of fragments stored in header;")
print("N_frag_act: no. of fragments written in trigger record;")
print("N_diff: N_frag_act - N_frag_exp")
print("i: Trigger record number;")
print("s: Sequence number;")
print("N_frag_exp: expected no. of fragments stored in header;")
print("N_frag_act: no. of fragments written in trigger record;")
print("N_diff: N_frag_act - N_frag_exp")
print("N_frag_empty: no. of empty fragments (size <= 72)")
print("{:-^80}".format("Column Definitions"))
print("{:^10}{:^10}{:^15}{:^15}{:^10}".format(
"i", "s", "N_frag_exp", "N_frag_act", "N_diff"))
print("{:^10}{:^10}{:^15}{:^15}{:^10}{:^12}".format(
"i", "s", "N_frag_exp", "N_frag_act", "N_diff", "N_frag_empty"))
for i in range(len(report)):
print("{:^10}{:^10}{:^15}{:^15}{:^10}".format(*report[i]))
print("{:^10}{:^10}{:^15}{:^15}{:^10}{:^12}".format(*report[i]))
return

class Record:
Expand Down
25 changes: 19 additions & 6 deletions test/apps/HDF5LIBS_TestDumpRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "hdf5libs/hdf5rawdatafile/Nljs.hpp"
#include "trgdataformats/TriggerObjectOverlay.hpp"

#include <bitset>
#include <fstream>
#include <iostream>
#include <sstream>
Expand Down Expand Up @@ -266,28 +267,40 @@ main(int argc, char** argv)
// Finding the bit positions for input_low and input_high
uint32_t bit_pos, bit_sniff;
uint32_t input_low = hsi_ptr->input_low;
std::bitset<32> low_bits{input_low};
size_t num_bits = low_bits.count();
ss << ",\n\t\t" << "Input Low Bitmap = " << input_low;
if (input_low != 0) { // Skip printing the positions if the value is 0.
ss << ", Input Low Bit Positions = ";
bit_sniff = 1;
for (bit_pos = 0; bit_pos < 32; bit_pos++) {
for (bit_pos = 0; bit_pos < 32, num_bits > 0; bit_pos++) {
if (input_low & bit_sniff) {
bit_sniff = bit_sniff << 1;
ss << bit_pos << " ";
if (num_bits == 1)
ss << bit_pos;
else
ss << bit_pos << ", ";
num_bits--;
}
bit_sniff = bit_sniff << 1;
}
}

uint32_t input_high = hsi_ptr->input_high;
std::bitset<32> high_bits{input_high};
num_bits = high_bits.count();
ss << ",\n\t\t" << "Input High Bitmap = " << input_high;
if (input_high != 0) {
ss << ", Input High Bit Positions = ";
bit_sniff = 1;
for (bit_pos = 0; bit_pos < 32; bit_pos++) {
for (bit_pos = 0; bit_pos < 32, num_bits > 0; bit_pos++) {
if (input_high & bit_sniff) {
bit_sniff = bit_sniff << 1;
ss << bit_pos << " ";
if (num_bits == 1)
ss << bit_pos;
else
ss << bit_pos << ", ";
num_bits--;
}
bit_sniff = bit_sniff << 1;
}
}
ss << "."; // Finishes the HSI section.
Expand Down
Loading