Metadata-Version: 2.4
Name: neng-relay-controller
Version: 0.1.3
Summary: 16-channel relay controller GUI with SCPI interface for NEnG RelayBank16 instruments.
Author-email: Flavio Abreu Araujo <flavio.abreuaraujo@uclouvain.be>
License-Expression: LicenseRef-Proprietary
Project-URL: Homepage, https://gitlab.flavio.be/flavio/relay-controller
Project-URL: Repository, https://gitlab.flavio.be/flavio/relay-controller.git
Project-URL: Changelog, https://gitlab.flavio.be/flavio/relay-controller/-/blob/main/CHANGELOG.md
Project-URL: Bug-Tracker, https://gitlab.flavio.be/flavio/relay-controller/-/issues
Keywords: RelayBank16,SCPI,serial,relay,controller,tkinter,NEnG
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Education
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Microsoft :: Windows
Classifier: Topic :: Scientific/Engineering
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pyserial>=3.5
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: ruff>=0.4; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: license-file

# Relay Controller

16-channel relay controller GUI for NEnG RelayBank16 instruments.

## Tools included

| Command | Description |
| --- | --- |
| `relay-controller-gui` | Tkinter GUI with 4x4 relay grid, bulk operations, SCPI console, dark/light theme |

Supports **USB serial** and **WiFi/TCP** connections with auto-detection.

This directory is a **standalone, pip-installable** Python package.

## Install

### Recommended: Install from PyPI

```bash
pip install neng-relay-controller
```

### Development install from source (editable mode)

```bash
cd RelayBank16/Python/relay-controller
python3 -m venv .venv
source .venv/bin/activate        # macOS / Linux
python -m pip install -U pip
python -m pip install -e .
```

### Tkinter on macOS

The GUI requires Tkinter. On macOS it may be missing depending on how
Python was installed:

```bash
brew install tcl-tk
brew install python-tk@3.xx      # replace xx with your Python minor version
```

## Run

```bash
relay-controller-gui
```

### Features

- **Visual Relay Grid** — 4x4 grid of 16 relay buttons, click to toggle, right-click to pulse
- **Real-time State Sync** — Automatic polling keeps display synchronized with hardware
- **Bulk Operations** — All ON, All OFF, Invert, Hex Mask, Reset (*RST), Relay Test
- **Pulse Configuration** — Adjustable default pulse duration
- **Connection Options** — Auto/Force USB/WiFi with port scanning and WiFi discovery
- **SCPI Console** — Direct command entry with Up/Down history navigation
- **Bitmask Display** — Current relay state shown as hex and spaced binary
- **Device Info** — Model, serial number, firmware version, connection type
- **Dark/Light Theme** — Professional appearance with one-click theme toggle
- **Safe Shutdown** — Optional "Turn all relays OFF?" prompt on close

## SCPI Commands (Quick Reference)

```bash
# Individual relay control
:RELA1:STAT ON              # Turn relay 1 ON
:RELA1:STAT?                # Query relay 1 state
:RELA5:PULS                 # Pulse relay 5

# Bulk control
:ROUT:MASK 0xFFFF           # All relays ON
:ROUT:MASK 0x0000           # All relays OFF
:ROUT:MASK 0x00FF           # Relays 1-8 ON
:ROUT:CLOS 1,3,5,7          # Close specific relays
:ROUT:OPEN 2,4              # Open specific relays

# System
*IDN?                       # Device identification
*RST                        # Reset (all OFF)
:ROUT:TEST                  # Sequential relay test
```

See [SCPI_COMMAND_REFERENCE.md](../../doc/SCPI_COMMAND_REFERENCE.md) for the full command reference.

## Notes

- Baud rate: 115 200 (USB CDC)
- TCP port: 5025 (standard SCPI-over-TCP)
- Only one client can use the serial port at a time

## Release

See [RELEASE_QUICK_START.md](RELEASE_QUICK_START.md) for release instructions.

---

(c) 2024-26 Prof. Flavio ABREU ARAUJO. All rights reserved.
