Efficiency and Pylogix
I receive quite a few questions about how to speed pylogix up. It is important to understand how pylogix reads/writes tags, once we have a good understanding, there are a few different strategies, depending on your usage. I’ll cover a few use cases. How Pylogix Reads/Writes Tags When you create an instance of pylogix, there is a dictionary KnownTags that stores each unique tag name read and its data type. The data type is necessary for a write because the PLC needs to know how many bytes you are sending. These data types are stored in the dictionary CIPTypes. I’m only going to cover the basic types, not STRUCTS (UDT’s, CONTROL, TIMER, COUNTER, etc.). Dealing with STRUCTS is a different subject. Since the PLC needs to know the type when writing a value to a tag, the first time a user reads or writes, I first make a read to get the type, that is saved in KnownTags dictionary. The next time you interact with the tag...