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

add: Number in uatypes.py #1785

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AndreasHeine
Copy link
Member

@oroulet not sure why Number is missing!? its just an abstract BaseDataType....

(env) C:\Users\Andreas\Documents\GitHub\opcua-tutorial>C:/Users/Andreas/Documents/GitHub/opcua-tutorial/env/Scripts/python.exe "c:/Users/Andreas/Documents/GitHub/opcua-tutorial/client/BaseClient copy.py"
WARNING:asyncua.client.client:Requested session timeout to be 300000ms, got 3000000ms instead
WARNING:asyncua.common.structures104:renamed 3DVector to _3DVector due to Python syntax
WARNING:asyncua.common.structures104:renamed 3DCartesianCoordinates to _3DCartesianCoordinates due to Python syntax
WARNING:asyncua.common.structures104:renamed 3DOrientation to _3DOrientation due to Python syntax
WARNING:asyncua.common.structures104:renamed 3DFrame to _3DFrame due to Python syntax
ERROR:asyncua.common.structures104:Failed to execute auto-generated code from UA datatype:

@dataclass
class CyclicProcessValueDataType:

    '''
    CyclicProcessValueDataType structure autogenerated from StructureDefinition object
    '''

    data_type = ua.NodeId.from_string('''ns=27;i=3003''')

    AnalogSignal: ua.Number = field(default_factory=ua.Number)
    Setpoint: ua.Number = field(default_factory=ua.Number)
    CycleCount: ua.Counter = ua.UInt32(0)
    IsActive: ua.Boolean = True
Traceback (most recent call last):
  File "C:\Users\Andreas\Documents\GitHub\opcua-tutorial\env\Lib\site-packages\asyncua\common\structures104.py", line 299, in _generate_object
    exec(code, env)
  File "<string>", line 4, in <module>
  File "<string>", line 12, in CyclicProcessValueDataType
AttributeError: module 'asyncua.ua' has no attribute 'Number'
Traceback (most recent call last):
  File "c:\Users\Andreas\Documents\GitHub\opcua-tutorial\client\BaseClient copy.py", line 24, in <module>
    asyncio.run(main())
  File "C:\Users\Andreas\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Andreas\AppData\Local\Programs\Python\Python311\Lib\asyncio\runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Andreas\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\Andreas\Documents\GitHub\opcua-tutorial\env\Lib\site-packages\asyncua\client\client.py", line 875, in load_data_type_definitions
    return await load_data_type_definitions(self, node, overwrite_existing=overwrite_existing)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                            nitions
  File "C:\Users\Andreas\Documents\GitHub\opcua-tutorial\env\Lib\site-packages\asyncua\common\structures104.py", line 482, in load_data_type_definitions
    env = await _generate_object(dts.name, dts.sdef, data_type=dts.data_type, log_fail=log_ex)                                            pe_definitions
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Andreas\Documents\GitHub\opcua-tutorial\env\Lib\site-packages\asyncua\common\structures104.py", line 299, in _generate_object                                                                                                                                      ject
    exec(code, env)
  File "<string>", line 4, in <module>
  File "<string>", line 12, in CyclicProcessValueDataType
AttributeError: module 'asyncua.ua' has no attribute 'Number'

@AndreasHeine
Copy link
Member Author

AndreasHeine commented Feb 5, 2025

mytestcode:

import asyncio
import logging
from asyncua import Client, ua

logging.basicConfig(level=logging.WARNING)
_logger = logging.getLogger('asyncua')


async def main():
    client = Client(url="opc.tcp://opcua.umati.app:4843", timeout=4)
    await client.connect()
    res = await client.load_data_type_definitions()
    print("--------------")
    print("Result:")
    for key, value in enumerate(res):
        print(key, value)
    print("--------------")
    await client.disconnect()


if __name__ == "__main__":
    asyncio.run(main())

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

Successfully merging this pull request may close these issues.

1 participant