Pycomm Scanlist
Python module for managing a list of tags being read from a Rockwell Automation PLC.
Scanlist Class
The module implements a Scanlist class with a required parameter of IP Address. Optionally, a plc_type and a change_handler parameter can be passed to the class.
plc_type parameter
Due to different implementations within pycomm for Micro800 PLCs, in order to read from a Micro800 PLC, the value of plc_type must be "Micro800". The default value for plc_type is "CLX" for ControlLogix/CompactLogix PLCs.
change_handler parameter
The change_handler should be a function with a required parameter sender and an optional parameter eargs. sender is a reference to the instance of Tag that has changed.
The default implementation of change_handler is:
def change_handler(sender):
"""Handle a tag value change."""
print("{} changed from {} to {}".format(sender.tag_name, sender.last_value, sender.value))
Scanlist.add(tag_name) function
Scanlist.add takes one parameter tag_name and adds it to the list of tags to scan.
Scanlist.remove(tag_name) function
Scanlist.add takes one parameter tag_name and removes it from the list of tags to scan.
Scanlist.print_tag_names() function
Scanlist.print_tag_names() prints all tag names currently in the list of tags to scan.
Scanlist.scan() function
Scanlist.scan() polls all tags in the list of tags to scan and runs the change_handler function if the tag value has changed.
Example
The following example creates two scanlists, one for the Micro800 PLC at 192.168.1.12 and another for the CLX PLC at 192.168.1.11. Each PLC has 4 tags in the scanlist.
import time
from pycomm_scanlist import Scanlist
def handle_tag_change(sender, eargs=None):
"""Handle a tag value change."""
print("{} CHANGED FROM {} TO {}".format(sender.tag_name, sender.last_value, sender.value))
micro_scan_list = Scanlist("192.168.1.12", plc_type="Micro800", change_handler=handle_tag_change)
micro_scan_list.add("pond1Volume")
micro_scan_list.add("pond2Volume")
micro_scan_list.add("pond3Volume")
micro_scan_list.add("pond4Volume")
clx_scan_list = Scanlist("192.168.1.11", change_handler=handle_tag_change)
clx_scan_list.add("DH_Fluid_Level")
clx_scan_list.add("DH_IntakePressure")
clx_scan_list.add("DH_IntakeTemperature")
clx_scan_list.add("DH_MaxIntakePressure_Forever")
micro_scan_list.print_tag_names()
clx_scan_list.print_tag_names()
while True:
micro_scan_list.scan()
clx_scan_list.scan()
time.sleep(5)
TODO
- Add tests to increase coverage.
- Per-tag handlers?
- PyPi package
Contributors
- Patrick McDonagh - @patrickjmcd - Owner
Metadata
Release files for pycomm-scanlist 0.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 | Provenance | Actions |
|---|---|---|---|---|
| pycomm-scanlist-0.1.tar.gz | 3.8 kB | Without provenance | Details for pycomm-scanlist-0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pycomm_scanlist-0.1-py2-none-any.whl | Python 2 | none | any | Details for pycomm_scanlist-0.1-py2-none-any.whl |
Total release size: 8.7 kB
Release files / pycomm-scanlist-0.1.tar.gz
| Download URL | pycomm-scanlist-0.1.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
af98a96515c0698b5c6948cb313903b0a3f6b1094815a1dbab08f4bdf41735b0
|
|
BLAKE2b-256 checksum How to use checksums |
5e9ec0ea2229a97f589338f2f25de2d3af6ea42983c7851bec359e9c94b6fb97
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.15
|
Release files / pycomm_scanlist-0.1-py2-none-any.whl
| Download URL | pycomm_scanlist-0.1-py2-none-any.whl |
|---|---|
| Size | 4.9 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
59adcbca316d82d0e4315755b1baa89c5e246b3a02f3490d3d14ba035299eab4
|
|
BLAKE2b-256 checksum How to use checksums |
3add6126b59266dbf16be87ce2ca90748d0b82098c29b46111ddb7302c399c74
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/2.7.15
|
Security for pycomm-scanlist 0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.