Giter Club home page Giter Club logo

Comments (4)

schroeder- avatar schroeder- commented on August 23, 2024

In OPC UA there are no tuples. But OPC UA allows multiple return values of a Method. So we unpack a tupple as return values. And if there is only one return value, we return the value instead an array of return values.

from opcua-asyncio.

tobiasbrinker avatar tobiasbrinker commented on August 23, 2024

Ok, but why is the behaviour for lists different? For example the same code with a list instead of a tuple:

@uamethod
def put_into_list(parent, input: str) -> list[str]:
    return [input]
    
def test_list_behaviour(client, idx):
    expected_result = ["test"]
    res = client.nodes.objects.call_method(f"{idx}:put_into_list", "test")
    assert res == expected_result

# Passed: ["test"] == ["test"]

This works as expected, returning a list with a single element, but a tuple is unpacked into a single element.

from opcua-asyncio.

schroeder- avatar schroeder- commented on August 23, 2024

Because in OPC UA you can return an OPC UA Array which is a list or chained lists, so there is no reason to convert it.

from opcua-asyncio.

tobiasbrinker avatar tobiasbrinker commented on August 23, 2024

Ok, this was not was I was expecting. So the expected behaviour is?

Input: Tuple with 1 item -> Output: Item (without List or Tuple)
Input: List with 1 item -> Output: List with 1 item

Input: Tuple with 2 items -> Output: List with 2 items
Input: List with 2 items -> Output: List with 2 items

from opcua-asyncio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.