Factory IO Modbus Interface
Project description
PyFactoryIO
PyFactoryIO is a Python library that provides a high-level, modular Modbus interface for interacting with Factory I/O. It allows you to easily connect your Python control logic to Factory I/O simulations, abstracting away the low-level Modbus TCP communication and mapping digital/register inputs and outputs by name.
Features
- Easy Configuration: Map Factory I/O sensors and actuators using descriptive names instead of Modbus addresses.
- Event-Driven & Loop-Based Execution: Provides decorators to run callbacks on state changes, or a continuous control loop for cyclic execution.
- Auto-Mapping: Automatically handles Modbus coils, discrete inputs, holding registers, and input registers.
- Lightweight: Built on top of
pyModbusTCP.
Installation
You can install pyfactoryio directly via pip:
pip install pyfactoryio
Quick Start
1. Configure Factory I/O
Ensure Factory I/O is configured to use the Modbus TCP Server driver. By default, PyFactoryIO listens on 127.0.0.1 port 5020.
2. Basic Example
Here is a simple example demonstrating how to read a sensor and trigger an actuator.
from pyfactoryio import FactoryIOServer
# Define your input and output names in the order they appear in Factory I/O
DI_NAMES = ["Sensor_1", "Start_Button"]
DO_NAMES = ["Conveyor", "Warning_Light"]
# Initialize the server
server = FactoryIOServer(
di_names=DI_NAMES,
do_names=DO_NAMES
)
# Example 1: Event-driven callback
@server.on_change("Start_Button")
def on_start_pressed(value):
if value:
print("Start button pressed!")
server.Conveyor = True
else:
print("Start button released!")
server.Conveyor = False
# Example 2: Continuous control loop
def my_logic(srv):
# This function is called continuously by run_loop
if srv.Sensor_1:
srv.Warning_Light = True
else:
srv.Warning_Light = False
if __name__ == "__main__":
# Start the event loop (e.g., at 10Hz)
server.run_loop(logic_func=my_logic, hz=10)
Supported Variable Types
- di_names: Digital Inputs (Sensors, Buttons) - Read from Factory I/O via Coils.
- do_names: Digital Outputs (Conveyors, Lights) - Written to Factory I/O via Discrete Inputs.
- ri_names: Register Inputs (Analog Sensors) - Read from Factory I/O via Holding Registers.
- ro_names: Register Outputs (Analog Actuators) - Written to Factory I/O via Input Registers.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfactoryio-0.1.0.tar.gz.
File metadata
- Download URL: pyfactoryio-0.1.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa8b5b0116a7d07cee515f98c4bcf9799d58f10a08242596eadbb1a8ffe9c8e3
|
|
| MD5 |
99e9535d325e9802bbc8a16d2d768068
|
|
| BLAKE2b-256 |
6b6a87c9a10951bfb1e3e870999851bd40a3576f5b358dbf196bbf91fc2b5da2
|
Provenance
The following attestation bundles were made for pyfactoryio-0.1.0.tar.gz:
Publisher:
pypi-publish.yml on Mostafasaad1/pyfactoryio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfactoryio-0.1.0.tar.gz -
Subject digest:
fa8b5b0116a7d07cee515f98c4bcf9799d58f10a08242596eadbb1a8ffe9c8e3 - Sigstore transparency entry: 1718243356
- Sigstore integration time:
-
Permalink:
Mostafasaad1/pyfactoryio@e9f1df6995677180850206347909d8f09fc62e44 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Mostafasaad1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@e9f1df6995677180850206347909d8f09fc62e44 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file pyfactoryio-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyfactoryio-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc174d5de5dac5758deb3ec471a3442e9a33e22287d0e394471d8bd75f2e742e
|
|
| MD5 |
c215699d369ee8690168cc9fa1f0628a
|
|
| BLAKE2b-256 |
5df5d9be952c964470ecc8f2e87826bf804589e743bdeee5e5c08835fb213360
|
Provenance
The following attestation bundles were made for pyfactoryio-0.1.0-py3-none-any.whl:
Publisher:
pypi-publish.yml on Mostafasaad1/pyfactoryio
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfactoryio-0.1.0-py3-none-any.whl -
Subject digest:
fc174d5de5dac5758deb3ec471a3442e9a33e22287d0e394471d8bd75f2e742e - Sigstore transparency entry: 1718243543
- Sigstore integration time:
-
Permalink:
Mostafasaad1/pyfactoryio@e9f1df6995677180850206347909d8f09fc62e44 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Mostafasaad1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi-publish.yml@e9f1df6995677180850206347909d8f09fc62e44 -
Trigger Event:
workflow_dispatch
-
Statement type: