Skip to content

objecttype

Canonical path: o6.objecttype

objecttype

objecttype(
    *,
    ns=None,
    nodeId=None,
    browseName=None,
    displayName=None,
    description=None,
    writeMask=None,
    userWriteMask=None,
    rolePermissions=None,
    accessRestrictions=0,
    isAbstract=False,
    interfaces=None
)

Declare an OPC UA ObjectType from a Python class.

The Python base class becomes the HasSubtype parent, so class MachineType(ns0.objtypes.BaseObjectType) declares a subtype of BaseObjectType. Annotated class attributes assigned with a reference helper such as o6.hasComponent become instance declarations of the type, Methods are declared with o6.call, and Optional[T] on the annotation makes the child Optional rather than Mandatory.

Calling the decorated class afterwards either creates a live server node or another declaration, depending on the server and parent arguments of the call. Behaviour is added separately, either by subclassing the declared type or with Server.implement.

Parameters:

Name Type Description Default
ns Optional[str]

Shortname of the declaring namespace. Inferred from nodeId when that carries a namespace, otherwise required.

None
nodeId Optional[str]

NodeId of the ObjectType node. Allocated in the declaring namespace when omitted.

None
browseName Optional[str]

BrowseName of the node. Defaults to the class name.

None
displayName Optional[str]

DisplayName of the node. Defaults to the BrowseName.

None
description Optional[str]

Description attribute. Defaults to the class docstring.

None
writeMask Optional[int]

WriteMask attribute of the node.

None
userWriteMask Optional[int]

UserWriteMask attribute of the node.

None
rolePermissions Optional[Mapping[Any, int]]

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

None
accessRestrictions int

AccessRestrictions attribute of the node.

0
isAbstract bool

Declare the type abstract, so it cannot be instantiated.

False
interfaces Optional[list[Any]]

OPC UA InterfaceTypes this type implements. They become HasInterface references and do not enter the Python MRO; their Mandatory members are instantiated by the normal OPC UA rules.

None

Raises:

Type Description
TypeError

The decorated object is not a class, or an entry of interfaces is not an InterfaceType.

See @o6.objecttype — typed Objects.