pymodaq_plugins_utils 5.0.2__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.
- pymodaq_plugins_utils-5.0.2/.gitattributes +2 -0
- pymodaq_plugins_utils-5.0.2/.github/workflows/Test.yml +10 -0
- pymodaq_plugins_utils-5.0.2/.github/workflows/Testbase.yml +44 -0
- pymodaq_plugins_utils-5.0.2/.github/workflows/compatibility.yml +78 -0
- pymodaq_plugins_utils-5.0.2/.github/workflows/python-publish.yml +40 -0
- pymodaq_plugins_utils-5.0.2/.github/workflows/updater.yml +24 -0
- pymodaq_plugins_utils-5.0.2/.gitignore +116 -0
- pymodaq_plugins_utils-5.0.2/LICENSE +21 -0
- pymodaq_plugins_utils-5.0.2/PKG-INFO +97 -0
- pymodaq_plugins_utils-5.0.2/README.rst +47 -0
- pymodaq_plugins_utils-5.0.2/hatch_build.py +10 -0
- pymodaq_plugins_utils-5.0.2/icon.ico +0 -0
- pymodaq_plugins_utils-5.0.2/pyproject.toml +71 -0
- pymodaq_plugins_utils-5.0.2/src/pymodaq_plugins_utils/__init__.py +13 -0
- pymodaq_plugins_utils-5.0.2/src/pymodaq_plugins_utils/app/__init__.py +0 -0
- pymodaq_plugins_utils-5.0.2/src/pymodaq_plugins_utils/exporters/__init__.py +6 -0
- pymodaq_plugins_utils-5.0.2/src/pymodaq_plugins_utils/extensions/__init__.py +6 -0
- pymodaq_plugins_utils-5.0.2/src/pymodaq_plugins_utils/extensions/custom_extension_template.py +140 -0
- pymodaq_plugins_utils-5.0.2/src/pymodaq_plugins_utils/hardware/__init__.py +0 -0
- pymodaq_plugins_utils-5.0.2/src/pymodaq_plugins_utils/hardware/camera_base_pylablib.py +398 -0
- pymodaq_plugins_utils-5.0.2/src/pymodaq_plugins_utils/models/__init__.py +6 -0
- pymodaq_plugins_utils-5.0.2/src/pymodaq_plugins_utils/resources/__init__.py +0 -0
- pymodaq_plugins_utils-5.0.2/src/pymodaq_plugins_utils/resources/config_template.toml +2 -0
- pymodaq_plugins_utils-5.0.2/src/pymodaq_plugins_utils/scanners/__init__.py +6 -0
- pymodaq_plugins_utils-5.0.2/src/pymodaq_plugins_utils/utils.py +15 -0
- pymodaq_plugins_utils-5.0.2/tests/test_plugin_package_structure.py +134 -0
|
@@ -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.13'
|
|
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,116 @@
|
|
|
1
|
+
# Compiled python modules.
|
|
2
|
+
*.pyc
|
|
3
|
+
|
|
4
|
+
# Byte-compiled / optimized / DLL files
|
|
5
|
+
__pycache__/
|
|
6
|
+
_version.py
|
|
7
|
+
|
|
8
|
+
*.py[cod]
|
|
9
|
+
*$py.class
|
|
10
|
+
|
|
11
|
+
# C extensions
|
|
12
|
+
*.so
|
|
13
|
+
|
|
14
|
+
# Distribution / packaging
|
|
15
|
+
.Python
|
|
16
|
+
build/
|
|
17
|
+
develop-eggs/
|
|
18
|
+
dist/
|
|
19
|
+
downloads/
|
|
20
|
+
eggs/
|
|
21
|
+
.eggs/
|
|
22
|
+
lib/
|
|
23
|
+
lib64/
|
|
24
|
+
parts/
|
|
25
|
+
sdist/
|
|
26
|
+
var/
|
|
27
|
+
wheels/
|
|
28
|
+
*.egg-info/
|
|
29
|
+
.installed.cfg
|
|
30
|
+
*.egg
|
|
31
|
+
MANIFEST
|
|
32
|
+
|
|
33
|
+
# PyInstaller
|
|
34
|
+
# Usually these files are written by a python script from a template
|
|
35
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
36
|
+
*.manifest
|
|
37
|
+
*.spec
|
|
38
|
+
|
|
39
|
+
# Installer logs
|
|
40
|
+
pip-log.txt
|
|
41
|
+
pip-delete-this-directory.txt
|
|
42
|
+
|
|
43
|
+
# Unit test / coverage reports
|
|
44
|
+
htmlcov/
|
|
45
|
+
.tox/
|
|
46
|
+
.coverage
|
|
47
|
+
.coverage.*
|
|
48
|
+
.cache
|
|
49
|
+
nosetests.xml
|
|
50
|
+
coverage.xml
|
|
51
|
+
*.cover
|
|
52
|
+
.hypothesis/
|
|
53
|
+
.pytest_cache/
|
|
54
|
+
|
|
55
|
+
# Translations
|
|
56
|
+
*.mo
|
|
57
|
+
*.pot
|
|
58
|
+
|
|
59
|
+
# Django stuff:
|
|
60
|
+
*.log
|
|
61
|
+
local_settings.py
|
|
62
|
+
db.sqlite3
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
target/
|
|
76
|
+
|
|
77
|
+
# Jupyter Notebook
|
|
78
|
+
.ipynb_checkpoints
|
|
79
|
+
|
|
80
|
+
# pyenv
|
|
81
|
+
.python-version
|
|
82
|
+
|
|
83
|
+
# celery beat schedule file
|
|
84
|
+
celerybeat-schedule
|
|
85
|
+
|
|
86
|
+
# SageMath parsed files
|
|
87
|
+
*.sage.py
|
|
88
|
+
|
|
89
|
+
# Environments
|
|
90
|
+
.env
|
|
91
|
+
.venv
|
|
92
|
+
env/
|
|
93
|
+
venv/
|
|
94
|
+
ENV/
|
|
95
|
+
env.bak/
|
|
96
|
+
venv.bak/
|
|
97
|
+
|
|
98
|
+
# Spyder project settings
|
|
99
|
+
.spyderproject
|
|
100
|
+
.spyproject
|
|
101
|
+
|
|
102
|
+
# Rope project settings
|
|
103
|
+
.ropeproject
|
|
104
|
+
|
|
105
|
+
# mkdocs documentation
|
|
106
|
+
/site
|
|
107
|
+
|
|
108
|
+
# mypy
|
|
109
|
+
.mypy_cache/
|
|
110
|
+
|
|
111
|
+
# pycharm
|
|
112
|
+
.idea/
|
|
113
|
+
.idea/*
|
|
114
|
+
|
|
115
|
+
*yacctab.py
|
|
116
|
+
*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,97 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pymodaq_plugins_utils
|
|
3
|
+
Version: 5.0.2
|
|
4
|
+
Summary: Set of utility methods and classes to interact with 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_utils
|
|
8
|
+
Author-email: Weber Sebastien <sebastien.weber@cemes.fr>
|
|
9
|
+
Maintainer-email: Weber Sebastien <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>=5.0.0
|
|
47
|
+
Provides-Extra: serial
|
|
48
|
+
Requires-Dist: pyvisa; extra == 'serial'
|
|
49
|
+
Description-Content-Type: text/x-rst
|
|
50
|
+
|
|
51
|
+
pymodaq_plugins_utils
|
|
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_utils.svg
|
|
57
|
+
:target: https://pypi.org/project/pymodaq_plugins_utils/
|
|
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_utils/workflows/Upload%20Python%20Package/badge.svg
|
|
65
|
+
:target: https://github.com/PyMoDAQ/pymodaq_plugins_utils
|
|
66
|
+
:alt: Publication Status
|
|
67
|
+
|
|
68
|
+
.. image:: https://github.com/PyMoDAQ/pymodaq_plugins_utils/actions/workflows/Test.yml/badge.svg
|
|
69
|
+
:target: https://github.com/PyMoDAQ/pymodaq_plugins_utils/actions/workflows/Test.yml
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
Authors
|
|
74
|
+
=======
|
|
75
|
+
|
|
76
|
+
* Sebastien J. Weber (sebastien.weber@cemes.fr)
|
|
77
|
+
* Other author (myotheremail@xxx.org)
|
|
78
|
+
|
|
79
|
+
.. if needed use this field
|
|
80
|
+
|
|
81
|
+
Contributors
|
|
82
|
+
============
|
|
83
|
+
|
|
84
|
+
* First Contributor
|
|
85
|
+
* Other Contributors
|
|
86
|
+
|
|
87
|
+
.. if needed use this field
|
|
88
|
+
|
|
89
|
+
Depending on the plugin type, delete/complete the fields below
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
Utilities
|
|
93
|
+
=========
|
|
94
|
+
|
|
95
|
+
* pysvisa stuff
|
|
96
|
+
* CameraBasePyLabLib: Base plugin class inheriting from DAQ_Viewer_base but implementing ROI management, binning,
|
|
97
|
+
the use of buffers through the pylablib package implementation. Mostly for (S)CMOS camera
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
pymodaq_plugins_utils
|
|
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_utils.svg
|
|
7
|
+
:target: https://pypi.org/project/pymodaq_plugins_utils/
|
|
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_utils/workflows/Upload%20Python%20Package/badge.svg
|
|
15
|
+
:target: https://github.com/PyMoDAQ/pymodaq_plugins_utils
|
|
16
|
+
:alt: Publication Status
|
|
17
|
+
|
|
18
|
+
.. image:: https://github.com/PyMoDAQ/pymodaq_plugins_utils/actions/workflows/Test.yml/badge.svg
|
|
19
|
+
:target: https://github.com/PyMoDAQ/pymodaq_plugins_utils/actions/workflows/Test.yml
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
Authors
|
|
24
|
+
=======
|
|
25
|
+
|
|
26
|
+
* Sebastien J. Weber (sebastien.weber@cemes.fr)
|
|
27
|
+
* Other author (myotheremail@xxx.org)
|
|
28
|
+
|
|
29
|
+
.. if needed use this field
|
|
30
|
+
|
|
31
|
+
Contributors
|
|
32
|
+
============
|
|
33
|
+
|
|
34
|
+
* First Contributor
|
|
35
|
+
* Other Contributors
|
|
36
|
+
|
|
37
|
+
.. if needed use this field
|
|
38
|
+
|
|
39
|
+
Depending on the plugin type, delete/complete the fields below
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
Utilities
|
|
43
|
+
=========
|
|
44
|
+
|
|
45
|
+
* pysvisa stuff
|
|
46
|
+
* CameraBasePyLabLib: Base plugin class inheriting from DAQ_Viewer_base but implementing ROI management, binning,
|
|
47
|
+
the use of buffers through the pylablib package implementation. Mostly for (S)CMOS camera
|
|
@@ -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,71 @@
|
|
|
1
|
+
[features] # defines the plugin features contained into this plugin
|
|
2
|
+
instruments = false # 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_utils'
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
[project]
|
|
14
|
+
name = "pymodaq_plugins_utils"
|
|
15
|
+
description = 'Set of utility methods and classes to interact with instruments'
|
|
16
|
+
dependencies = [
|
|
17
|
+
"pymodaq>=5.0.0",
|
|
18
|
+
#todo: list here all dependencies your package may have
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
authors = [
|
|
22
|
+
{name = "Weber Sebastien", email = "sebastien.weber@cemes.fr"},
|
|
23
|
+
#todo: list here all authors of your plugin
|
|
24
|
+
]
|
|
25
|
+
maintainers = [
|
|
26
|
+
{name = "Weber Sebastien", email = "sebastien.weber@cemes.fr"},
|
|
27
|
+
#todo: list here all maintainers of your plugin
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
# nottodo: leave everything below as is!
|
|
31
|
+
|
|
32
|
+
dynamic = ["version", "urls", "entry-points"]
|
|
33
|
+
readme = "README.rst"
|
|
34
|
+
license = { file="LICENSE" }
|
|
35
|
+
requires-python = ">=3.8"
|
|
36
|
+
|
|
37
|
+
classifiers = [
|
|
38
|
+
"Development Status :: 5 - Production/Stable",
|
|
39
|
+
"Intended Audience :: Science/Research",
|
|
40
|
+
"License :: OSI Approved :: MIT License",
|
|
41
|
+
"Natural Language :: English",
|
|
42
|
+
"Operating System :: OS Independent",
|
|
43
|
+
"Programming Language :: Python :: 3.8",
|
|
44
|
+
"Programming Language :: Python :: 3.9",
|
|
45
|
+
"Programming Language :: Python :: 3.10",
|
|
46
|
+
"Programming Language :: Python :: 3.11",
|
|
47
|
+
"Topic :: Scientific/Engineering :: Human Machine Interfaces",
|
|
48
|
+
"Topic :: Scientific/Engineering :: Visualization",
|
|
49
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
50
|
+
"Topic :: Software Development :: User Interfaces",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[project.optional-dependencies]
|
|
54
|
+
serial = [
|
|
55
|
+
"pyvisa",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
[build-system]
|
|
60
|
+
requires = [
|
|
61
|
+
"hatchling>=1.9.0",
|
|
62
|
+
"hatch-vcs", "toml",
|
|
63
|
+
"pymodaq_utils>=0.0.6",
|
|
64
|
+
]
|
|
65
|
+
build-backend = "hatchling.build"
|
|
66
|
+
|
|
67
|
+
[tool.hatch.metadata.hooks.custom]
|
|
68
|
+
|
|
69
|
+
[tool.hatch.version]
|
|
70
|
+
source = "vcs"
|
|
71
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
|
|
12
|
+
|
|
13
|
+
|
|
File without changes
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
from qtpy import QtWidgets
|
|
2
|
+
|
|
3
|
+
from pymodaq_gui import utils as gutils
|
|
4
|
+
from pymodaq_utils.config import Config, ConfigError
|
|
5
|
+
from pymodaq_utils.logger import set_logger, get_module_name
|
|
6
|
+
|
|
7
|
+
from pymodaq.utils.config import get_set_preset_path
|
|
8
|
+
from pymodaq.extensions.utils import CustomExt
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# todo: replace here *pymodaq_plugins_utils* by your plugin package name
|
|
12
|
+
from pymodaq_plugins_template.utils import Config as PluginConfig
|
|
13
|
+
|
|
14
|
+
logger = set_logger(get_module_name(__file__))
|
|
15
|
+
|
|
16
|
+
main_config = Config()
|
|
17
|
+
plugin_config = PluginConfig()
|
|
18
|
+
|
|
19
|
+
# todo: modify this as you wish
|
|
20
|
+
EXTENSION_NAME = 'MY_EXTENSION_NAME' # the name that will be displayed in the extension list in the
|
|
21
|
+
# dashboard
|
|
22
|
+
CLASS_NAME = 'CustomExtensionTemplate' # this should be the name of your class defined below
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# todo: modify the name of this class to reflect its application and change the name in the main
|
|
26
|
+
# method at the end of the script
|
|
27
|
+
class CustomExtensionTemplate(CustomExt):
|
|
28
|
+
|
|
29
|
+
# todo: if you wish to create custom Parameter and corresponding widgets. These will be
|
|
30
|
+
# automatically added as children of self.settings. Morevover, the self.settings_tree will
|
|
31
|
+
# render the widgets in a Qtree. If you wish to see it in your app, add is into a Dock
|
|
32
|
+
params = []
|
|
33
|
+
|
|
34
|
+
def __init__(self, parent: gutils.DockArea, dashboard):
|
|
35
|
+
super().__init__(parent, dashboard)
|
|
36
|
+
|
|
37
|
+
# info: in an extension, if you want to interact with ControlModules you have to use the
|
|
38
|
+
# object: self.modules_manager which is a ModulesManager instance from the dashboard
|
|
39
|
+
|
|
40
|
+
self.setup_ui()
|
|
41
|
+
|
|
42
|
+
def setup_docks(self):
|
|
43
|
+
"""Mandatory method to be subclassed to setup the docks layout
|
|
44
|
+
|
|
45
|
+
Examples
|
|
46
|
+
--------
|
|
47
|
+
>>>self.docks['ADock'] = gutils.Dock('ADock name')
|
|
48
|
+
>>>self.dockarea.addDock(self.docks['ADock'])
|
|
49
|
+
>>>self.docks['AnotherDock'] = gutils.Dock('AnotherDock name')
|
|
50
|
+
>>>self.dockarea.addDock(self.docks['AnotherDock'''], 'bottom', self.docks['ADock'])
|
|
51
|
+
|
|
52
|
+
See Also
|
|
53
|
+
--------
|
|
54
|
+
pyqtgraph.dockarea.Dock
|
|
55
|
+
"""
|
|
56
|
+
# todo: create docks and add them here to hold your widgets
|
|
57
|
+
# reminder, the attribute self.settings_tree will render the widgets in a Qtree.
|
|
58
|
+
# If you wish to see it in your app, add is into a Dock
|
|
59
|
+
raise NotImplementedError
|
|
60
|
+
|
|
61
|
+
def setup_actions(self):
|
|
62
|
+
"""Method where to create actions to be subclassed. Mandatory
|
|
63
|
+
|
|
64
|
+
Examples
|
|
65
|
+
--------
|
|
66
|
+
>>> self.add_action('quit', 'Quit', 'close2', "Quit program")
|
|
67
|
+
>>> self.add_action('grab', 'Grab', 'camera', "Grab from camera", checkable=True)
|
|
68
|
+
>>> self.add_action('load', 'Load', 'Open', "Load target file (.h5, .png, .jpg) or data from camera"
|
|
69
|
+
, checkable=False)
|
|
70
|
+
>>> self.add_action('save', 'Save', 'SaveAs', "Save current data", checkable=False)
|
|
71
|
+
|
|
72
|
+
See Also
|
|
73
|
+
--------
|
|
74
|
+
ActionManager.add_action
|
|
75
|
+
"""
|
|
76
|
+
raise NotImplementedError(f'You have to define actions here')
|
|
77
|
+
|
|
78
|
+
def connect_things(self):
|
|
79
|
+
"""Connect actions and/or other widgets signal to methods"""
|
|
80
|
+
raise NotImplementedError
|
|
81
|
+
|
|
82
|
+
def setup_menu(self, menubar: QtWidgets.QMenuBar = None):
|
|
83
|
+
"""Non mandatory method to be subclassed in order to create a menubar
|
|
84
|
+
|
|
85
|
+
create menu for actions contained into the self._actions, for instance:
|
|
86
|
+
|
|
87
|
+
Examples
|
|
88
|
+
--------
|
|
89
|
+
>>>file_menu = menubar.addMenu('File')
|
|
90
|
+
>>>self.affect_to('load', file_menu)
|
|
91
|
+
>>>self.affect_to('save', file_menu)
|
|
92
|
+
|
|
93
|
+
>>>file_menu.addSeparator()
|
|
94
|
+
>>>self.affect_to('quit', file_menu)
|
|
95
|
+
|
|
96
|
+
See Also
|
|
97
|
+
--------
|
|
98
|
+
pymodaq.utils.managers.action_manager.ActionManager
|
|
99
|
+
"""
|
|
100
|
+
# todo create and populate menu using actions defined above in self.setup_actions
|
|
101
|
+
pass
|
|
102
|
+
|
|
103
|
+
def value_changed(self, param):
|
|
104
|
+
""" Actions to perform when one of the param's value in self.settings is changed from the
|
|
105
|
+
user interface
|
|
106
|
+
|
|
107
|
+
For instance:
|
|
108
|
+
if param.name() == 'do_something':
|
|
109
|
+
if param.value():
|
|
110
|
+
print('Do something')
|
|
111
|
+
self.settings.child('main_settings', 'something_done').setValue(False)
|
|
112
|
+
|
|
113
|
+
Parameters
|
|
114
|
+
----------
|
|
115
|
+
param: (Parameter) the parameter whose value just changed
|
|
116
|
+
"""
|
|
117
|
+
pass
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def main():
|
|
121
|
+
from pymodaq.utils.gui_utils.utils import mkQApp
|
|
122
|
+
from pymodaq.utils.gui_utils.loader_utils import load_dashboard_with_preset
|
|
123
|
+
from pymodaq.utils.messenger import messagebox
|
|
124
|
+
|
|
125
|
+
app = mkQApp(EXTENSION_NAME)
|
|
126
|
+
try:
|
|
127
|
+
preset_file_name = plugin_config('presets', f'preset_for_{CLASS_NAME.lower()}')
|
|
128
|
+
load_dashboard_with_preset(preset_file_name, EXTENSION_NAME)
|
|
129
|
+
app.exec()
|
|
130
|
+
|
|
131
|
+
except ConfigError as e:
|
|
132
|
+
messagebox(f'No entry with name f"preset_for_{CLASS_NAME.lower()}" has been configured'
|
|
133
|
+
f'in the plugin config file. The toml entry should be:\n'
|
|
134
|
+
f'[presets]'
|
|
135
|
+
f"preset_for_{CLASS_NAME.lower()} = {'a name for an existing preset'}"
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
if __name__ == '__main__':
|
|
140
|
+
main()
|
|
File without changes
|
|
@@ -0,0 +1,398 @@
|
|
|
1
|
+
import cv2
|
|
2
|
+
from pymodaq_utils.logger import set_logger, get_module_name
|
|
3
|
+
from pymodaq_utils.utils import ThreadCommand
|
|
4
|
+
from pymodaq_gui.parameter import Parameter
|
|
5
|
+
try:
|
|
6
|
+
from pymodaq_gui.plotting.items.roi import RoiInfo # pymodaq > 5.1.x
|
|
7
|
+
except ImportError:
|
|
8
|
+
from pymodaq_gui.plotting.utils.plot_utils import RoiInfo
|
|
9
|
+
|
|
10
|
+
from pymodaq.utils.data import DataFromPlugins, Axis
|
|
11
|
+
from pymodaq.control_modules.viewer_utility_classes import DAQ_Viewer_base, comon_parameters, main
|
|
12
|
+
|
|
13
|
+
from qtpy import QtWidgets, QtCore
|
|
14
|
+
import numpy as np
|
|
15
|
+
from time import perf_counter
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
cam_params = [
|
|
19
|
+
{'title': 'Camera name:', 'name': 'camera_name', 'type': 'str', 'value': '', 'readonly': True},
|
|
20
|
+
{'title': 'Sensor type:', 'name': 'sensor', 'type': 'list', 'limits': ['Monochrome', 'Bayer']},
|
|
21
|
+
{'title': 'Ouput Color:', 'name': 'output_color', 'type': 'list', 'limits': ['RGB', 'MonoChrome']},
|
|
22
|
+
{'title': 'ROI', 'name': 'roi', 'type': 'group', 'children': [
|
|
23
|
+
{'title': 'Update ROI from Viewer', 'name': 'update_roi', 'type': 'led', 'value': False},
|
|
24
|
+
{'title': 'Apply ROI', 'name': 'apply_roi', 'type': 'led', 'value': False},
|
|
25
|
+
{'title': 'Clear ROI+Bin', 'name': 'clear_roi', 'type': 'bool_push', 'value': False},
|
|
26
|
+
{'title': 'ROI:', 'name': 'roi_slices', 'type': 'str', 'value': ''},
|
|
27
|
+
{'title': 'X binning', 'name': 'x_binning', 'type': 'int', 'value': 1},
|
|
28
|
+
{'title': 'Y binning', 'name': 'y_binning', 'type': 'int', 'value': 1},
|
|
29
|
+
], },
|
|
30
|
+
{'title': 'Image width', 'name': 'hdet', 'type': 'int', 'value': 1, 'readonly': True},
|
|
31
|
+
{'title': 'Image height', 'name': 'vdet', 'type': 'int', 'value': 1, 'readonly': True},
|
|
32
|
+
{'title': 'Timing', 'name': 'timing_opts', 'type': 'group', 'children':
|
|
33
|
+
[{'title': 'Exposure Time (ms)', 'name': 'exposure_time', 'type': 'int', 'value': 1},
|
|
34
|
+
{'title': 'Compute FPS', 'name': 'fps_on', 'type': 'bool', 'value': True},
|
|
35
|
+
{'title': 'FPS', 'name': 'fps', 'type': 'float', 'value': 0.0, 'readonly': True}]
|
|
36
|
+
},
|
|
37
|
+
{'title': 'Buffer', 'name': 'buffer', 'type': 'group', 'children': [
|
|
38
|
+
{'title': 'Size:', 'name': 'size', 'type': 'int', 'value': 10},
|
|
39
|
+
{'title': 'mode:', 'name': 'mode', 'type': 'list', 'value': 'now',
|
|
40
|
+
'limits': ['now', 'lastread', 'lastwait', 'start']},
|
|
41
|
+
]},
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class CameraBasePyLabLib(DAQ_Viewer_base):
|
|
46
|
+
"""
|
|
47
|
+
Base implementation for Camera using pylablib framework. Works for TSI and uc480 thorlabs camera and rpobaly others
|
|
48
|
+
"""
|
|
49
|
+
serial_numbers = []
|
|
50
|
+
|
|
51
|
+
serial_params = [{'title': 'Serial number:', 'name': 'serial_number', 'type': 'list', 'limits': serial_numbers}]
|
|
52
|
+
|
|
53
|
+
params = comon_parameters + serial_params + cam_params
|
|
54
|
+
|
|
55
|
+
callback_signal = QtCore.Signal(bool)
|
|
56
|
+
live_mode_available = True
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def ini_attributes(self):
|
|
60
|
+
self.controller = None
|
|
61
|
+
self.callback_thread: QtCore.QThread = None
|
|
62
|
+
|
|
63
|
+
self.x_axis: Axis = None
|
|
64
|
+
self.y_axis: Axis = None
|
|
65
|
+
|
|
66
|
+
self.roi_select_info: RoiInfo = None
|
|
67
|
+
|
|
68
|
+
self.last_tick = 0.0 # time counter used to compute FPS
|
|
69
|
+
self.fps = 0.0
|
|
70
|
+
|
|
71
|
+
self.data_shape: str = ''
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def roi_select(self, roi_info: RoiInfo, ind_viewer: int = 0):
|
|
75
|
+
""" Automatically called when a user use the RoiSelect ROi from a 2D viewer"""
|
|
76
|
+
self.roi_select_info = roi_info
|
|
77
|
+
self.roi_select_viewer_index = ind_viewer
|
|
78
|
+
|
|
79
|
+
if self.settings['roi', 'update_roi']:
|
|
80
|
+
self.settings['roi', 'roi_slices'] = str(roi_info.to_slices())
|
|
81
|
+
if self.settings['roi', 'apply_roi']:
|
|
82
|
+
self.apply_roi()
|
|
83
|
+
|
|
84
|
+
def apply_roi(self):
|
|
85
|
+
roi_info = RoiInfo.from_slices(eval(self.settings['roi', 'roi_slices']))
|
|
86
|
+
new_roi = (roi_info.origin[1], roi_info.size[1], self.settings['roi', 'x_binning'],
|
|
87
|
+
roi_info.origin[0], roi_info.size[0], self.settings['roi', 'y_binning'])
|
|
88
|
+
self.update_rois(new_roi)
|
|
89
|
+
|
|
90
|
+
def compute_axes(self):
|
|
91
|
+
(hstart, hend, vstart, vend, hbin, vbin) = self.controller.get_roi()
|
|
92
|
+
slices = [slice(vstart, vend, vbin), slice(hstart, hend, hbin)]
|
|
93
|
+
self.settings.child('roi', 'roi_slices').setValue(str(slices))
|
|
94
|
+
roi_info = RoiInfo.from_slices(slices)
|
|
95
|
+
|
|
96
|
+
self.x_axis = Axis('x_axis', offset=roi_info.origin[1],
|
|
97
|
+
scaling=self.settings['roi', 'x_binning'],
|
|
98
|
+
size=int(roi_info.size[1]),
|
|
99
|
+
index=1)
|
|
100
|
+
self.y_axis = Axis('y_axis', offset=roi_info.origin[0],
|
|
101
|
+
scaling=self.settings['roi', 'y_binning'],
|
|
102
|
+
size=int(roi_info.size[0]),
|
|
103
|
+
index=0)
|
|
104
|
+
|
|
105
|
+
def clear_roi(self):
|
|
106
|
+
wdet, hdet = self.controller.get_detector_size()
|
|
107
|
+
self.settings.child('roi', 'x_binning').setValue(1)
|
|
108
|
+
self.settings.child('roi', 'y_binning').setValue(1)
|
|
109
|
+
|
|
110
|
+
new_roi = (0, wdet, 1, 0, hdet, 1)
|
|
111
|
+
self.update_rois(new_roi)
|
|
112
|
+
|
|
113
|
+
def update_rois(self, new_roi):
|
|
114
|
+
# In pylablib, ROIs compare as tuples
|
|
115
|
+
(new_x, new_width, new_xbinning, new_y, new_height, new_ybinning) = new_roi
|
|
116
|
+
if new_roi != self.controller.get_roi():
|
|
117
|
+
# self.controller.set_attribute_value("ROIs",[new_roi])
|
|
118
|
+
self.controller.set_roi(hstart=new_x, hend=new_x + new_width, vstart=new_y, vend=new_y + new_height,
|
|
119
|
+
hbin=new_xbinning, vbin=new_ybinning)
|
|
120
|
+
self.emit_status(ThreadCommand('Update_Status', [f'Changed ROI: {new_roi}']))
|
|
121
|
+
self.controller.clear_acquisition()
|
|
122
|
+
self.controller.setup_acquisition()
|
|
123
|
+
# Finally, prepare view for displaying the new data
|
|
124
|
+
self._prepare_view()
|
|
125
|
+
self.compute_axes()
|
|
126
|
+
|
|
127
|
+
def commit_settings(self, param: Parameter):
|
|
128
|
+
"""Apply the consequences of a change of value in the detector settings
|
|
129
|
+
|
|
130
|
+
Parameters
|
|
131
|
+
----------
|
|
132
|
+
param: Parameter
|
|
133
|
+
A given parameter (within detector_settings) whose value has been changed by the user
|
|
134
|
+
"""
|
|
135
|
+
if param.name() == "exposure_time":
|
|
136
|
+
self.controller.set_exposure(param.value()/1000)
|
|
137
|
+
|
|
138
|
+
if param.name() == "fps_on":
|
|
139
|
+
self.settings.child('timing_opts', 'fps').setOpts(visible=param.value())
|
|
140
|
+
|
|
141
|
+
if param.name() == "apply_roi":
|
|
142
|
+
if param.value(): # Switching on ROI
|
|
143
|
+
self.apply_roi()
|
|
144
|
+
else:
|
|
145
|
+
self.clear_roi()
|
|
146
|
+
|
|
147
|
+
if param.name() in ['x_binning', 'y_binning']:
|
|
148
|
+
# We handle ROI and binning separately for clarity
|
|
149
|
+
(x0, w, y0, h, *_) = self.controller.get_roi() # Get current ROI
|
|
150
|
+
xbin = self.settings['roi', 'x_binning']
|
|
151
|
+
ybin = self.settings['roi', 'y_binning']
|
|
152
|
+
new_roi = (x0, w, xbin, y0, h, ybin)
|
|
153
|
+
self.update_rois(new_roi)
|
|
154
|
+
|
|
155
|
+
if param.name() == "clear_roi":
|
|
156
|
+
if param.value(): # Switching on ROI
|
|
157
|
+
self.clear_roi()
|
|
158
|
+
param.setValue(False)
|
|
159
|
+
|
|
160
|
+
def ini_detector_custom(self, controller=None):
|
|
161
|
+
raise NotImplementedError
|
|
162
|
+
|
|
163
|
+
def ini_detector(self, controller=None):
|
|
164
|
+
"""Detector communication initialization
|
|
165
|
+
|
|
166
|
+
Parameters
|
|
167
|
+
----------
|
|
168
|
+
controller: (object)
|
|
169
|
+
custom object of a PyMoDAQ plugin (Slave case). None if only one actuator/detector by controller
|
|
170
|
+
(Master case)
|
|
171
|
+
|
|
172
|
+
Returns
|
|
173
|
+
-------
|
|
174
|
+
info: str
|
|
175
|
+
initialized: bool
|
|
176
|
+
False if initialization failed otherwise True
|
|
177
|
+
"""
|
|
178
|
+
self.ini_detector_custom(controller)
|
|
179
|
+
|
|
180
|
+
self.get_device_info()
|
|
181
|
+
self.get_set_color()
|
|
182
|
+
self.get_set_main_parameters()
|
|
183
|
+
self.setup_callback_thread()
|
|
184
|
+
|
|
185
|
+
info = "Initialized camera"
|
|
186
|
+
initialized = True
|
|
187
|
+
return info, initialized
|
|
188
|
+
|
|
189
|
+
def get_device_info(self):
|
|
190
|
+
|
|
191
|
+
device_info = self.controller.get_device_info()
|
|
192
|
+
|
|
193
|
+
# Get camera name/model
|
|
194
|
+
if hasattr(device_info, 'name'):
|
|
195
|
+
self.settings.child('camera_name').setValue(device_info.name)
|
|
196
|
+
elif hasattr(device_info, 'model'):
|
|
197
|
+
self.settings.child('camera_name').setValue(device_info.model)
|
|
198
|
+
|
|
199
|
+
def get_set_color(self):
|
|
200
|
+
if 'monochrome' in self.settings['sensor'].lower():
|
|
201
|
+
self.settings.child('output_color').setValue('MonoChrome')
|
|
202
|
+
self.settings.child('output_color').setOpts(visible=False)
|
|
203
|
+
|
|
204
|
+
def get_set_main_parameters(self):
|
|
205
|
+
# Set exposure time
|
|
206
|
+
self.controller.set_exposure(self.settings['timing_opts', 'exposure_time']/1000)
|
|
207
|
+
|
|
208
|
+
# FPS visibility
|
|
209
|
+
self.settings.child('timing_opts', 'fps').setOpts(visible=self.settings['timing_opts', 'fps_on'])
|
|
210
|
+
|
|
211
|
+
# get roi limits
|
|
212
|
+
self.controller.get_roi_limits()
|
|
213
|
+
|
|
214
|
+
# Update image parameters
|
|
215
|
+
(hstart, hend, vstart, vend, hbin, vbin) = self.controller.get_roi()
|
|
216
|
+
height, width = self.controller.get_data_dimensions()
|
|
217
|
+
self.settings.child('roi', 'x_binning').setValue(hbin)
|
|
218
|
+
self.settings.child('roi', 'y_binning').setValue(vbin)
|
|
219
|
+
self.settings.child('hdet').setValue(width)
|
|
220
|
+
self.settings.child('vdet').setValue(height)
|
|
221
|
+
slices = [slice(vstart, vend, vbin), slice(hstart, hend, hbin)]
|
|
222
|
+
self.settings.child('roi', 'roi_slices').setValue(str(slices))
|
|
223
|
+
self.compute_axes()
|
|
224
|
+
|
|
225
|
+
def setup_callback_thread(self):
|
|
226
|
+
# Way to define a wait function with arguments
|
|
227
|
+
wait_func = lambda: self.controller.wait_for_frame(since=self.settings['buffer', 'mode'],
|
|
228
|
+
nframes=1, timeout=20.0)
|
|
229
|
+
callback = CameraCallback(wait_func)
|
|
230
|
+
self.settings.child('buffer', 'mode').setReadonly(True)
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
self.callback_thread = QtCore.QThread() # creation of a Qt5 thread
|
|
234
|
+
callback.moveToThread(self.callback_thread) # callback object will live within this thread
|
|
235
|
+
callback.data_sig.connect(
|
|
236
|
+
self.emit_data) # when the wait for acquisition returns (with data taken), emit_data will be fired
|
|
237
|
+
|
|
238
|
+
self.callback_signal.connect(callback.set_do_grab)
|
|
239
|
+
self.callback_thread.callback = callback
|
|
240
|
+
self.callback_thread.start()
|
|
241
|
+
|
|
242
|
+
self._prepare_view()
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def _prepare_view(self):
|
|
246
|
+
"""Preparing a data viewer by emitting temporary data. Typically, needs to be called whenever the
|
|
247
|
+
ROIs are changed"""
|
|
248
|
+
|
|
249
|
+
height, width = self.controller.get_data_dimensions()
|
|
250
|
+
|
|
251
|
+
self.settings.child('hdet').setValue(width)
|
|
252
|
+
self.settings.child('vdet').setValue(height)
|
|
253
|
+
mock_data = np.zeros((height, width))
|
|
254
|
+
|
|
255
|
+
if width != 1 and height != 1:
|
|
256
|
+
data_shape = 'Data2D'
|
|
257
|
+
else:
|
|
258
|
+
data_shape = 'Data1D'
|
|
259
|
+
|
|
260
|
+
if data_shape != self.data_shape:
|
|
261
|
+
self.data_shape = data_shape
|
|
262
|
+
# init the viewers
|
|
263
|
+
self.data_grabed_signal_temp.emit([DataFromPlugins(name='Thorlabs Camera',
|
|
264
|
+
data=[np.squeeze(mock_data)],
|
|
265
|
+
dim=self.data_shape,
|
|
266
|
+
labels=[f'ThorCam_{self.data_shape}'])])
|
|
267
|
+
QtWidgets.QApplication.processEvents()
|
|
268
|
+
|
|
269
|
+
def grab_data(self, Naverage=1, **kwargs):
|
|
270
|
+
"""
|
|
271
|
+
Grabs the data. ASynchronous method (kinda).
|
|
272
|
+
----------
|
|
273
|
+
Naverage: (int) Number of averaging
|
|
274
|
+
kwargs: (dict) of others optionals arguments
|
|
275
|
+
"""
|
|
276
|
+
try:
|
|
277
|
+
# Warning, acquisition_in_progress returns 1,0 and not a real bool
|
|
278
|
+
if not kwargs.get('live', False):
|
|
279
|
+
self.emit_data(self.controller.snap())
|
|
280
|
+
else:
|
|
281
|
+
if not self.controller.acquisition_in_progress():
|
|
282
|
+
self.controller.clear_acquisition()
|
|
283
|
+
self.controller.start_acquisition(nframes=self.settings['buffer', 'size'])
|
|
284
|
+
#Then start the acquisition
|
|
285
|
+
self.callback_signal.emit(True) # will trigger the wait for acquisition
|
|
286
|
+
|
|
287
|
+
except Exception as e:
|
|
288
|
+
self.emit_status(ThreadCommand('Update_Status', [str(e), "log"]))
|
|
289
|
+
|
|
290
|
+
def emit_data(self, frame: np.ndarray=None):
|
|
291
|
+
""" Function used to emit data obtained by callback.
|
|
292
|
+
|
|
293
|
+
Parameter
|
|
294
|
+
---------
|
|
295
|
+
status: bool
|
|
296
|
+
If True a frame is available, If False, a Timeout occurred while waiting for the frame
|
|
297
|
+
|
|
298
|
+
See Also
|
|
299
|
+
--------
|
|
300
|
+
daq_utils.ThreadCommand
|
|
301
|
+
"""
|
|
302
|
+
try:
|
|
303
|
+
# Get data from buffer
|
|
304
|
+
if frame is None:
|
|
305
|
+
frame = self.controller.read_newest_image()
|
|
306
|
+
# Emit the frame.
|
|
307
|
+
if frame is not None: # happens for last frame when stopping camera
|
|
308
|
+
if self.settings['output_color'] == 'RGB':
|
|
309
|
+
rgb_image = cv2.cvtColor(frame, cv2.COLOR_BAYER_BG2RGB)
|
|
310
|
+
data_arrays = [np.atleast_1d(rgb_image[..., ind]) for ind in range(3)]
|
|
311
|
+
else:
|
|
312
|
+
if 'monochrome' in self.settings['sensor'].lower():
|
|
313
|
+
data_arrays = [np.atleast_1d(frame)]
|
|
314
|
+
else:
|
|
315
|
+
data_arrays = [np.atleast_1d(cv2.cvtColor(frame, cv2.COLOR_BAYER_BG2GRAY))]
|
|
316
|
+
|
|
317
|
+
self.data_grabed_signal.emit([DataFromPlugins(name='Thorlabs Camera',
|
|
318
|
+
data=data_arrays,
|
|
319
|
+
dim=self.data_shape,
|
|
320
|
+
labels=[f'ThorCam_{self.data_shape}'],
|
|
321
|
+
axes=[self.x_axis, self.y_axis])])
|
|
322
|
+
if self.settings.child('timing_opts', 'fps_on').value():
|
|
323
|
+
self.update_fps()
|
|
324
|
+
|
|
325
|
+
# To make sure that timed events are executed in continuous grab mode
|
|
326
|
+
QtWidgets.QApplication.processEvents()
|
|
327
|
+
|
|
328
|
+
except Exception as e:
|
|
329
|
+
self.emit_status(ThreadCommand('Update_Status', [str(e), 'log']))
|
|
330
|
+
|
|
331
|
+
def update_fps(self):
|
|
332
|
+
current_tick = perf_counter()
|
|
333
|
+
frame_time = current_tick-self.last_tick
|
|
334
|
+
|
|
335
|
+
if self.last_tick != 0.0 and frame_time != 0.0:
|
|
336
|
+
# We don't update FPS for the first frame, and we also avoid divisions by zero
|
|
337
|
+
|
|
338
|
+
if self.fps == 0.0:
|
|
339
|
+
self.fps = 1 / frame_time
|
|
340
|
+
else:
|
|
341
|
+
# If we already have an FPS calculated, we smooth its evolution
|
|
342
|
+
self.fps = 0.9 * self.fps + 0.1 / frame_time
|
|
343
|
+
|
|
344
|
+
self.last_tick = current_tick
|
|
345
|
+
|
|
346
|
+
# Update reading
|
|
347
|
+
self.settings.child('timing_opts', 'fps').setValue(round(self.fps, 1))
|
|
348
|
+
|
|
349
|
+
def close(self):
|
|
350
|
+
"""
|
|
351
|
+
Terminate the communication protocol
|
|
352
|
+
"""
|
|
353
|
+
# Terminate the communication
|
|
354
|
+
|
|
355
|
+
self.stop()
|
|
356
|
+
if self.callback_thread is not None:
|
|
357
|
+
self.callback_thread.quit()
|
|
358
|
+
self.callback_thread.wait()
|
|
359
|
+
|
|
360
|
+
self.controller.close()
|
|
361
|
+
self.settings.child('buffer', 'mode').setReadonly(False)
|
|
362
|
+
|
|
363
|
+
def stop(self):
|
|
364
|
+
"""Stop the acquisition."""
|
|
365
|
+
self.callback_signal.emit(False)
|
|
366
|
+
QtWidgets.QApplication.processEvents()
|
|
367
|
+
|
|
368
|
+
self.controller.clear_acquisition()
|
|
369
|
+
return ''
|
|
370
|
+
|
|
371
|
+
|
|
372
|
+
class CameraCallback(QtCore.QObject):
|
|
373
|
+
"""Callback object """
|
|
374
|
+
data_sig = QtCore.Signal()
|
|
375
|
+
|
|
376
|
+
def __init__(self, wait_fn):
|
|
377
|
+
super().__init__()
|
|
378
|
+
# Set the wait function
|
|
379
|
+
self.wait_fn = wait_fn
|
|
380
|
+
self.do_grab = True
|
|
381
|
+
|
|
382
|
+
def set_do_grab(self, do_grab=True):
|
|
383
|
+
self.do_grab = do_grab
|
|
384
|
+
if do_grab:
|
|
385
|
+
self.wait_for_acquisition()
|
|
386
|
+
|
|
387
|
+
def wait_for_acquisition(self):
|
|
388
|
+
while self.do_grab:
|
|
389
|
+
try:
|
|
390
|
+
new_data = self.wait_fn()
|
|
391
|
+
if new_data is not False: # will be returned if the main thread called CancelWait
|
|
392
|
+
self.data_sig.emit()
|
|
393
|
+
except Exception as e:
|
|
394
|
+
pass
|
|
395
|
+
QtWidgets.QApplication.processEvents()
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
|
|
File without changes
|
|
@@ -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,134 @@
|
|
|
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
|
+
from collections.abc import Iterable
|
|
12
|
+
|
|
13
|
+
from pymodaq_data import Q_, Unit
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
MANDATORY_MOVE_METHODS = ['ini_attributes', 'get_actuator_value', 'close', 'commit_settings',
|
|
17
|
+
'ini_stage', 'move_abs', 'move_home', 'move_rel', 'stop_motion']
|
|
18
|
+
MANDATORY_VIEWER_METHODS = ['ini_attributes', 'grab_data', 'close', 'commit_settings',
|
|
19
|
+
'ini_detector', ]
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def get_package_name():
|
|
23
|
+
here = Path(__file__).parent
|
|
24
|
+
package_name = here.parent.stem
|
|
25
|
+
return package_name
|
|
26
|
+
|
|
27
|
+
def get_move_plugins():
|
|
28
|
+
pkg_name = get_package_name()
|
|
29
|
+
try:
|
|
30
|
+
move_mod = importlib.import_module(f'{pkg_name}.daq_move_plugins')
|
|
31
|
+
plugin_list = [mod for mod in [mod[1] for mod in
|
|
32
|
+
pkgutil.iter_modules([str(move_mod.path.parent)])]
|
|
33
|
+
if 'daq_move_' in mod]
|
|
34
|
+
except ModuleNotFoundError:
|
|
35
|
+
plugin_list = []
|
|
36
|
+
move_mod = None
|
|
37
|
+
return plugin_list, move_mod
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def get_viewer_plugins(dim='0D'):
|
|
41
|
+
pkg_name = get_package_name()
|
|
42
|
+
try:
|
|
43
|
+
viewer_mod = importlib.import_module(f'{pkg_name}.daq_viewer_plugins.plugins_{dim}')
|
|
44
|
+
|
|
45
|
+
plugin_list = [mod for mod in [mod[1] for mod in
|
|
46
|
+
pkgutil.iter_modules([str(viewer_mod.path.parent)])]
|
|
47
|
+
if f'daq_{dim}viewer_' in mod]
|
|
48
|
+
except ModuleNotFoundError:
|
|
49
|
+
plugin_list = []
|
|
50
|
+
viewer_mod = None
|
|
51
|
+
return plugin_list, viewer_mod
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def test_package_name_ok():
|
|
55
|
+
assert 'pymodaq_plugins_' in get_package_name()[0:16]
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def test_imports():
|
|
59
|
+
pkg_name = get_package_name()
|
|
60
|
+
mod = importlib.import_module(pkg_name)
|
|
61
|
+
assert hasattr(mod, 'config')
|
|
62
|
+
assert hasattr(mod, '__version__')
|
|
63
|
+
move_mod = importlib.import_module(f'{pkg_name}', 'daq_move_plugins')
|
|
64
|
+
importlib.import_module(f'{pkg_name}', 'daq_viewer_plugins')
|
|
65
|
+
importlib.import_module(f'{pkg_name}', 'extensions')
|
|
66
|
+
importlib.import_module(f'{pkg_name}', 'models')
|
|
67
|
+
importlib.import_module(f'{pkg_name}.daq_viewer_plugins', 'plugins_0D')
|
|
68
|
+
importlib.import_module(f'{pkg_name}.daq_viewer_plugins', 'plugins_1D')
|
|
69
|
+
importlib.import_module(f'{pkg_name}.daq_viewer_plugins', 'plugins_2D')
|
|
70
|
+
importlib.import_module(f'{pkg_name}.daq_viewer_plugins', 'plugins_ND')
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_move_inst_plugins_name():
|
|
74
|
+
plugin_list, move_mod = get_move_plugins()
|
|
75
|
+
for plug in plugin_list:
|
|
76
|
+
name = plug.split('daq_move_')[1]
|
|
77
|
+
assert hasattr(getattr(move_mod, plug), f'DAQ_Move_{name}')
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def test_move_has_mandatory_methods():
|
|
81
|
+
plugin_list, move_mod = get_move_plugins()
|
|
82
|
+
for plug in plugin_list:
|
|
83
|
+
name = plug.split('daq_move_')[1]
|
|
84
|
+
klass = getattr(getattr(move_mod, plug), f'DAQ_Move_{name}')
|
|
85
|
+
for meth in MANDATORY_MOVE_METHODS:
|
|
86
|
+
assert hasattr(klass, meth)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def test_move_has_correct_units():
|
|
90
|
+
plugin_list, move_mod = get_move_plugins()
|
|
91
|
+
for plug in plugin_list:
|
|
92
|
+
name = plug.split('daq_move_')[1]
|
|
93
|
+
klass = getattr(getattr(move_mod, plug), f'DAQ_Move_{name}')
|
|
94
|
+
if not isinstance(klass._controller_units, list):
|
|
95
|
+
if isinstance(klass._controller_units, dict):
|
|
96
|
+
units = list(klass._controller_units.values())
|
|
97
|
+
elif isinstance(klass._controller_units, str):
|
|
98
|
+
units = [klass._controller_units]
|
|
99
|
+
else:
|
|
100
|
+
raise TypeError(f'{klass._controller_units} is an invalid type')
|
|
101
|
+
else:
|
|
102
|
+
units = klass._controller_units
|
|
103
|
+
for unit in units:
|
|
104
|
+
Unit(unit) # check if the unit is known from pint
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
@pytest.mark.parametrize('dim', ('0D', '1D', '2D', 'ND'))
|
|
108
|
+
def test_viewer_has_mandatory_methods(dim):
|
|
109
|
+
plugin_list, mod = get_viewer_plugins(dim)
|
|
110
|
+
for plug in plugin_list:
|
|
111
|
+
name = plug.split(f'daq_{dim}viewer_')[1]
|
|
112
|
+
try:
|
|
113
|
+
module = importlib.import_module(f'.{plug}', mod.__package__)
|
|
114
|
+
except Exception:
|
|
115
|
+
break
|
|
116
|
+
klass = getattr(module, f'DAQ_{dim}Viewer_{name}')
|
|
117
|
+
for meth in MANDATORY_VIEWER_METHODS:
|
|
118
|
+
assert hasattr(klass, meth)
|
|
119
|
+
|
|
120
|
+
def test_compatibility(capsys):
|
|
121
|
+
capsys.disabled()
|
|
122
|
+
try:
|
|
123
|
+
from pymodaq_plugin_manager.compatibility_checker import PyMoDAQPlugin
|
|
124
|
+
except (ModuleNotFoundError, ImportError) as e:
|
|
125
|
+
pytest.fail(f"Please update pymodaq_plugin_manager to a newer version: {e}")
|
|
126
|
+
|
|
127
|
+
plugin = PyMoDAQPlugin(get_package_name(), None)
|
|
128
|
+
success = plugin.all_imports_valid()
|
|
129
|
+
msg = '\n'.join(plugin.failed_imports + [''])
|
|
130
|
+
|
|
131
|
+
if not success:
|
|
132
|
+
plugin.save_import_report(".")
|
|
133
|
+
|
|
134
|
+
assert success, msg
|