Skip to content

bitmask

Canonical path: o6.bitmask

bitmask

bitmask(
    value, *, name=None, description=None, displayName=None
)

Declare one bit of an OPC UA OptionSet.

Used as the assigned value of a member in an @o6.optionsettype class body. value is the member's mask, not its bit position — write it as 0x01 << n so the source shows the bit position and the value it produces at once.

@o6.optionsettype(ns="plant", base=o6.Byte)
class AccessLevelType:
    CURRENT_READ = o6.bitmask(0x01 << 0, name="CurrentRead")
    HISTORY_WRITE = o6.bitmask(0x01 << 3, name="HistoryWrite")

This is not an alias of o6.enumfield: an enumeration member and an OptionSet bit are different things, so each decorator accepts only its own helper.

Parameters:

Name Type Description Default
value int

The member's bit mask. Exactly one bit must be set, and it must lie inside the width of the OptionSet's declared base.

required
name Optional[str]

OPC UA member name, for a UA name that is not a valid Python identifier.

None
description Optional[str]

Description of the member in the EnumDefinition.

None
displayName Optional[str]

DisplayName of the member in the EnumDefinition.

None

Returns:

Type Description
int

A value that behaves as the member's int and carries the metadata until

int

the decorator consumes it.