JFJochReceiver: Use DiffractionExperiment and JFCalibration, instead of ProtoBuf structure
This commit is contained in:
+12
-11
@@ -8,7 +8,6 @@
|
||||
#include "../jungfrau/JFPedestalCalc.h"
|
||||
#include "../image_analysis/IndexerWrapper.h"
|
||||
#include "../common/DiffractionGeometry.h"
|
||||
#include "../common/ADUHistogram.h"
|
||||
|
||||
inline std::string time_UTC(const std::chrono::time_point<std::chrono::system_clock> &input) {
|
||||
auto time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(input.time_since_epoch()).count();
|
||||
@@ -20,14 +19,16 @@ inline std::string time_UTC(const std::chrono::time_point<std::chrono::system_cl
|
||||
return std::string(buf1) + std::string(buf2) + "Z";
|
||||
}
|
||||
|
||||
JFJochReceiver::JFJochReceiver(const JFJochProtoBuf::ReceiverInput &settings,
|
||||
JFJochReceiver::JFJochReceiver(const DiffractionExperiment& in_experiment,
|
||||
const JFCalibration *in_calibration,
|
||||
std::vector<AcquisitionDevice *> &in_aq_device,
|
||||
ImagePusher &in_image_sender,
|
||||
Logger &in_logger, int64_t in_forward_and_sum_nthreads,
|
||||
int64_t in_send_buffer_count,
|
||||
ZMQPreviewPublisher* in_preview_publisher,
|
||||
const NUMAHWPolicy &in_numa_policy) :
|
||||
experiment(settings.jungfraujoch_settings()),
|
||||
experiment(in_experiment),
|
||||
calibration(in_calibration),
|
||||
acquisition_device(in_aq_device),
|
||||
logger(in_logger),
|
||||
image_pusher(in_image_sender),
|
||||
@@ -44,9 +45,8 @@ JFJochReceiver::JFJochReceiver(const JFJochProtoBuf::ReceiverInput &settings,
|
||||
send_buffer = (uint8_t *) malloc(send_buffer_size * send_buffer_count);
|
||||
|
||||
try {
|
||||
if (settings.has_calibration()) {
|
||||
calib.emplace(settings.calibration());
|
||||
one_byte_mask = calib->CalculateOneByteMask(experiment);
|
||||
if (calibration != nullptr) {
|
||||
one_byte_mask = calibration->CalculateOneByteMask(experiment);
|
||||
} else {
|
||||
one_byte_mask.resize(experiment.GetPixelsNum());
|
||||
for (auto &i: one_byte_mask) i = 1;
|
||||
@@ -141,11 +141,11 @@ JFJochReceiver::JFJochReceiver(const JFJochProtoBuf::ReceiverInput &settings,
|
||||
std::vector<uint8_t> pixel_mask;
|
||||
std::vector<std::vector<uint8_t> > pedestal;
|
||||
|
||||
if (calib) {
|
||||
if (calibration != nullptr) {
|
||||
size_t xpixel = experiment.GetXPixelsNum();
|
||||
size_t ypixel = experiment.GetYPixelsNum();
|
||||
|
||||
pixel_mask = compressor.Compress(calib->CalculateNexusMask(experiment, 0));
|
||||
pixel_mask = compressor.Compress(calibration->CalculateNexusMask(experiment, 0));
|
||||
message.AddPixelMask(CBORImage{
|
||||
.data = pixel_mask.data(),
|
||||
.size = pixel_mask.size(),
|
||||
@@ -160,7 +160,7 @@ JFJochReceiver::JFJochReceiver(const JFJochProtoBuf::ReceiverInput &settings,
|
||||
if (experiment.GetSaveCalibration()) {
|
||||
for (int sc = 0; sc < experiment.GetStorageCellNumber(); sc++) {
|
||||
for (int gain = 0; gain < 3; gain++) {
|
||||
auto tmp = compressor.Compress(calib->GetPedestal(gain, sc));
|
||||
auto tmp = compressor.Compress(calibration->GetPedestal(gain, sc));
|
||||
pedestal.emplace_back(tmp);
|
||||
std::string channel = "pedestal_G" + std::to_string(gain);
|
||||
|
||||
@@ -241,8 +241,8 @@ void JFJochReceiver::AcquireThread(uint16_t data_stream) {
|
||||
}
|
||||
|
||||
try {
|
||||
if (calib)
|
||||
acquisition_device[data_stream]->InitializeCalibration(experiment, calib.value());
|
||||
if (calibration != nullptr)
|
||||
acquisition_device[data_stream]->InitializeCalibration(experiment, *calibration);
|
||||
|
||||
if (rad_int_mapping)
|
||||
acquisition_device[data_stream]->InitializeIntegrationMap(experiment,
|
||||
@@ -339,6 +339,7 @@ void JFJochReceiver::FrameTransformationThread() {
|
||||
std::vector<char> writer_buffer(experiment.GetMaxCompressedSize());
|
||||
|
||||
std::unique_ptr<IndexerWrapper> indexer;
|
||||
|
||||
if (experiment.HasUnitCell()) {
|
||||
indexer = std::make_unique<IndexerWrapper>();
|
||||
indexer->Setup(experiment.GetUnitCell());
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
#include "../common/ADUHistogram.h"
|
||||
|
||||
class JFJochReceiver {
|
||||
DiffractionExperiment experiment;
|
||||
const DiffractionExperiment &experiment;
|
||||
const JFCalibration *calibration;
|
||||
std::vector<JFModulePedestal> pedestal_result;
|
||||
std::optional<JFCalibration> calib;
|
||||
|
||||
std::vector<uint8_t> one_byte_mask;
|
||||
Logger &logger;
|
||||
@@ -112,7 +112,8 @@ class JFJochReceiver {
|
||||
void UpdateMaxImage(int64_t image_number);
|
||||
void UpdateMaxDelay(int64_t delay);
|
||||
public:
|
||||
JFJochReceiver(const JFJochProtoBuf::ReceiverInput &settings,
|
||||
JFJochReceiver(const DiffractionExperiment& experiment,
|
||||
const JFCalibration *calibration,
|
||||
std::vector<AcquisitionDevice *> &open_capi_device,
|
||||
ImagePusher &image_pusher,
|
||||
Logger &logger, int64_t forward_and_sum_nthreads,
|
||||
|
||||
@@ -19,7 +19,11 @@ grpc::Status JFJochReceiverService::Start(grpc::ServerContext *context, const JF
|
||||
// ensure that everything was rolled back
|
||||
// But it is important to do it in correct order - first abort old receiver, close it, than start new one
|
||||
receiver.reset();
|
||||
receiver = std::make_unique<JFJochReceiver>(*request, aq_devices, image_pusher,
|
||||
experiment = std::make_unique<DiffractionExperiment>(request->jungfraujoch_settings());
|
||||
calibration = std::make_unique<JFCalibration>(request->calibration());
|
||||
|
||||
receiver = std::make_unique<JFJochReceiver>(*experiment, calibration.get(),
|
||||
aq_devices, image_pusher,
|
||||
logger, nthreads, send_buffer_count,
|
||||
preview_publisher, numa_policy);
|
||||
try {
|
||||
|
||||
@@ -14,7 +14,8 @@ class JFJochReceiverService final : public JFJochProtoBuf::gRPC_JFJochReceiver::
|
||||
NUMAHWPolicy numa_policy;
|
||||
std::unique_ptr<JFJochReceiver> receiver;
|
||||
std::vector<AcquisitionDevice *> &aq_devices;
|
||||
|
||||
std::unique_ptr<JFCalibration> calibration;
|
||||
std::unique_ptr<DiffractionExperiment> experiment;
|
||||
Logger &logger;
|
||||
|
||||
ImagePusher &image_pusher;
|
||||
|
||||
Reference in New Issue
Block a user