Skip to content

Commit 278a2b3

Browse files
AndreasHeineoroulet
authored andcommitted
changed return from list to tuple
return must be tuple of variant!
1 parent ca42c2a commit 278a2b3

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

examples/server-extension-object-as-method-argument.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
@uamethod
44
def callback(parent, in_extobj):
5-
65
out_extobj = ua.uaprotocol_auto.AxisInformation() # get new instanace of AxisInformation
76
out_extobj.EngineeringUnits = in_extobj.EngineeringUnits
87
out_extobj.EURange.Low = in_extobj.EURange.Low
@@ -12,10 +11,13 @@ def callback(parent, in_extobj):
1211
out_extobj.AxisSteps = in_extobj.AxisSteps
1312

1413
axis_info.set_value(out_extobj) #write values to variable
15-
16-
return [
17-
out_extobj
18-
]
14+
15+
ret = (
16+
ua.Variant(out_extobj, ua.VariantType.ExtensionObject),
17+
ua.Variant("test", ua.VariantType.String)
18+
)
19+
20+
return ret
1921

2022
server = Server()
2123
server.set_endpoint("opc.tcp://0.0.0.0:4840/freeopcua/server/")
@@ -40,6 +42,13 @@ def callback(parent, in_extobj):
4042
outarg_extobj.ArrayDimensions = []
4143
outarg_extobj.Description = ua.LocalizedText("Actual AxisInformation")
4244

45+
status = ua.Argument()
46+
status.Name = "Status"
47+
status.DataType = ua.NodeId(12, 0)
48+
status.ValueRank = -1
49+
status.ArrayDimensions = []
50+
status.Description = ua.LocalizedText("MSG")
51+
4352
method_parent = obj.add_object(idx, "Methods")
4453
method_node = method_parent.add_method(
4554
idx,
@@ -49,12 +58,13 @@ def callback(parent, in_extobj):
4958
inarg_extobj
5059
],
5160
[
52-
outarg_extobj
61+
outarg_extobj,
62+
status
5363
]
5464
)
5565

5666
#add a variable of type AxisInformation
5767
axis_info = obj.add_variable(idx, "AxisInformation", ua.uaprotocol_auto.AxisInformation(), varianttype=ua.VariantType.ExtensionObject)
5868

5969
if __name__ == "__main__":
60-
server.start()
70+
server.start()

0 commit comments

Comments
 (0)