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

DINT in binary "style" #14

Open
maveric opened this issue Dec 19, 2023 · 0 comments
Open

DINT in binary "style" #14

maveric opened this issue Dec 19, 2023 · 0 comments

Comments

@maveric
Copy link

maveric commented Dec 19, 2023

We use UDTs that have DINTs formatted in binary style. It's stupid, and I'll be changing the UDTs going forward because it's also causing issues for my other forms of automation as well.

However, the library expects a dint to be a base 10 number (which makes sense) but that's not what I get.

My code:

import l5x

prj = l5x.Project('FILENAME.L5X')

# for tag in prj.controller.tags:
#     print(tag)
# print(prj.controller.tags.names)
names = prj.controller.tags.names

for name in names:
    print(name)
    print(prj.controller.tags[name].data_type)
    print(prj.controller.tags[name].description)
    print(prj.controller.tags[name].value)

with output:

Traceback (most recent call last):
  File "c:\VMs\SharedFilesBetweenVMs\l5x testing\test.py", line 15, in <module>
    print(prj.controller.tags[name].value)
  File "C:\Users\Wes\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\l5x\tag.py", line 31, in __get__
    return getattr(tag.data, self.attr)
  File "C:\Users\Wes\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\l5x\tag.py", line 519, in __get__
    return dict(zip(member_names, [struct[m].value for m in member_names]))
  File "C:\Users\Wes\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\l5x\tag.py", line 519, in <listcomp>
    return dict(zip(member_names, [struct[m].value for m in member_names]))
  File "C:\Users\Wes\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\l5x\tag.py", line 372, in __get__
    return int(instance.element.attrib['Value'])
ValueError: invalid literal for int() with base 10: '2#0000_0001_1110_0000_0000_1010_0000_0000'
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

1 participant