DiffractionExperiment: Move DetectorSettings and DatasetSettings to JFJochStateMachine

This commit is contained in:
2023-11-14 16:33:19 +01:00
parent 6b2ff27f31
commit 2b6901af58
6 changed files with 262 additions and 253 deletions
-133
View File
@@ -637,139 +637,6 @@ TEST_CASE("DiffractionExperiment_DetectorInput_StorageCell","[DiffractionExperim
REQUIRE(ret.storage_cell_start() == x.GetStorageCellStart());
}
TEST_CASE("DiffractionExperiment_LoadDatasetSettings", "[DiffractionExperiment]") {
DiffractionExperiment x;
x.ImagesPerTrigger(567).BeamY_pxl(324).Compression(CompressionAlgorithm::BSHUF_ZSTD);
JFJochProtoBuf::DatasetSettings settings;
settings.set_images_per_trigger(234);
settings.set_ntrigger(56);
settings.set_beam_x_pxl(23.4);
settings.set_beam_y_pxl(123.4);
settings.set_photon_energy_kev(WVL_1A_IN_KEV);
settings.set_detector_distance_mm(57.6);
settings.set_data_file_count(5);
settings.set_space_group_number(45);
settings.set_sample_name("lyso1");
settings.set_summation(36);
settings.set_fpga_pixel_output(JFJochProtoBuf::INT16);
REQUIRE_NOTHROW(x.LoadDatasetSettings(settings));
REQUIRE(x.GetImageNumPerTrigger() == 234);
REQUIRE(x.GetBeamX_pxl() == Approx(23.4));
REQUIRE(x.GetBeamY_pxl() == Approx(123.4));
REQUIRE(x.GetSpaceGroupNumber() == 45);
REQUIRE(x.GetCompressionAlgorithm() == CompressionAlgorithm::BSHUF_LZ4);
REQUIRE(x.GetSampleName() == "lyso1");
REQUIRE(x.GetDataFileCount() == 5);
REQUIRE(x.GetDetectorDistance_mm() == Approx(57.6));
REQUIRE(x.GetSummation() == 36);
REQUIRE(x.GetFPGAOutputMode() == FPGAPixelOutput::Int16);
}
TEST_CASE("DiffractionExperiment_LoadDatasetSettings_Invalid", "[DiffractionExperiment]") {
DiffractionExperiment x;
x.ImagesPerTrigger(567).BeamY_pxl(324).Compression(CompressionAlgorithm::BSHUF_ZSTD);
JFJochProtoBuf::DatasetSettings settings;
settings.set_images_per_trigger(-1);
settings.set_ntrigger(56);
settings.set_beam_x_pxl(23.4);
settings.set_beam_y_pxl(123.4);
settings.set_photon_energy_kev(WVL_1A_IN_KEV);
settings.set_detector_distance_mm(57.6);
settings.set_data_file_count(5);
settings.set_space_group_number(45);
settings.set_sample_name("lyso1");
REQUIRE_THROWS(x.LoadDatasetSettings(settings));
REQUIRE(x.GetImageNumPerTrigger() == 567);
REQUIRE(x.GetBeamY_pxl() == Approx(324));
REQUIRE(x.GetSpaceGroupNumber() == 0);
}
TEST_CASE("DiffractionExperiment_LoadDetectorSettings", "[DiffractionExperiment]") {
DiffractionExperiment x;
x.PedestalG0Frames(456).PedestalG1Frames(1234).PedestalG2Frames(123).StorageCellDelay(2500ns);
JFJochProtoBuf::DetectorSettings settings;
settings.set_frame_time_us(600);
settings.set_count_time_us(400);
settings.set_storage_cell_count(8);
settings.set_use_internal_packet_generator(true);
settings.set_collect_raw_data(true);
settings.set_pedestal_g0_frames(5000);
settings.set_pedestal_g1_frames(100);
settings.set_pedestal_g2_frames(150);
REQUIRE_NOTHROW(x.LoadDetectorSettings(settings));
REQUIRE(x.GetFrameTime().count() == 600);
REQUIRE(x.GetFrameCountTime().count() == 400);
REQUIRE(x.IsUsingInternalPacketGen());
REQUIRE(x.GetStorageCellNumber() == 8);
REQUIRE(x.GetDetectorMode() == DetectorMode::Raw);
REQUIRE(x.GetPedestalG0Frames() == 5000);
REQUIRE(x.GetPedestalG1Frames() == 100);
REQUIRE(x.GetPedestalG2Frames() == 150);
REQUIRE(x.GetStorageCellDelay().count() == 2500);
}
TEST_CASE("DiffractionExperiment_LoadDetectorSettings_StorageCellDelay", "[DiffractionExperiment]") {
DiffractionExperiment x;
x.PedestalG0Frames(456).PedestalG1Frames(1234).PedestalG2Frames(123).StorageCellDelay(5000ns);
JFJochProtoBuf::DetectorSettings settings;
settings.set_frame_time_us(600);
settings.set_count_time_us(400);
settings.set_storage_cell_count(8);
settings.set_use_internal_packet_generator(true);
settings.set_collect_raw_data(true);
settings.set_storage_cell_delay_ns(7000);
REQUIRE_NOTHROW(x.LoadDetectorSettings(settings));
REQUIRE(x.GetStorageCellDelay().count() == 7000);
}
TEST_CASE("DiffractionExperiment_LoadDetectorSettings_invalid", "[DiffractionExperiment]") {
DiffractionExperiment x;
x.PedestalG0Frames(456).PedestalG1Frames(1234).PedestalG2Frames(123);
x.FrameTime(525us).Mode(DetectorMode::Conversion);
JFJochProtoBuf::DetectorSettings settings;
settings.set_frame_time_us(600);
settings.set_count_time_us(800);
settings.set_storage_cell_count(16);
settings.set_use_internal_packet_generator(true);
settings.set_collect_raw_data(true);
settings.set_pedestal_g0_frames(5000);
settings.set_pedestal_g1_frames(100);
settings.set_pedestal_g2_frames(150);
REQUIRE_THROWS(x.LoadDetectorSettings(settings));
REQUIRE(x.GetFrameTime().count() == 525);
REQUIRE(x.GetFrameCountTime().count() == 525 - READOUT_TIME_IN_US);
REQUIRE(!x.IsUsingInternalPacketGen());
REQUIRE(x.GetStorageCellNumber() == 1);
REQUIRE(x.GetDetectorMode() == DetectorMode::Conversion);
REQUIRE(x.GetPedestalG0Frames() == 456);
REQUIRE(x.GetPedestalG1Frames() == 1234);
REQUIRE(x.GetPedestalG2Frames() == 123);
}
TEST_CASE("DiffractionExperiment_LoadDetectorSettings_inferred", "[DiffractionExperiment]") {
DiffractionExperiment x;
x.PedestalG0Frames(456).PedestalG1Frames(1234).PedestalG2Frames(123);
JFJochProtoBuf::DetectorSettings settings;
settings.set_frame_time_us(600);
settings.set_storage_cell_count(1);
REQUIRE_NOTHROW(x.LoadDetectorSettings(settings));
REQUIRE(x.GetFrameTime().count() == 600);
REQUIRE(x.GetFrameCountTime().count() == 600 - READOUT_TIME_IN_US);
REQUIRE(!x.IsUsingInternalPacketGen());
REQUIRE(x.GetStorageCellNumber() == 1);
REQUIRE(x.GetDetectorMode() == DetectorMode::Conversion);
}
TEST_CASE("DiffractionExperiment_DefaultDataProcessingSettings","[DiffractionExperiment]") {
REQUIRE_NOTHROW(DiffractionExperiment::CheckDataProcessingSettings(
DiffractionExperiment::DefaultDataProcessingSettings()));