matterlab_valves
matterlab_valves is a Python package for controlling several valve controllers used in the Matter Lab. It provides a shared switching-valve interface plus device-specific drivers built on top of matterlab_serial_device.
Supported Devices
JKem4in1Valve: classic JKem 4-in-1 serial valve controllerJKemNewValve: newer JKem serial valve protocolValcoSelectionValve: Valco selection valvesRunzeSelectionValve: Runze RS485 selection valvesSwitchingValve: shared abstract base class for valve-like devices
Installation
Install the package:
pip install matterlab_valves
For development:
pip install -e .[dev]
The package depends on matterlab_serial_device, which is installed automatically as a runtime dependency.
Quick Start
Example with a Valco valve:
from matterlab_valves import ValcoSelectionValve
valve = ValcoSelectionValve(
com_port="COM5",
num_port=10,
ports={"home": 1, "collect": 2},
)
print("Current port:", valve.port)
valve.switch_port("collect")
print("Current port:", valve.port)
All valve implementations expose a port property for reading and setting the active position. If you provide a ports mapping, you can use human-readable names with switch_port(...).
Device Overview
JKem 4-in-1
Required parameters:
com_portvalve_num
Example:
from matterlab_valves import JKem4in1Valve
valve = JKem4in1Valve(
com_port="COM11",
valve_num=3,
ports={"load": 1, "inject": 2},
)
valve.port = 1
valve.switch_port("inject")
JKem New
Required parameters:
com_portvalve_num
Example:
from matterlab_valves import JKemNewValve
valve = JKemNewValve(
com_port="COM11",
valve_num=1,
ports={"load": 1, "inject": 2},
)
print(valve.port)
Valco Selection Valve
Required parameters:
com_portnum_port
Example:
from matterlab_valves import ValcoSelectionValve
valve = ValcoSelectionValve(
com_port="COM5",
num_port=10,
ports={"home": 1, "collect": 2},
)
valve.port = 2
valve.switch_port("home")
Runze Selection Valve
Required parameters:
com_portaddressnum_port
Example:
from matterlab_valves import RunzeSelectionValve
valve = RunzeSelectionValve(
com_port="COM3",
address=0,
num_port=10,
ports={"home": 1, "collect": 2},
)
valve.port = 2
valve.switch_port("home")
Examples
Readable usage examples live in examples/:
examples/test_sim.py: one-click simulation-only test runnerexamples/real_devices.py: human-readable hardware usage examplesexamples/README.md: short guide to the examples directory
Run the simulation suite with:
python examples/test_sim.py
Testing
Simulation Tests
The simulation suite is the default validation layer and is safe for CI.
One-click run:
python examples/test_sim.py
Direct pytest run:
pytest tests/test_jkem_4in1_sim.py tests/test_jkem_new_sim.py tests/test_valco_selection_sim.py tests/test_runze_selection_sim.py tests/test_switching_valve.py
Hardware Tests
Hardware tests are present for all supported valve families, but they are opt-in because physical devices may not be connected in every environment.
Available hardware test files:
tests/test_jkem_4in1_real.pytests/test_jkem_new_real.pytests/test_valco_selection_real.pytests/test_runze_selection_real.py
They are marked with @pytest.mark.real and are skipped unless --run-real is provided.
Example:
pytest tests/test_jkem_4in1_real.py --run-real --com-port COM11 --valve-num 3
Hardware configuration may be supplied through CLI flags or environment variables:
--com-portorVALVE_COM_PORT--num-portorVALVE_NUM_PORT--addressorVALVE_ADDRESS--valve-numorVALVE_VALVE_NUM
Development
Useful commands:
pytest
ruff check .
ruff format .
The default pytest configuration includes timeout, rerun, and coverage options from pyproject.toml.
Package Layout
src/matterlab_valves/
base_valve.py
jkem_4in1_valve.py
jkem_new.py
runze_valve.py
valco_selection_valve.py
tests/
examples/
License
This project is distributed under the MIT License. See LICENSE for details.
Metadata
Release files for matterlab-valves 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| matterlab_valves-1.2.1.tar.gz | 19.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| matterlab_valves-1.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.5 kB
Release files / matterlab_valves-1.2.1.tar.gz
| Download URL | matterlab_valves-1.2.1.tar.gz |
|---|---|
| Size | 19.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7a529232f6357dfbad19fd2e05310dbd68f95ec03e86f6083d7a0c69aa455ae
|
|
BLAKE2b-256 checksum How to use checksums |
ded6c0ce47a857148a8e4f20a5cdc76ee4267512978b5bab72eb1882f7bae97c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.13
|
Release files / matterlab_valves-1.2.1-py3-none-any.whl
| Download URL | matterlab_valves-1.2.1-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fc8818363abe6166e4023c612153dcf013f917bd7a4e40c1dd4c213b5f5c1bf5
|
|
BLAKE2b-256 checksum How to use checksums |
08787191b1b50f2426bb174d5199147a53bcf78cf42a4c19e3b042c1061e0606
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.13
|