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.

A bit field belongs in @o6.optionsettype, whose members are masks; a member declared with o6.bitmask is rejected here.

A value a non-conforming peer sends that the declaration does not carry still decodes, so one out-of-specification field does not fail the read that contains it. It is integer-equal to what arrived and re-encodes unchanged in binary and JSON; it has no member name, and name reads as None. XML spells an enumeration as Name_Value, so that one encoding has nothing to write for it and raises.

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 PermissionType 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, two members share a numeric value, or a member is declared with o6.bitmask.

See @o6.enumtype — enumerations.