Skip to content

optionsettype

Canonical path: o6.optionsettype

optionsettype

optionsettype(
    *,
    base=None,
    ns=None,
    nodeId=None,
    browseName=None,
    displayName=None,
    description=None,
    writeMask=None,
    userWriteMask=None,
    rolePermissions=None,
    accessRestrictions=0
)

Declare an OPC UA OptionSet DataType from a Python class.

An OptionSet is a bit field, not an enumeration: each member is the mask of one bit, and members compose with |. Every member is declared with o6.bitmask and written as 0x01 << n, so the source shows the bit position and the value it produces at once.

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


int(AccessLevelType.HISTORY_WRITE)                          # 8
AccessLevelType.CURRENT_READ | AccessLevelType.HISTORY_WRITE  # 9

base is the unsigned integer the OptionSet subtypes and is mandatory: it is the OptionSet's width, and nothing else in the declaration carries it. It is a keyword rather than a Python base class because the inheritance form cannot be made real.

This decorator declares the integer form of an OptionSet. The structure form — a subtype of the ns0 OptionSet with Value and ValidBits ByteStrings — is an ordinary @o6.datatype.

Parameters:

Name Type Description Default
base Any

The unsigned integer the OptionSet subtypes: o6.Byte, o6.UInt16, o6.UInt32 or o6.UInt64. Mandatory.

None
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

Raises:

Type Description
TypeError

The decorated object is not a class; base is missing or is not one of the four unsigned integers; the class has no members; a member is not exactly one set bit; a member's bit lies outside the base's width; two members carry the same mask; or a member is not declared with o6.bitmask — a bare integer, a numpy scalar and o6.enumfield are all rejected, so a mis-spelled member cannot silently drop out of the bit field.

See @o6.optionsettype — option sets.