(parent, nodeid, qname, callback, inputs, outputs)
| 308 | |
| 309 | |
| 310 | def _create_method(parent, nodeid, qname, callback, inputs, outputs): |
| 311 | addnode = ua.AddNodesItem() |
| 312 | addnode.RequestedNewNodeId = nodeid |
| 313 | addnode.BrowseName = qname |
| 314 | addnode.NodeClass = ua.NodeClass.Method |
| 315 | addnode.ParentNodeId = parent.nodeid |
| 316 | addnode.ReferenceTypeId = ua.NodeId(ua.ObjectIds.HasComponent) |
| 317 | #node.TypeDefinition = ua.NodeId(ua.ObjectIds.BaseObjectType) |
| 318 | attrs = ua.MethodAttributes() |
| 319 | attrs.Description = ua.LocalizedText(qname.Name) |
| 320 | attrs.DisplayName = ua.LocalizedText(qname.Name) |
| 321 | attrs.WriteMask = 0 |
| 322 | attrs.UserWriteMask = 0 |
| 323 | attrs.Executable = True |
| 324 | attrs.UserExecutable = True |
| 325 | addnode.NodeAttributes = attrs |
| 326 | results = parent.server.add_nodes([addnode]) |
| 327 | results[0].StatusCode.check() |
| 328 | method = node.Node(parent.server, results[0].AddedNodeId) |
| 329 | if inputs: |
| 330 | create_property(method, |
| 331 | ua.NodeId(namespaceidx=method.nodeid.NamespaceIndex), |
| 332 | ua.QualifiedName("InputArguments", 0), |
| 333 | [_vtype_to_argument(vtype) for vtype in inputs], |
| 334 | varianttype=ua.VariantType.ExtensionObject, |
| 335 | datatype=ua.ObjectIds.Argument) |
| 336 | if outputs: |
| 337 | create_property(method, |
| 338 | ua.NodeId(namespaceidx=method.nodeid.NamespaceIndex), |
| 339 | ua.QualifiedName("OutputArguments", 0), |
| 340 | [_vtype_to_argument(vtype) for vtype in outputs], |
| 341 | varianttype=ua.VariantType.ExtensionObject, |
| 342 | datatype=ua.ObjectIds.Argument) |
| 343 | if hasattr(parent.server, "add_method_callback"): |
| 344 | parent.server.add_method_callback(method.nodeid, callback) |
| 345 | return results[0].AddedNodeId |
| 346 | |
| 347 | |
| 348 | def _vtype_to_argument(vtype): |
no test coverage detected