obis-laser 0.1.0__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.
- obis_laser-0.1.0/.github/workflows/obis-laser.yml +114 -0
- obis_laser-0.1.0/.gitignore +9 -0
- obis_laser-0.1.0/.python-version +1 -0
- obis_laser-0.1.0/LICENSE +21 -0
- obis_laser-0.1.0/PKG-INFO +159 -0
- obis_laser-0.1.0/README.md +138 -0
- obis_laser-0.1.0/examples/basic.py +22 -0
- obis_laser-0.1.0/pyproject.toml +70 -0
- obis_laser-0.1.0/setup.cfg +4 -0
- obis_laser-0.1.0/src/obis/__init__.py +46 -0
- obis_laser-0.1.0/src/obis/aio.py +363 -0
- obis_laser-0.1.0/src/obis/cli.py +80 -0
- obis_laser-0.1.0/src/obis/connection.py +181 -0
- obis_laser-0.1.0/src/obis/discovery.py +109 -0
- obis_laser-0.1.0/src/obis/errors.py +48 -0
- obis_laser-0.1.0/src/obis/laser.py +305 -0
- obis_laser-0.1.0/src/obis/models.py +176 -0
- obis_laser-0.1.0/src/obis/protocol.py +537 -0
- obis_laser-0.1.0/src/obis/py.typed +0 -0
- obis_laser-0.1.0/src/obis_laser.egg-info/PKG-INFO +159 -0
- obis_laser-0.1.0/src/obis_laser.egg-info/SOURCES.txt +31 -0
- obis_laser-0.1.0/src/obis_laser.egg-info/dependency_links.txt +1 -0
- obis_laser-0.1.0/src/obis_laser.egg-info/entry_points.txt +2 -0
- obis_laser-0.1.0/src/obis_laser.egg-info/requires.txt +1 -0
- obis_laser-0.1.0/src/obis_laser.egg-info/scm_file_list.json +28 -0
- obis_laser-0.1.0/src/obis_laser.egg-info/top_level.txt +1 -0
- obis_laser-0.1.0/tests/fakes.py +77 -0
- obis_laser-0.1.0/tests/test_aio.py +33 -0
- obis_laser-0.1.0/tests/test_discovery.py +78 -0
- obis_laser-0.1.0/tests/test_hardware.py +169 -0
- obis_laser-0.1.0/tests/test_laser.py +169 -0
- obis_laser-0.1.0/tests/test_protocol.py +86 -0
- obis_laser-0.1.0/uv.lock +306 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
name: obis-laser
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
release:
|
|
9
|
+
types: [published]
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
# ---- Tests ----
|
|
14
|
+
tests:
|
|
15
|
+
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
|
|
16
|
+
runs-on: ${{ matrix.os }}
|
|
17
|
+
strategy:
|
|
18
|
+
matrix:
|
|
19
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
20
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
21
|
+
fail-fast: false
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v7
|
|
24
|
+
|
|
25
|
+
- uses: astral-sh/setup-uv@v8.3.2
|
|
26
|
+
with:
|
|
27
|
+
enable-cache: true
|
|
28
|
+
|
|
29
|
+
- name: Install python dependencies
|
|
30
|
+
run: uv sync --group dev --python ${{ matrix.python-version }}
|
|
31
|
+
|
|
32
|
+
- name: Run codespell
|
|
33
|
+
run: uv run codespell
|
|
34
|
+
|
|
35
|
+
- name: Run ruff format
|
|
36
|
+
run: uv run ruff format --check
|
|
37
|
+
|
|
38
|
+
- name: Run ruff check
|
|
39
|
+
run: uv run ruff check
|
|
40
|
+
|
|
41
|
+
- name: Run pyright
|
|
42
|
+
run: uv run pyright
|
|
43
|
+
|
|
44
|
+
# Hardware tests are skipped automatically because CI is set.
|
|
45
|
+
- name: Run pytest
|
|
46
|
+
run: uv run pytest --cov obis
|
|
47
|
+
|
|
48
|
+
- name: Build
|
|
49
|
+
run: uv build
|
|
50
|
+
|
|
51
|
+
# ---- Release build ----
|
|
52
|
+
build-release:
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
name: Build release distributions
|
|
55
|
+
needs: tests
|
|
56
|
+
if: github.event_name == 'release' && github.event.action == 'published'
|
|
57
|
+
permissions:
|
|
58
|
+
# gh release upload attaches the distributions to the release.
|
|
59
|
+
contents: write
|
|
60
|
+
|
|
61
|
+
steps:
|
|
62
|
+
- uses: actions/checkout@v7
|
|
63
|
+
|
|
64
|
+
- uses: astral-sh/setup-uv@v8.3.2
|
|
65
|
+
with:
|
|
66
|
+
enable-cache: true
|
|
67
|
+
|
|
68
|
+
- name: Build
|
|
69
|
+
env:
|
|
70
|
+
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.event.release.tag_name }}
|
|
71
|
+
run: uv build
|
|
72
|
+
|
|
73
|
+
- name: Verify setuptools-scm applied the release tag
|
|
74
|
+
shell: bash
|
|
75
|
+
run: |
|
|
76
|
+
ls -1 dist/
|
|
77
|
+
if ls dist/*-0.0.0.tar.gz >/dev/null 2>&1; then
|
|
78
|
+
echo "::error::Built version 0.0.0, so setuptools-scm did not apply the tag. Check that pyproject.toml still declares a tool.setuptools_scm table."
|
|
79
|
+
exit 1
|
|
80
|
+
fi
|
|
81
|
+
|
|
82
|
+
- name: Upload distributions as artifact
|
|
83
|
+
uses: actions/upload-artifact@v7
|
|
84
|
+
with:
|
|
85
|
+
name: dist
|
|
86
|
+
path: dist/
|
|
87
|
+
|
|
88
|
+
- name: Upload release assets
|
|
89
|
+
env:
|
|
90
|
+
GH_TOKEN: ${{ github.token }}
|
|
91
|
+
run: gh release upload --repo ${{ github.repository }} ${{ github.event.release.tag_name }} dist/* --clobber
|
|
92
|
+
|
|
93
|
+
# ---- Publish to PyPI ----
|
|
94
|
+
publish-to-pypi:
|
|
95
|
+
runs-on: ubuntu-latest
|
|
96
|
+
name: Publish to PyPI
|
|
97
|
+
needs: build-release
|
|
98
|
+
environment: pypi
|
|
99
|
+
permissions:
|
|
100
|
+
# uv publish exchanges this token with PyPI trusted publishing.
|
|
101
|
+
id-token: write
|
|
102
|
+
steps:
|
|
103
|
+
- name: Download distributions artifact
|
|
104
|
+
uses: actions/download-artifact@v8
|
|
105
|
+
with:
|
|
106
|
+
name: dist
|
|
107
|
+
path: dist/
|
|
108
|
+
|
|
109
|
+
- uses: astral-sh/setup-uv@v8.3.2
|
|
110
|
+
with:
|
|
111
|
+
enable-cache: true
|
|
112
|
+
|
|
113
|
+
- name: Publish to PyPI
|
|
114
|
+
run: uv publish
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.11
|
obis_laser-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bruno F. Cruz
|
|
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 all
|
|
13
|
+
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 THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: obis-laser
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python client for Coherent OBIS LX/LS lasers (unofficial, not affiliated with Coherent).
|
|
5
|
+
Author: Bruno F. Cruz
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Repository, https://github.com/bruno-f-cruz/obis-laser
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/bruno-f-cruz/obis-laser/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/bruno-f-cruz/obis-laser/releases
|
|
10
|
+
Keywords: obis,laser,scpi,serial,instrument-control
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering
|
|
14
|
+
Classifier: Topic :: System :: Hardware :: Hardware Drivers
|
|
15
|
+
Classifier: Typing :: Typed
|
|
16
|
+
Requires-Python: >=3.11
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: pyserial>=3.5
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# obis-laser
|
|
23
|
+
|
|
24
|
+
Python client for Coherent OBIS LX/LS lasers, over USB or RS-232. It covers the whole
|
|
25
|
+
host command set from the OBIS LX/LS Operator's Manual: device metadata, emission and
|
|
26
|
+
power control, operating modes, temperatures, status and fault words, the error queue
|
|
27
|
+
and persistent settings. Synchronous and `asyncio` APIs are provided.
|
|
28
|
+
|
|
29
|
+
> OBIS and Coherent are trademarks of Coherent Corp. This project is not affiliated
|
|
30
|
+
> with or endorsed by Coherent.
|
|
31
|
+
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
uv add obis-laser # in a project
|
|
36
|
+
uv tool install obis-laser # just the command line tool
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Requires Python 3.11+. The only dependency is [pyserial](https://github.com/pyserial/pyserial).
|
|
40
|
+
|
|
41
|
+
## Quick start
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from obis import ObisLaser, OperatingMode
|
|
45
|
+
|
|
46
|
+
with ObisLaser.open("COM3") as laser: # "/dev/ttyACM0" on Linux
|
|
47
|
+
info = laser.get_info()
|
|
48
|
+
print(info.model, info.serial_number, info.wavelength, "nm")
|
|
49
|
+
|
|
50
|
+
laser.set_operating_mode(OperatingMode.CWP)
|
|
51
|
+
laser.set_power(0.010) # watts
|
|
52
|
+
laser.set_emission(True)
|
|
53
|
+
print(laser.get_state())
|
|
54
|
+
laser.set_emission(False)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Units are SI as used by the device: power in **watts**, current in **amperes**,
|
|
58
|
+
temperatures in **degrees Celsius**.
|
|
59
|
+
|
|
60
|
+
### Several lasers behind an OBIS Remote or LaserBox
|
|
61
|
+
|
|
62
|
+
Channel 0 is the controller; lasers are numbered from 1.
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from obis import ObisConnection
|
|
66
|
+
|
|
67
|
+
with ObisConnection.open("COM3") as connection:
|
|
68
|
+
blue, green = connection.laser(1), connection.laser(2)
|
|
69
|
+
blue.set_power(0.02)
|
|
70
|
+
connection.broadcast("SOUR:AM:STAT ON") # every laser at once
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### asyncio
|
|
74
|
+
|
|
75
|
+
```python
|
|
76
|
+
from obis import AsyncObisLaser
|
|
77
|
+
|
|
78
|
+
async with await AsyncObisLaser.open("COM3") as laser:
|
|
79
|
+
await laser.set_power(0.010)
|
|
80
|
+
state = await laser.get_state()
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Finding lasers
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
import obis
|
|
87
|
+
|
|
88
|
+
for device in obis.discover(exclude=["COM1"]):
|
|
89
|
+
print(device.port, device.channel, device.model, device.serial_number)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`discover()` sends `*IDN?` to every serial port, so it may disturb other serial devices
|
|
93
|
+
(it does not change any setting on them). Pass `ports=[...]` to probe only some ports,
|
|
94
|
+
or `exclude=[...]` to skip ports.
|
|
95
|
+
|
|
96
|
+
### Anything else
|
|
97
|
+
|
|
98
|
+
Every command is available as a request in `obis.protocol`, and raw commands can be sent:
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from obis import protocol
|
|
102
|
+
|
|
103
|
+
laser.execute(protocol.get_wavelength())
|
|
104
|
+
laser.query("SYST:INF:FVER?") # -> ["V3.0.5"]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Command line
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
obis-laser list # find devices
|
|
111
|
+
obis-laser list --exclude COM1 # ... without probing COM1
|
|
112
|
+
obis-laser info COM3 # static information
|
|
113
|
+
obis-laser state COM3 --channel 1
|
|
114
|
+
obis-laser power COM3 0.02
|
|
115
|
+
obis-laser on COM3
|
|
116
|
+
obis-laser off COM3
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Online control
|
|
120
|
+
|
|
121
|
+
- Each call is a single request/reply exchange (a few milliseconds at 115200 baud).
|
|
122
|
+
`get_info()` and `get_state()` combine several exchanges; for fast loops, call the
|
|
123
|
+
specific getters you need, e.g. `get_power()` or `get_status()`.
|
|
124
|
+
- Connections are thread-safe: exchanges are serialized with a lock. The async client
|
|
125
|
+
runs them on a single worker thread, in the order they are awaited.
|
|
126
|
+
- Device errors raise `ObisDeviceError` (with `code` and `description`), missing replies
|
|
127
|
+
raise `ObisTimeoutError`. All exceptions derive from `ObisError`.
|
|
128
|
+
- On connection, the client enables message handshaking (`OK`/`ERR` replies) if it is off.
|
|
129
|
+
This setting is stored in the laser.
|
|
130
|
+
|
|
131
|
+
## Development
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
uv sync
|
|
135
|
+
uv run pytest
|
|
136
|
+
uv run ruff check && uv run ruff format --check
|
|
137
|
+
uv run pyright
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Tests use a simulated device and need no hardware.
|
|
141
|
+
|
|
142
|
+
### Testing with a real laser
|
|
143
|
+
|
|
144
|
+
`tests/test_hardware.py` runs against a real device. It is skipped unless `OBIS_PORT`
|
|
145
|
+
is set, and always skipped in CI (when `CI` is set). Only settings that are restored to
|
|
146
|
+
their original value are written.
|
|
147
|
+
|
|
148
|
+
```powershell
|
|
149
|
+
$env:OBIS_PORT = "COM3"
|
|
150
|
+
$env:OBIS_CHANNEL = "0" # optional: laser behind an OBIS Remote / LaserBox
|
|
151
|
+
$env:OBIS_TEST_EMISSION = "1" # optional: also turn emission ON (5 % of max power)
|
|
152
|
+
uv run pytest tests/test_hardware.py -v -s
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Block the beam before enabling `OBIS_TEST_EMISSION`.
|
|
156
|
+
|
|
157
|
+
## License
|
|
158
|
+
|
|
159
|
+
MIT
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# obis-laser
|
|
2
|
+
|
|
3
|
+
Python client for Coherent OBIS LX/LS lasers, over USB or RS-232. It covers the whole
|
|
4
|
+
host command set from the OBIS LX/LS Operator's Manual: device metadata, emission and
|
|
5
|
+
power control, operating modes, temperatures, status and fault words, the error queue
|
|
6
|
+
and persistent settings. Synchronous and `asyncio` APIs are provided.
|
|
7
|
+
|
|
8
|
+
> OBIS and Coherent are trademarks of Coherent Corp. This project is not affiliated
|
|
9
|
+
> with or endorsed by Coherent.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
uv add obis-laser # in a project
|
|
15
|
+
uv tool install obis-laser # just the command line tool
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Requires Python 3.11+. The only dependency is [pyserial](https://github.com/pyserial/pyserial).
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from obis import ObisLaser, OperatingMode
|
|
24
|
+
|
|
25
|
+
with ObisLaser.open("COM3") as laser: # "/dev/ttyACM0" on Linux
|
|
26
|
+
info = laser.get_info()
|
|
27
|
+
print(info.model, info.serial_number, info.wavelength, "nm")
|
|
28
|
+
|
|
29
|
+
laser.set_operating_mode(OperatingMode.CWP)
|
|
30
|
+
laser.set_power(0.010) # watts
|
|
31
|
+
laser.set_emission(True)
|
|
32
|
+
print(laser.get_state())
|
|
33
|
+
laser.set_emission(False)
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Units are SI as used by the device: power in **watts**, current in **amperes**,
|
|
37
|
+
temperatures in **degrees Celsius**.
|
|
38
|
+
|
|
39
|
+
### Several lasers behind an OBIS Remote or LaserBox
|
|
40
|
+
|
|
41
|
+
Channel 0 is the controller; lasers are numbered from 1.
|
|
42
|
+
|
|
43
|
+
```python
|
|
44
|
+
from obis import ObisConnection
|
|
45
|
+
|
|
46
|
+
with ObisConnection.open("COM3") as connection:
|
|
47
|
+
blue, green = connection.laser(1), connection.laser(2)
|
|
48
|
+
blue.set_power(0.02)
|
|
49
|
+
connection.broadcast("SOUR:AM:STAT ON") # every laser at once
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### asyncio
|
|
53
|
+
|
|
54
|
+
```python
|
|
55
|
+
from obis import AsyncObisLaser
|
|
56
|
+
|
|
57
|
+
async with await AsyncObisLaser.open("COM3") as laser:
|
|
58
|
+
await laser.set_power(0.010)
|
|
59
|
+
state = await laser.get_state()
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Finding lasers
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import obis
|
|
66
|
+
|
|
67
|
+
for device in obis.discover(exclude=["COM1"]):
|
|
68
|
+
print(device.port, device.channel, device.model, device.serial_number)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`discover()` sends `*IDN?` to every serial port, so it may disturb other serial devices
|
|
72
|
+
(it does not change any setting on them). Pass `ports=[...]` to probe only some ports,
|
|
73
|
+
or `exclude=[...]` to skip ports.
|
|
74
|
+
|
|
75
|
+
### Anything else
|
|
76
|
+
|
|
77
|
+
Every command is available as a request in `obis.protocol`, and raw commands can be sent:
|
|
78
|
+
|
|
79
|
+
```python
|
|
80
|
+
from obis import protocol
|
|
81
|
+
|
|
82
|
+
laser.execute(protocol.get_wavelength())
|
|
83
|
+
laser.query("SYST:INF:FVER?") # -> ["V3.0.5"]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Command line
|
|
87
|
+
|
|
88
|
+
```sh
|
|
89
|
+
obis-laser list # find devices
|
|
90
|
+
obis-laser list --exclude COM1 # ... without probing COM1
|
|
91
|
+
obis-laser info COM3 # static information
|
|
92
|
+
obis-laser state COM3 --channel 1
|
|
93
|
+
obis-laser power COM3 0.02
|
|
94
|
+
obis-laser on COM3
|
|
95
|
+
obis-laser off COM3
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Online control
|
|
99
|
+
|
|
100
|
+
- Each call is a single request/reply exchange (a few milliseconds at 115200 baud).
|
|
101
|
+
`get_info()` and `get_state()` combine several exchanges; for fast loops, call the
|
|
102
|
+
specific getters you need, e.g. `get_power()` or `get_status()`.
|
|
103
|
+
- Connections are thread-safe: exchanges are serialized with a lock. The async client
|
|
104
|
+
runs them on a single worker thread, in the order they are awaited.
|
|
105
|
+
- Device errors raise `ObisDeviceError` (with `code` and `description`), missing replies
|
|
106
|
+
raise `ObisTimeoutError`. All exceptions derive from `ObisError`.
|
|
107
|
+
- On connection, the client enables message handshaking (`OK`/`ERR` replies) if it is off.
|
|
108
|
+
This setting is stored in the laser.
|
|
109
|
+
|
|
110
|
+
## Development
|
|
111
|
+
|
|
112
|
+
```sh
|
|
113
|
+
uv sync
|
|
114
|
+
uv run pytest
|
|
115
|
+
uv run ruff check && uv run ruff format --check
|
|
116
|
+
uv run pyright
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Tests use a simulated device and need no hardware.
|
|
120
|
+
|
|
121
|
+
### Testing with a real laser
|
|
122
|
+
|
|
123
|
+
`tests/test_hardware.py` runs against a real device. It is skipped unless `OBIS_PORT`
|
|
124
|
+
is set, and always skipped in CI (when `CI` is set). Only settings that are restored to
|
|
125
|
+
their original value are written.
|
|
126
|
+
|
|
127
|
+
```powershell
|
|
128
|
+
$env:OBIS_PORT = "COM3"
|
|
129
|
+
$env:OBIS_CHANNEL = "0" # optional: laser behind an OBIS Remote / LaserBox
|
|
130
|
+
$env:OBIS_TEST_EMISSION = "1" # optional: also turn emission ON (5 % of max power)
|
|
131
|
+
uv run pytest tests/test_hardware.py -v -s
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Block the beam before enabling `OBIS_TEST_EMISSION`.
|
|
135
|
+
|
|
136
|
+
## License
|
|
137
|
+
|
|
138
|
+
MIT
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"""Print laser information, then emit at 10% of the maximum power for two seconds.
|
|
2
|
+
|
|
3
|
+
Usage: uv run examples/basic.py COM3
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import sys
|
|
7
|
+
import time
|
|
8
|
+
|
|
9
|
+
from obis import ObisLaser, OperatingMode
|
|
10
|
+
|
|
11
|
+
with ObisLaser.open(sys.argv[1]) as laser:
|
|
12
|
+
info = laser.get_info()
|
|
13
|
+
print(f"{info.model} (S/N {info.serial_number}), {info.wavelength:g} nm")
|
|
14
|
+
|
|
15
|
+
laser.set_operating_mode(OperatingMode.CWP)
|
|
16
|
+
laser.set_power(0.1 * info.max_power)
|
|
17
|
+
laser.set_emission(True)
|
|
18
|
+
try:
|
|
19
|
+
time.sleep(2)
|
|
20
|
+
print(laser.get_state())
|
|
21
|
+
finally:
|
|
22
|
+
laser.set_emission(False)
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "obis-laser"
|
|
3
|
+
dynamic = ["version"]
|
|
4
|
+
description = "Python client for Coherent OBIS LX/LS lasers (unofficial, not affiliated with Coherent)."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
license-files = ["LICENSE"]
|
|
8
|
+
authors = [{ name = "Bruno F. Cruz" }]
|
|
9
|
+
requires-python = ">=3.11"
|
|
10
|
+
dependencies = ["pyserial>=3.5"]
|
|
11
|
+
keywords = ["obis", "laser", "scpi", "serial", "instrument-control"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Programming Language :: Python :: 3",
|
|
14
|
+
"Operating System :: OS Independent",
|
|
15
|
+
"Topic :: Scientific/Engineering",
|
|
16
|
+
"Topic :: System :: Hardware :: Hardware Drivers",
|
|
17
|
+
"Typing :: Typed",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.urls]
|
|
21
|
+
Repository = "https://github.com/bruno-f-cruz/obis-laser"
|
|
22
|
+
"Bug Tracker" = "https://github.com/bruno-f-cruz/obis-laser/issues"
|
|
23
|
+
Changelog = "https://github.com/bruno-f-cruz/obis-laser/releases"
|
|
24
|
+
|
|
25
|
+
[project.scripts]
|
|
26
|
+
obis-laser = "obis.cli:main"
|
|
27
|
+
|
|
28
|
+
[dependency-groups]
|
|
29
|
+
dev = [
|
|
30
|
+
"codespell>=2.3.0",
|
|
31
|
+
"pyright>=1.1.390",
|
|
32
|
+
"pytest>=8.3.5",
|
|
33
|
+
"pytest-cov>=6.1.1",
|
|
34
|
+
"ruff>=0.11.0",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["setuptools>=77", "setuptools-scm>=8"]
|
|
39
|
+
build-backend = "setuptools.build_meta"
|
|
40
|
+
|
|
41
|
+
# The version comes from git tags. Release builds set SETUPTOOLS_SCM_PRETEND_VERSION to the
|
|
42
|
+
# release tag (e.g. v0.1.0); 0.0.0 is only used when no version information is available.
|
|
43
|
+
[tool.setuptools_scm]
|
|
44
|
+
fallback_version = "0.0.0"
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.packages.find]
|
|
47
|
+
where = ["src"]
|
|
48
|
+
include = ["obis*"]
|
|
49
|
+
|
|
50
|
+
[tool.setuptools.package-data]
|
|
51
|
+
obis = ["py.typed"]
|
|
52
|
+
|
|
53
|
+
[tool.codespell]
|
|
54
|
+
skip = "*.lock,./.venv,./.git,./.ruff_cache,./.pytest_cache,./dist,*.pyc"
|
|
55
|
+
check-filenames = true
|
|
56
|
+
|
|
57
|
+
[tool.ruff]
|
|
58
|
+
line-length = 100
|
|
59
|
+
target-version = "py311"
|
|
60
|
+
|
|
61
|
+
[tool.ruff.lint]
|
|
62
|
+
select = ["E", "F", "W", "I", "UP", "B", "SIM", "RUF"]
|
|
63
|
+
|
|
64
|
+
[tool.pyright]
|
|
65
|
+
pythonVersion = "3.11"
|
|
66
|
+
include = ["src", "tests"]
|
|
67
|
+
typeCheckingMode = "standard"
|
|
68
|
+
|
|
69
|
+
[tool.pytest.ini_options]
|
|
70
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""Python client for Coherent OBIS LX/LS lasers.
|
|
2
|
+
|
|
3
|
+
OBIS and Coherent are trademarks of Coherent Corp. This project is not affiliated with
|
|
4
|
+
or endorsed by Coherent.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from . import protocol
|
|
8
|
+
from .aio import AsyncObisConnection, AsyncObisLaser
|
|
9
|
+
from .connection import ObisConnection
|
|
10
|
+
from .discovery import DiscoveredDevice, discover
|
|
11
|
+
from .errors import ObisDeviceError, ObisError, ObisProtocolError, ObisTimeoutError
|
|
12
|
+
from .laser import ObisLaser
|
|
13
|
+
from .models import (
|
|
14
|
+
AnalogImpedance,
|
|
15
|
+
DeviceInfo,
|
|
16
|
+
DeviceType,
|
|
17
|
+
ErrorRecord,
|
|
18
|
+
FaultFlags,
|
|
19
|
+
LaserState,
|
|
20
|
+
OperatingMode,
|
|
21
|
+
StatusFlags,
|
|
22
|
+
TemperatureLimits,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"AnalogImpedance",
|
|
27
|
+
"AsyncObisConnection",
|
|
28
|
+
"AsyncObisLaser",
|
|
29
|
+
"DeviceInfo",
|
|
30
|
+
"DeviceType",
|
|
31
|
+
"DiscoveredDevice",
|
|
32
|
+
"ErrorRecord",
|
|
33
|
+
"FaultFlags",
|
|
34
|
+
"LaserState",
|
|
35
|
+
"ObisConnection",
|
|
36
|
+
"ObisDeviceError",
|
|
37
|
+
"ObisError",
|
|
38
|
+
"ObisLaser",
|
|
39
|
+
"ObisProtocolError",
|
|
40
|
+
"ObisTimeoutError",
|
|
41
|
+
"OperatingMode",
|
|
42
|
+
"StatusFlags",
|
|
43
|
+
"TemperatureLimits",
|
|
44
|
+
"discover",
|
|
45
|
+
"protocol",
|
|
46
|
+
]
|