Commit 0702ad2f authored by Alexander Schrode's avatar Alexander Schrode Committed by oroulet

Add modeling rule for method arguments

parent 137740f8
......@@ -400,7 +400,7 @@ async def _create_method(parent, nodeid, qname, callback, inputs, outputs):
results[0].StatusCode.check()
method = make_node(parent.server, results[0].AddedNodeId)
if inputs:
await create_property(
prob = await create_property(
method,
ua.NodeId(NamespaceIndex=method.nodeid.NamespaceIndex),
ua.QualifiedName("InputArguments", 0),
......@@ -408,8 +408,9 @@ async def _create_method(parent, nodeid, qname, callback, inputs, outputs):
varianttype=ua.VariantType.ExtensionObject,
datatype=ua.ObjectIds.Argument
)
await prob.set_modelling_rule(True)
if outputs:
await create_property(
prob = await create_property(
method,
ua.NodeId(NamespaceIndex=method.nodeid.NamespaceIndex),
ua.QualifiedName("OutputArguments", 0),
......@@ -417,6 +418,7 @@ async def _create_method(parent, nodeid, qname, callback, inputs, outputs):
varianttype=ua.VariantType.ExtensionObject,
datatype=ua.ObjectIds.Argument
)
await prob.set_modelling_rule(True)
if hasattr(parent.server, "add_method_callback"):
parent.server.add_method_callback(method.nodeid, callback)
return results[0].AddedNodeId
......
......@@ -1534,3 +1534,18 @@ async def test_sub_class(opc):
val = await var.read_value()
assert val == struct_with_sub
assert val.DataSetSource == struct_with_sub.DataSetSource
async def test_object_meth_args(opc):
# Test if InputArguments and OutputArguments are create in an instantiated object
base_otype = opc.opc.get_node(ua.ObjectIds.BaseObjectType)
custom_otype = await base_otype.add_object_type(2, 'ObjectWithMethodTestArgs')
@uamethod
def func(_parent, value):
return value * 2
meth = await custom_otype.add_method(ua.NodeId('ObjectWithMethodTestArgsTest', 2), ua.QualifiedName('ObjectWithMethodTestArgsTest', 2), func, [ua.VariantType.Int64], [ua.VariantType.Int64])
await meth.set_modelling_rule(True)
obj = await opc.opc.nodes.objects.add_object(2, 'ObjectWithMethodsArgs', custom_otype)
await obj.get_child(['2:ObjectWithMethodTestArgsTest', 'InputArguments'])
await obj.get_child(['2:ObjectWithMethodTestArgsTest', 'OutputArguments'])
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment