Skip to content

enumtype

Canonical path: o6.enumtype

enumtype

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

Declare an OPC UA enumeration DataType from a Python class.

The decorated class is a real enum.IntEnum afterwards, so its members are usable wherever an integer is expected and as the annotation that gives a struct field or Variable that DataType. Bare integer class attributes are enough; o6.enumfield adds per-member OPC UA metadata and mixes freely with plain values. Duplicate numeric values are rejected because they are ambiguous on the wire.

Python inheritance is the HasSubtype chain. An isAbstract=True enum has no members and no wire representation: it is a type-system placeholder that concrete enums share, and a Variable typed with it accepts any of its concrete subtypes.

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 DataType 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[bool]

WriteMask attribute of the node.

None
userWriteMask Optional[bool]

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 enumeration abstract, leaving it without members and without a wire representation.

False

Raises:

Type Description
TypeError

The decorated object is not a class, a concrete enumeration has no members, or two members share a numeric value.

See @o6.enumtype — enumerations.