v1.0.0-rc.36

This commit is contained in:
2025-05-05 19:32:22 +02:00
parent 759243d1bf
commit 040cf08386
333 changed files with 22724 additions and 15251 deletions

View File

@@ -3,7 +3,7 @@
#include <random>
#include <catch2/catch_all.hpp>
#include "../writer/ZMQImagePuller.h"
#include "../image_puller/ZMQImagePuller.h"
#include "../image_pusher/ZMQStream2Pusher.h"
void test_puller(ZMQImagePuller *puller,
@@ -16,39 +16,40 @@ void test_puller(ZMQImagePuller *puller,
std::vector<size_t> &diff_content,
std::vector<size_t> &nimages) {
auto img = puller->WaitForImage();
if (!img.cbor || !img.cbor->start_message) {
auto timeout = std::chrono::minutes(3);
auto img = puller->PollImage(timeout);
if (!img || !img->cbor || !img->cbor->start_message) {
diff_content[writer_id]++;
return;
}
if ((!img.cbor->start_message->write_master_file) || (img.cbor->start_message->write_master_file.value() != (writer_id == 0)))
if ((!img->cbor->start_message->write_master_file) || (img->cbor->start_message->write_master_file.value() != (writer_id == 0)))
diff_content[writer_id]++;
img = puller->WaitForImage();
while (img.cbor && !img.cbor->end_message) {
if (img.cbor->data_message) {
if ((nwriter > 1) && ((img.cbor->data_message->number / 16) % nwriter != writer_id))
img = puller->PollImage(timeout);
while (img && img->cbor && !img->cbor->end_message) {
if (img->cbor->data_message) {
if ((nwriter > 1) && ((img->cbor->data_message->number / 16) % nwriter != writer_id))
diff_split[writer_id]++;
if (img.cbor->data_message->image.size != x.GetPixelsNum() * sizeof(uint16_t))
if (img->cbor->data_message->image.size != x.GetPixelsNum() * sizeof(uint16_t))
diff_size[writer_id]++;
else if (memcmp(img.cbor->data_message->image.data, image1.data() + img.cbor->data_message->number * x.GetPixelsNum(),
else if (memcmp(img->cbor->data_message->image.data, image1.data() + img->cbor->data_message->number * x.GetPixelsNum(),
x.GetPixelsNum() * sizeof(uint16_t)) != 0)
diff_content[writer_id]++;
if (img.cbor->data_message->image.xpixel != RAW_MODULE_COLS)
if (img->cbor->data_message->image.xpixel != RAW_MODULE_COLS)
diff_content[writer_id]++;
if (img.cbor->data_message->image.ypixel != RAW_MODULE_LINES)
if (img->cbor->data_message->image.ypixel != RAW_MODULE_LINES)
diff_content[writer_id]++;
if (img.cbor->data_message->image.pixel_depth_bytes != 2)
if (img->cbor->data_message->image.pixel_depth_bytes != 2)
diff_content[writer_id]++;
if (img.cbor->data_message->image.algorithm != CompressionAlgorithm::NO_COMPRESSION)
if (img->cbor->data_message->image.algorithm != CompressionAlgorithm::NO_COMPRESSION)
diff_content[writer_id]++;
nimages[writer_id]++;
}
img = puller->WaitForImage();
img = puller->PollImage(timeout);
}
}
TEST_CASE("ZMQImageCommTest_1Writer","[ZeroMQ]") {
@@ -56,7 +57,7 @@ TEST_CASE("ZMQImageCommTest_1Writer","[ZeroMQ]") {
Logger logger(Catch::getResultCapture().getCurrentTestName());
DiffractionExperiment x(DetectorGeometry(1));
DiffractionExperiment x(DetJF(1));
x.Mode(DetectorMode::Raw);
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(false).IncidentEnergy_keV(12.4)
.ImagesPerTrigger(nframes).Compression(CompressionAlgorithm::NO_COMPRESSION);
@@ -74,13 +75,12 @@ TEST_CASE("ZMQImageCommTest_1Writer","[ZeroMQ]") {
// Puller needs to be declared first, but both objects need to exist till communication finished
// TODO: ImageSender should not allow if there are still completions to be done
ZMQImagePuller puller;
ZMQStream2Pusher pusher({"ipc://*"});
std::vector<size_t> diff_size(1), diff_content(1), diff_split(1), nimages(1);
auto pusher_addr = pusher.GetAddress();
puller.Connect(pusher_addr[0]);
ZMQImagePuller puller(pusher_addr[0]);
std::thread sender_thread = std::thread([&] {
std::vector<uint8_t> serialization_buffer(16*1024*1024);
@@ -122,7 +122,7 @@ TEST_CASE("ZMQImageCommTest_2Writers","[ZeroMQ]") {
const size_t nframes = 256;
Logger logger(Catch::getResultCapture().getCurrentTestName());
DiffractionExperiment x(DetectorGeometry(1));
DiffractionExperiment x(DetJF(1));
x.Mode(DetectorMode::Raw);
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(false).IncidentEnergy_keV(12.4)
.ImagesPerTrigger(nframes).Compression(CompressionAlgorithm::NO_COMPRESSION);
@@ -153,8 +153,7 @@ TEST_CASE("ZMQImageCommTest_2Writers","[ZeroMQ]") {
auto pusher_addr = pusher.GetAddress();
REQUIRE(pusher_addr.size() == 2);
for (int i = 0; i < npullers; i++) {
puller.push_back(std::make_unique<ZMQImagePuller>());
puller[i]->Connect(pusher_addr[i]);
puller.push_back(std::make_unique<ZMQImagePuller>(pusher_addr[i]));
}
std::vector<size_t> diff_size(npullers), diff_content(npullers), diff_split(npullers), nimages(npullers);
@@ -211,7 +210,7 @@ TEST_CASE("ZMQImageCommTest_4Writers","[ZeroMQ]") {
const size_t nframes = 255;
Logger logger(Catch::getResultCapture().getCurrentTestName());
DiffractionExperiment x(DetectorGeometry(1));
DiffractionExperiment x(DetJF(1));
x.Mode(DetectorMode::Raw);
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(false).IncidentEnergy_keV(12.4)
.ImagesPerTrigger(nframes).Compression(CompressionAlgorithm::NO_COMPRESSION);
@@ -241,8 +240,7 @@ TEST_CASE("ZMQImageCommTest_4Writers","[ZeroMQ]") {
// TODO: ImageSender should not allow if there are still completions to be done
std::vector<std::unique_ptr<ZMQImagePuller> > puller;
for (int i = 0; i < npullers; i++) {
puller.push_back(std::make_unique<ZMQImagePuller>());
puller[i]->Connect(pusher_addr[i]);
puller.push_back(std::make_unique<ZMQImagePuller>(pusher_addr[i]));
}
std::vector<size_t> diff_size(npullers), diff_content(npullers), diff_split(npullers), nimages(npullers);
@@ -298,28 +296,6 @@ TEST_CASE("ZMQImageCommTest_4Writers","[ZeroMQ]") {
}
}
TEST_CASE("ZMQImagePuller_abort","[ZeroMQ]") {
Logger logger(Catch::getResultCapture().getCurrentTestName());
const size_t nframes = 256;
DiffractionExperiment x;
x.Mode(DetectorMode::Raw);
x.PedestalG0Frames(0).NumTriggers(1).UseInternalPacketGenerator(false).IncidentEnergy_keV(12.4)
.ImagesPerTrigger(nframes).Compression(CompressionAlgorithm::NO_COMPRESSION);
ZMQImagePuller puller;
std::vector<size_t> diff_size(1), diff_content(1), diff_split(1), nimages(1);
std::vector<uint16_t> image1(x.GetPixelsNum());
std::thread puller_thread(test_puller, &puller, std::cref(x), std::cref(image1), 1, 0,
std::ref(diff_split), std::ref(diff_size), std::ref(diff_content),
std::ref(nimages));
puller.Abort();
puller_thread.join();
REQUIRE(nimages[0] == 0);
}
TEST_CASE("ZMQImageCommTest_NoWriter","[ZeroMQ]") {
Logger logger(Catch::getResultCapture().getCurrentTestName());
ZMQStream2Pusher pusher({"ipc://*"});