Files
Jungfraujoch/tools/jfjoch_preview_test.cpp
leonarski_f d315506633 * Enhancements for XFEL
* Enhancements for EIGER
* Writer is more flexible and capable of handling DECTRIS data
2024-03-05 20:41:47 +01:00

74 lines
2.7 KiB
C++

// Copyright (2019-2023) Paul Scherrer Institute
#include "../frame_serialize/ZMQStream2PreviewPublisher.h"
#include "../common/Logger.h"
#include "../compression/JFJochCompressor.h"
int main(int argc, char **argv) {
Logger logger("jfjoch_preview_test");
if (argc != 2) {
logger.Error("Usage ./jfjoch_preview_test <ZeroMQ address>");
exit(EXIT_FAILURE);
}
ZMQContext context;
ZMQStream2PreviewPublisher publisher(context, argv[1]);
logger.Info("Preview messages published on socket {}", publisher.GetAddress());
size_t xpixel = 2068;
size_t ypixel = 2164;
std::vector<int16_t> data(xpixel * ypixel);
for (int i = 0; i < 100000; i++) {
for (int j = 0; j < xpixel * ypixel; j++)
data[j] = (i * 10 + j % 10) % INT16_MAX;
JFJochBitShuffleCompressor compressor(CompressionAlgorithm::BSHUF_LZ4);
auto compressed_data = compressor.Compress(data);
std::vector<SpotToSave> spots;
spots.push_back(SpotToSave{.x = 1000, .y = 1200, .intensity = 34, .indexed = false});
spots.push_back(SpotToSave{.x = 1300, .y = 1150, .intensity = 678, .indexed = false});
spots.push_back(SpotToSave{.x = 1600, .y = 1200, .intensity = 234, .indexed = false});
spots.push_back(SpotToSave{.x = 1200, .y = 1000, .intensity = 123, .indexed = true});
spots.push_back(SpotToSave{.x = 1500, .y = 1100, .intensity = 12, .indexed = true});
spots.push_back(SpotToSave{.x = 1700, .y = 1300, .intensity = 345, .indexed = true});
CompressedImage image {
.data = compressed_data.data(),
.size = compressed_data.size(),
.xpixel = xpixel,
.ypixel = ypixel,
.pixel_depth_bytes = 2,
.pixel_is_signed = true,
.pixel_is_float = false,
.algorithm = CompressionAlgorithm::BSHUF_LZ4,
.channel = "default"
};
DataMessage message {
.number = i,
.image = image,
.image_collection_efficiency = 1.0,
.spots = spots,
.bkg_estimate = 12.345f,
.indexing_result = 1,
.timestamp = 1ul<<27 | 1ul <<35,
.exptime = 100,
.series_unique_id = "111: image/test/lyso",
.series_id = 111,
.saturated_pixel_count = 378,
.user_data = "Some random string ABCDEF",
.jf_info = UINT32_MAX,
.receiver_aq_dev_delay = 2323,
.storage_cell = 0xF
};
publisher.SendImage(message);
std::this_thread::sleep_for(std::chrono::seconds(1));
logger.Info("Published image {}", i);
}
}