45 lines
1.9 KiB
C++
45 lines
1.9 KiB
C++
// Copyright (2019-2023) Paul Scherrer Institute
|
|
|
|
#ifndef JUNGFRAUJOCH_MOCKACQUISITIONDEVICE_H
|
|
#define JUNGFRAUJOCH_MOCKACQUISITIONDEVICE_H
|
|
|
|
#include "AcquisitionDevice.h"
|
|
#include "../common/ThreadSafeFIFO.h"
|
|
#include <future>
|
|
|
|
class MockAcquisitionDevice : public AcquisitionDevice {
|
|
uint32_t current_handle = 0;
|
|
uint32_t max_handle = 0;
|
|
std::atomic<uint32_t> completed_descriptors = 0;
|
|
bool idle = true;
|
|
std::future<void> measure;
|
|
volatile bool cancel = false;
|
|
std::vector<uint16_t> internal_pkt_gen_frame;
|
|
std::vector<uint16_t> internal_pkt_gen_frame_conv;
|
|
ThreadSafeFIFO<Completion> mock_completions;
|
|
|
|
void SendCompletion(uint32_t handle, uint16_t module_number, uint64_t frame_number);
|
|
void Start(const DiffractionExperiment& experiment) override;
|
|
void MeasureThread();
|
|
void InternalPacketGeneratorThread(uint32_t nmodules, uint32_t nframes);
|
|
public:
|
|
MockAcquisitionDevice(uint16_t data_stream, size_t in_frame_buffer_size_modules,
|
|
int16_t numa_node = -1);
|
|
void AddModule(uint64_t frame, uint16_t module_number, const uint16_t *data);
|
|
void Terminate();
|
|
std::string GetMACAddress() const override;
|
|
std::string GetIPv4Address() const override;
|
|
void Cancel() override;
|
|
void Finalize() override;
|
|
|
|
// Warning - internal packet generator in MockAcquisitionDevice has one limitation:
|
|
// it assumes the same calibration for all modules of the device
|
|
// For routine receiver tests one should always set one module per device
|
|
void SetCustomInternalGeneratorFrame(const std::vector<uint16_t> &v);
|
|
std::vector<uint16_t> GetInternalGeneratorFrame() const override;
|
|
void InitializeCalibration(const DiffractionExperiment &experiment, const JFCalibration &calib) override;
|
|
uint32_t GetCompletedDescriptors() const override;
|
|
};
|
|
|
|
#endif //JUNGFRAUJOCH_MOCKACQUISITIONDEVICE_H
|