-
Notifications
You must be signed in to change notification settings - Fork 669
Description
I am adding a method to an object type (myType.add_method()). In the clients (I am using the Prosys Browser and UaExpert clients) I can see the object type with the method and the input/output arguments.
When I create an object instance, in the clients I can see the object instance with the method. However, the input/output arguments are missing, and I am not able to call the method with input arguments. The issue applies to both clients.
`@uamethod
def method_handler(parent, input):
print("In handler")
return True
inargs = []
outargs = []
inarg = ua.Argument()
inarg.Name = "TestMethod"
inarg.DataType = ua.NodeId(ua.ObjectIds.String)
inarg.ValueRank = -1
inarg.ArrayDimensions = []
inarg.Description = ua.LocalizedText("Test method input")
inargs.append(inarg)
outarg = ua.Argument()
outarg.Name = "Result"
outarg.DataType = ua.NodeId(ua.ObjectIds.Boolean)
outarg.ValueRank = -1
outarg.ArrayDimensions = []
outarg.Description = ua.LocalizedText("Test method result")
outargs.append(outarg)
myType.add_method(
2,
"TestMethod",
method_handler,
inargs,
outargs,
).set_modelling_rule(True)
myInstance = objects.add_object(2, "myObjectInstance", myType.nodeid)`
However, when I add a method to an object instance (myInstance.add_method()), everything works. I can see the input/output arguments.
`@uamethod
def method_handler(parent, input):
print("In handler")
return True
myInstance = objects.add_object(2, "myObjectInstance", myType.nodeid)
inargs = []
outargs = []
inarg = ua.Argument()
inarg.Name = "TestMethod"
inarg.DataType = ua.NodeId(ua.ObjectIds.String)
inarg.ValueRank = -1
inarg.ArrayDimensions = []
inarg.Description = ua.LocalizedText("Test method input")
inargs.append(inarg)
outarg = ua.Argument()
outarg.Name = "Result"
outarg.DataType = ua.NodeId(ua.ObjectIds.Boolean)
outarg.ValueRank = -1
outarg.ArrayDimensions = []
outarg.Description = ua.LocalizedText("Test method result")
outargs.append(outarg)
myInstance.add_method(
2,
"TestMethod",
method_handler,
inargs,
outargs,
).set_modelling_rule(True)`
Any ideas on what I am doing wrong? In the examples the methods are added to object instances.