🐍 PyVaem
📋 Overview
This Python API provides control for the Festo VAEM valve control module via Modbus TCP/IP communication. It is based on the original VAEM driver and features comprehensive refactoring and improvements.
🛠️ Requirements
- Python: 3.10 or higher
📚 Core Dependencies
🚀 Installation
Option 1: From PyPI (Recommended)
# Create virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install the latest release from PyPI
pip install pyvaem
Option 2: From GitHub Releases
# Create virtual environment (recommended)
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install the latest release from GitHub
pip install https://github.com/jlmoraleshellin/pyvaem/releases/download/v1.0.0/pyvaem-1.0.0-py3-none-any.whl
📖 Quick Start
Basic Usage
from pyvaem import VaemDriver, VaemConfig, ValveSettings
# Set the VAEM connection configuration
config = VaemConfig(
ip='192.168.1.100',
port=502, # Default VAEM port
slave_id=1
)
# Initialize the driver
vaem = VaemDriver(config)
# Select and open a single valve
vaem.select_valve(1) # Select valve 1
vaem.open_valves() # Open selected valves
# Close all valves before
vaem.close_valves()
# Select multiple valves at once
valve_states = [1, 0, 1, 0, 0, 0, 0, 0] # Open valves 1 and 3
vaem.select_valves(valve_states)
vaem.open_valves()
vaem.close_valves()
Valve Configuration
# Configure valve settings
settings = ValveSettings(
NominalVoltage=24000,
InrushCurrent=300,
HoldingCurrent=100,
ResponseTime=500,
PickUpTime=125,
TimeDelay=0,
HitNHold=100
)
# You can also specify only the settings to change - others use defaults
settings = ValveSettings(
InrushCurrent=300,
HoldingCurrent=100,
ResponseTime=500,
PickUpTime=125,
# NominalVoltage will be 24000 (default)
# TimeDelay will be 0 (default)
# HitNHold will be 100 (default)
)
# Apply settings to valve 1
vaem.set_valve_settings(1, settings)
# Or use a dictionary for better compatibility
settings_dict = {
'NominalVoltage': 12000,
'InrushCurrent': 250
# All other parameter will use default values
}
vaem.set_valve_settings(2, settings_dict)
# Save settings to device memory (optional)
vaem.save_settings()
📝 Complete usage example
See example_usage.py.
🎯 API Reference
Core classes and methods
VaemDriver
The main driver class for controlling VAEM devices.
Constructor:
VaemDriver(vaem_config: VaemConfig)
VaemConfig
Configuration dataclass for VAEM connection parameters.
@dataclass
class VaemConfig:
ip: str # Device IP address
port: int # Modbus TCP port (typically 502)
slave_id: int # Modbus slave ID
ValveSettings
Configuration dataclass for valve parameters with VAEM defaults.
@dataclass
class ValveSettings:
NominalVoltage: int = 24000 # Voltage (8000-24000 mV)
ResponseTime: int = 500 # Response time (1-2³²-1 ms)
TimeDelay: int = 0 # Time delay (0-2³²-1 ms)
PickUpTime: int = 125 # Pick-up time (1-500 ms)
InrushCurrent: int = 300 # Inrush current (20-1000 mA)
HitNHold: int = 100 # Hit & hold (0-1000 ms)
HoldingCurrent: int = 100 # Holding current (20-400 mA)
Valve Selection Methods
select_valve(valve_id: int)- Select a single valve (1-8)deselect_valve(valve_id: int)- Deselect a single valve (1-8)select_valves(states: list[int])- Select multiple valves with 8-element list of 0s and 1sselect_all_valves()- Select all valvesdeselect_all_valves()- Deselect all valvesread_valves_state()- Get current valve selection as tuple
Valve Operation Methods
open_valves()- Open all selected valvesclose_valves()- Close all valvesclear_error()- Clear any device errors
Configuration Methods
set_valve_settings(valve_id: int, settings: ValveSettings | dict | None)- Configure valve parametersread_valve_settings(valve_id: int)- Read current valve settingssave_settings()- Save current configuration to device memory
Status Methods
get_status()- Get device status including valve states and errors
🚨 Error Handling
The driver includes comprehensive error handling with specific exception types:
IndexError- Invalid parameter index or subindexPermissionError- Read/write operation not allowedValueError- Parameter value out of range or invalidTypeError- Incorrect data typeRuntimeError- Command execution failedConnectionError- Failed to connect to VAEM device
All valve operations are automatically wrapped with error checking and clearing.
📚 Documentation
For detailed documentation check the operating manual
🤝 Contributing
Contributions are welcome!
📄 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
🙏 Attribution
This project is based on the original VAEM driver developed by Milen Kolev (milen.kolev@festo.com) and the Festo team. The original project provided the foundation for this improved implementation.
Original Repository: Festo VAEM Driver
📧 Contact
For questions, issues, or contributions:
- Email: jlmoraleshellin@gmail.com
🔄 Changelog
Version 1.0.0 (Current)
- Complete rewrite with improved architecture
- Enhanced error handling with specific exception types
- Comprehensive valve configuration with ValveSettings dataclass
- Improved logging and connection management
- Better API design with clear method separation
- Support for multiple valve selection patterns
- Automatic error clearing on operations
Version 0.0.2 (Original)
- Basic VAEM control functionality
- Modbus TCP communication
- Simple valve operations
Release files for pyvaem 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pyvaem-1.0.2.tar.gz | 14.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyvaem-1.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.4 kB
Release files / pyvaem-1.0.2.tar.gz
| Download URL | pyvaem-1.0.2.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25f91793edd02f31b9b4c1cf678e4158652a4668547b7ccaca32623a4fc09ba2
|
|
BLAKE2b-256 checksum How to use checksums |
ac0ed245e1891827126a78aa275edd2d9fcc0e6b673ceca926c90d7c3f0697c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|
Release files / pyvaem-1.0.2-py3-none-any.whl
| Download URL | pyvaem-1.0.2-py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3b75288a06e332c09834593ccb0e7823d847b09772288bf6784d3b6658d7e3d1
|
|
BLAKE2b-256 checksum How to use checksums |
7aaf9a66f367ac78298d5c978ac024c1e54f708e3f1f1591bc82af41b6fc9339
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.3
|