TCP: Improve behavior and documentation

This commit is contained in:
2026-03-04 15:30:07 +01:00
parent 5345b41e16
commit 2914d77dbd
11 changed files with 186 additions and 26 deletions
+27 -3
View File
@@ -10,6 +10,9 @@ void HDF5FilePusher::StartDataCollection(StartMessage &message) {
throw JFJochException(JFJochExceptionCategory::WrongDAQState, "Image pusher is already writing images");
writer = std::make_unique<FileWriter>(message);
writer_future = std::async(std::launch::async, &HDF5FilePusher::WriterThread, this);
images_written = 0;
images_err = 0;
last_processed_image = 0;
}
bool HDF5FilePusher::EndDataCollection(const EndMessage &message) {
@@ -33,9 +36,16 @@ bool HDF5FilePusher::SendImage(const uint8_t *image_data, size_t image_size, int
throw JFJochException(JFJochExceptionCategory::WrongDAQState, "Image pusher not ready for sending");
auto deserialized = CBORStream2Deserialize(image_data, image_size);
if (deserialized->data_message)
writer->Write(*deserialized->data_message);
else
if (deserialized->data_message) {
try {
writer->Write(*deserialized->data_message);
images_written++;
if (image_number > last_processed_image)
last_processed_image = image_number;
} catch (const JFJochException &e) {
images_err++;
}
} else
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
"HDF5FilePusher::SendImage accepts only data image");
return true;
@@ -70,3 +80,17 @@ std::string HDF5FilePusher::PrintSetup() const {
std::filesystem::path currentPath = std::filesystem::current_path();
return "HDF5FilePusher: Images are written directly to file in base directory " + currentPath.string();
}
std::optional<ImagePusherAckProgress> HDF5FilePusher::GetAckProgress() const {
uint64_t ack_ok = images_written;
uint64_t ack_bad = images_err;
uint64_t ack_total = ack_ok + ack_bad;
uint64_t last = last_processed_image;
return ImagePusherAckProgress{
.data_acked_ok = ack_ok,
.data_acked_bad = ack_bad,
.data_acked_total = ack_total,
.last_processed_images = last
};
}