mirror of
https://github.com/paulscherrerinstitute/sf_daq_buffer.git
synced 2026-05-02 21:24:13 +02:00
Revert back to pre-writing
This commit is contained in:
@@ -145,38 +145,14 @@ int main (int argc, char *argv[])
|
||||
ref(ring_buffer),
|
||||
ctx);
|
||||
|
||||
auto n_pulses = stop_pulse_id-start_pulse_id;
|
||||
|
||||
auto current_output_file_ = H5::H5File(output_file,
|
||||
H5F_ACC_TRUNC | H5F_ACC_SWMR_WRITE);
|
||||
|
||||
hsize_t dataset_dimension[3] =
|
||||
{n_pulses, n_modules*MODULE_Y_SIZE, MODULE_X_SIZE};
|
||||
hsize_t max_dataset_dimension[3] =
|
||||
{n_pulses, n_modules*MODULE_Y_SIZE, MODULE_X_SIZE};
|
||||
H5::DataSpace dataspace(
|
||||
3, dataset_dimension, max_dataset_dimension);
|
||||
|
||||
hsize_t dataset_chunking[3] =
|
||||
{1, n_modules*MODULE_Y_SIZE, MODULE_X_SIZE};
|
||||
H5::DSetCreatPropList dataset_properties;
|
||||
dataset_properties.setChunk(3, dataset_chunking);
|
||||
|
||||
current_output_file_.createDataSet(
|
||||
"image",
|
||||
H5::PredType::NATIVE_UINT16,
|
||||
dataspace,
|
||||
dataset_properties);
|
||||
|
||||
auto current_image_dataset_ = current_output_file_.openDataSet("image");
|
||||
H5Writer writer(output_file);
|
||||
writer.create_file();
|
||||
|
||||
// TODO: Remove stats trash.
|
||||
int i_write = 0;
|
||||
size_t total_ms = 0;
|
||||
size_t max_ms = 0;
|
||||
|
||||
char* buffer = new char[n_modules*MODULE_Y_SIZE*MODULE_X_SIZE*2];
|
||||
|
||||
for (
|
||||
size_t current_pulse_id=start_pulse_id;
|
||||
current_pulse_id <= stop_pulse_id;
|
||||
@@ -202,31 +178,14 @@ int main (int argc, char *argv[])
|
||||
auto metadata = received_data.first;
|
||||
auto data = received_data.second;
|
||||
|
||||
// cout << "Received pulse_id " << metadata->pulse_id << endl;
|
||||
//
|
||||
// if (metadata->pulse_id != current_pulse_id) {
|
||||
// cout << "ERROR expecting " << current_pulse_id;
|
||||
// cout << " diff " << current_pulse_id - metadata->pulse_id << endl;
|
||||
// }
|
||||
cout << "Received pulse_id " << metadata->pulse_id << endl;
|
||||
|
||||
std::vector<size_t> data_shape = {n_modules*512, 1024};
|
||||
if (metadata->pulse_id != current_pulse_id) {
|
||||
cout << "ERROR expecting " << current_pulse_id;
|
||||
cout << " diff " << current_pulse_id - metadata->pulse_id << endl;
|
||||
}
|
||||
|
||||
hsize_t buff_dim[2] = {n_modules*MODULE_Y_SIZE, MODULE_X_SIZE};
|
||||
H5::DataSpace buffer_space (2, buff_dim);
|
||||
|
||||
hsize_t disk_dim[3] =
|
||||
{n_pulses, n_modules*MODULE_Y_SIZE, MODULE_X_SIZE};
|
||||
H5::DataSpace disk_space(3, disk_dim);
|
||||
|
||||
hsize_t count[] = {1, n_modules*MODULE_Y_SIZE, MODULE_X_SIZE};
|
||||
hsize_t start[] = {current_pulse_id-start_pulse_id, 0, 0};
|
||||
disk_space.selectHyperslab(H5S_SELECT_SET, count, start);
|
||||
|
||||
current_image_dataset_.write(
|
||||
buffer,
|
||||
H5::PredType::NATIVE_UINT16,
|
||||
buffer_space,
|
||||
disk_space);
|
||||
// TODO: Write to H5
|
||||
|
||||
ring_buffer.release(metadata->buffer_slot_index);
|
||||
|
||||
@@ -252,7 +211,7 @@ int main (int argc, char *argv[])
|
||||
|
||||
}
|
||||
|
||||
current_output_file_.close();
|
||||
writer.close_file();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user