Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read/Write multiple tags when tags are array #136

Open
3 of 7 tasks
ramezanifar opened this issue Jun 2, 2020 · 1 comment
Open
3 of 7 tasks

Read/Write multiple tags when tags are array #136

ramezanifar opened this issue Jun 2, 2020 · 1 comment

Comments

@ramezanifar
Copy link

ramezanifar commented Jun 2, 2020

Preflight checks

  • Have you tried the examples?
  • Have you tried pylogix-tester?
  • Have you read previous issues?

Type of issue

  • Bug
  • Feature Request
  • Question
  • Other

Description of issue

Hello;
I was trying to read/write multiple tags while tags are arrays.
Example:

tag_list = ['array1', 'array2']

where array1 is SINT[100] and array2 is SINT[100]

Now if I read the tag list in one attempt, it returns only the first index of each array:

ret = comm.Read(tag_list)
for r in ret:
   print(r.Value)

Is there a way to pass the length?
I tried to sum up the length of all tags and use something like:

ret = comm.Read(tag_list, 200)

But still the same problem.

In addition to the read, I could not figure out multiple write when tags are array.
Can you please give me a hint?
Thank you in advance

@dmroeder
Copy link
Owner

First, apologies for the long delay.

Short answer, you cannot read arrays with lists of tags.

Long answer: at some point I added the ability to provide the data type with with a single tag read or a list of tags to read. This helped improve performance for people that read a lot of unique tags because it eliminates getting the data type first. So when you attempt to do something like this:

tags = [('tag1[0]', 10), ('tag2[0]', 10)]
ret = comm.Read(tags)

I'm assuming that the 10 in those cases is the data type. It would then skip getting the data type, assuming that it was "10", and get the values for tag1[0] and tag2[0]. That is why you only get the first element.

I made some changes the other day to take advantage of the multi-service message object in order to bundle getting the data multiple data types into one packet. This speeds things up quite a bit for reading unique tags.

This doesn't help you though when trying to read lists of arrays. For now, only read non-arrays in lists, read arrays individually to get the best performance. I have functioning code to read arrays with lists, but I will have to figure out 2 things: Using multi-service messages (mulit-read) with arrays larger an a single packet, and what to do about people that are currently providing the data type to bypass discovering the data type. In other words, I'll probably have to make a change that would break compatibility in to accommodate this, which I don't like to do.

dmroeder added a commit that referenced this issue Jun 3, 2021
When writing lists of tags, if an item was attempting to
write a list of values, only the first value would be written.
This is because only the first value was passed to the method
generating the request.  This will pass all of the values, allowing
writing the whole list of values

[Issue #136]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants