Metadata-Version: 2.4
Name: agiltron-selfalign
Version: 0.2.0
Summary: Python interface for the Agiltron SelfAlign fiber switch
Project-URL: Homepage, https://github.com/ograsdijk/Agiltron-SelfAlign
Project-URL: Repository, https://github.com/ograsdijk/Agiltron-SelfAlign
Project-URL: Issues, https://github.com/ograsdijk/Agiltron-SelfAlign/issues
Author-email: ograsdijk <o.grasdijk@gmail.com>
License: MIT
License-File: LICENSE
Keywords: agiltron,fiber,lab-automation,serial,switch
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.11
Requires-Dist: pyserial<4,>=3.5
Description-Content-Type: text/markdown

# Agiltron-SelfAlign
[![Python versions on PyPI](https://img.shields.io/pypi/pyversions/agiltron-selfalign.svg)](https://pypi.org/project/agiltron-selfalign/)
[![agiltron-selfalign version on PyPI](https://img.shields.io/pypi/v/agiltron-selfalign.svg "Agiltron-SelfAlign on PyPI")](https://pypi.org/project/agiltron-selfalign/)

Python interface for the [Agiltron SelfAlign](https://agiltron.com/product/selfalign-series-1xn-switch-box/) fiber switch.

Requires Python 3.11 or newer.

## Install
```
uv add agiltron-selfalign
```

Or install directly from source:
```
uv add git+https://github.com/ograsdijk/Agiltron-SelfAlign.git
```

## Code Example
```Python
from agiltron_selfalign import AgiltronSelfAlign

resource_name = "COM8"
switch = AgiltronSelfAlign(resource_name, number_of_ports=16)

# change port to port 14
switch.set_fiber_port(14)

# home switch to port 1
switch.home()
```

## Context Manager Example
```Python
from agiltron_selfalign import AgiltronSelfAlign

resource_name = "COM8"

with AgiltronSelfAlign(resource_name, number_of_ports=16) as switch:
		switch.set_fiber_port(14)
		switch.home()
```

## API
- `AgiltronSelfAlign(resource_name, timeout=2.0, number_of_ports=16, baudrate=9600, write_timeout=None, inter_byte_timeout=None)`
	- Opens the serial connection to the switch.
	- `write_timeout=None` defaults to the read `timeout` value.
- `set_fiber_port(fiber_port)`
	- Switches to the requested fiber port and validates the acknowledgement frame.
- `home()`
	- Sends the home command to move the switch to port 1.
- `close()`
	- Closes the serial connection.
- `AgiltronSelfAlignError`
	- Raised for serial communication failures and protocol response errors.