ottowayi / pycomm3

A Python Ethernet/IP library for communicating with Allen-Bradley PLCs.
MIT License
406 stars 88 forks source link

Adds a tag namespace filter parameter to LogixDriver for targeted/selective Tag parsing #312

Open benersuay opened 9 months ago

benersuay commented 9 months ago

Introduces a new constructor argument tag_namespace_filter to LogixDriver class.

Similar to program/task filtering, this filter applies to all tags that start with a string of user's choice; only tags that start with the provided filter get parsed and created in LogixDriver during initialization.

This filtering can prevent byte parsing errors in applications where there are thousands of tags that may not be relevant for communicating with pycomm3 (e.g. tags that are used on the PLC for internal logic handling purposes).

Before this namespace filter, all tags need to be added to a particular program to be filtered (program attribute is not exposed to the constructor either unfortunately), whereas this PR enables filtering simply by tags' names initial common string.

For example setting tag_namespace_filter = MyFavoriteSetOfTags in an environment where MyFavoriteSetOfTags.Struct1, MyFavoriteSetOfTags.Struct2 etc. exist would enable pycomm3 to only parse Struct1 and Struct2 ignoring all other, potentially irrelevant, tags from being created and parsed during initialization.

benersuay commented 7 months ago

@ottowayi any feedback on this?