1- """At the first run, if the program complains about a _build_scu programm not being present, just run the
2- _build_smaract.py, that will look at the C header file to produce connexion between the dll and the python files"""
31
2+ from typing import Union , List , Dict
43
5- from typing import Union
4+ from pymodaq .control_modules .move_utility_classes import DAQ_Move_base , main , comon_parameters_fun , DataActuatorType
5+ from pymodaq .utils .daq_utils import ThreadCommand
6+ from easydict import EasyDict as edict
67
7- from pymodaq .control_modules .move_utility_classes import DAQ_Move_base , main , comon_parameters_fun
8- from pymodaq_utils .logger import set_logger , get_module_name
9- logger = set_logger (get_module_name (__file__ ))
8+ from pymodaq_plugins_smaract .hardware .smaract .scu .scu_wrapper import (get_devices , SCUType , SCUWrapper ,
9+ SCULinear , SCURotation )
1010
11- from instrumental import instrument , list_instruments
12- try :
13- from instrumental .drivers .motion ._smaract .scu import SCU , SCULinear , SCURotation , Q_
14- except Exception as e :
15- logger .exception (f'Could not load the SmarAct instrumental drivers: { str (e )} ' )
11+ from pymodaq .utils .data import DataActuator
1612
17-
18- psets = list_instruments (module = 'motion._smaract' )
19- psets_str = [f"Dev. Id{ pset ['id' ]} channel { pset ['index' ]} " for pset in psets ]
13+ psets : list [SCUType ] = get_devices ()
14+ psets_str = [f"Dev. Id{ pset .device_id } channel { pset .channel } ({ pset .scu_type .__name__ } )" for pset in psets ]
2015
2116
2217class DAQ_Move_SmarActSCU (DAQ_Move_base ):
2318 """
2419
2520 """
2621 _controller_units = ""
27- _epsilon = 0.002
22+ _epsilon = 2
2823 # find controller locators
2924
30- is_multiaxes = False
31- stage_names = []
25+ is_multiaxes = True
26+ _axis_names = ['1' ]
27+
28+ data_actuator_type = DataActuatorType .DataActuator
3229
3330 params = [
34- {'title' : 'Device' , 'name' : 'device' , 'type' : 'list' , 'limits' : psets_str },
35- {'title' : 'Frequency (Hz)' , 'name' : 'frequency' , 'type' : 'int' , 'value' : 450 },
36- {'title' : 'Amplitude (V)' , 'name' : 'amplitude' , 'type' : 'int' , 'value' : 100 },
37- {'title' : 'Max Frequency (Hz)' , 'name' : 'maxfreq' , 'type' : 'int' , 'value' : 18500 },
38- ] + comon_parameters_fun (is_multiaxes , epsilon = _epsilon )
31+ {'title' : 'Device' , 'name' : 'device' , 'type' : 'list' ,'limits' : psets_str },
32+ {'title' : 'Frequency (Hz)' , 'name' : 'frequency' , 'type' : 'int' , 'value' : 1000 , 'limits' : SCUWrapper .frequency_limits },
33+ {'title' : 'Amplitude (V)' , 'name' : 'amplitude' , 'type' : 'int' , 'value' : 100 , 'limits' :SCUWrapper .amplitude_limits },
34+ ] + comon_parameters_fun (is_multiaxes = is_multiaxes , axis_names = _axis_names , epsilon = _epsilon )
3935 ##########################################################
4036
4137 def ini_attributes (self ):
42- self .controller : Union [SCU , SCULinear , SCURotation ] = None
43- self .settings .child ("epsilon" ).setValue (0.002 )
38+ self .controller : Union [SCUWrapper , SCULinear , SCURotation ] = None
39+ self .settings .child ("epsilon" ).setValue (2 )
4440
4541 def commit_settings (self , param ):
4642 if param .name () == 'amplitude' :
47- self .controller .amplitude = Q_ ( param .value (), units = 'V' )
43+ self .controller .amplitude = param .value ()
4844 elif param .name () == 'frequency' :
49- self .controller .frequency = Q_ (param .value (), 'Hz' )
50-
51- elif param .name () == 'maxfreq' :
52- self .controller .max_frequency = Q_ (param .value (), 'Hz' )
53- self .settings .child ('maxfreq' ).setValue (self .controller .max_frequency .m_as ('Hz' ))
45+ self .controller .frequency = param .value ()
5446
5547 def ini_stage (self , controller = None ):
5648 """Initialize the controller and stages (axes) with given parameters.
5749
5850 """
5951 index = self .settings .child ('device' ).opts ['limits' ].index (self .settings ['device' ])
60- self .ini_stage_init (controller , instrument (psets [index ]))
52+ if self .is_master :
53+ self .controller = psets [index ].scu_type ()
54+ self .controller .open (index )
55+ self .controller .amplitude = self .settings ['amplitude' ]
56+ self .controller .frequency = self .settings ['frequency' ]
6157
62- self .settings .child ('units' ).setValue (self .controller .units )
63- self .settings .child ('amplitude' ).setOpts (limits = list (self .controller .amplitude_limits .m_as ('V' )))
64- self .settings .child ('frequency' ).setOpts (limits = list (self .controller .frequency_limits .m_as ('Hz' )))
65- self .settings .child ('amplitude' ).setValue (self .controller .amplitude .m_as ('V' ))
66- self .settings .child ('frequency' ).setValue (self .controller .frequency .m_as ('Hz' ))
67- if not isinstance (self .controller , SCU ):
68- self .settings .child ('maxfreq' ).setValue (self .controller .max_frequency .m_as ('Hz' ))
58+ else :
59+ self .controller = controller
60+
61+ self .axis_unit = self .controller .units
6962
7063 info = ''
7164 initialized = True
7265
7366 return info , initialized
7467
7568 def close (self ):
76- """Close the communication with the SmarAct controller.
69+ """
70+ Close the communication with the SmarAct controller.
7771 """
7872 self .controller .close ()
79- self .controller = None
8073
8174 def get_actuator_value (self ):
82- """Get the current position from the hardware with scaling conversion.
75+ """
76+ Get the current position from the hardware with scaling conversion.
8377
8478 Returns
8579 -------
8680 float: The position obtained after scaling conversion.
8781 """
88- position = self .controller .check_position (). magnitude
82+ position = DataActuator ( data = self .controller .get_position (), units = self . axis_unit )
8983 # convert position if scaling options have been used, mandatory here
9084 position = self .get_position_with_scaling (position )
9185 #position = self.target_position
9286 self .current_position = position
9387 return position
9488
9589 def move_abs (self , position ):
96- """Move to an absolute position
90+ """
91+ Move to an absolute position
9792
98- Parameters
93+ Parameters:
9994 ----------
100- position: float
95+ - position: float
10196 """
10297 # limit position if bounds options has been selected and if position is
10398 # out of them
@@ -107,29 +102,32 @@ def move_abs(self, position):
107102 # has been activated by user
108103 position = self .set_position_with_scaling (position )
109104
110- self .controller .move_to ( Q_ ( position , self . settings [ 'units' ]), 'abs' )
105+ self .controller .move_abs ( position . value () )
111106
112107 def move_rel (self , position ):
113- """Move to a relative position
108+ """
109+ Move to a relative position
114110
115- Parameters
111+ Parameters:
116112 ----------
117- position: float
113+ - position: float
118114 """
119115 position = (self .check_bound (self .current_position + position ) - self .current_position )
120116 self .target_position = position + self .current_position
121117 position = self .set_position_relative_with_scaling (position )
122118
123- self .controller .move_to ( Q_ ( position , self . settings [ 'units' ]), 'rel' )
119+ self .controller .move_rel ( position . value () )
124120
125121 def move_home (self ):
126- """Move to home and reset position to zero.
122+ """
123+ Move to home and reset position to zero.
127124 """
128125 self .controller .move_home ()
129126 self .get_actuator_value ()
130127
131128 def stop_motion (self ):
132129 """
130+ Stop any ongoing movement of the positionner.
133131 """
134132 self .controller .stop ()
135133 self .move_done ()
0 commit comments