pymodaq_plugins_raspberry 5.0.1__tar.gz

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 (32) hide show
  1. pymodaq_plugins_raspberry-5.0.1/.gitattributes +2 -0
  2. pymodaq_plugins_raspberry-5.0.1/.github/workflows/Test.yml +10 -0
  3. pymodaq_plugins_raspberry-5.0.1/.github/workflows/Testbase.yml +44 -0
  4. pymodaq_plugins_raspberry-5.0.1/.github/workflows/compatibility.yml +78 -0
  5. pymodaq_plugins_raspberry-5.0.1/.github/workflows/python-publish.yml +40 -0
  6. pymodaq_plugins_raspberry-5.0.1/.github/workflows/updater.yml +24 -0
  7. pymodaq_plugins_raspberry-5.0.1/.gitignore +115 -0
  8. pymodaq_plugins_raspberry-5.0.1/LICENSE +21 -0
  9. pymodaq_plugins_raspberry-5.0.1/MANIFEST.in +3 -0
  10. pymodaq_plugins_raspberry-5.0.1/PKG-INFO +105 -0
  11. pymodaq_plugins_raspberry-5.0.1/README.rst +56 -0
  12. pymodaq_plugins_raspberry-5.0.1/hatch_build.py +10 -0
  13. pymodaq_plugins_raspberry-5.0.1/icon.ico +0 -0
  14. pymodaq_plugins_raspberry-5.0.1/pyproject.toml +61 -0
  15. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/__init__.py +11 -0
  16. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/daq_move_plugins/__init__.py +13 -0
  17. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/daq_viewer_plugins/__init__.py +3 -0
  18. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/daq_viewer_plugins/plugins_0D/__init__.py +13 -0
  19. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/daq_viewer_plugins/plugins_1D/__init__.py +13 -0
  20. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/daq_viewer_plugins/plugins_2D/__init__.py +14 -0
  21. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/daq_viewer_plugins/plugins_2D/daq_2Dviewer_PiCamera.py +160 -0
  22. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/daq_viewer_plugins/plugins_ND/__init__.py +13 -0
  23. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/exporters/__init__.py +6 -0
  24. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/extensions/__init__.py +6 -0
  25. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/hardware/__init__.py +0 -0
  26. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/models/__init__.py +6 -0
  27. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/resources/__init__.py +0 -0
  28. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/resources/config_template.toml +2 -0
  29. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/scanners/__init__.py +6 -0
  30. pymodaq_plugins_raspberry-5.0.1/src/pymodaq_plugins_raspberry/utils.py +15 -0
  31. pymodaq_plugins_raspberry-5.0.1/tests/test_plugin_package_structure.py +91 -0
  32. pymodaq_plugins_raspberry-5.0.1/tox.ini +3 -0
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,10 @@
1
+ name: 'Tests'
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ call_workflow:
7
+ uses: ./.github/workflows/Testbase.yml
8
+ with:
9
+ python: '3.11'
10
+ qt5: 'pyqt5'
@@ -0,0 +1,44 @@
1
+ name: Base
2
+
3
+ on:
4
+ workflow_call:
5
+ inputs:
6
+ python:
7
+ required: true
8
+ type: string
9
+ qt5:
10
+ required: true
11
+ type: string
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+ env:
17
+ DISPLAY: ':99.0'
18
+ QT_DEBUG_PLUGINS: 1
19
+ steps:
20
+ - name: Set up Python ${{ inputs.python }}
21
+ uses: actions/checkout@v5.0.0
22
+ - name: Install dependencies
23
+ uses: actions/setup-python@v6.0.0
24
+ with:
25
+ python-version: ${{ inputs.python }}
26
+ - name: Install package
27
+ run: |
28
+ sudo apt install libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils
29
+ python -m pip install --upgrade pip
30
+ export QT_DEBUG_PLUGINS=1
31
+ pip install flake8 pytest pytest-cov pytest-qt pytest-xdist pytest-xvfb setuptools wheel numpy h5py ${{ inputs.qt5 }} toml
32
+ pip install pymodaq pyqt5
33
+ pip install -e .
34
+ - name: create local pymodaq folder and setting permissions
35
+ run: |
36
+ sudo mkdir /etc/.pymodaq
37
+ sudo chmod uo+rw /etc/.pymodaq
38
+ - name: Linting with flake8
39
+ run: |
40
+ # stop the build if there are Python syntax errors or undefined names
41
+ flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude=src/pymodaq/resources/QtDesigner_Ressources,docs
42
+ - name: Test with pytest
43
+ run: |
44
+ pytest -n auto -k "not test_compatibility"
@@ -0,0 +1,78 @@
1
+ name: Compatibility with pymodaq (latest release)
2
+
3
+ on:
4
+ workflow_call:
5
+
6
+ pull_request:
7
+
8
+ push:
9
+ branches:
10
+ - '*'
11
+
12
+ concurrency:
13
+ # github.workflow: name of the workflow
14
+ # github.event.pull_request.number || github.ref: pull request number or branch name if not a pull request
15
+ group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
16
+ # Cancel in-progress runs when a new workflow with the same group name is triggered
17
+ cancel-in-progress: true
18
+
19
+ jobs:
20
+ tests:
21
+ continue-on-error: true
22
+ strategy:
23
+ fail-fast: false
24
+ matrix:
25
+ os: ["ubuntu-latest", "windows-latest"]
26
+ python-version: ["3.9", "3.10", "3.11", "3.12"]
27
+ qt-backend: ["pyqt5", "pyqt6", "pyside6"]
28
+ runs-on: ${{ matrix.os }}
29
+ env:
30
+ DISPLAY: ':99'
31
+ QT_DEBUG_PLUGINS: 1
32
+
33
+ steps:
34
+ - name: Set project name environment variable
35
+ run: |
36
+ echo "plugin_name=$(echo '${{ github.repository }}' | cut -d'/' -f2)" >> $GITHUB_ENV
37
+
38
+ - name: Checkout the repo
39
+ uses: actions/checkout@v5.0.0
40
+
41
+ - name: Set up Python ${{ matrix.python-version }}
42
+ uses: actions/setup-python@v6.0.0
43
+ with:
44
+ python-version: ${{ matrix.python-version }}
45
+
46
+ - name: Install dependencies
47
+ run: |
48
+ python -m pip install --upgrade pip
49
+ pip install flake8 pytest pytest-cov pytest-qt pytest-xvfb pytest-xdist setuptools wheel numpy h5py pymodaq ${{ matrix.qt-backend }}
50
+ pip install -e .
51
+
52
+ # Create folder and set permissions on Ubuntu
53
+ - name: Create local pymodaq folder setup env (Linux)
54
+ if: runner.os == 'Linux'
55
+ run: |
56
+ sudo apt update
57
+ sudo apt install -y libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-cursor0 libxcb-randr0 libxcb-render-util0 libxcb-xinerama0 libxcb-xfixes0 x11-utils libgl1 libegl1
58
+ export QT_DEBUG_PLUGINS=1
59
+ sudo mkdir -p /etc/.pymodaq
60
+ sudo chmod uo+rw /etc/.pymodaq
61
+ - name: Exporting debug variables (Windows)
62
+ if: runner.os == 'Windows'
63
+ run: |
64
+ set QT_DEBUG_PLUGINS=1
65
+
66
+ - name: Compatibility tests with ${{ matrix.os }} ${{ matrix.python-version }} ${{ matrix.qt-backend}}
67
+ run: |
68
+ pytest -vv -n 1 -k "test_compatibility"
69
+
70
+ - name: Upload compatibility report
71
+ if: failure()
72
+ uses: actions/upload-artifact@v4.6.2
73
+ with:
74
+ name:
75
+ path: 'import_report_tests_${{ env.plugin_name }}_None.txt'
76
+ if-no-files-found: error
77
+
78
+
@@ -0,0 +1,40 @@
1
+ # This workflow will upload a Python Package using Twine when a release is created
2
+ # For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3
+
4
+ name: Upload Python Package
5
+
6
+ on:
7
+ release:
8
+ types: [created]
9
+
10
+ jobs:
11
+ deploy:
12
+
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - uses: actions/checkout@v5.0.0
17
+ - name: Set up Python
18
+ uses: actions/setup-python@v6.0.0
19
+ with:
20
+ python-version: '3.x'
21
+ - name: Install dependencies
22
+ run: |
23
+ python -m pip install --upgrade pip
24
+ pip install hatch hatchling toml twine
25
+ - name: Get history and tags for SCM versioning to work
26
+ run: |
27
+ git branch
28
+ git fetch --prune --unshallow
29
+ git fetch --depth=1 origin +refs/tags/*:refs/tags/*
30
+ hatch version
31
+ - name: Build
32
+ run: hatch build
33
+ - name: Check the build
34
+ run: twine check dist/*
35
+ - name: publish
36
+ env:
37
+ HATCH_INDEX_USER: ${{ secrets.PYPI_USERNAME }}
38
+ HATCH_INDEX_AUTH: ${{ secrets.PYPI_PASSWORD }}
39
+ run: |
40
+ hatch publish
@@ -0,0 +1,24 @@
1
+ name: GitHub Actions Version Updater
2
+
3
+ # Controls when the action will run.
4
+ on:
5
+ workflow_dispatch:
6
+ schedule:
7
+ # Automatically run at 00:00 on day-of-month 5.
8
+ - cron: '0 0 5 * *'
9
+
10
+ jobs:
11
+ build:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v5.0.0
16
+ with:
17
+ # [Required] Access token with `workflow` scope.
18
+ token: ${{ secrets.WORKFLOW_SECRET }}
19
+
20
+ - name: Run GitHub Actions Version Updater
21
+ uses: saadmk11/github-actions-version-updater@v0.9.0
22
+ with:
23
+ # [Required] Access token with `workflow` scope.
24
+ token: ${{ secrets.WORKFLOW_SECRET }}
@@ -0,0 +1,115 @@
1
+ # Compiled python modules.
2
+ *.pyc
3
+
4
+ # Byte-compiled / optimized / DLL files
5
+ __pycache__/
6
+
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ *.egg-info/
28
+ .installed.cfg
29
+ *.egg
30
+ MANIFEST
31
+
32
+ # PyInstaller
33
+ # Usually these files are written by a python script from a template
34
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
35
+ *.manifest
36
+ *.spec
37
+
38
+ # Installer logs
39
+ pip-log.txt
40
+ pip-delete-this-directory.txt
41
+
42
+ # Unit test / coverage reports
43
+ htmlcov/
44
+ .tox/
45
+ .coverage
46
+ .coverage.*
47
+ .cache
48
+ nosetests.xml
49
+ coverage.xml
50
+ *.cover
51
+ .hypothesis/
52
+ .pytest_cache/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+
63
+ # Flask stuff:
64
+ instance/
65
+ .webassets-cache
66
+
67
+ # Scrapy stuff:
68
+ .scrapy
69
+
70
+ # Sphinx documentation
71
+ docs/_build/
72
+
73
+ # PyBuilder
74
+ target/
75
+
76
+ # Jupyter Notebook
77
+ .ipynb_checkpoints
78
+
79
+ # pyenv
80
+ .python-version
81
+
82
+ # celery beat schedule file
83
+ celerybeat-schedule
84
+
85
+ # SageMath parsed files
86
+ *.sage.py
87
+
88
+ # Environments
89
+ .env
90
+ .venv
91
+ env/
92
+ venv/
93
+ ENV/
94
+ env.bak/
95
+ venv.bak/
96
+
97
+ # Spyder project settings
98
+ .spyderproject
99
+ .spyproject
100
+
101
+ # Rope project settings
102
+ .ropeproject
103
+
104
+ # mkdocs documentation
105
+ /site
106
+
107
+ # mypy
108
+ .mypy_cache/
109
+
110
+ # pycharm
111
+ .idea/
112
+ .idea/*
113
+
114
+ *yacctab.py
115
+ *lextab.py
@@ -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.
@@ -0,0 +1,3 @@
1
+ include README.rst
2
+ include LICENSE
3
+ graft src
@@ -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,56 @@
1
+ Raspberry plugin
2
+ ################
3
+
4
+ .. the following must be adapted to your developed package, links to pypi, github description...
5
+
6
+ .. image:: https://img.shields.io/pypi/v/pymodaq_plugins_raspberry.svg
7
+ :target: https://pypi.org/project/pymodaq_plugins_raspberry/
8
+ :alt: Latest Version
9
+
10
+ .. image:: https://readthedocs.org/projects/pymodaq/badge/?version=latest
11
+ :target: https://pymodaq.readthedocs.io/en/stable/?badge=latest
12
+ :alt: Documentation Status
13
+
14
+ .. image:: https://github.com/PyMoDAQ/pymodaq_plugins_raspberry/workflows/Upload%20Python%20Package/badge.svg
15
+ :target: https://github.com/PyMoDAQ/pymodaq_plugins_raspberry
16
+ :alt: Publication Status
17
+
18
+ .. image:: https://github.com/PyMoDAQ/pymodaq_plugins_raspberry/actions/workflows/Test.yml/badge.svg
19
+ :target: https://github.com/PyMoDAQ/pymodaq_plugins_raspberry/actions/workflows/Test.yml
20
+
21
+
22
+ Set of instrument plugins to be used from or on your Raspberry Pi
23
+
24
+ Authors
25
+ =======
26
+
27
+ * Sebastien J. Weber (sebastien.weber@cnrs.fr)
28
+
29
+
30
+ Instruments
31
+ ===========
32
+
33
+ Below is the list of instruments included in this plugin
34
+
35
+
36
+ Viewer2D
37
+ ++++++++
38
+
39
+ * **picamera**: control of the integrated pi camera using the Picamera2 library
40
+
41
+ .. if needed use this field
42
+
43
+ PID Models
44
+ ==========
45
+
46
+
47
+ Extensions
48
+ ==========
49
+
50
+
51
+ Installation instructions
52
+ =========================
53
+
54
+ * PyMoDAQ’s version >= 4
55
+ * Tested on/with a raspberry pi 4
56
+
@@ -0,0 +1,10 @@
1
+ from pathlib import Path
2
+ from hatchling.metadata.plugin.interface import MetadataHookInterface
3
+ from pymodaq_utils.resources.hatch_build_plugins import update_metadata_from_toml
4
+
5
+ here = Path(__file__).absolute().parent
6
+
7
+
8
+ class PluginInfoTomlHook(MetadataHookInterface):
9
+ def update(self, metadata: dict) -> None:
10
+ update_metadata_from_toml(metadata, here)
Binary file
@@ -0,0 +1,61 @@
1
+ [features] # defines the plugin features contained into this plugin
2
+ instruments = true # true if plugin contains instrument classes (else false, notice the lowercase for toml files)
3
+ extensions = false # true if plugins contains dashboard extensions
4
+ models = false # true if plugins contains pid models
5
+ h5exporters = false # true if plugin contains custom h5 file exporters
6
+ scanners = false # true if plugin contains custom scan layout (daq_scan extensions)
7
+
8
+ [urls]
9
+ package-url = 'https://github.com/PyMoDAQ/pymodaq_plugins_raspberry'
10
+
11
+ [project]
12
+ name = "pymodaq_plugins_raspberry"
13
+ description = 'Set of instrument plugins to use with a raspberry'
14
+ dependencies = [
15
+ "pymodaq>=5.0.0",
16
+ 'picamera2',
17
+ ]
18
+
19
+ authors = [
20
+ {name = "Weber Sébastien", email = "sebastien.weber@cnrs.fr"},
21
+ ]
22
+ maintainers = [
23
+ {name = "Weber Sébastien", email = "sebastien.weber@cnrs.fr"},
24
+ ]
25
+
26
+ # nottodo: leave everything below as is!
27
+
28
+ dynamic = ["version", "urls", "entry-points"]
29
+ readme = "README.rst"
30
+ license = { file="LICENSE" }
31
+ requires-python = ">=3.8"
32
+
33
+ classifiers = [
34
+ "Development Status :: 5 - Production/Stable",
35
+ "Intended Audience :: Science/Research",
36
+ "License :: OSI Approved :: MIT License",
37
+ "Natural Language :: English",
38
+ "Operating System :: OS Independent",
39
+ "Programming Language :: Python :: 3.8",
40
+ "Programming Language :: Python :: 3.9",
41
+ "Programming Language :: Python :: 3.10",
42
+ "Programming Language :: Python :: 3.11",
43
+ "Topic :: Scientific/Engineering :: Human Machine Interfaces",
44
+ "Topic :: Scientific/Engineering :: Visualization",
45
+ "Topic :: Software Development :: Libraries :: Python Modules",
46
+ "Topic :: Software Development :: User Interfaces",
47
+ ]
48
+
49
+ [build-system]
50
+ requires = [
51
+ "hatchling>=1.9.0",
52
+ "hatch-vcs", "toml",
53
+ "pymodaq_utils>=0.0.6",
54
+ ]
55
+ build-backend = "hatchling.build"
56
+
57
+ [tool.hatch.metadata.hooks.custom]
58
+
59
+ [tool.hatch.version]
60
+ source = "vcs"
61
+
@@ -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
+ """
@@ -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,91 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created the 17/10/2023
4
+
5
+ @author: Sebastien Weber
6
+ """
7
+ import pytest
8
+ from pathlib import Path
9
+ import importlib
10
+ import pkgutil
11
+
12
+
13
+ MANDATORY_MOVE_METHODS = ['ini_attributes', 'get_actuator_value', 'close', 'commit_settings',
14
+ 'ini_stage', 'move_abs', 'move_home', 'move_rel', 'stop_motion']
15
+ MANDATORY_VIEWER_METHODS = ['ini_attributes', 'grab_data', 'close', 'commit_settings',
16
+ 'ini_detector', ]
17
+
18
+
19
+ def get_package_name():
20
+ here = Path(__file__).parent
21
+ package_name = here.parent.stem
22
+ return package_name
23
+
24
+
25
+ def get_move_plugins():
26
+ pkg_name = get_package_name()
27
+ move_mod = importlib.import_module(f'{pkg_name}.daq_move_plugins')
28
+
29
+ plugin_list = [mod for mod in [mod[1] for mod in
30
+ pkgutil.iter_modules([str(move_mod.path.parent)])]
31
+ if 'daq_move_' in mod]
32
+ return plugin_list, move_mod
33
+
34
+
35
+ def get_viewer_plugins(dim='0D'):
36
+ pkg_name = get_package_name()
37
+ viewer_mod = importlib.import_module(f'{pkg_name}.daq_viewer_plugins.plugins_{dim}')
38
+
39
+ plugin_list = [mod for mod in [mod[1] for mod in
40
+ pkgutil.iter_modules([str(viewer_mod.path.parent)])]
41
+ if f'daq_{dim}viewer_' in mod]
42
+ return plugin_list, viewer_mod
43
+
44
+
45
+ def test_package_name_ok():
46
+ assert 'pymodaq_plugins_' in get_package_name()[0:16]
47
+
48
+
49
+ def test_imports():
50
+ pkg_name = get_package_name()
51
+ mod = importlib.import_module(pkg_name)
52
+ assert hasattr(mod, 'config')
53
+ assert hasattr(mod, '__version__')
54
+ move_mod = importlib.import_module(f'{pkg_name}', 'daq_move_plugins')
55
+ importlib.import_module(f'{pkg_name}', 'daq_viewer_plugins')
56
+ importlib.import_module(f'{pkg_name}', 'extensions')
57
+ importlib.import_module(f'{pkg_name}', 'models')
58
+ importlib.import_module(f'{pkg_name}.daq_viewer_plugins', 'plugins_0D')
59
+ importlib.import_module(f'{pkg_name}.daq_viewer_plugins', 'plugins_1D')
60
+ importlib.import_module(f'{pkg_name}.daq_viewer_plugins', 'plugins_2D')
61
+ importlib.import_module(f'{pkg_name}.daq_viewer_plugins', 'plugins_ND')
62
+
63
+
64
+ def test_move_inst_plugins_name():
65
+ plugin_list, move_mod = get_move_plugins()
66
+ for plug in plugin_list:
67
+ name = plug.split('daq_move_')[1]
68
+ assert hasattr(getattr(move_mod, plug), f'DAQ_Move_{name}')
69
+
70
+
71
+ def test_move_has_mandatory_methods():
72
+ plugin_list, move_mod = get_move_plugins()
73
+ for plug in plugin_list:
74
+ name = plug.split('daq_move_')[1]
75
+ klass = getattr(getattr(move_mod, plug), f'DAQ_Move_{name}')
76
+ for meth in MANDATORY_MOVE_METHODS:
77
+ assert hasattr(klass, meth)
78
+
79
+
80
+ @pytest.mark.parametrize('dim', ('0D', '1D', '2D', 'ND'))
81
+ def test_viewer_has_mandatory_methods(dim):
82
+ plugin_list, mod = get_viewer_plugins(dim)
83
+ for plug in plugin_list:
84
+ name = plug.split(f'daq_{dim}viewer_')[1]
85
+ try:
86
+ module = importlib.import_module(f'.{plug}', mod.__package__)
87
+ except Exception:
88
+ break
89
+ klass = getattr(module, f'DAQ_{dim}Viewer_{name}')
90
+ for meth in MANDATORY_VIEWER_METHODS:
91
+ assert hasattr(klass, meth)
@@ -0,0 +1,3 @@
1
+ [flake8]
2
+ exclude = .git,__pycache__,build,dist,pymodaq/QtDesigner_Ressources
3
+ ignore = E501, F401, F841, F811, F403