jfjoch_action_test_mock: Added, to be later merged with jfjoch_action_test
This commit is contained in:
@@ -72,4 +72,8 @@ INSTALL(TARGETS jfjoch_receiver RUNTIME)
|
||||
|
||||
ADD_EXECUTABLE(jfjoch_action_test jfjoch_action_test.cpp)
|
||||
TARGET_LINK_LIBRARIES(jfjoch_action_test JungfraujochHost JFJochReceiver)
|
||||
INSTALL(TARGETS jfjoch_action_test RUNTIME)
|
||||
INSTALL(TARGETS jfjoch_action_test RUNTIME)
|
||||
|
||||
ADD_EXECUTABLE(jfjoch_action_test_mock jfjoch_action_test_mock.cpp)
|
||||
TARGET_LINK_LIBRARIES(jfjoch_action_test_mock JungfraujochHost JFJochReceiver)
|
||||
INSTALL(TARGETS jfjoch_action_test_mock RUNTIME)
|
||||
@@ -0,0 +1,89 @@
|
||||
// Copyright (2019-2022) Paul Scherrer Institute
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include "MockAcquisitionDevice.h"
|
||||
#include "JFJochReceiverTest.h"
|
||||
#include "../tests/FPGAUnitTest.h"
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
uint16_t nstreams = 1;
|
||||
const uint16_t nmodules = 1;
|
||||
size_t nimages = 2;
|
||||
uint64_t processing_period = 20;
|
||||
|
||||
Logger logger("ActionTest");
|
||||
logger.Verbose(true);
|
||||
|
||||
bool abort_test = false;
|
||||
|
||||
if ((argc == 1) || (argc > 6)) {
|
||||
logger.Error("Usage ./jfjoch_action_test <path to JFjoch source> {<# of images> {<# of modules> {<# of streams> {<processing period>}}}}");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (argc >= 3) nimages = atol(argv[2]);
|
||||
if (argc >= 4) nstreams = atoi(argv[3]);
|
||||
if (argc >= 5) processing_period = atoi(argv[4]);
|
||||
|
||||
DiffractionExperiment x(DetectorGeometry(nmodules*nstreams, 2, 8, 36, true));
|
||||
|
||||
x.Mode(DetectorMode::Conversion);
|
||||
x.ImagesPerTrigger(nimages).PedestalG0Frames(0).UseInternalPacketGenerator(true).PhotonEnergy_keV(12.4).NumTriggers(1);
|
||||
x.SpotFindingPeriod(std::chrono::milliseconds(processing_period)).MaskModuleEdges(false).MaskChipEdges(false);
|
||||
x.Compression(JFJochProtoBuf::BSHUF_LZ4).DataStreams(nstreams);
|
||||
|
||||
bool verbose = false;
|
||||
bool print_status_updates = true;
|
||||
uint16_t nthreads = 16;
|
||||
|
||||
logger.Verbose(verbose);
|
||||
|
||||
std::vector<std::unique_ptr<MockAcquisitionDevice>> pcie_devices;
|
||||
std::vector<AcquisitionDevice *> aq_devices;
|
||||
|
||||
std::string image_path = std::string(argv[1]) + "/tests/test_data/mod5_raw0.bin";
|
||||
std::vector<uint16_t> input(RAW_MODULE_SIZE, 0);
|
||||
LoadBinaryFile(image_path, input.data(), RAW_MODULE_SIZE);
|
||||
|
||||
for (int i = 0; i < nstreams; i++) {
|
||||
pcie_devices.push_back(std::make_unique<MockAcquisitionDevice>(i, 1024));
|
||||
pcie_devices[i]->SetCustomInternalGeneratorFrame(input);
|
||||
pcie_devices[i]->EnableLogging(&logger);
|
||||
aq_devices.push_back(pcie_devices[i].get());
|
||||
}
|
||||
|
||||
volatile bool done = false;
|
||||
JFJochProtoBuf::ReceiverOutput output;
|
||||
bool ret;
|
||||
std::thread run_thread([&] {
|
||||
try {
|
||||
ret = JFJochReceiverTest(output, logger, aq_devices, x, nthreads,abort_test, verbose);
|
||||
} catch (std::exception &e) {
|
||||
logger.Error(e.what());
|
||||
ret = false;
|
||||
}
|
||||
done = true;
|
||||
});
|
||||
|
||||
|
||||
run_thread.join();
|
||||
|
||||
double receiving_time = static_cast<double>(output.end_time_ms() - output.start_time_ms())/1000.0;
|
||||
|
||||
logger.Info("Efficiency: {:.2f}%", output.efficiency() * 100.f);
|
||||
logger.Info("Max delay: {}",output.max_receive_delay());
|
||||
logger.Info("Compression factor: {}x", output.compressed_ratio());
|
||||
logger.Info("Receiving time: {} s", receiving_time);
|
||||
logger.Info("Frame rate: {} Hz", static_cast<double>(nimages)/receiving_time);
|
||||
logger.Info("Total throughput: {:.2f} GB/s",
|
||||
static_cast<double>(nimages*nstreams*nmodules*RAW_MODULE_SIZE*sizeof(uint16_t)) / (receiving_time * 1e9));
|
||||
logger.Info("");
|
||||
|
||||
if (ret) {
|
||||
logger.Info("Test properly executed! (check stall values manually)");
|
||||
exit(EXIT_SUCCESS);
|
||||
} else
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
Reference in New Issue
Block a user