Skip to content

call

Canonical path: o6.call

call

call(target: str) -> Callable[[_F], _F]
call(
    *,
    browseName: Optional[str] = None,
    nodeId: Optional[str] = None,
    inputArgs: Optional[list[Any]] = None,
    outputArgs: Optional[list[Any]] = None,
    executable: bool = True,
    userExecutable: bool = True,
    modellingRule: Optional[str] = None,
    referenceType: Optional[Any] = None,
    parent: Optional[Any] = None,
    description: Optional[str] = None,
    displayName: Optional[str] = None,
    writeMask: Optional[int] = None,
    userWriteMask: Optional[int] = None,
    rolePermissions: Optional[Mapping[Any, int]] = None,
    accessRestrictions: int = 0
) -> Any
call(
    target=None,
    /,
    *,
    browseName=None,
    nodeId=None,
    inputArgs=None,
    outputArgs=None,
    executable=True,
    userExecutable=True,
    modellingRule=None,
    referenceType=None,
    parent=None,
    description=None,
    displayName=None,
    writeMask=None,
    userWriteMask=None,
    rolePermissions=None,
    accessRestrictions=0,
)

Declare an OPC UA Method child, or bind a Python implementation to one.

With keyword arguments, o6.call(...) declares a Method instance declaration in the body of a @o6.objecttype (or, rarely, @o6.variabletype) class. The child is attached with HasComponent unless referenceType says otherwise; annotate it as Optional[o6.node.MethodNode] to make the linkage Optional.

@o6.objecttype(ns="plant")
class MachineType(ns0.objtypes.BaseObjectType):
    reset: o6.node.MethodNode = o6.hasComponent(
        o6.call(
            browseName="ns=plant;Reset",
            inputArgs=[ns0.datatypes.Argument(name="mode", dataType=o6.Int32)],
        )
    )

With a positional target, @o6.call("BrowseName") binds a Python method as the implementation of a declared or inherited Method child, on an ObjectType or on an undecorated implementation subclass. The two forms cannot be mixed: passing declaration options together with a positional target raises TypeError.

A dotted positional target is a Python member path, resolved once when the containing Object finishes, and stores the implementation with that Object on the concrete Method node:

class CellImpl(CellType):
    @o6.call("controller.reset")
    def resetController(self, mode):
        return (o6.StatusCode.GOOD,)

The path uses generated Python member names, not OPC UA BrowseNames. It overrides behaviour copied from the Method's type implementation. As with o6.read and o6.write paths, clearing a callback later does not rerun Object construction or restore an earlier callback.

Resolution happens once during Object creation. The most-derived matching type implementation is copied onto the concrete Method first. Dotted paths are then applied as containing Objects finish, replacing that concrete slot. Nested Objects finish before their containers, so an outer path that targets the same Method is applied last. The creation-time class lookup starts at the Object's concrete Python type and proceeds upwards through its base types. A subclass can override the same Python method normally, or repeat @o6.call("BrowseName") on a different Python method name. Invocation performs no class or path lookup: it calls the stored callback, or returns BAD_NOT_IMPLEMENTED.

Every Object instance owns copies of its Mandatory and selected Optional Methods, so per-instance callbacks are isolated while both cases use the same construction-time resolution. Each class may associate only one Python method with a given qualified UA BrowseName; competing @o6.call(...) decorators raise TypeError naming the class, UA Method, and both Python attributes. A decorator that matches no declared, inherited, or interface Method is rejected as an unknown UA Method. Multiple inheritance is not ambiguous: normal Python type-hierarchy order selects the nearest base implementation.

The invoking Object is part of the call, not of Method identity. Dot lookup returns a lightweight bound Method carrying the Object and Method node for that lookup, so machine.reset() works on clients and local servers alike. For a Method obtained directly by NodeId, pass the Object explicitly, as a node or a NodeId-like value:

reset = client[resetNodeId]
reset(object=machine)

Adding a reference never changes callback ownership.

Parameters:

Name Type Description Default
target str | None

BrowseName or dotted Python member path of the Method to implement. Selects the implementation form, and cannot be combined with any declaration option.

None
browseName Optional[str]

BrowseName of the declared Method node.

None
nodeId Optional[str]

NodeId of the declared Method node. Allocated in the declaring namespace when omitted.

None
inputArgs Optional[list[Any]]

InputArguments, as a list of ns0.datatypes.Argument or a declared Variable holding them.

None
outputArgs Optional[list[Any]]

OutputArguments, as a list of ns0.datatypes.Argument or a declared Variable holding them.

None
executable bool

Executable attribute of the Method node.

True
userExecutable bool

UserExecutable attribute of the Method node.

True
modellingRule Optional[str]

Modelling rule of the child, for example "Mandatory". Normally inferred from Optional[...] on the annotation instead.

None
referenceType Optional[Any]

ReferenceType linking the Method to its owner. Defaults to HasComponent.

None
parent Optional[Any]

Node or declaration that owns the Method, for a free-standing declaration outside a type body.

None
description Optional[str]

Description attribute of the Method node.

None
displayName Optional[str]

DisplayName attribute of the Method node.

None
writeMask Optional[int]

WriteMask attribute of the Method node.

None
userWriteMask Optional[int]

UserWriteMask attribute of the Method node.

None
rolePermissions Optional[Mapping[Any, int]]

RolePermissions, as a mapping of role to o6.Permission mask.

None
accessRestrictions int

AccessRestrictions attribute of the Method node.

0

Raises:

Type Description
TypeError

A positional target is combined with declaration options, or inputArgs/outputArgs are declarations that are not Variables.

See Server callbacks for the shared read/write/call precedence and reset behaviour.