ottowayi / pycomm3

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

[FEATURE] - Assign tag list from another LogixDriver object #286

Closed Fryj2841 closed 1 year ago

Fryj2841 commented 1 year ago

Your current API for the LogixDriver allows for tags to be uploaded from the PLC. Some programs need to utilize multiple connections to the same PLC and don't want to wait for the upload to complete upon opening a new connection.

Please add a setattr or a new method for setting the LogixDriver tags list without uploading such as from an already established connection.

I am currently trying to create a program that utilizes several poll groups with a PLC that has a very large number of tags. I am assigning a new connection to each poll group and polling using a threading approach. I noticed that when connecting to the PLC if I have the init_tags flag set to true it takes 9.45 seconds to open the connection. When I don't initialize the connection, it only takes 99ms I would like to take advantage of the quick opening speeds by being able to read in a global tag list and assigning that to each connection so I can open connections faster.

ottowayi commented 1 year ago

you can do that by setting the private _tags attribute, like:

with LogixDriver('1.2.3.4') as plc1:
     ...

plc2 = LogixDriver('1.2.3.4', init_tags=False)
plc2._tags = plc1._tags

I may add setting the tag list as an option in __init__ in the future, but this method works currently.

Fryj2841 commented 1 year ago

Thank you