[Question] uamethod no parent #1496
-
Good afternoon everyone; opcua-asyncio/asyncua/common/methods.py Lines 73 to 90 in e9978c1 When the fuction decorated with it is actually a method and the class is already the parent of the "function" I see little use in having it being part of every of our server methods? If I understand it correctly a method currently can't look like this, if I want to decorate it with uamethod, even if it' not making use of 'parent'? from asyncua.common import uamethod
from asyncua.sync import Server
class PinController:
def __init__(self, some_server: Server):
self.server = some_server
server.link_method(
server.get_node(ua.NodeId.from_string("ns=1;i=42")), uamethod(self.on_set_output)
)
def on_set_output(self, pin: ua.UInt32, value: ua.Boolean) -> None:
# set the pin to something useful
pass |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
ua methods are always part of an opc ua objecttype so the always have a parent! |
Beta Was this translation helpful? Give feedback.
-
you probably need to create a own Pincontrollertype, instantiate a instance of that type and bind the instances methods to class functions |
Beta Was this translation helpful? Give feedback.
-
Maybe my example was misleading. If I were to implement an OPC UA Server based on PinController, and wanted the method Lets see. The Class above could have a reference to a server like this and link methods accordingly. I've updated the example above; maybe my case became somewhat clearer. Sorry for the confusion. |
Beta Was this translation helpful? Give feedback.
-
Just make a wrapper function
|
Beta Was this translation helpful? Give feedback.
Just make a wrapper function