Python Beckhoff communication over ads
Project description
An Example of How To Use the Package
from pycat3 import PyCat3, EdgeTrigger
pc3 = PyCat3()
OR
pc3 = PyCat3(ip='127.0.0.1.1.1', port=851)
write a tag
pc3.write_tag('MAIN.nAlive', 9)
read a tag
print(pc3.read_tag('MAIN.nAlive')
Tags change notification subscription
Make lists of the tags to be monitored (Types: Integer, REAL, BOOL)
tags_int = ['MAIN.Int1', 'MAIN.Int2']
tags_real = ['MAIN.Real1']
tags_bool = ['MAIN.Bool1']
call monitor method from ads instance
pc3.monitor(monitored_int=tags_int, monitored_real=tags_real, monitored_bool=tags_bool)
Access 'data' dictionary to read a certain tag
print(pc3.data['MAIN.Int1'])
Use of Edge Detector
Create your callback function
def my_callback(oldVal, newVal):
print(f"Value changed from {oldVal} to {newVal}.")
Create EdgeTrigger object wit callback function as argument
detector = EdgeTrigger(my_callback)
Call the detector with the monitored PLC tag
detector1(pc3.data['MAIN.Int1'])
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
pycat3-0.6.tar.gz
(3.3 kB
view details)
File details
Details for the file pycat3-0.6.tar.gz.
File metadata
- Download URL: pycat3-0.6.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c285329256ccf3247cd0c13ec27483e15f6c6ca7509d6bf2c4f69b4514a8a8a7
|
|
| MD5 |
e7b76d10a3b68d9b30be37d9921addf7
|
|
| BLAKE2b-256 |
079a8236971ff45dd8ce3f3b9285de60e3c2238c2c8450e860ee25cf7cb528f1
|