DiffractionExperiment: Storage cell number can be adjusted from the frontend
This commit is contained in:
@@ -941,11 +941,7 @@ void DiffractionExperiment::LoadDetectorSettings(const JFJochProtoBuf::DetectorS
|
||||
else
|
||||
FrameTime(std::chrono::microseconds(settings.frame_time_us()));
|
||||
|
||||
if (settings.use_storage_cells())
|
||||
StorageCells(16);
|
||||
else
|
||||
StorageCells(1);
|
||||
|
||||
StorageCells(settings.storage_cell_count());
|
||||
UseInternalPacketGenerator(settings.use_internal_packet_generator());
|
||||
|
||||
if (settings.collect_raw_data())
|
||||
@@ -975,7 +971,7 @@ JFJochProtoBuf::DetectorSettings DiffractionExperiment::GetDetectorSettings() co
|
||||
ret.set_count_time_us(GetFrameCountTime().count());
|
||||
ret.set_collect_raw_data(GetDetectorMode() != DetectorMode::Conversion);
|
||||
ret.set_use_internal_packet_generator(IsUsingInternalPacketGen());
|
||||
ret.set_use_storage_cells(GetStorageCellNumber() > 1);
|
||||
ret.set_storage_cell_count(GetStorageCellNumber());
|
||||
ret.set_pedestal_g0_frames(GetPedestalG0Frames());
|
||||
ret.set_pedestal_g1_frames(GetPedestalG1Frames());
|
||||
ret.set_pedestal_g2_frames(GetPedestalG2Frames());
|
||||
|
||||
@@ -4,6 +4,10 @@ import {Switch, Grid, InputAdornment, TextField} from "@mui/material";
|
||||
import Button from "@mui/material/Button";
|
||||
import Paper from "@mui/material/Paper";
|
||||
import {handleErrors} from "./handleErrors";
|
||||
import FormControl from "@mui/material/FormControl";
|
||||
import InputLabel from "@mui/material/InputLabel";
|
||||
import Select, {SelectChangeEvent} from "@mui/material/Select";
|
||||
import MenuItem from "@mui/material/MenuItem";
|
||||
|
||||
type MyProps = {
|
||||
addr: string;
|
||||
@@ -12,7 +16,7 @@ type MyProps = {
|
||||
type MyState = {
|
||||
s: {
|
||||
frameTimeUs: number | string,
|
||||
useStorageCells: boolean,
|
||||
storageCellCount: number | string,
|
||||
useInternalPacketGenerator: boolean,
|
||||
collectRawData: boolean,
|
||||
countTimeUs: number | string,
|
||||
@@ -20,6 +24,7 @@ type MyState = {
|
||||
pedestalG1Frames: number | string,
|
||||
pedestalG2Frames: number | string
|
||||
},
|
||||
storage_cell_list_value: string,
|
||||
frame_time_error: boolean,
|
||||
count_time_error: boolean,
|
||||
connection_error: boolean
|
||||
@@ -35,7 +40,7 @@ class DetectorSettings extends Component<MyProps, MyState> {
|
||||
state = {
|
||||
s: {
|
||||
frameTimeUs: 1000,
|
||||
useStorageCells: false,
|
||||
storageCellCount: 1,
|
||||
useInternalPacketGenerator: false,
|
||||
collectRawData: false,
|
||||
countTimeUs: 980,
|
||||
@@ -43,6 +48,7 @@ class DetectorSettings extends Component<MyProps, MyState> {
|
||||
pedestalG1Frames: 300,
|
||||
pedestalG2Frames: 300
|
||||
},
|
||||
storage_cell_list_value: "1",
|
||||
frame_time_error: false,
|
||||
count_time_error: false,
|
||||
connection_error: true
|
||||
@@ -91,14 +97,6 @@ class DetectorSettings extends Component<MyProps, MyState> {
|
||||
this.updateCollectionTime(this.state.s.frameTimeUs, event.target.value);
|
||||
}
|
||||
|
||||
storageCellToggle = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
this.setState(prevState => (
|
||||
{
|
||||
s : {...prevState.s,
|
||||
useStorageCells: event.target.checked}
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
rawDataToggle = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
this.setState(prevState => (
|
||||
@@ -123,12 +121,23 @@ class DetectorSettings extends Component<MyProps, MyState> {
|
||||
.catch(error => console.log(error) );
|
||||
}
|
||||
|
||||
handleChange = (event : SelectChangeEvent<String>) => {
|
||||
this.setState(prevState => ({
|
||||
storage_cell_list_value: String(event.target.value).toString(),
|
||||
s : {...prevState.s,
|
||||
storageCellCount: String(event.target.value).toString()
|
||||
}
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
getValues = () => {
|
||||
fetch(this.addr + 'detector/settings')
|
||||
.then(handleErrors)
|
||||
.then(res => res.json())
|
||||
.then(data => this.setState({
|
||||
s: data,
|
||||
storage_cell_list_value: String(data.storageCellCount),
|
||||
connection_error: false
|
||||
}))
|
||||
.catch(error => {
|
||||
@@ -175,9 +184,24 @@ class DetectorSettings extends Component<MyProps, MyState> {
|
||||
|
||||
<br/><br/>
|
||||
|
||||
<Switch onChange={this.storageCellToggle} checked={this.state.s.useStorageCells}
|
||||
disabled={this.state.connection_error}/>
|
||||
Measure with storage cells<br/><br/>
|
||||
<FormControl>
|
||||
<InputLabel id="demo-simple-select-label">Storage cell count</InputLabel>
|
||||
<Select
|
||||
labelId="demo-simple-select-label"
|
||||
id="demo-simple-select"
|
||||
value={this.state.storage_cell_list_value}
|
||||
label="Storage cell count"
|
||||
onChange={this.handleChange}
|
||||
disabled={this.state.connection_error}
|
||||
>
|
||||
<MenuItem value={"1"}>1</MenuItem>
|
||||
<MenuItem value={"2"}>2</MenuItem>
|
||||
<MenuItem value={"4"}>4</MenuItem>
|
||||
<MenuItem value={"8"}>8</MenuItem>
|
||||
<MenuItem value={"16"}>16</MenuItem>
|
||||
</Select>
|
||||
</FormControl>
|
||||
<br/><br/>
|
||||
|
||||
<Switch onChange={this.rawDataToggle} checked={this.state.s.collectRawData}
|
||||
disabled={this.state.connection_error}/>
|
||||
|
||||
+1
-1
@@ -106,7 +106,7 @@ message DetectorSettings {
|
||||
int64 frame_time_us = 1;
|
||||
optional int64 count_time_us = 2;
|
||||
|
||||
bool use_storage_cells = 3;
|
||||
int64 storage_cell_count = 3;
|
||||
bool use_internal_packet_generator = 4;
|
||||
bool collect_raw_data = 5;
|
||||
|
||||
|
||||
+100
-100
File diff suppressed because one or more lines are too long
@@ -285,14 +285,9 @@ int64_t JFJochReceiver::MiniSummationThread(int d, int m, size_t image_number, b
|
||||
}
|
||||
|
||||
int64_t JFJochReceiver::FrameTransformationThread() {
|
||||
|
||||
|
||||
FrameTransformation transformation(experiment);
|
||||
|
||||
JFJochFrameSerializer serializer(experiment.GetPixelsNum()*sizeof(uint32_t)*2);
|
||||
|
||||
std::binary_semaphore serializer_buffer_sempahore(1);
|
||||
|
||||
std::unique_ptr<GPUImageAnalysis> spot_finder;
|
||||
|
||||
try {
|
||||
|
||||
@@ -817,7 +817,7 @@ TEST_CASE("DiffractionExperiment_LoadDetectorSettings", "[DiffractionExperiment]
|
||||
JFJochProtoBuf::DetectorSettings settings;
|
||||
settings.set_frame_time_us(600);
|
||||
settings.set_count_time_us(400);
|
||||
settings.set_use_storage_cells(true);
|
||||
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);
|
||||
@@ -828,7 +828,7 @@ TEST_CASE("DiffractionExperiment_LoadDetectorSettings", "[DiffractionExperiment]
|
||||
REQUIRE(x.GetFrameTime().count() == 600);
|
||||
REQUIRE(x.GetFrameCountTime().count() == 400);
|
||||
REQUIRE(x.IsUsingInternalPacketGen());
|
||||
REQUIRE(x.GetStorageCellNumber() == 16);
|
||||
REQUIRE(x.GetStorageCellNumber() == 8);
|
||||
REQUIRE(x.GetDetectorMode() == DetectorMode::Raw);
|
||||
REQUIRE(x.GetPedestalG0Frames() == 5000);
|
||||
REQUIRE(x.GetPedestalG1Frames() == 100);
|
||||
@@ -842,7 +842,7 @@ TEST_CASE("DiffractionExperiment_LoadDetectorSettings_invalid", "[DiffractionExp
|
||||
JFJochProtoBuf::DetectorSettings settings;
|
||||
settings.set_frame_time_us(600);
|
||||
settings.set_count_time_us(800);
|
||||
settings.set_use_storage_cells(true);
|
||||
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);
|
||||
@@ -866,7 +866,7 @@ TEST_CASE("DiffractionExperiment_LoadDetectorSettings_inferred", "[DiffractionEx
|
||||
|
||||
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);
|
||||
@@ -898,6 +898,7 @@ TEST_CASE("DiffractionExperiment_ConversionOnCPU","[DiffractionExperiment]") {
|
||||
// Loading detector settings without explicit option should reset to standard behavior
|
||||
JFJochProtoBuf::DetectorSettings settings;
|
||||
settings.set_frame_time_us(600);
|
||||
settings.set_storage_cell_count(1);
|
||||
x.LoadDetectorSettings(settings);
|
||||
REQUIRE(x.GetConversionOnFPGA());
|
||||
REQUIRE(!x.GetConversionOnCPU());
|
||||
|
||||
@@ -63,7 +63,7 @@ TEST_CASE("JFJochStateMachine_State_Pedestal") {
|
||||
|
||||
JFJochProtoBuf::DetectorSettings settings;
|
||||
settings.set_frame_time_us(500);
|
||||
settings.set_use_storage_cells(true);
|
||||
settings.set_storage_cell_count(16);
|
||||
REQUIRE_THROWS(state_machine.SetDetectorSettings(settings));
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ TEST_CASE("JFJochStateMachine_State_Measure") {
|
||||
|
||||
JFJochProtoBuf::DetectorSettings settings;
|
||||
settings.set_frame_time_us(500);
|
||||
settings.set_use_storage_cells(true);
|
||||
settings.set_storage_cell_count(16);
|
||||
REQUIRE_THROWS(state_machine.SetDetectorSettings(settings));
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ TEST_CASE("JFJochStateMachine_State_Error") {
|
||||
|
||||
JFJochProtoBuf::DetectorSettings settings;
|
||||
settings.set_frame_time_us(500);
|
||||
settings.set_use_storage_cells(true);
|
||||
settings.set_storage_cell_count(16);
|
||||
REQUIRE_NOTHROW(state_machine.SetDetectorSettings(settings));
|
||||
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
@@ -147,7 +147,7 @@ TEST_CASE("JFJochStateMachine_Setup") {
|
||||
settings.set_pedestal_g2_frames(2800);
|
||||
settings.set_pedestal_g1_frames(3000);
|
||||
settings.set_pedestal_g0_frames(2378);
|
||||
settings.set_use_storage_cells(true);
|
||||
settings.set_storage_cell_count(16);
|
||||
settings.set_frame_time_us(600);
|
||||
settings.set_count_time_us(247);
|
||||
REQUIRE_NOTHROW(state_machine.SetDetectorSettings(settings));
|
||||
@@ -159,7 +159,7 @@ TEST_CASE("JFJochStateMachine_Setup") {
|
||||
REQUIRE(state_machine.NotThreadSafe_Experiment().GetFrameCountTime() == std::chrono::microseconds(247));
|
||||
|
||||
REQUIRE_NOTHROW(settings_save = state_machine.GetDetectorSettings());
|
||||
REQUIRE(settings_save.use_storage_cells());
|
||||
REQUIRE(settings_save.storage_cell_count() == 16);
|
||||
REQUIRE(settings_save.count_time_us() == 247);
|
||||
}
|
||||
|
||||
@@ -200,7 +200,7 @@ TEST_CASE("JFJochStateMachine_StorageCells") {
|
||||
|
||||
JFJochProtoBuf::DetectorSettings settings;
|
||||
settings.set_frame_time_us(500);
|
||||
settings.set_use_storage_cells(true);
|
||||
settings.set_storage_cell_count(16);
|
||||
REQUIRE_NOTHROW(state_machine.SetDetectorSettings(settings));
|
||||
REQUIRE(state_machine.NotThreadSafe_Experiment().GetStorageCellNumber() == 16);
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
|
||||
@@ -365,6 +365,7 @@ TEST_CASE("JFJochIntegrationTest_ZMQ_RAW", "[JFJochReceiver]") {
|
||||
JFJochProtoBuf::DetectorSettings detector_settings;
|
||||
detector_settings.set_frame_time_us(500);
|
||||
detector_settings.set_collect_raw_data(true);
|
||||
detector_settings.set_storage_cell_count(1);
|
||||
REQUIRE_NOTHROW(state_machine.SetDetectorSettings(detector_settings));
|
||||
REQUIRE_NOTHROW(state_machine.Initialize());
|
||||
logger.Info("Initialized");
|
||||
|
||||
Reference in New Issue
Block a user