Method - no vars? (.set_modelling_rule(True)) - auto creation of nodeid's #938
Unanswered
dannyolsen
asked this question in
Q&A
Replies: 1 comment 8 replies
-
The InputArguments and OutputArguments are missing the modeling rule mandatory, so they aren't instantiated. |
Beta Was this translation helpful? Give feedback.
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
can anyone explain why the variables on the one method shows and the other one not? And is it even relevant?
We need the node id to create a meaning name by itself - like "ns=2;s=mydevice.door.mymethod". My best guess is that this can be done with the ".set_modelling_rule(True)" function.
This is just a very slight modification of the server_example.py from the repo.
Any help appreciated - thanks!
I have attached the the code at the boottom of this post.
What UAexpert shows this
This shows the code that i create the two methods.
#CODE server_example.py
import asyncio
import copy
import logging
from datetime import datetime
import time
from math import sin
from asyncua import ua, uamethod, Server
class SubHandler(object):
method to be exposed through server
def func(parent, variant):
ret = False
if variant.Value % 2 == 0:
ret = True
return [ua.Variant(ret, ua.VariantType.Boolean)]
method to be exposed through server
uses a decorator to automatically convert to and from variants
@uamethod
def multiply(parent, x, y):
print("multiply method call with parameters: ", x, y)
return x * y
async def main():
# optional: setup logging
#logger = logging.getLogger("asyncua.address_space")
# logger.setLevel(logging.DEBUG)
#logger = logging.getLogger("asyncua.internal_server")
# logger.setLevel(logging.DEBUG)
#logger = logging.getLogger("asyncua.binary_server_asyncio")
# logger.setLevel(logging.DEBUG)
#logger = logging.getLogger("asyncua.uaprocessor")
# logger.setLevel(logging.DEBUG)
if name == "main":
logging.basicConfig(level=logging.INFO)
asyncio.run(main())
Beta Was this translation helpful? Give feedback.
All reactions