AcquisitionDevice: Enable access to integration results

This commit is contained in:
2023-09-22 20:31:48 +02:00
parent 3f3ce6f354
commit 5cf0d30603
9 changed files with 140 additions and 5 deletions

View File

@@ -1030,3 +1030,63 @@ TEST_CASE("HLS_C_Simulation_internal_packet_generator_storage_cell_convert_G1",
}
}
TEST_CASE("HLS_C_Simulation_internal_packet_generator_integration", "[FPGA][Full]") {
const uint16_t nmodules = 4;
DiffractionExperiment x((DetectorGeometry(nmodules)));
x.Mode(DetectorMode::Raw);
x.UseInternalPacketGenerator(true).ImagesPerTrigger(1).PedestalG0Frames(0);
HLSSimulatedDevice test(0, 64);
std::vector<uint16_t> frame(RAW_MODULE_SIZE);
frame[0] = INT16_MAX;
frame[1] = INT16_MIN;
for (int i = 2; i < RAW_MODULE_SIZE; i++)
frame[i] = 32754;
test.SetCustomInternalGeneratorFrame(frame);
std::vector<uint16_t> integration_map(nmodules * RAW_MODULE_SIZE, 54);
for (int i = 0; i < RAW_MODULE_SIZE/2; i++) {
integration_map[2 * i] = 0;
integration_map[2 * i + 1] = FPGA_INTEGRATION_BIN_COUNT - 1;
}
integration_map[RAW_MODULE_SIZE - 1] = FPGA_INTEGRATION_BIN_COUNT;
test.InitializeIntegrationMap(x, integration_map);
REQUIRE_NOTHROW(test.StartAction(x));
REQUIRE_NOTHROW(test.WaitForActionComplete());
REQUIRE(test.OutputStream().size() == 1);
JFJochProtoBuf::AcquisitionDeviceStatistics device_statistics;
REQUIRE_NOTHROW(test.SaveStatistics(x, device_statistics));
REQUIRE(device_statistics.bytes_received() == 128 * nmodules * JUNGFRAU_PACKET_SIZE_BYTES);
auto imageBuf = test.GetFrameBuffer(0, 0);
REQUIRE(memcmp(imageBuf, frame.data(), RAW_MODULE_SIZE * sizeof(uint16_t)) == 0);
auto integration_result = test.GetIntegrationResult(0, 0);
CHECK(integration_result[0].sum == 32754LU * (RAW_MODULE_SIZE / 2 - 1));
CHECK(integration_result[0].count == RAW_MODULE_SIZE / 2 - 1);
CHECK(integration_result[1].sum == 0);
CHECK(integration_result[1].count == 0);
CHECK(integration_result[FPGA_INTEGRATION_BIN_COUNT - 1].sum == 32754LU * (RAW_MODULE_SIZE / 2 - 2));
CHECK(integration_result[FPGA_INTEGRATION_BIN_COUNT - 1].count == RAW_MODULE_SIZE / 2 - 2);
integration_result = test.GetIntegrationResult(0, 1);
CHECK(integration_result[54].sum == 32754 * (RAW_MODULE_SIZE - 2));
CHECK(integration_result[54].count == RAW_MODULE_SIZE - 2);
integration_result = test.GetIntegrationResult(0, 2);
CHECK(integration_result[54].sum == 32754 * (RAW_MODULE_SIZE - 2));
CHECK(integration_result[54].count == RAW_MODULE_SIZE - 2);
integration_result = test.GetIntegrationResult(0, 3);
CHECK(integration_result[54].sum == 32754 * (RAW_MODULE_SIZE - 2));
CHECK(integration_result[54].count == RAW_MODULE_SIZE - 2);
}