Python driver for Koyo Ethernet ClickPLCs.
Project description
clickplc
Python ≥3.5 driver and command-line tool for Koyo Ethernet ClickPLCs.
Installation
pip install clickplc
Usage
Command Line
$ clickplc the-plc-ip-address
This will print all the X, Y, and DF registers to stdout as JSON. You can pipe this as needed. However, you'll likely want the python functionality below.
Python
This uses Python ≥3.5's async/await syntax to asynchronously communicate with a ClickPLC. For example:
import asyncio
from clickplc import ClickPLC
async def get():
async with ClickPLC('the-plc-ip-address') as plc:
print(await plc.get('df1-df500'))
asyncio.run(get())
The entire API is get
and set
, and takes a range of inputs:
>>> await plc.get('df1')
0.0
>>> await plc.get('df1-df20')
{'df1': 0.0, 'df2': 0.0, ..., 'df20': 0.0}
>>> await plc.get('y101-y316')
{'y101': False, 'y102': False, ..., 'y316': False}
>>> await plc.set('df1', 0.0) # Sets DF1 to 0.0
>>> await plc.set('df1', [0.0, 0.0, 0.0]) # Sets DF1-DF3 to 0.0.
>>> await plc.set('y101', True) # Sets Y101 to true
Currently, only X, Y, and DF are supported. I personally haven't needed to use the other categories, but they are straightforward to add if needed.
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
clickplc-0.2.4.tar.gz
(6.3 kB
view hashes)
Built Distribution
Close
Hashes for clickplc-0.2.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce3e906ee1e092a825427311964235dab44cafb168c2c6f0676fa900a1dcc0d4 |
|
MD5 | b7fc82eeb5aca0199865cf24f04bbb3e |
|
BLAKE2b-256 | 965795c83cb0660703388c8e8a76c75e79d55b600b251a50c8dd0e1018ed3040 |