============== Classic Events ============== Classic events and auditing require the :doc:`full profile <../profiles>`. A client receives events through an event monitored item. The server supports transient classic OPC UA Events through the same Subscription and Publish pipeline used for data changes. This is distinct from PubSub Event DataSets and does not yet include retained Conditions, Alarms, or historical event storage. Automatic Events ################ Events are enabled by default. The selected server audit profile is shown below. Audit events contain the common ``ActionTimeStamp``, ``Status``, ``ServerId``, ``ClientAuditEntryId``, and ``ClientUserId`` fields in addition to the type-specific fields in the matrix. .. list-table:: Service-to-audit-event coverage :header-rows: 1 :widths: 18 24 22 36 * - Service or path - Event type - Emission - Type-specific fields * - OpenSecureChannel - ``AuditOpenSecureChannelEventType`` - Success and rejection; one per request - ``SecureChannelId``, ``ClientCertificate``, ``ClientCertificateThumbprint``, ``RequestType``, ``SecurityPolicyUri``, ``SecurityMode``, ``RequestedLifetime``, and optional ``CertificateErrorEventId`` * - CreateSession - ``AuditCreateSessionEventType`` - Success and rejection; one per request - ``SessionId``, ``SecureChannelId``, ``ClientCertificate``, ``ClientCertificateThumbprint``, and ``RevisedSessionTimeout`` * - ActivateSession - ``AuditActivateSessionEventType`` - Success and rejection; one per request - ``SessionId``, empty ``ClientSoftwareCertificates``, redacted ``UserIdentityToken``, and ``SecureChannelId`` * - Invalid application or user certificate parsing - ``AuditCertificateInvalidEventType`` - Failure only; one per invalid certificate - ``Certificate`` * - Write - ``AuditWriteUpdateEventType`` - Success and failure; one per requested write after session validation - ``AttributeId``, ``IndexRange``, unavailable ``OldValue`` as Null, and requested ``NewValue`` * - Call - ``AuditUpdateMethodEventType`` - Success and failure; one per requested Method call after session validation - ``MethodId`` and ``InputArguments`` * - AddNodes - ``AuditAddNodesEventType`` - One per service request after session validation; ``Status`` is true only when every operation succeeds - ``NodesToAdd`` * - DeleteNodes - ``AuditDeleteNodesEventType`` - One per service request after session validation; ``Status`` is true only when every operation succeeds - ``NodesToDelete`` * - AddReferences - ``AuditAddReferencesEventType`` - One per service request after session validation; ``Status`` is true only when every operation succeeds - ``ReferencesToAdd`` * - DeleteReferences - ``AuditDeleteReferencesEventType`` - One per service request after session validation; ``Status`` is true only when every operation succeeds - ``ReferencesToDelete`` Set ``events.enabled`` to ``false`` to disable every Event. Set ``events.auditing`` to ``false`` to disable only Audit Events. ``Server.Auditing`` (``i=2994``) is true only when both options are true, so it reports whether this automatic audit profile is active. Activation Audit Events identify an authenticated user as ``anonymous``, the username, ``x509``, or ``issued``. The ``UserIdentityToken`` field is always a Null ExtensionObject and ``ClientSoftwareCertificates`` is always empty; passwords, issued-token contents, and user certificates are never copied into these fields. Application certificates occur only in the standard certificate fields of OpenSecureChannel, CreateSession, and certificate-validation Audit Events. The OPC UA Audit types require Write ``NewValue`` and Call ``InputArguments``, so these application values are included. The server cannot infer whether arbitrary application values are confidential; applications must not use audited writable attributes or Method arguments to carry secrets that must not be recorded. Write and Method Audit Events use the affected Node as ``SourceNode``. Connection, Session, certificate, and node-management Audit Events use the Server Object. Failure messages explicitly report that the operation failed. Outside the audit profile, Services emit ``SystemStatusChangeEventType`` on startup and graceful shutdown and ``GeneralModelChangeEventType`` for each successful AddNodes, DeleteNodes, AddReferences, or DeleteReferences operation. The start Event occurs before a Client can establish a live Subscription, so it becomes observable only when event history is added. During graceful shutdown, the server sends the stop Event to clients that already have an outstanding Publish request. Application Events ################## :ref:`server:emitEvent` emits a transient Event. ``EventType`` must be a known ObjectType derived from ``BaseEventType``, and ``SourceNode`` must exist. The Server Object is the default source and root notifier. The server supplies defaults for ``EventId``, ``SourceNode``, ``SourceName``, ``Time``, ``Message``, and ``Severity`` and always supplies ``EventType`` and ``ReceiveTime``. An application may override those defaults and add custom fields through ``Fields``. A supplied ``EventId`` must be a non-empty ByteString. ``Time``, ``SourceName``, ``Message``, and ``Severity`` use the DateTime, String, LocalizedText, and UInt16 representations respectively. Custom field values use the normal Lua Variant representation. A field key is a BrowsePath whose elements are separated by ``/``. Each element has ``NamespaceIndex:Name`` form. For example, ``0:Machine/0:State`` selects two namespace 0 elements. The ``/`` character is reserved as the path separator. Call :ref:`server:validateEvent` during development to verify that every ``Fields`` entry is declared by the selected EventType or one of its supertypes and that its Variant type and rank match that declaration. Validation is explicit because checking the complete Event on every emission adds runtime overhead. ``emitEvent`` does not call it. The method returns the supplied or generated EventId. Emit an Application Event ------------------------- This example uses ``editor:addEventType`` to define a concrete ``TemperatureEventType``. The method derives it from ``BaseEventType`` by default. The example then declares a ``Temperature`` field and emits an instance of that type. Each entry in ``Fields`` is a :ref:`Variant ` whose key matches the BrowseName of a field declared by the EventType: .. literalinclude:: ../examples/server/server_emit_event.lua :language: lua :lines: 6-46 :example:`Full source ` Call the application function from device logic, a timer, or a server callback when the occurrence actually happens. Because the Event is transient, a Client receives it only if its Event MonitoredItem is active when ``emitEvent`` is called. ``emitEvent`` returns the supplied or generated EventId. Event Routing ############# Object creation establishes the normal address-space hierarchy with ``Organizes`` or ``HasComponent``. It does not infer Event routes. Applications create those routes explicitly with :luamethod:`object:addReference`, :luamethod:`editor:addReference`, or the AddReferences Service. Use ``HasEventSource`` between an event source and its notifier, and ``HasNotifier`` between notifier Objects. An Event is delivered to its source when that Node has the ``ua.EventNotifierType.SubscribeToEvents`` bit in ``EventNotifier``. It is also propagated through inverse ``HasEventSource`` and ``HasNotifier`` References, with duplicate notifiers removed. The Server Object is always included as the root notifier. Reference changes take effect on the next Event because the route is traversed at emission time; no route cache is retained. Clients monitor the notifier's ``EventNotifier`` Attribute and provide an EventFilter. See :ref:`client_subscriptions` for a complete Lua client example. Current Limits ############## Event MonitoredItems on View nodes are not supported because View Event aggregation is not implemented. Creating such a MonitoredItem returns ``BadNotSupported``. Monitor an Object with the ``SubscribeToEvents`` bit set instead. WhereClause operands may use ``SimpleAttributeOperand`` or ``AttributeOperand``. An ``AttributeOperand`` RelativePath honors each element's ReferenceTypeId, direction, and IncludeSubtypes setting. The server supports ordered SelectClauses. The current WhereClause evaluator supports all basic FilterOperators, including typed conversions, three-valued NULL logic, ``Like``, ``Cast``, and the bitwise operators. It also supports ``OfType`` for Events. The complex Query operators ``InView`` and ``RelatedTo`` remain unsupported and cause MonitoredItem creation to fail. See :ref:`FilterOperator ` for the complete standard operator list, operand counts, descriptions, and current support status. Event queues are bounded and honor ``DiscardOldest``. If an Event is lost, the affected MonitoredItem receives an ``EventQueueOverflowEventType`` control Event in addition to its configured queue size. The control Event bypasses the user's WhereClause and is never routed to unrelated MonitoredItems. For Event MonitoredItems, a requested queue size of zero uses ``subscriptions.defaultEventQueueSize``; this defaults to ``subscriptions.maxQueueSize``. A request of ``MaxUInt32`` uses the maximum. Queued data changes and Events are selected in deterministic arrival order. ``MaxNotificationsPerPublish`` counts the individual data changes and Events, and ``MoreNotifications`` remains set while reportable entries are queued. Event notification messages use the common acknowledgement, retransmission, and Republish path. ConditionRefresh, Alarms, and historical Events remain planned work.