66from pymodaq_utils .utils import ThreadCommand # object used to send info back to the main thread
77from pymodaq_gui .parameter import Parameter
88
9- from pymodaq_plugins_teaching .hardware .spectrometer import Spectrometer
9+ # TODO:
10+ # Replace the following fake import with the import of the real Python wrapper of your instrument. Here we suppose that
11+ # the wrapper is in the hardware directory, but it could come from an external librairy like pylablib or pymeasure.
12+ from pymodaq_plugins_template .hardware .python_wrapper_file_of_your_instrument import PythonWrapperObjectOfYourInstrument
13+
14+ # TODO:
15+ # (1) change the name of the following class to DAQ_Move_TheNameOfYourChoice
16+ # (2) change the name of this file to daq_move_TheNameOfYourChoice ("TheNameOfYourChoice" should be the SAME
17+ # for the class name and the file name.)
18+ # (3) this file should then be put into the right folder, namely IN THE FOLDER OF THE PLUGIN YOU ARE DEVELOPING:
19+ # pymodaq_plugins_my_plugin/daq_move_plugins
1020
1121
1222class DAQ_Move_Monochromator (DAQ_Move_base ):
@@ -33,7 +43,7 @@ class DAQ_Move_Monochromator(DAQ_Move_base):
3343 """
3444 is_multiaxes = False # TODO for your plugin set to True if this plugin is controlled for a multiaxis controller
3545 _axis_names : Union [List [str ], Dict [str , int ]] = ['Axis1' , 'Axis2' ] # TODO for your plugin: complete the list
36- _controller_units : Union [str , List [str ]] = 'nm ' # TODO for your plugin: put the correct unit here, it could be
46+ _controller_units : Union [str , List [str ]] = 'mm ' # TODO for your plugin: put the correct unit here, it could be
3747 # TODO a single str (the same one is applied to all axes) or a list of str (as much as the number of axes)
3848 _epsilon : Union [float , List [float ]] = 0.1 # TODO replace this by a value that is correct depending on your controller
3949 # TODO it could be a single float of a list of float (as much as the number of axes)
@@ -46,7 +56,12 @@ class DAQ_Move_Monochromator(DAQ_Move_base):
4656 # the target value. It is the developer responsibility to put here a meaningful value
4757
4858 def ini_attributes (self ):
49- self .controller : Spectrometer = None
59+ # TODO declare the type of the wrapper (and assign it to self.controller) you're going to use for easy
60+ # autocompletion
61+ self .controller : PythonWrapperObjectOfYourInstrument = None
62+
63+ #TODO declare here attributes you want/need to init with a default value
64+ pass
5065
5166 def get_actuator_value (self ):
5267 """Get the current value from the hardware with scaling conversion.
@@ -55,7 +70,9 @@ def get_actuator_value(self):
5570 -------
5671 float: The position obtained after scaling conversion.
5772 """
58- pos = DataActuator (data = self .controller .get_wavelength (), # when writing your own plugin replace this line
73+ ## TODO for your custom plugin
74+ raise NotImplementedError # when writing your own plugin remove this line
75+ pos = DataActuator (data = self .controller .your_method_to_get_the_actuator_value (), # when writing your own plugin replace this line
5976 units = self .axis_unit )
6077 pos = self .get_position_with_scaling (pos )
6178 return pos
@@ -76,9 +93,11 @@ def user_condition_to_reach_target(self) -> bool:
7693
7794 def close (self ):
7895 """Terminate the communication protocol"""
79-
96+ ## TODO for your custom plugin
97+ raise NotImplementedError # when writing your own plugin remove this line
8098 if self .is_master :
81- self .controller .close_communication ()
99+ # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line
100+ ...
82101
83102 def commit_settings (self , param : Parameter ):
84103 """Apply the consequences of a change of value in the detector settings
@@ -114,9 +133,12 @@ def ini_stage(self, controller=None):
114133 initialized: bool
115134 False if initialization failed otherwise True
116135 """
136+ raise NotImplementedError # TODO when writing your own plugin remove this line and modify the ones below
117137 if self .is_master : # is needed when controller is master
118- self .controller = Spectrometer ()
119- initialized = self .controller .open_communication ()
138+ self .controller = PythonWrapperObjectOfYourInstrument (arg1 , arg2 , ...) # arguments for instantiation!)
139+ initialized = self .controller .a_method_or_atttribute_to_check_if_init () # todo
140+ # todo: enter here whatever is needed for your controller initialization and eventual
141+ # opening of the communication channel
120142 else :
121143 self .controller = controller
122144 initialized = True
@@ -135,7 +157,9 @@ def move_abs(self, value: DataActuator):
135157 value = self .check_bound (value ) #if user checked bounds, the defined bounds are applied here
136158 self .target_value = value
137159 value = self .set_position_with_scaling (value ) # apply scaling if the user specified one
138- self .controller .set_wavelength (value .value (self .axis_unit )) # when writing your own plugin replace this line
160+ ## TODO for your custom plugin
161+ raise NotImplementedError # when writing your own plugin remove this line
162+ self .controller .your_method_to_set_an_absolute_value (value .value (self .axis_unit )) # when writing your own plugin replace this line
139163 self .emit_status (ThreadCommand ('Update_Status' , ['Some info you want to log' ]))
140164
141165 def move_rel (self , value : DataActuator ):
@@ -149,20 +173,25 @@ def move_rel(self, value: DataActuator):
149173 self .target_value = value + self .current_position
150174 value = self .set_position_relative_with_scaling (value )
151175
152- self .controller .set_wavelength (value .value (self .axis_unit ),
153- set_type = 'rel' ) # when writing your own plugin replace this line
176+ ## TODO for your custom plugin
177+ raise NotImplementedError # when writing your own plugin remove this line
178+ self .controller .your_method_to_set_a_relative_value (value .value (self .axis_unit )) # when writing your own plugin replace this line
154179 self .emit_status (ThreadCommand ('Update_Status' , ['Some info you want to log' ]))
155180
156181 def move_home (self ):
157182 """Call the reference method of the controller"""
158183
159- self .controller .find_reference () # when writing your own plugin replace this line
184+ ## TODO for your custom plugin
185+ raise NotImplementedError # when writing your own plugin remove this line
186+ self .controller .your_method_to_get_to_a_known_reference () # when writing your own plugin replace this line
160187 self .emit_status (ThreadCommand ('Update_Status' , ['Some info you want to log' ]))
161188
162189 def stop_motion (self ):
163190 """Stop the actuator and emits move_done signal"""
164191
165- self .controller .stop () # when writing your own plugin replace this line
192+ ## TODO for your custom plugin
193+ raise NotImplementedError # when writing your own plugin remove this line
194+ self .controller .your_method_to_stop_positioning () # when writing your own plugin replace this line
166195 self .emit_status (ThreadCommand ('Update_Status' , ['Some info you want to log' ]))
167196
168197
0 commit comments