Skip to content

Event

Canonical path: o6.server.Event

Root shortcut: o6.Event

Event dataclass

Bases: MutableMapping[QualifiedName | str, Any]

Reusable server-side event draft.

Construct with o6.Event(server, ...) and trigger as often as needed. Construction does not access the address space or emit an event. As a mutable mapping of event fields, it supports dict(event), len(event), del event[key], and iteration. The attributes below can be reassigned between triggers.

Field keys are event-filter path strings such as "/BatchId", or QualifiedName values when a namespace matters.

When eventType is None, each trigger() resolves it from eventInstance's type if supplied, otherwise from source's declared GeneratesEvent target. The draft itself keeps eventType=None.

See Events.

Attributes

eventType class-attribute instance-attribute

eventType = None

source class-attribute instance-attribute

source = field(default_factory=lambda: server)

message class-attribute instance-attribute

message = ''

severity class-attribute instance-attribute

severity = 1

fields class-attribute instance-attribute

fields = field(default_factory=dict)

eventInstance class-attribute instance-attribute

eventInstance = None

Functions

__init__

__init__(
    _server,
    eventType=None,
    source=(lambda: ns0.instances.server)(),
    message="",
    severity=1,
    fields=dict(),
    eventInstance=None,
)

__post_init__

__post_init__()

__getitem__

__getitem__(key)

Read one explicit event field.

__setitem__

__setitem__(key, value)

Set one explicit event field.

__delitem__

__delitem__(key)

Remove one explicit event field.

__iter__

__iter__()

Iterate the explicit event field keys.

__len__

__len__()

The number of explicit event fields.

trigger

trigger()

Emit this event once and return its EventId.

Field values are resolved from fields first, then from eventInstance, then from the BaseEventType defaults.

Returns:

Type Description
MaybeAwaitable[bytes]

The generated 16-byte EventId.

Raises:

Type Description
ValueError

severity is outside the OPC UA range 1..1000; or neither eventType nor eventInstance is provided and the source has no type definition or more than one GeneratesEvent target on its declared type.

TypeError

eventInstance is not an event Object instance on this server.

StatusCodeError

Reading the instance or emitting the event failed.