Classic Events
Classic events and auditing require the full profile. 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.
Service or path |
Event type |
Emission |
Type-specific fields |
|---|---|---|---|
OpenSecureChannel |
|
Success and rejection; one per request |
|
CreateSession |
|
Success and rejection; one per request |
|
ActivateSession |
|
Success and rejection; one per request |
|
Invalid application or user certificate parsing |
|
Failure only; one per invalid certificate |
|
Write |
|
Success and failure; one per requested write after session validation |
|
Call |
|
Success and failure; one per requested Method call after session validation |
|
AddNodes |
|
One per service request after session validation; |
|
DeleteNodes |
|
One per service request after session validation; |
|
AddReferences |
|
One per service request after session validation; |
|
DeleteReferences |
|
One per service request after session validation; |
|
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
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 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
Variant whose key matches the BrowseName of a field
declared by the EventType:
-- Define a concrete application EventType derived from BaseEventType.
local editor = server.model:edit()
local temperatureEventType = editor:addEventType("TemperatureEventType")
temperatureEventType:addProperty("Temperature", {
Type = ua.VariantType.Double,
Value = 0,
})
-- Keep containment and Event routing explicit and independent.
local plant = editor:addObject("Plant")
local temperatureSource = plant:addObject("TemperatureSource")
plant.Attrs.EventNotifier = ua.EventNotifierType.SubscribeToEvents
temperatureSource.Attrs.EventNotifier = ua.EventNotifierType.SubscribeToEvents
plant:addReference(temperatureSource, ua.ReferenceType.HasEventSource)
editor:save()
server:run()
-- Call this function when the corresponding application condition occurs.
local function emitTemperatureEvent(temperature)
local event = {
EventType = temperatureEventType.Attrs.NodeId,
SourceNode = temperatureSource.Attrs.NodeId,
SourceName = "Temperature monitor",
Message = {
Text = string.format("Temperature is %.1f C", temperature),
},
Severity = temperature >= 80 and 700 or 200,
Fields = {
["0:Temperature"] = {
Type = ua.VariantType.Double,
Value = temperature,
},
},
}
-- Early validation allows to catch programming errors before the event is emitted to clients,
-- which may be harder to debug if the event rejected on later stages of the event processing pipeline.
server:validateEvent(event)
-- Emit the event to all subscribed clients.
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 object:addReference,
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 Data Change and Event 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
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.