From c21a1bf069c1eac390d6a70d742d9c6a2a9c350b Mon Sep 17 00:00:00 2001 From: Arnaud Meyer Date: Tue, 24 Jun 2025 09:26:24 +0200 Subject: [PATCH 1/5] Corrected typos in NotImplementedError --- .../daq_move_plugins/daq_move_Template.py | 14 +++++++------- .../plugins_0D/daq_0Dviewer_Template.py | 10 +++++----- .../plugins_1D/daq_1Dviewer_Template.py | 6 +++--- .../plugins_2D/daq_2Dviewer_Template.py | 6 +++--- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py b/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py index 26b4c84..eff8f37 100644 --- a/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py +++ b/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py @@ -69,7 +69,7 @@ def get_actuator_value(self): float: The position obtained after scaling conversion. """ ## TODO for your custom plugin - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line pos = DataActuator(data=self.controller.your_method_to_get_the_actuator_value()) # when writing your own plugin replace this line pos = self.get_position_with_scaling(pos) return pos @@ -91,7 +91,7 @@ def user_condition_to_reach_target(self) -> bool: def close(self): """Terminate the communication protocol""" ## TODO for your custom plugin - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line def commit_settings(self, param: Parameter): @@ -128,7 +128,7 @@ def ini_stage(self, controller=None): initialized: bool False if initialization failed otherwise True """ - raise NotImplemented # TODO when writing your own plugin remove this line and modify the ones below + raise NotImplementedError # TODO when writing your own plugin remove this line and modify the ones below self.ini_stage_init(slave_controller=controller) # will be useful when controller is slave if self.is_master: # is needed when controller is master @@ -152,7 +152,7 @@ def move_abs(self, value: DataActuator): self.target_value = value value = self.set_position_with_scaling(value) # apply scaling if the user specified one ## TODO for your custom plugin - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line self.controller.your_method_to_set_an_absolute_value(value.value()) # when writing your own plugin replace this line self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log'])) @@ -168,7 +168,7 @@ def move_rel(self, value: DataActuator): value = self.set_position_relative_with_scaling(value) ## TODO for your custom plugin - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line self.controller.your_method_to_set_a_relative_value(value.value()) # when writing your own plugin replace this line self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log'])) @@ -176,7 +176,7 @@ def move_home(self): """Call the reference method of the controller""" ## TODO for your custom plugin - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line self.controller.your_method_to_get_to_a_known_reference() # when writing your own plugin replace this line self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log'])) @@ -184,7 +184,7 @@ def stop_motion(self): """Stop the actuator and emits move_done signal""" ## TODO for your custom plugin - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line self.controller.your_method_to_stop_positioning() # when writing your own plugin replace this line self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log'])) diff --git a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py index 7ceb2ec..2f83d96 100644 --- a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py +++ b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py @@ -82,7 +82,7 @@ def ini_detector(self, controller=None): False if initialization failed otherwise True """ - raise NotImplemented # TODO when writing your own plugin remove this line and modify the one below + raise NotImplementedError # TODO when writing your own plugin remove this line and modify the one below self.ini_detector_init(slave_controller=controller) if self.is_master: @@ -103,7 +103,7 @@ def ini_detector(self, controller=None): def close(self): """Terminate the communication protocol""" ## TODO for your custom plugin - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line def grab_data(self, Naverage=1, **kwargs): @@ -120,7 +120,7 @@ def grab_data(self, Naverage=1, **kwargs): ## TODO for your custom plugin: you should choose EITHER the synchrone or the asynchrone version following # synchrone version (blocking function) - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line data_tot = self.controller.your_method_to_start_a_grab_snap() self.dte_signal.emit(DataToExport(name='myplugin', data=[DataFromPlugins(name='Mock1', data=data_tot, @@ -128,7 +128,7 @@ def grab_data(self, Naverage=1, **kwargs): ######################################################### # asynchrone version (non-blocking function with callback) - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line self.controller.your_method_to_start_a_grab_snap(self.callback) # when writing your own plugin replace this line ######################################################### @@ -143,7 +143,7 @@ def callback(self): def stop(self): """Stop the current grab hardware wise if necessary""" ## TODO for your custom plugin - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line self.controller.your_method_to_stop_acquisition() # when writing your own plugin replace this line self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log'])) ############################## diff --git a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py index f33aace..1ae6777 100644 --- a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py +++ b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py @@ -87,7 +87,7 @@ def ini_detector(self, controller=None): False if initialization failed otherwise True """ - raise NotImplemented # TODO when writing your own plugin remove this line and modify the one below + raise NotImplementedError # TODO when writing your own plugin remove this line and modify the one below self.ini_detector_init(slave_controller=controller) if self.is_master: @@ -114,7 +114,7 @@ def ini_detector(self, controller=None): def close(self): """Terminate the communication protocol""" ## TODO for your custom plugin - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line def grab_data(self, Naverage=1, **kwargs): @@ -152,7 +152,7 @@ def callback(self): def stop(self): """Stop the current grab hardware wise if necessary""" ## TODO for your custom plugin - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line self.controller.your_method_to_stop_acquisition() # when writing your own plugin replace this line self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log'])) ############################## diff --git a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py index 379629f..951ce55 100644 --- a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py +++ b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py @@ -82,7 +82,7 @@ def ini_detector(self, controller=None): initialized: bool False if initialization failed otherwise True """ - raise NotImplemented # TODO when writing your own plugin remove this line and modify the one below + raise NotImplementedError # TODO when writing your own plugin remove this line and modify the one below self.ini_detector_init(slave_controller=controller) if self.is_master: @@ -111,7 +111,7 @@ def ini_detector(self, controller=None): def close(self): """Terminate the communication protocol""" ## TODO for your custom plugin - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line def grab_data(self, Naverage=1, **kwargs): @@ -150,7 +150,7 @@ def callback(self): def stop(self): """Stop the current grab hardware wise if necessary""" ## TODO for your custom plugin - raise NotImplemented # when writing your own plugin remove this line + raise NotImplementedError # when writing your own plugin remove this line self.controller.your_method_to_stop_acquisition() # when writing your own plugin replace this line self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log'])) ############################## From 13c1ab3ce67afa040eb4317007dcb4f8b10a2119 Mon Sep 17 00:00:00 2001 From: Arnaud Meyer Date: Tue, 24 Jun 2025 09:28:15 +0200 Subject: [PATCH 2/5] Corrected indent in .stop_motion() --- .../daq_move_plugins/daq_move_Template.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py b/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py index eff8f37..4102c60 100644 --- a/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py +++ b/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py @@ -181,12 +181,12 @@ def move_home(self): self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log'])) def stop_motion(self): - """Stop the actuator and emits move_done signal""" + """Stop the actuator and emits move_done signal""" - ## TODO for your custom plugin - raise NotImplementedError # when writing your own plugin remove this line - self.controller.your_method_to_stop_positioning() # when writing your own plugin replace this line - self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log'])) + ## TODO for your custom plugin + raise NotImplementedError # when writing your own plugin remove this line + self.controller.your_method_to_stop_positioning() # when writing your own plugin replace this line + self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log'])) if __name__ == '__main__': From 816672399628de0b8a1dfadd5a9f740f157b9c64 Mon Sep 17 00:00:00 2001 From: Arnaud Meyer Date: Tue, 24 Jun 2025 09:31:40 +0200 Subject: [PATCH 3/5] Explicit unit specification in DataActuator instances --- .../daq_move_plugins/daq_move_Template.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py b/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py index 4102c60..55d3f31 100644 --- a/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py +++ b/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py @@ -70,7 +70,8 @@ def get_actuator_value(self): """ ## TODO for your custom plugin raise NotImplementedError # when writing your own plugin remove this line - pos = DataActuator(data=self.controller.your_method_to_get_the_actuator_value()) # when writing your own plugin replace this line + pos = DataActuator(data=self.controller.your_method_to_get_the_actuator_value(), # when writing your own plugin replace this line + units=self.axis_unit) pos = self.get_position_with_scaling(pos) return pos @@ -153,7 +154,7 @@ def move_abs(self, value: DataActuator): value = self.set_position_with_scaling(value) # apply scaling if the user specified one ## TODO for your custom plugin raise NotImplementedError # when writing your own plugin remove this line - self.controller.your_method_to_set_an_absolute_value(value.value()) # when writing your own plugin replace this line + self.controller.your_method_to_set_an_absolute_value(value.value(self.axis_unit)) # when writing your own plugin replace this line self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log'])) def move_rel(self, value: DataActuator): @@ -169,7 +170,7 @@ def move_rel(self, value: DataActuator): ## TODO for your custom plugin raise NotImplementedError # when writing your own plugin remove this line - self.controller.your_method_to_set_a_relative_value(value.value()) # when writing your own plugin replace this line + self.controller.your_method_to_set_a_relative_value(value.value(self.axis_unit)) # when writing your own plugin replace this line self.emit_status(ThreadCommand('Update_Status', ['Some info you want to log'])) def move_home(self): From 62cdef5dcaf52e706150909c2ba4366206091916 Mon Sep 17 00:00:00 2001 From: Arnaud Meyer Date: Tue, 24 Jun 2025 13:28:58 +0200 Subject: [PATCH 4/5] Switch to new implementation of master/slave declaration --- .../daq_move_plugins/daq_move_Template.py | 7 ++++--- .../daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py | 7 ++++--- .../daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py | 7 ++++--- .../daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py b/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py index 55d3f31..34311e6 100644 --- a/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py +++ b/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py @@ -130,15 +130,16 @@ def ini_stage(self, controller=None): False if initialization failed otherwise True """ raise NotImplementedError # TODO when writing your own plugin remove this line and modify the ones below - self.ini_stage_init(slave_controller=controller) # will be useful when controller is slave - if self.is_master: # is needed when controller is master self.controller = PythonWrapperOfYourInstrument(arg1, arg2, ...) # arguments for instantiation!) + initialized = self.controller.a_method_or_atttribute_to_check_if_init() # todo # todo: enter here whatever is needed for your controller initialization and eventual # opening of the communication channel + else: + self.controller = controller + initialized = True info = "Whatever info you want to log" - initialized = self.controller.a_method_or_atttribute_to_check_if_init() # todo return info, initialized def move_abs(self, value: DataActuator): diff --git a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py index 2f83d96..2c3ff9d 100644 --- a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py +++ b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py @@ -83,11 +83,13 @@ def ini_detector(self, controller=None): """ raise NotImplementedError # TODO when writing your own plugin remove this line and modify the one below - self.ini_detector_init(slave_controller=controller) - if self.is_master: self.controller = PythonWrapperOfYourInstrument() #instantiate you driver with whatever arguments are needed self.controller.open_communication() # call eventual methods + initialized = self.controller.a_method_or_atttribute_to_check_if_init() # TODO + else: + self.controller = controller + initialized = True # TODO for your custom plugin (optional) initialize viewers panel with the future type of data self.dte_signal_temp.emit(DataToExport(name='myplugin', @@ -97,7 +99,6 @@ def ini_detector(self, controller=None): labels=['Mock1', 'label2'])])) info = "Whatever info you want to log" - initialized = self.controller.a_method_or_atttribute_to_check_if_init() # TODO return info, initialized def close(self): diff --git a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py index 1ae6777..5ecf217 100644 --- a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py +++ b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py @@ -88,11 +88,13 @@ def ini_detector(self, controller=None): """ raise NotImplementedError # TODO when writing your own plugin remove this line and modify the one below - self.ini_detector_init(slave_controller=controller) - if self.is_master: self.controller = PythonWrapperOfYourInstrument() #instantiate you driver with whatever arguments are needed self.controller.open_communication() # call eventual methods + initialized = self.controller.a_method_or_atttribute_to_check_if_init() # TODO + else: + self.controller = controller + initialized = True ## TODO for your custom plugin # get the x_axis (you may want to to this also in the commit settings if x_axis may have changed @@ -108,7 +110,6 @@ def ini_detector(self, controller=None): axes=[self.x_axis])])) info = "Whatever info you want to log" - initialized = True return info, initialized def close(self): diff --git a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py index 951ce55..0175f6a 100644 --- a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py +++ b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py @@ -83,11 +83,13 @@ def ini_detector(self, controller=None): False if initialization failed otherwise True """ raise NotImplementedError # TODO when writing your own plugin remove this line and modify the one below - self.ini_detector_init(slave_controller=controller) - if self.is_master: self.controller = PythonWrapperOfYourInstrument() #instantiate you driver with whatever arguments are needed self.controller.open_communication() # call eventual methods + initialized = self.controller.a_method_or_atttribute_to_check_if_init() # TODO + else: + self.controller = controller + initialized = True ## TODO for your custom plugin # get the x_axis (you may want to to this also in the commit settings if x_axis may have changed @@ -105,7 +107,6 @@ def ini_detector(self, controller=None): axes=[self.x_axis, self.y_axis]), ])) info = "Whatever info you want to log" - initialized = True return info, initialized def close(self): From d56df096f8437a107bef4c9acb8d800c86d2ebdf Mon Sep 17 00:00:00 2001 From: Arnaud Meyer Date: Tue, 24 Jun 2025 15:03:57 +0200 Subject: [PATCH 5/5] Added new master/slave declaration to .close() --- .../daq_move_plugins/daq_move_Template.py | 4 +++- .../daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py | 4 +++- .../daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py | 4 +++- .../daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py b/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py index 34311e6..3dafa38 100644 --- a/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py +++ b/src/pymodaq_plugins_template/daq_move_plugins/daq_move_Template.py @@ -93,7 +93,9 @@ def close(self): """Terminate the communication protocol""" ## TODO for your custom plugin raise NotImplementedError # when writing your own plugin remove this line - # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line + if self.is_master: + # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line + ... def commit_settings(self, param: Parameter): """Apply the consequences of a change of value in the detector settings diff --git a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py index 2c3ff9d..f75a38c 100644 --- a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py +++ b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_0D/daq_0Dviewer_Template.py @@ -105,7 +105,9 @@ def close(self): """Terminate the communication protocol""" ## TODO for your custom plugin raise NotImplementedError # when writing your own plugin remove this line - # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line + if self.is_master: + # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line + ... def grab_data(self, Naverage=1, **kwargs): """Start a grab from the detector diff --git a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py index 5ecf217..34b7a6c 100644 --- a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py +++ b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_1D/daq_1Dviewer_Template.py @@ -116,7 +116,9 @@ def close(self): """Terminate the communication protocol""" ## TODO for your custom plugin raise NotImplementedError # when writing your own plugin remove this line - # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line + if self.is_master: + # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line + ... def grab_data(self, Naverage=1, **kwargs): """Start a grab from the detector diff --git a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py index 0175f6a..80419b0 100644 --- a/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py +++ b/src/pymodaq_plugins_template/daq_viewer_plugins/plugins_2D/daq_2Dviewer_Template.py @@ -113,7 +113,9 @@ def close(self): """Terminate the communication protocol""" ## TODO for your custom plugin raise NotImplementedError # when writing your own plugin remove this line - # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line + if self.is_master: + # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line + ... def grab_data(self, Naverage=1, **kwargs): """Start a grab from the detector