From 492a85d096aefc07069d52be1ae10a582bf2fae2 Mon Sep 17 00:00:00 2001 From: Serwan Asaad Date: Wed, 4 Dec 2024 20:22:59 +0100 Subject: [PATCH] added readout amplitude --- .../data_acquirers/base_data_aqcuirer.py | 15 +++++++++++++-- .../data_acquirers/opx_data_acquirer.py | 3 +++ .../video_mode/inner_loop_actions.py | 12 ++++++++++++ .../control_panel/video_mode/video_mode.py | 15 +-------------- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/qualang_tools/control_panel/video_mode/data_acquirers/base_data_aqcuirer.py b/qualang_tools/control_panel/video_mode/data_acquirers/base_data_aqcuirer.py index 9494ac34..a5ecf19e 100644 --- a/qualang_tools/control_panel/video_mode/data_acquirers/base_data_aqcuirer.py +++ b/qualang_tools/control_panel/video_mode/data_acquirers/base_data_aqcuirer.py @@ -7,7 +7,7 @@ import dash_bootstrap_components as dbc from qualang_tools.control_panel.video_mode.sweep_axis import SweepAxis -from qualang_tools.control_panel.video_mode.dash_tools import create_axis_layout +from qualang_tools.control_panel.video_mode.dash_tools import create_axis_layout, create_input_field from qualang_tools.control_panel.video_mode.dash_tools import BaseDashComponent, ModifiedFlags @@ -136,13 +136,24 @@ def get_dash_components(self, include_subcomponents: bool = True) -> List[html.D className="g-0", ), # g-0 removes gutters between columns ] - ) + ), + create_input_field( + id={"type": self.component_id, "index": "num-averages"}, + label="Averages", + value=self.num_averages, + min=1, + step=1, + debounce=True, + ), ] def update_parameters(self, parameters: Dict[str, Dict[str, Any]]) -> ModifiedFlags: """Update the data acquirer's attributes based on the input values.""" params = parameters[self.component_id] flags = ModifiedFlags.NONE + if self.num_averages != params["num-averages"]: + self.num_averages = params["num-averages"] + flags |= ModifiedFlags.PARAMETERS_MODIFIED if self.x_axis.span != params["x-span"]: self.x_axis.span = params["x-span"] flags |= ModifiedFlags.PARAMETERS_MODIFIED diff --git a/qualang_tools/control_panel/video_mode/data_acquirers/opx_data_acquirer.py b/qualang_tools/control_panel/video_mode/data_acquirers/opx_data_acquirer.py index 02b40ac4..065ff98c 100644 --- a/qualang_tools/control_panel/video_mode/data_acquirers/opx_data_acquirer.py +++ b/qualang_tools/control_panel/video_mode/data_acquirers/opx_data_acquirer.py @@ -203,6 +203,9 @@ def update_parameters(self, parameters: Dict[str, Dict[str, Any]]) -> ModifiedFl flags |= self.scan_mode.update_parameters(parameters) flags |= self.qua_inner_loop_action.update_parameters(parameters) + if flags & ModifiedFlags.PARAMETERS_MODIFIED: + self.data_history.clear() + if flags & ModifiedFlags.CONFIG_MODIFIED: self.generate_config() diff --git a/qualang_tools/control_panel/video_mode/inner_loop_actions.py b/qualang_tools/control_panel/video_mode/inner_loop_actions.py index 52cdea8e..d6fe9a0a 100644 --- a/qualang_tools/control_panel/video_mode/inner_loop_actions.py +++ b/qualang_tools/control_panel/video_mode/inner_loop_actions.py @@ -213,6 +213,12 @@ def get_dash_components(self, include_subcomponents: bool = True) -> List[html.D value=self.readout_pulse.length, units="ns", ), + create_input_field( + id={"type": self.component_id, "index": "readout_amplitude"}, + label="Readout amplitude", + value=self.readout_pulse.amplitude, + units="V", + ), ] ) ) @@ -240,4 +246,10 @@ def update_parameters(self, parameters: Dict[str, Dict[str, Any]]) -> ModifiedFl flags |= ModifiedFlags.PROGRAM_MODIFIED flags |= ModifiedFlags.CONFIG_MODIFIED + if self.readout_pulse.amplitude != params["readout_amplitude"]: + self.readout_pulse.amplitude = params["readout_amplitude"] + flags |= ModifiedFlags.PARAMETERS_MODIFIED + flags |= ModifiedFlags.PROGRAM_MODIFIED + flags |= ModifiedFlags.CONFIG_MODIFIED + return flags diff --git a/qualang_tools/control_panel/video_mode/video_mode.py b/qualang_tools/control_panel/video_mode/video_mode.py index ebc81805..19c2696a 100644 --- a/qualang_tools/control_panel/video_mode/video_mode.py +++ b/qualang_tools/control_panel/video_mode/video_mode.py @@ -100,14 +100,6 @@ def create_layout(self): ], className="mb-4", ), - create_input_field( - "num-averages", - "Averages", - self.data_acquirer.num_averages, - min=1, - step=1, - debounce=True, - ), html.Div(self.data_acquirer.get_dash_components(include_subcomponents=True)), dbc.Row( [ @@ -152,11 +144,6 @@ def create_layout(self): logging.debug(f"Dash layout created, update interval: {self.update_interval*1000} ms") self.add_callbacks() - def clear_data(self): - """Clears data history and resets averages.""" - self.data_acquirer.data_history.clear() - logging.debug("Cleared all averages and data history.") - def add_callbacks(self): @self.app.callback( Output("pause-button", "children"), @@ -204,7 +191,7 @@ def update_heatmap(n_intervals): component_states, blocking=True, ) - def update_params(n_update_clicks, num_averages, *component_inputs): + def update_params(n_update_clicks, *component_inputs): if n_update_clicks <= self._last_update_clicks: return