pymodaq_plugins_stanford_research_systems 1.0.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. pymodaq_plugins_stanford_research_systems/__init__.py +11 -0
  2. pymodaq_plugins_stanford_research_systems/daq_move_plugins/__init__.py +13 -0
  3. pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/__init__.py +3 -0
  4. pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_0D/__init__.py +13 -0
  5. pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_0D/daq_0Dviewer_LockInSR830.py +183 -0
  6. pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_0D/daq_0Dviewer_LockInSR830Legacy.py +235 -0
  7. pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_1D/__init__.py +13 -0
  8. pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_1D/daq_1Dviewer_LockInSR830.py +75 -0
  9. pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_2D/__init__.py +14 -0
  10. pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_ND/__init__.py +13 -0
  11. pymodaq_plugins_stanford_research_systems/exporters/__init__.py +6 -0
  12. pymodaq_plugins_stanford_research_systems/extensions/__init__.py +6 -0
  13. pymodaq_plugins_stanford_research_systems/hardware/__init__.py +0 -0
  14. pymodaq_plugins_stanford_research_systems/models/PIDModelTemplate.py +90 -0
  15. pymodaq_plugins_stanford_research_systems/models/__init__.py +6 -0
  16. pymodaq_plugins_stanford_research_systems/resources/__init__.py +0 -0
  17. pymodaq_plugins_stanford_research_systems/resources/config_template.toml +2 -0
  18. pymodaq_plugins_stanford_research_systems/scanners/__init__.py +6 -0
  19. pymodaq_plugins_stanford_research_systems/utils.py +15 -0
  20. pymodaq_plugins_stanford_research_systems-1.0.1.dist-info/METADATA +101 -0
  21. pymodaq_plugins_stanford_research_systems-1.0.1.dist-info/RECORD +24 -0
  22. pymodaq_plugins_stanford_research_systems-1.0.1.dist-info/WHEEL +4 -0
  23. pymodaq_plugins_stanford_research_systems-1.0.1.dist-info/entry_points.txt +5 -0
  24. pymodaq_plugins_stanford_research_systems-1.0.1.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,11 @@
