66from pymodaq_utils .utils import ThreadCommand # object used to send info back to the main thread
77from pymodaq_gui .parameter import Parameter
88
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
9+ from pymodaq_plugins_teaching .hardware .spectrometer import Spectrometer
2010
2111
2212class DAQ_Move_Monochromator (DAQ_Move_base ):
@@ -41,12 +31,10 @@ class DAQ_Move_Monochromator(DAQ_Move_base):
4131 # TODO add your particular attributes here if any
4232
4333 """
44- is_multiaxes = False # TODO for your plugin set to True if this plugin is controlled for a multiaxis controller
45- _axis_names : Union [List [str ], Dict [str , int ]] = ['Axis1' , 'Axis2' ] # TODO for your plugin: complete the list
46- _controller_units : Union [str , List [str ]] = 'mm' # TODO for your plugin: put the correct unit here, it could be
47- # TODO a single str (the same one is applied to all axes) or a list of str (as much as the number of axes)
48- _epsilon : Union [float , List [float ]] = 0.1 # TODO replace this by a value that is correct depending on your controller
49- # TODO it could be a single float of a list of float (as much as the number of axes)
34+ is_multiaxes = False
35+ _axis_names : Union [List [str ], Dict [str , int ]] = ['' ]
36+ _controller_units : Union [str , List [str ]] = 'nm'
37+ _epsilon : Union [float , List [float ]] = 0.1
5038 data_actuator_type = DataActuatorType .DataActuator # wether you use the new data style for actuator otherwise set this
5139 # as DataActuatorType.float (or entirely remove the line)
5240
@@ -58,21 +46,19 @@ class DAQ_Move_Monochromator(DAQ_Move_base):
5846 def ini_attributes (self ):
5947 # TODO declare the type of the wrapper (and assign it to self.controller) you're going to use for easy
6048 # autocompletion
61- self .controller : PythonWrapperObjectOfYourInstrument = None
49+ self .controller : Spectrometer = None
6250
6351 #TODO declare here attributes you want/need to init with a default value
6452 pass
6553
66- def get_actuator_value (self ):
54+ def get_actuator_value (self ) -> DataActuator :
6755 """Get the current value from the hardware with scaling conversion.
6856
6957 Returns
7058 -------
71- float : The position obtained after scaling conversion.
59+ DataActuator : The position as a DataActuator object obtained after scaling conversion.
7260 """
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
61+ pos = DataActuator (data = self .controller .get_wavelength (), # when writing your own plugin replace this line
7662 units = self .axis_unit )
7763 pos = self .get_position_with_scaling (pos )
7864 return pos
@@ -93,11 +79,8 @@ def user_condition_to_reach_target(self) -> bool:
9379
9480 def close (self ):
9581 """Terminate the communication protocol"""
96- ## TODO for your custom plugin
97- raise NotImplementedError # when writing your own plugin remove this line
9882 if self .is_master :
99- # self.controller.your_method_to_terminate_the_communication() # when writing your own plugin replace this line
100- ...
83+ self .controller .close_communication ()
10184
10285 def commit_settings (self , param : Parameter ):
10386 """Apply the consequences of a change of value in the detector settings
@@ -133,10 +116,9 @@ def ini_stage(self, controller=None):
133116 initialized: bool
134117 False if initialization failed otherwise True
135118 """
136- raise NotImplementedError # TODO when writing your own plugin remove this line and modify the ones below
137119 if self .is_master : # is needed when controller is master
138- self .controller = PythonWrapperObjectOfYourInstrument ( arg1 , arg2 , ...) # arguments for instantiation! )
139- initialized = self .controller .a_method_or_atttribute_to_check_if_init () # todo
120+ self .controller = Spectrometer ( )
121+ initialized = self .controller .open_communication () # todo
140122 # todo: enter here whatever is needed for your controller initialization and eventual
141123 # opening of the communication channel
142124 else :
@@ -153,13 +135,10 @@ def move_abs(self, value: DataActuator):
153135 ----------
154136 value: (float) value of the absolute target positioning
155137 """
156-
157138 value = self .check_bound (value ) #if user checked bounds, the defined bounds are applied here
158139 self .target_value = value
159140 value = self .set_position_with_scaling (value ) # apply scaling if the user specified one
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
141+ self .controller .set_wavelength (value .value (self .axis_unit )) # when writing your own plugin replace this line
163142 self .emit_status (ThreadCommand ('Update_Status' , ['Some info you want to log' ]))
164143
165144 def move_rel (self , value : DataActuator ):
@@ -173,27 +152,16 @@ def move_rel(self, value: DataActuator):
173152 self .target_value = value + self .current_position
174153 value = self .set_position_relative_with_scaling (value )
175154
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
155+ self .move_abs (self .target_value )# when writing your own plugin replace this line
179156 self .emit_status (ThreadCommand ('Update_Status' , ['Some info you want to log' ]))
180157
181158 def move_home (self ):
182159 """Call the reference method of the controller"""
183-
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
187- self .emit_status (ThreadCommand ('Update_Status' , ['Some info you want to log' ]))
160+ self .controller .find_reference ()
188161
189162 def stop_motion (self ):
190163 """Stop the actuator and emits move_done signal"""
191-
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
195- self .emit_status (ThreadCommand ('Update_Status' , ['Some info you want to log' ]))
196-
164+ self .controller .stop ()
197165
198166if __name__ == '__main__' :
199167 main (__file__ )
0 commit comments