pymodaq_plugins_raspberry 5.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.
@@ -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
+ config = Config()
7
+ try:
8
+ __version__ = get_version(__package__)
9
+ except PackageNotFoundError:
10
+ __version__ = '0.0.0dev'
11
+
@@ -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,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,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,160 @@
1
+ import numpy as np
2
+ from qtpy import QtWidgets
3
+
4
+ from pymodaq.utils.daq_utils import ThreadCommand
5
+ from pymodaq.utils.data import DataFromPlugins, Axis, DataToExport
6
+ from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main
7
+ from pymodaq.utils.parameter import Parameter
8
+ from pymodaq_utils.logger import set_logger, get_module_name
9
+
10
+ logger = set_logger(get_module_name(__file__))
11
+
12
+ from picamera2 import Picamera2
13
+
14
+
15
+ class DAQ_2DViewer_PiCamera(DAQ_Viewer_base):
16
+ """ Instrument plugin class for a 2D viewer.
17
+
18
+ This object inherits all functionalities to communicate with PyMoDAQ’s DAQ_Viewer module through inheritance via
19
+ DAQ_Viewer_base. It makes a bridge between the DAQ_Viewer module and the Python wrapper of a particular instrument.
20
+
21
+ Attributes:
22
+ -----------
23
+ controller: object
24
+ The particular object that allow the communication with the hardware, in general a python wrapper around the
25
+ hardware library.
26
+
27
+ """
28
+
29
+ hardware_averaging = True
30
+ live_mode_available = False
31
+
32
+ params = comon_parameters + [
33
+ {'title': 'Resolution:', 'name': 'resolution', 'type': 'list', 'value': 'low', 'limits': ['low', 'high']},
34
+ #{'title': 'Zoom:', 'name': 'zoom', 'type': 'slide', 'value': 1.0, 'min': 0., 'max': 1., 'subtype': 'linear'},
35
+ #{'title': 'Brightness:', 'name': 'brightness', 'type': 'slide', 'value': 50, 'min': 0, 'max': 100,
36
+ # 'subtype': 'linear', 'int': True},
37
+ #{'title': 'Contrast:', 'name': 'contrast', 'type': 'slide', 'value': 0, 'min': -100, 'max': 100,
38
+ # 'subtype': 'linear', 'int': True},
39
+ ]
40
+
41
+ def ini_attributes(self):
42
+ # TODO declare the type of the wrapper (and assign it to self.controller) you're going to use for easy
43
+ # autocompletion
44
+ self.controller: PiCamera2 = None
45
+
46
+ # TODO declare here attributes you want/need to init with a default value
47
+ self.live = False
48
+
49
+ self.x_axis = None
50
+ self.y_axis = None
51
+ self.width = 640
52
+ self.height = 480
53
+
54
+ def commit_settings(self, param: Parameter):
55
+ """Apply the consequences of a change of value in the detector settings
56
+
57
+ Parameters
58
+ ----------
59
+ param: Parameter
60
+ A given parameter (within detector_settings) whose value has been changed by the user
61
+ """
62
+ # TODO for your custom plugin
63
+ if param.name() == "resolution":
64
+ if param.value() == 'low':
65
+ self.controller.switch_mode(self.low_res_config)
66
+ else:
67
+ self.controller.switch_mode(self.high_res_config)
68
+ #elif ...
69
+
70
+ def ini_detector(self, controller=None):
71
+ """Detector communication initialization
72
+
73
+ Parameters
74
+ ----------
75
+ controller: (object)
76
+ custom object of a PyMoDAQ plugin (Slave case). None if only one actuator/detector by controller
77
+ (Master case)
78
+
79
+ Returns
80
+ -------
81
+ info: str
82
+ initialized: bool
83
+ False if initialization failed otherwise True
84
+ """
85
+ if self.is_master:
86
+ self.controller = Picamera2()
87
+ else:
88
+ self.controller = controller
89
+
90
+ self.low_res_config = self.controller.create_preview_configuration()
91
+ self.high_res_config = self.controller.create_still_configuration()
92
+
93
+ self.controller.configure(self.low_res_config)
94
+
95
+
96
+ logger.info(self.controller.camera_controls)
97
+ logger.info(self.controller.camera_properties)
98
+ #print(self.controller.capture_metadata())
99
+ self.controller.start()
100
+
101
+ info = "Whatever info you want to log"
102
+ initialized = True
103
+ return info, initialized
104
+
105
+ def close(self):
106
+ """Terminate the communication protocol"""
107
+ if self.controller is not None and self.is_master:
108
+ self.controller.close()
109
+
110
+ def grab_data(self, Naverage=1, **kwargs):
111
+ """Start a grab from the detector
112
+
113
+ Parameters
114
+ ----------
115
+ Naverage: int
116
+ Number of hardware averaging (if hardware averaging is possible, self.hardware_averaging should be set to
117
+ True in class preamble and you should code this implementation)
118
+ kwargs: dict
119
+ others optionals arguments
120
+ """
121
+
122
+ self.camera_done = False
123
+ self.Naverage = Naverage
124
+ if 'live' in kwargs:
125
+ self.live = kwargs['live']
126
+ else:
127
+ self.live = False
128
+ logger.debug(f'live: {self.live}')
129
+ if 'wait_time' in kwargs:
130
+ self.wait_time = kwargs['wait_time']
131
+ logger.debug(self.wait_time)
132
+
133
+ self.grab(Naverage)
134
+
135
+ def grab(self, Naverage):
136
+ for ind in range(Naverage):
137
+ array = self.controller.capture_array("main")
138
+ logger.debug(f'array shape: {array.shape}')
139
+ if len(array.shape) == 2:
140
+ arrays = [array]
141
+ elif len(array.shape) == 3:
142
+ arrays = [array[..., ind] for ind in range(3)] #alpha is with the last index equal to 4, we may skip it!
143
+ else:
144
+ raise ValueError(f'The array shape is {array.shape} and is not handled')
145
+ if ind == 0:
146
+ dwa_camera = DataFromPlugins('PiCamera', data=arrays)
147
+ else:
148
+ dwa_camera = dwa_camera.average(DataFromPlugins('PiCamera', data=arrays),
149
+ weight= ind+1)
150
+ self.dte_signal.emit(DataToExport('myplugin', data=[dwa_camera]))
151
+
152
+
153
+ def stop(self):
154
+ """Stop the current grab hardware wise if necessary"""
155
+ self.live = False
156
+ return ''
157
+
158
+
159
+ if __name__ == '__main__':
160
+ 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('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
+ """
File without changes
@@ -0,0 +1,6 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 01/06/2023
4
+
5
+ @author: Sebastien Weber
6
+ """
File without changes
@@ -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,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: pymodaq_plugins_raspberry
3
+ Version: 5.0.1
4
+ Summary: Set of instrument plugins to use with a raspberry
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_raspberry
8
+ Author-email: Weber Sébastien <sebastien.weber@cnrs.fr>
9
+ Maintainer-email: Weber Sébastien <sebastien.weber@cnrs.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: picamera2
47
+ Requires-Dist: pymodaq>=5.0.0
48
+ Description-Content-Type: text/x-rst
49
+
50
+ Raspberry plugin
51
+ ################
52
+
53
+ .. the following must be adapted to your developed package, links to pypi, github description...
54
+
55
+ .. image:: https://img.shields.io/pypi/v/pymodaq_plugins_raspberry.svg
56
+ :target: https://pypi.org/project/pymodaq_plugins_raspberry/
57
+ :alt: Latest Version
58
+
59
+ .. image:: https://readthedocs.org/projects/pymodaq/badge/?version=latest
60
+ :target: https://pymodaq.readthedocs.io/en/stable/?badge=latest
61
+ :alt: Documentation Status
62
+
63
+ .. image:: https://github.com/PyMoDAQ/pymodaq_plugins_raspberry/workflows/Upload%20Python%20Package/badge.svg
64
+ :target: https://github.com/PyMoDAQ/pymodaq_plugins_raspberry
65
+ :alt: Publication Status
66
+
67
+ .. image:: https://github.com/PyMoDAQ/pymodaq_plugins_raspberry/actions/workflows/Test.yml/badge.svg
68
+ :target: https://github.com/PyMoDAQ/pymodaq_plugins_raspberry/actions/workflows/Test.yml
69
+
70
+
71
+ Set of instrument plugins to be used from or on your Raspberry Pi
72
+
73
+ Authors
74
+ =======
75
+
76
+ * Sebastien J. Weber (sebastien.weber@cnrs.fr)
77
+
78
+
79
+ Instruments
80
+ ===========
81
+
82
+ Below is the list of instruments included in this plugin
83
+
84
+
85
+ Viewer2D
86
+ ++++++++
87
+
88
+ * **picamera**: control of the integrated pi camera using the Picamera2 library
89
+
90
+ .. if needed use this field
91
+
92
+ PID Models
93
+ ==========
94
+
95
+
96
+ Extensions
97
+ ==========
98
+
99
+
100
+ Installation instructions
101
+ =========================
102
+
103
+ * PyMoDAQ’s version >= 4
104
+ * Tested on/with a raspberry pi 4
105
+
@@ -0,0 +1,21 @@
1
+ pymodaq_plugins_raspberry/__init__.py,sha256=u-fOvR0JC9f2mTbw9qWM5TjXEC7XbwQDgq7yrL1z-9w,304
2
+ pymodaq_plugins_raspberry/utils.py,sha256=saBKehqiq5myeh7GCW1vYf5wq4QVYhSVLTxFK6KkdP4,419
3
+ pymodaq_plugins_raspberry/daq_move_plugins/__init__.py,sha256=H-DnuGG6lezGyUjuhavlXRbzoQqzMbZaT3mfMNnAhHk,454
4
+ pymodaq_plugins_raspberry/daq_viewer_plugins/__init__.py,sha256=ajz1GSNU9xYVrFEDSz6Xwg7amWQ_yvW75tQa1ZvRIWc,3
5
+ pymodaq_plugins_raspberry/daq_viewer_plugins/plugins_0D/__init__.py,sha256=ooWW3pJyqQ8lk_bgXe8RXvCZLzl41Cm5gJxwSc-vaCc,459
6
+ pymodaq_plugins_raspberry/daq_viewer_plugins/plugins_1D/__init__.py,sha256=R2Z_g54zfMJ16Kj3dA7MRj3TF8rjK8lWVAqwJ_yPYTA,459
7
+ pymodaq_plugins_raspberry/daq_viewer_plugins/plugins_2D/__init__.py,sha256=U43pcyA6aNdltDFbW0TbxpQ2MWYJy3BW-dNucGTjoBc,460
8
+ pymodaq_plugins_raspberry/daq_viewer_plugins/plugins_2D/daq_2Dviewer_PiCamera.py,sha256=DUGRDNo3V-cf_te29b5F824Mnl206t79UJOJX_l_msY,5804
9
+ pymodaq_plugins_raspberry/daq_viewer_plugins/plugins_ND/__init__.py,sha256=AkMkmRCEIkEN8Jxnd0xFhmaTfLm-Sg95TozVstPsHLI,459
10
+ pymodaq_plugins_raspberry/exporters/__init__.py,sha256=vqgY3SHF6EhPcfeS8lzb7QvAiTIXWmyObIaCYeJNb6Y,81
11
+ pymodaq_plugins_raspberry/extensions/__init__.py,sha256=vqgY3SHF6EhPcfeS8lzb7QvAiTIXWmyObIaCYeJNb6Y,81
12
+ pymodaq_plugins_raspberry/hardware/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ pymodaq_plugins_raspberry/models/__init__.py,sha256=vqgY3SHF6EhPcfeS8lzb7QvAiTIXWmyObIaCYeJNb6Y,81
14
+ pymodaq_plugins_raspberry/resources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ pymodaq_plugins_raspberry/resources/config_template.toml,sha256=wJnPtBbfpOs5-AwGV4C4W3y9p4ZiyuARnJoUXUW97f4,47
16
+ pymodaq_plugins_raspberry/scanners/__init__.py,sha256=vqgY3SHF6EhPcfeS8lzb7QvAiTIXWmyObIaCYeJNb6Y,81
17
+ pymodaq_plugins_raspberry-5.0.1.dist-info/METADATA,sha256=fE1iByVgWIRJsVUVFoDZzC4G_cDd5pZ6oWoroUkG5fE,3946
18
+ pymodaq_plugins_raspberry-5.0.1.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
19
+ pymodaq_plugins_raspberry-5.0.1.dist-info/entry_points.txt,sha256=kRsnQEzwHVJJIds1x4wpzYG-7rFXkOb13FxpgvIw4m4,117
20
+ pymodaq_plugins_raspberry-5.0.1.dist-info/licenses/LICENSE,sha256=VKOejxexXAe3XwfhAhcFGqeXQ12irxVHdeAojZwFEI8,1108
21
+ pymodaq_plugins_raspberry-5.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.29.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,5 @@
1
+ [pymodaq.instruments]
2
+ raspberry = pymodaq_plugins_raspberry
3
+
4
+ [pymodaq.plugins]
5
+ raspberry = pymodaq_plugins_raspberry
@@ -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.