1
+ from pathlib import Path
2
+ from .utils import Config
3
+ from pymodaq_utils.utils import get_version, PackageNotFoundError
4
+ from pymodaq_utils.logger import set_logger, get_module_name
5
+
6
+
7
+ config = Config()
8
+ try:
9
+ __version__ = get_version(__package__)
10
+ except PackageNotFoundError:
11
+ __version__ = '0.0.0dev'
@@ -0,0 +1,13 @@
1
+ import importlib
2
+ from pathlib import Path
3
+ from .. import set_logger
4
+ logger = set_logger('move_plugins', add_to_console=False)
5
+
6
+ for path in Path(__file__).parent.iterdir():
7
+ try:
8
+ if '__init__' not in str(path):
9
+ importlib.import_module('.' + path.stem, __package__)
10
+ except Exception as e:
11
+ logger.warning("{:} plugin couldn't be loaded due to some missing packages or errors: {:}".format(path.stem, str(e)))
12
+ pass
13
+
@@ -0,0 +1,13 @@
1
+ import importlib
2
+ from pathlib import Path
3
+ from ... import set_logger
4
+ logger = set_logger('viewer0D_plugins', add_to_console=False)
5
+
6
+ for path in Path(__file__).parent.iterdir():
7
+ try:
8
+ if '__init__' not in str(path):
9
+ importlib.import_module('.' + path.stem, __package__)
10
+ except Exception as e:
11
+ logger.warning("{:} plugin couldn't be loaded due to some missing packages or errors: {:}".format(path.stem, str(e)))
12
+ pass
13
+
@@ -0,0 +1,183 @@
1
+ from typing import List
2
+ from time import perf_counter
3
+ from qtpy.QtCore import QThread
4
+ import numpy as np
5
+ from pymodaq.utils.daq_utils import ThreadCommand
6
+ from pymodaq.utils.data import DataFromPlugins, DataToExport
7
+ from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main
8
+ from pymodaq.utils.parameter import Parameter
9
+
10
+ from pymeasure.instruments.srs.sr830 import SR830
11
+ from pyvisa import ResourceManager
12
+
13
+ VISA_rm = ResourceManager()
14
+ devices = list(VISA_rm.list_resources())
15
+ device = ''
16
+ for dev in devices:
17
+ if 'GPIB' in dev:
18
+ device = dev
19
+ break
20
+
21
+
22
+ class DAQ_0DViewer_LockInSR830(DAQ_Viewer_base):
23
+ """ Instrument plugin class for a OD viewer.
24
+
25
+ This object inherits all functionalities to communicate with PyMoDAQ’s DAQ_Viewer module through inheritance via
26
+ DAQ_Viewer_base. It makes a bridge between the DAQ_Viewer module and the Python wrapper of a particular instrument.
27
+
28
+ Attributes:
29
+ -----------
30
+ controller: object
31
+ The particular object that allow the communication with the hardware, in general a python wrapper around the
32
+ hardware library.
33
+
34
+ """
35
+ channels = ['X', 'Y', 'R', 'Theta', 'Aux In 1',
36
+ 'Aux In 2', 'Aux In 3', 'Aux In 4', 'Frequency', 'CH1', 'CH2']
37
+
38
+ params = comon_parameters + [
39
+ {'title': 'VISA:', 'name': 'device', 'type': 'list', 'limits': devices, 'value': device},
40
+ {'title': 'ID:', 'name': 'id', 'type': 'str', 'value': ""},
41
+ {'title': 'Acquisition:', 'name': 'acq', 'type': 'group', 'children': [
42
+ {'title': 'Use Trigger:', 'name': 'trigger', 'type': 'bool', 'value': False},
43
+ {'title': 'Channels in separate viewer:', 'name': 'separate_viewers', 'type': 'bool', 'value': True},
44
+ {'title': 'Channels:', 'name': 'channels', 'type': 'itemselect',
45
+ 'value': dict(all_items=channels, selected=['CH1', 'CH2'])},
46
+ {'title': 'Sampling (Hz):', 'name': 'sampling_rate', 'type': 'list', 'limits': SR830.SAMPLE_FREQUENCIES},
47
+ ]},
48
+ {'title': 'Configuration:', 'name': 'config', 'type': 'group', 'children': [
49
+ {'title': 'Reset:', 'name': 'reset', 'type': 'bool_push', 'value': False},
50
+ {'title': 'Setup number:', 'name': 'setup_number', 'type': 'int', 'value': 1, 'min': 1, 'max': 9},
51
+ {'title': 'Save setup:', 'name': 'save_setup', 'type': 'bool_push', 'value': False,
52
+ 'label': 'Save'},
53
+ {'title': 'Load setup:', 'name': 'load_setup', 'type': 'bool_push', 'value': False,
54
+ 'label': 'Load'},
55
+ ]},
56
+ ]
57
+
58
+ def ini_attributes(self):
59
+ self.controller: SR830 = None
60
+
61
+ def commit_settings(self, param: Parameter):
62
+ """Apply the consequences of a change of value in the detector settings
63
+
64
+ Parameters
65
+ ----------
66
+ param: Parameter
67
+ A given parameter (within detector_settings) whose value has been changed by the user
68
+ """
69
+ if param.name() == 'load_setup':
70
+ self.controller.load_setup(self.settings['config', 'setup_number'])
71
+ param.setValue(False)
72
+
73
+ elif param.name() == 'save_setup':
74
+ self.controller.save_setup(self.settings['config', 'setup_number'])
75
+ param.setValue(False)
76
+
77
+ elif param.name() == 'channels':
78
+ selected_channels = param.value()['selected']
79
+ data_list_array = [np.array([0.]) for _ in range(len(selected_channels))]
80
+ dwas = self.create_dwas(data_list_array)
81
+ self.dte_signal.emit(DataToExport(name='SR830', data=dwas))
82
+
83
+ elif param.name() == 'reset':
84
+ self.controller.reset()
85
+ param.setValue(False)
86
+
87
+ elif param.name() == 'trigger':
88
+ self.controller.aquireOnTrigger(param.value())
89
+
90
+ elif param.name() == 'sampling_rate':
91
+ self.controller.sample_frequency = param.value()
92
+ param.setValue(self.controller.sample_frequency) # check it
93
+
94
+ def ini_detector(self, controller=None):
95
+ """Detector communication initialization
96
+
97
+ Parameters
98
+ ----------
99
+ controller: (object)
100
+ custom object of a PyMoDAQ plugin (Slave case). None if only one actuator/detector by controller
101
+ (Master case)
102
+
103
+ Returns
104
+ -------
105
+ info: str
106
+ initialized: bool
107
+ False if initialization failed otherwise True
108
+ """
109
+
110
+ if self.settings['controller_status'] == "Slave":
111
+ if controller is None:
112
+ raise Exception('no controller has been defined externally while this axe is a slave one')
113
+ else:
114
+ controller = controller
115
+ else: # Master stage
116
+ controller = SR830(self.settings['device'])
117
+ self.controller = controller
118
+
119
+ self.controller.reset_buffer()
120
+ self.controller.start_buffer(False)
121
+
122
+ self.settings.child('acq', 'sampling_rate').setValue(self.controller.sample_frequency)
123
+ info = self.controller.id
124
+ self.settings.child('id').setValue(info)
125
+ initialized = True
126
+ return info, initialized
127
+
128
+ def close(self):
129
+ """Terminate the communication protocol"""
130
+ if self.controller is not None:
131
+ self.controller.clear()
132
+ self.controller.shutdown()
133
+
134
+ def grab_data(self, Naverage=1, **kwargs):
135
+ """Start a grab from the detector
136
+
137
+ Parameters
138
+ ----------
139
+ Naverage: int
140
+ Number of hardware averaging (if hardware averaging is possible, self.hardware_averaging should be set to
141
+ True in class preamble and you should code this implementation)
142
+ kwargs: dict
143
+ others optionals arguments
144
+ """
145
+
146
+ selected_channels = self.settings['acq', 'channels']['selected']
147
+ snapped_list = self.controller.snap(*selected_channels)[:len(selected_channels)]
148
+ data_list_array = [np.array([snapped]) for snapped in snapped_list]
149
+ dwas = self.create_dwas(data_list_array)
150
+
151
+ self.dte_signal.emit(DataToExport(name='SR830', data=dwas))
152
+
153
+ def create_dwas(self, data_list_array: List[np.ndarray]) -> List[DataFromPlugins]:
154
+ """ Create a list of DataFromPlugins according to the selected channels
155
+
156
+ Parameters
157
+ ----------
158
+ data_list_array: List[np.ndarray]
159
+ The list of numpy ndarray to put into a list of DataFromPlugins
160
+
161
+ Returns
162
+ -------
163
+ List[DataFromPlugins]
164
+ """
165
+ selected_channels = self.settings['acq', 'channels']['selected']
166
+ if self.settings['acq', 'separate_viewers']:
167
+
168
+ dwas = [DataFromPlugins(f'SR830:{selected_channels[ind]}',
169
+ data=[array],
170
+ labels=[selected_channels[ind]]) for ind, array in enumerate(data_list_array)]
171
+ else:
172
+ dwas = [DataFromPlugins('SR830',
173
+ data=data_list_array,
174
+ labels=selected_channels)]
175
+ return dwas
176
+
177
+ def stop(self):
178
+ """Stop the current grab hardware wise if necessary"""
179
+ return ''
180
+
181
+
182
+ if __name__ == '__main__':
183
+ main(__file__, init=False)
@@ -0,0 +1,235 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on Thu Jun 14 15:14:54 2018
4
+
5
+ @author: Weber Sébastien
6
+ @email: seba.weber@gmail.com
7
+ """
8
+ from qtpy.QtCore import Signal
9
+ from easydict import EasyDict as edict
10
+
11
+ from pymodaq.utils.daq_utils import ThreadCommand, getLineInfo
12
+ from pymodaq.utils.data import DataFromPlugins
13
+ from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, main, comon_parameters
14
+ from collections import OrderedDict
15
+
16
+ import numpy as np
17
+ import re
18
+
19
+ ##checking VISA ressources
20
+ try:
21
+ from pyvisa import ResourceManager
22
+
23
+ VISA_rm = ResourceManager()
24
+ devices = list(VISA_rm.list_resources())
25
+ device = ''
26
+ for dev in devices:
27
+ if 'GPIB' in dev:
28
+ device = dev
29
+ break
30
+ except Exception as e:
31
+ devices = []
32
+ device = ''
33
+ raise e
34
+
35
+
36
+ class DAQ_0DViewer_LockInSR830Legacy(DAQ_Viewer_base):
37
+ """
38
+ ==================== ========================
39
+ **Attributes** **Type**
40
+ *data_grabed_signal* instance of Signal
41
+ *VISA_rm* ResourceManager
42
+ *com_ports*
43
+ *params* dictionnary list
44
+ *inst*
45
+ *settings*
46
+ ==================== ========================
47
+ """
48
+ data_grabed_signal = Signal(list)
49
+ channels = ['X', 'Y', 'MAG', 'PHA', 'Aux In 1', 'Aux In 2', 'Aux In 3', 'Aux In 4', 'Ref frequency', 'CH1 display',
50
+ 'CH2 display']
51
+
52
+ params = comon_parameters + [
53
+ {'title': 'VISA:', 'name': 'VISA_ressources', 'type': 'list', 'limits': devices, 'value': device},
54
+ {'title': 'Manufacturer:', 'name': 'manufacturer', 'type': 'str', 'value': ""},
55
+ {'title': 'Serial number:', 'name': 'serial_number', 'type': 'str', 'value': ""},
56
+ {'title': 'Model:', 'name': 'model', 'type': 'str', 'value': ""},
57
+ {'title': 'Timeout (ms):', 'name': 'timeout', 'type': 'int', 'value': 2000, 'default': 2000, 'min': 1000},
58
+ {'title': 'Configuration:', 'name': 'config', 'type': 'group', 'children': [
59
+ {'title': 'Reset:', 'name': 'reset', 'type': 'bool_push', 'value': False},
60
+ {'title': 'Channels in separate viewer:', 'name': 'separate_viewers', 'type': 'bool', 'value': True},
61
+ {'title': 'Channels:', 'name': 'channels', 'type': 'itemselect',
62
+ 'value': dict(all_items=channels, selected=['MAG', 'PHA'])},
63
+ {'title': 'Setup:', 'name': 'setup', 'type': 'group', 'children': [
64
+ {'title': 'Setup number:', 'name': 'setup_number', 'type': 'int', 'value': 0},
65
+ {'title': 'Save setup:', 'name': 'save_setup', 'type': 'bool', 'value': False},
66
+ {'title': 'Load setup:', 'name': 'load_setup', 'type': 'bool', 'value': False}, ]}
67
+ ]},
68
+ ]
69
+
70
+ def __init__(self, parent=None, params_state=None):
71
+ super().__init__(parent, params_state)
72
+ self.controller = None
73
+
74
+ def query_data(self, cmd):
75
+ try:
76
+ res = self.controller.query(cmd)
77
+ searched = re.search('\n', res)
78
+ status_byte = res[searched.start() + 1]
79
+ overload_byte = res[searched.start() + 3]
80
+ if searched.start != 0:
81
+ data = np.array([float(x) for x in res[0:searched.start()].split(",")])
82
+ else:
83
+ data = None
84
+ return (status_byte, overload_byte, data)
85
+ except:
86
+ return ('\x01', '\x00', None)
87
+
88
+ def query_string(self, cmd):
89
+ try:
90
+ res = self.controller.query(cmd)
91
+ searched = re.search('\n', res)
92
+ status_byte = res[searched.start() + 1]
93
+ overload_byte = res[searched.start() + 3]
94
+ if searched.start != 0:
95
+ str = res[0:searched.start()]
96
+ else:
97
+ str = ""
98
+ return (status_byte, overload_byte, str)
99
+ except:
100
+ return ('\x01', '\x00', "")
101
+
102
+ def ini_detector(self, controller=None):
103
+ """
104
+ Initialisation procedure of the detector.
105
+
106
+ Returns
107
+ -------
108
+
109
+ The initialized status.
110
+
111
+ See Also
112
+ --------
113
+ daq_utils.ThreadCommand
114
+ """
115
+ self.status.update(edict(initialized=False, info="", x_axis=None, y_axis=None, controller=None))
116
+ try:
117
+
118
+ if self.settings.child(('controller_status')).value() == "Slave":
119
+ if controller is None:
120
+ raise Exception('no controller has been defined externally while this detector is a slave one')
121
+ else:
122
+ self.controller = controller
123
+ else:
124
+ VISA_rm = ResourceManager()
125
+ self.controller = VISA_rm.open_resource(self.settings.child(('VISA_ressources')).value())
126
+
127
+ self.controller.timeout = self.settings.child(('timeout')).value()
128
+ idn = self.controller.query('OUTX1;*IDN?;')
129
+ idn = idn.rstrip('\n')
130
+ idn = idn.rsplit(',')
131
+ if len(idn) >= 0:
132
+ self.settings.child(('manufacturer')).setValue(idn[0])
133
+ if len(idn) >= 1:
134
+ self.settings.child(('model')).setValue(idn[1])
135
+ if len(idn) >= 2:
136
+ self.settings.child(('serial_number')).setValue(idn[2])
137
+
138
+ # self.reset()
139
+
140
+ self.status.controller = self.controller
141
+ self.status.initialized = True
142
+ return self.status
143
+
144
+ except Exception as e:
145
+ self.emit_status(ThreadCommand('Update_Status', [getLineInfo() + str(e), 'log']))
146
+ self.status.info = getLineInfo() + str(e)
147
+ self.status.initialized = False
148
+ return self.status
149
+
150
+ def reset(self):
151
+ self.controller.write('*RST')
152
+
153
+ def grab_data(self, Naverage=1, **kwargs):
154
+ """
155
+ | Start new acquisition.
156
+ | grab the current values.
157
+ | Send the data_grabed_signal once done.
158
+
159
+ =============== ======== ===============================================
160
+ **Parameters** **Type** **Description**
161
+ *Naverage* int Number of values to average
162
+ =============== ======== ===============================================
163
+ """
164
+ data_tot = []
165
+ data = self.controller.query_ascii_values('SNAP ? 1,2,3,4,5,6')
166
+ data.extend(self.controller.query_ascii_values('SNAP ? 7,8,9,10,11'))
167
+ selected_channels = self.settings.child('config', 'channels').value()['selected']
168
+ data_to_export = [np.array([data[ind]]) for ind in [self.channels.index(sel) for sel in selected_channels]]
169
+
170
+ if self.settings.child('config', 'separate_viewers').value():
171
+ for ind_channel, dat in enumerate(data_to_export):
172
+ data_tot.append(DataFromPlugins(name=selected_channels[ind_channel], data=[dat], dim='Data0D',
173
+ labels=[selected_channels[ind_channel]]))
174
+ self.data_grabed_signal.emit(data_tot)
175
+ else:
176
+ self.data_grabed_signal.emit(
177
+ [DataFromPlugins(name='SR830', data=data_to_export, dim='Data0D', labels=selected_channels)])
178
+
179
+ def commit_settings(self, param):
180
+ """
181
+ Activate the parameters changes in the hardware.
182
+
183
+ =============== ================================= ============================
184
+ **Parameters** **Type** **Description**
185
+ *param* instance of pyqtgraph.parameter The parameter to be checked.
186
+ =============== ================================= ============================
187
+
188
+ See Also
189
+ --------
190
+ daq_utils.ThreadCommand
191
+ """
192
+ try:
193
+ if param.name() == 'timeout':
194
+ self.controller.timeout = self.settings.child(('timeout')).value()
195
+
196
+ if param.name() == 'load_setup':
197
+ self.controller.write(
198
+ 'RSET{:d};'.format(self.settings.child('config', 'setup', 'setup_number').value()))
199
+ param.setValue(False)
200
+
201
+ if param.name() == 'save_setup':
202
+ self.controller.write(
203
+ 'SSET{:d};'.format(self.settings.child('config', 'setup', 'setup_number').value()))
204
+ param.setValue(False)
205
+
206
+ elif param.name() == 'channels':
207
+ data_init = []
208
+ for channel in param.value()['selected']:
209
+ if self.settings.child('config', 'separate_viewers').value():
210
+ data_init.append(DataFromPlugins(name=channel, data=[np.array([0])], dim='Data0D'))
211
+ else:
212
+ data_init.append(np.array([0]))
213
+ if self.settings.child('config', 'separate_viewers').value():
214
+ self.data_grabed_signal_temp.emit(data_init)
215
+ else:
216
+ self.data_grabed_signal_temp.emit([DataFromPlugins(name='SR830', data=data_init, dim='Data0D')])
217
+ elif param.name() == 'reset':
218
+ self.reset()
219
+ param.setValue(False)
220
+
221
+ except Exception as e:
222
+ self.emit_status(ThreadCommand('Update_Status', [getLineInfo() + str(e), 'log']))
223
+
224
+ def close(self):
225
+ """
226
+ close the current instance of the visa session.
227
+ """
228
+ self.controller.close()
229
+
230
+ def stop(self):
231
+ pass
232
+
233
+
234
+ if __name__ == '__main__':
235
+ main(__file__, init=False)
@@ -0,0 +1,13 @@
1
+ import importlib
2
+ from pathlib import Path
3
+ from ... import set_logger
4
+ logger = set_logger('viewer1D_plugins', add_to_console=False)
5
+
6
+ for path in Path(__file__).parent.iterdir():
7
+ try:
8
+ if '__init__' not in str(path):
9
+ importlib.import_module('.' + path.stem, __package__)
10
+ except Exception as e:
11
+ logger.warning("{:} plugin couldn't be loaded due to some missing packages or errors: {:}".format(path.stem, str(e)))
12
+ pass
13
+
@@ -0,0 +1,75 @@
1
+ from typing import List
2
+ from time import perf_counter
3
+ from qtpy.QtCore import QThread
4
+ import numpy as np
5
+ from pymodaq.utils.daq_utils import ThreadCommand
6
+ from pymodaq.utils.data import DataFromPlugins, DataToExport
7
+ from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main
8
+ from pymodaq.utils.parameter import Parameter
9
+
10
+ from pymeasure.instruments.srs.sr830 import SR830
11
+ from pyvisa import ResourceManager
12
+
13
+ from pymodaq_plugins_stanford_research_systems.daq_viewer_plugins.plugins_0D.daq_0Dviewer_LockInSR830 import (
14
+ DAQ_0DViewer_LockInSR830)
15
+
16
+
17
+ class DAQ_1DViewer_LockInSR830(DAQ_0DViewer_LockInSR830):
18
+ """ Instrument plugin class for a OD viewer.
19
+
20
+ This object inherits all functionalities to communicate with PyMoDAQ’s DAQ_Viewer module through inheritance via
21
+ DAQ_Viewer_base. It makes a bridge between the DAQ_Viewer module and the Python wrapper of a particular instrument.
22
+
23
+ Attributes:
24
+ -----------
25
+ controller: object
26
+ The particular object that allow the communication with the hardware, in general a python wrapper around the
27
+ hardware library.
28
+
29
+ """
30
+ params = [
31
+ {'title': 'Npts:', 'name': 'npts', 'type': 'int', 'min': 1, 'max': 16380, 'value': 10},
32
+ ] + DAQ_0DViewer_LockInSR830.params
33
+
34
+ def ini_detector(self, controller=None):
35
+ info, initialized = super().ini_detector(controller)
36
+ self.settings.child('acq', 'separate_viewers').show(False)
37
+ self.settings.child('acq', 'channels').show(False)
38
+
39
+ self.dte_signal_temp.emit(DataToExport(name='SR830', data=[
40
+ DataFromPlugins('CH1', data=[np.zeros((self.settings['npts'],))], labels=['CH1']),
41
+ DataFromPlugins('CH2', data=[np.zeros((self.settings['npts'],))], labels=['CH2']),
42
+ ]))
43
+ return info, initialized
44
+
45
+ def grab_data(self, Naverage=1, **kwargs):
46
+ """Start a grab from the detector
47
+
48
+ Parameters
49
+ ----------
50
+ Naverage: int
51
+ Number of hardware averaging (if hardware averaging is possible, self.hardware_averaging should be set to
52
+ True in class preamble and you should code this implementation)
53
+ kwargs: dict
54
+ others optionals arguments
55
+ """
56
+ self.controller.clear()
57
+ rate = self.settings['acq', 'sampling_rate']
58
+ self.controller.reset_buffer()
59
+ start = perf_counter()
60
+ self.controller.start_scan()
61
+ counts = self.settings['npts']
62
+ self.controller.wait_for_buffer(counts, timeout=60, timestep=0.01)
63
+ print(f'acq time: {perf_counter() - start}s, should be: {counts / rate}')
64
+ ch1 = self.controller.get_buffer(1)
65
+ ch2 = self.controller.get_buffer(2)
66
+ self.controller.pause_scan()
67
+
68
+ self.dte_signal.emit(DataToExport(name='SR830', data=[
69
+ DataFromPlugins('CH1', data=[ch1], labels=['CH1']),
70
+ DataFromPlugins('CH2', data=[ch2], labels=['CH2']),
71
+ ]))
72
+
73
+
74
+ if __name__ == '__main__':
75
+ main(__file__, init=False)
@@ -0,0 +1,14 @@
1
+ import importlib
2
+ from pathlib import Path
3
+ from ... import set_logger
4
+ logger = set_logger('viewer2D_plugins', add_to_console=False)
5
+
6
+ for path in Path(__file__).parent.iterdir():
7
+ try:
8
+ if '__init__' not in str(path):
9
+ importlib.import_module('.' + path.stem, __package__)
10
+ except Exception as e:
11
+ logger.warning("{:} plugin couldn't be loaded due to some missing packages or errors: {:}".format(path.stem, str(e)))
12
+ pass
13
+
14
+
@@ -0,0 +1,13 @@
1
+ import importlib
2
+ from pathlib import Path
3
+ from ... import set_logger
4
+ logger = set_logger('viewerND_plugins', add_to_console=False)
5
+
6
+ for path in Path(__file__).parent.iterdir():
7
+ try:
8
+ if '__init__' not in str(path):
9
+ importlib.import_module('.' + path.stem, __package__)
10
+ except Exception as e:
11
+ logger.warning("{:} plugin couldn't be loaded due to some missing packages or errors: {:}".format(path.stem, str(e)))
12
+ pass
13
+
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 01/06/2023
4
+
5
+ @author: Sebastien Weber
6
+ """
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 01/06/2023
4
+
5
+ @author: Sebastien Weber
6
+ """
@@ -0,0 +1,90 @@
1
+ from pymodaq.extensions.pid.utils import PIDModelGeneric, OutputToActuator, InputFromDetector, main
2
+ from pymodaq.utils.data import DataToExport
3
+ from typing import List
4
+
5
+
6
+ def some_function_to_convert_the_pid_outputs(outputs: List[float], dt: float, stab=True):
7
+ """ Should be replaced here or in the model class to process the outputs """
8
+ return outputs
9
+
10
+
11
+ def some_function_to_convert_the_data(measurements: DataToExport):
12
+ """ Should be replaced here or in the model class to process the measurement """
13
+ a = 0
14
+ b = 1
15
+ return [a, b]
16
+
17
+
18
+ class PIDModelTemplate(PIDModelGeneric):
19
+ limits = dict(max=dict(state=False, value=100),
20
+ min=dict(state=False, value=-100),)
21
+ konstants = dict(kp=0.1, ki=0.000, kd=0.0000)
22
+
23
+ Nsetpoints = 2 # number of setpoints
24
+ setpoint_ini = [128, 128] # number and values of initial setpoints
25
+ setpoints_names = ['Xaxis', 'Yaxis'] # number and names of setpoints
26
+
27
+ actuators_name = ["Xpiezo", "Ypiezo"] # names of actuator's control modules involved in the PID
28
+ detectors_name = ['Camera'] # names of detector's control modules involved in the PID
29
+
30
+ params = [] # list of dict to initialize specific Parameters
31
+
32
+ def __init__(self, pid_controller):
33
+ super().__init__(pid_controller)
34
+
35
+ def update_settings(self, param):
36
+ """
37
+ Get a parameter instance whose value has been modified by a user on the UI
38
+ Parameters
39
+ ----------
40
+ param: (Parameter) instance of Parameter object
41
+ """
42
+ if param.name() == '':
43
+ pass
44
+
45
+ def ini_model(self):
46
+ super().ini_model()
47
+
48
+ # add here other specifics initialization if needed
49
+
50
+ def convert_input(self, measurements: DataToExport):
51
+ """
52
+ Convert the measurements in the units to be fed to the PID (same dimensionality as the setpoint)
53
+ Parameters
54
+ ----------
55
+ measurements: DataToExport
56
+ Data from the declared detectors from which the model extract a value of the same units as the setpoint
57
+
58
+ Returns
59
+ -------
60
+ InputFromDetector: the converted input in the setpoints units
61
+
62
+ """
63
+
64
+ x, y = some_function_to_convert_the_data(measurements)
65
+ return InputFromDetector([y, x])
66
+
67
+ def convert_output(self, outputs: List[float], dt: float, stab=True):
68
+ """
69
+ Convert the output of the PID in units to be fed into the actuator
70
+ Parameters
71
+ ----------
72
+ outputs: List of float
73
+ output value from the PID from which the model extract a value of the same units as the actuator
74
+ dt: float
75
+ Ellapsed time since the last call to this function
76
+ stab: bool
77
+
78
+ Returns
79
+ -------
80
+ OutputToActuator: the converted output
81
+
82
+ """
83
+ outputs = some_function_to_convert_the_pid_outputs(outputs, dt, stab)
84
+ return OutputToActuator(mode='rel', values=outputs)
85
+
86
+
87
+ if __name__ == '__main__':
88
+ main("BeamSteeringMockNoModel.xml") # some preset configured with the right actuators and detectors
89
+
90
+
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 01/06/2023
4
+
5
+ @author: Sebastien Weber
6
+ """
@@ -0,0 +1,2 @@
1
+ #this is the configuration file of the plugin
2
+
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 01/06/2023
4
+
5
+ @author: Sebastien Weber
6
+ """
@@ -0,0 +1,15 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 31/08/2023
4
+
5
+ @author: Sebastien Weber
6
+ """
7
+ from pathlib import Path
8
+
9
+ from pymodaq.utils.config import BaseConfig, USER
10
+
11
+
12
+ class Config(BaseConfig):
13
+ """Main class to deal with configuration values for this plugin"""
14
+ config_template_path = Path(__file__).parent.joinpath('resources/config_template.toml')
15
+ config_name = f"config_{__package__.split('pymodaq_plugins_')[1]}"
@@ -0,0 +1,101 @@
1
+ Metadata-Version: 2.4
2
+ Name: pymodaq_plugins_stanford_research_systems
3
+ Version: 1.0.1
4
+ Summary: Set of plugins for the Stanford Research Systems (SRS) Instruments
5
+ Project-URL: Homepage, https://pymodaq.cnrs.fr
6
+ Project-URL: Documentation , https://pymodaq.cnrs.fr
7
+ Project-URL: Repository , https://github.com/PyMoDAQ/pymodaq_plugins_stanford_research_systems
8
+ Author-email: "Sebastien J. Weber" <sebastien.weber@cemes.fr>
9
+ Maintainer-email: "Sebastien J. Weber" <sebastien.weber@cemes.fr>
10
+ License: The MIT License (MIT)
11
+
12
+ Copyright (c) 2021 Sebastien Weber <sebastien.weber@cemes.fr>
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in
22
+ all copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
+ THE SOFTWARE.
31
+ License-File: LICENSE
32
+ Classifier: Development Status :: 5 - Production/Stable
33
+ Classifier: Intended Audience :: Science/Research
34
+ Classifier: License :: OSI Approved :: MIT License
35
+ Classifier: Natural Language :: English
36
+ Classifier: Operating System :: OS Independent
37
+ Classifier: Programming Language :: Python :: 3.8
38
+ Classifier: Programming Language :: Python :: 3.9
39
+ Classifier: Programming Language :: Python :: 3.10
40
+ Classifier: Programming Language :: Python :: 3.11
41
+ Classifier: Topic :: Scientific/Engineering :: Human Machine Interfaces
42
+ Classifier: Topic :: Scientific/Engineering :: Visualization
43
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
44
+ Classifier: Topic :: Software Development :: User Interfaces
45
+ Requires-Python: >=3.8
46
+ Requires-Dist: pymodaq-utils
47
+ Requires-Dist: pymodaq>=4.0.0
48
+ Requires-Dist: pyvisa
49
+ Description-Content-Type: text/x-rst
50
+
51
+ pymodaq_plugins_stanford_research_systems
52
+ #########################################
53
+
54
+ .. the following must be adapted to your developed package, links to pypi, github description...
55
+
56
+ .. image:: https://img.shields.io/pypi/v/pymodaq_plugins_stanford_research_systems.svg
57
+ :target: https://pypi.org/project/pymodaq_plugins_stanford_research_systems/
58
+ :alt: Latest Version
59
+
60
+ .. image:: https://readthedocs.org/projects/pymodaq/badge/?version=latest
61
+ :target: https://pymodaq.readthedocs.io/en/stable/?badge=latest
62
+ :alt: Documentation Status
63
+
64
+ .. image:: https://github.com/PyMoDAQ/pymodaq_plugins_stanford_research_systems/workflows/Upload%20Python%20Package/badge.svg
65
+ :target: https://github.com/PyMoDAQ/pymodaq_plugins_stanford_research_systems
66
+ :alt: Publication Status
67
+
68
+ .. image:: https://github.com/PyMoDAQ/pymodaq_plugins_stanford_research_systems/actions/workflows/Test.yml/badge.svg
69
+ :target: https://github.com/PyMoDAQ/pymodaq_plugins_stanford_research_systems/actions/workflows/Test.yml
70
+
71
+
72
+ Set of instruments from the Stanford Research Systems brand
73
+
74
+ Authors
75
+ =======
76
+
77
+ * Sebastien J. Weber (sebastien.weber@cemes.fr)
78
+
79
+
80
+
81
+ Instruments
82
+ ===========
83
+
84
+ Below is the list of instruments included in this plugin
85
+
86
+
87
+
88
+ Viewer0D
89
+ ++++++++
90
+
91
+ * * **LockinSR830Legacy**: LockIn Amplifier SR830 (legacy implementation)
92
+ * * **LockinSR830**: LockIn Amplifier SR830 (uses the pymeasure driver and is recommended)
93
+
94
+
95
+
96
+ Installation instructions
97
+ =========================
98
+
99
+ * PyMoDAQ version > 4.0.8
100
+ * VISA backend if connected using GPIB
101
+
@@ -0,0 +1,24 @@
1
+ pymodaq_plugins_stanford_research_systems/__init__.py,sha256=f0-Mjjc8INR1I-p9MzgwLn7XTJYRSb9Q2c1X1rW3Imw,304
2
+ pymodaq_plugins_stanford_research_systems/utils.py,sha256=MWgdJVYqFcG2r7MeHRixkCQv4zi-_-zCbTBn6gRsMVE,419
3
+ pymodaq_plugins_stanford_research_systems/daq_move_plugins/__init__.py,sha256=H-DnuGG6lezGyUjuhavlXRbzoQqzMbZaT3mfMNnAhHk,454
4
+ pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/__init__.py,sha256=ajz1GSNU9xYVrFEDSz6Xwg7amWQ_yvW75tQa1ZvRIWc,3
5
+ pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_0D/__init__.py,sha256=ooWW3pJyqQ8lk_bgXe8RXvCZLzl41Cm5gJxwSc-vaCc,459
6
+ pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_0D/daq_0Dviewer_LockInSR830.py,sha256=Qtt7O6jGAfPQPb03ZGawYuWvg4PYXppZR-OAR34dwUg,7237
7
+ pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_0D/daq_0Dviewer_LockInSR830Legacy.py,sha256=FNH3ahksvj7rPzIeKgDDPLEGJLF5F9OSwTmpn1PJ9P8,9454
8
+ pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_1D/__init__.py,sha256=R2Z_g54zfMJ16Kj3dA7MRj3TF8rjK8lWVAqwJ_yPYTA,459
9
+ pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_1D/daq_1Dviewer_LockInSR830.py,sha256=9Rsg_SKXBrwNSZnSGLgQ6iG2ucMxQaxQH08gQ8zGpiE,3037
10
+ pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_2D/__init__.py,sha256=U43pcyA6aNdltDFbW0TbxpQ2MWYJy3BW-dNucGTjoBc,460
11
+ pymodaq_plugins_stanford_research_systems/daq_viewer_plugins/plugins_ND/__init__.py,sha256=AkMkmRCEIkEN8Jxnd0xFhmaTfLm-Sg95TozVstPsHLI,459
12
+ pymodaq_plugins_stanford_research_systems/exporters/__init__.py,sha256=vqgY3SHF6EhPcfeS8lzb7QvAiTIXWmyObIaCYeJNb6Y,81
13
+ pymodaq_plugins_stanford_research_systems/extensions/__init__.py,sha256=vqgY3SHF6EhPcfeS8lzb7QvAiTIXWmyObIaCYeJNb6Y,81
14
+ pymodaq_plugins_stanford_research_systems/hardware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ pymodaq_plugins_stanford_research_systems/models/PIDModelTemplate.py,sha256=hMa8soj9fpODV8Mr-s1nkc33tyn01ps0O19I-NnNvpE,3077
16
+ pymodaq_plugins_stanford_research_systems/models/__init__.py,sha256=vqgY3SHF6EhPcfeS8lzb7QvAiTIXWmyObIaCYeJNb6Y,81
17
+ pymodaq_plugins_stanford_research_systems/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
+ pymodaq_plugins_stanford_research_systems/resources/config_template.toml,sha256=wJnPtBbfpOs5-AwGV4C4W3y9p4ZiyuARnJoUXUW97f4,47
19
+ pymodaq_plugins_stanford_research_systems/scanners/__init__.py,sha256=vqgY3SHF6EhPcfeS8lzb7QvAiTIXWmyObIaCYeJNb6Y,81
20
+ pymodaq_plugins_stanford_research_systems-1.0.1.dist-info/METADATA,sha256=-UHsj1qwBR1sE9dBJvoEsmglvEqXSem7neSSPoWsYmQ,4172
21
+ pymodaq_plugins_stanford_research_systems-1.0.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
22
+ pymodaq_plugins_stanford_research_systems-1.0.1.dist-info/entry_points.txt,sha256=UUPvXKOKEipqH7xdVDu8Hfmxt0jh9clbd7mhGNKzsxU,181
23
+ pymodaq_plugins_stanford_research_systems-1.0.1.dist-info/licenses/LICENSE,sha256=VKOejxexXAe3XwfhAhcFGqeXQ12irxVHdeAojZwFEI8,1108
24
+ pymodaq_plugins_stanford_research_systems-1.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,5 @@
1
+ [pymodaq.instruments]
2
+ stanford_research_systems = pymodaq_plugins_stanford_research_systems
3
+
4
+ [pymodaq.plugins]
5
+ stanford_research_systems = pymodaq_plugins_stanford_research_systems
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Sebastien Weber <sebastien.weber@cemes.fr>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.