Aller au contenu principal

Event Types

Event types define custom OPC UA events that nodes can emit. They are modelled as ObjectType subclasses of ua:BaseEventType and can carry custom fields.

Event type definition
eventTypes:
- browseName: TemperatureAlarmType
subtypeOf: ua:AlarmConditionType
description: Fired when a temperature sensor exceeds its threshold.
properties:
- browseName: ThresholdValue
dataType: ua:Double
description: The configured threshold that was exceeded.
- browseName: MeasuredValue
dataType: ua:Double
description: The actual measured temperature at the time of the alarm.

Fields

Event types support the same fields as objectTypes:

FieldDescription
browseNameName of the event type (PascalCase, suffix Type by convention)
subtypeOfParent event type (default: ua:BaseEventType)
propertiesCustom fields carried by the event
componentsSub-objects attached to the event
descriptionHuman-readable description of when the event fires
isAbstracttrue for base event types not emitted directly

Common base types

Base typeUse for
ua:BaseEventTypeGeneric custom events
ua:AuditEventTypeSecurity audit trail events
ua:ConditionTypeStateful condition events
ua:AlarmConditionTypeAlarm events with active/inactive states
ua:DiscreteAlarmTypeAlarms triggered by discrete state changes
ua:LimitAlarmTypeAlarms triggered by high/low/high-high/low-low limits

Linking event types to nodes: generatedEvents

Declare which event types an object or object type can emit using generatedEvents:

Linking generatedEvents to an object type
objectTypes:
- browseName: TemperatureSensorType
components:
- browseName: Temperature
dataType: ua:Double
modellingRule: Mandatory
generatedEvents:
- TemperatureAlarmType

This emits a GeneratesEvent reference in the NodeSet, informing OPC UA clients which event types they should subscribe to on instances of this type.

📄 Full working example — event-types.model.yaml
event-types.model.yaml
# yaml-language-server: $schema=../../../../schemas/nodeset2.schema.json
#
# Living documentation example for: s45_event-types.md
# Validate: opcua-modeler generate --input event-types.model.yaml

namespaceUri: http://example.com/doc/event-types/
version: 1.0.0

eventTypes:
- browseName: TemperatureAlarmType
subtypeOf: ua:AlarmConditionType
description: Fired when a temperature sensor exceeds its threshold.
properties:
- browseName: ThresholdValue
dataType: ua:Double
description: The configured threshold that was exceeded.
- browseName: MeasuredValue
dataType: ua:Double
description: The actual measured temperature at the time of the alarm.

objectTypes:
- browseName: TemperatureSensorType
components:
- browseName: Temperature
dataType: ua:Double
modellingRule: Mandatory
generatedEvents:
- TemperatureAlarmType

# ── Full standalone example ────────────────────────────────────────────────────
# namespaceUri: http://example.com/sensor/
# version: 1.0.0

# eventTypes:
# - browseName: SensorFaultType
# subtypeOf: ua:BaseEventType
# description: |
# Emitted when a sensor self-diagnosis detects a hardware fault.
# properties:
# - browseName: FaultCode
# dataType: ua:UInt32
# - browseName: FaultDescription
# dataType: ua:LocalizedText

# objectTypes:
# - browseName: SmartSensorType
# generatedEvents:
# - SensorFaultType
# components:
# - browseName: Status
# dataType: ua:Byte
📄 Generated NodeSet2.xml — event-types.model.Nodeset2.xml
event-types.model.Nodeset2.xml
<?xml version="1.0"?>
<UANodeSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd" xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd" xmlns:ns1="http://example.com/doc/event-types/Type.xsd">
<NamespaceUris>
<Uri>http://example.com/doc/event-types/</Uri>
</NamespaceUris>
<Models>
<Model ModelUri="http://example.com/doc/event-types/" Version="1.0.0" PublicationDate="2026-05-26T09:24:00.000Z">
<RequiredModel ModelUri="http://opcfoundation.org/UA/" Version="1.05.06" PublicationDate="2025-11-08T00:00:00.000Z"/>
</Model>
</Models>
<Aliases>
<Alias Alias="Double">i=11</Alias>
<Alias Alias="GeneratesEvent">i=41</Alias>
<Alias Alias="HasComponent">i=47</Alias>
<Alias Alias="HasModellingRule">i=37</Alias>
<Alias Alias="HasProperty">i=46</Alias>
<Alias Alias="HasSubtype">i=45</Alias>
<Alias Alias="HasTypeDefinition">i=40</Alias>
</Aliases>
<!--ReferenceTypes-->
<!--ObjectTypes-->
<!--ObjectType - 1:TemperatureAlarmType {{{{ -->
<UAObjectType NodeId="ns=1;i=1000" BrowseName="1:TemperatureAlarmType">
<DisplayName>TemperatureAlarmType</DisplayName>
<Description>Fired when a temperature sensor exceeds its threshold.</Description>
<References>
<Reference ReferenceType="HasSubtype" IsForward="false">i=2915</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1001</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=1002</Reference>
</References>
</UAObjectType>
<UAVariable NodeId="ns=1;i=1001" BrowseName="1:ThresholdValue" ParentNodeId="ns=1;i=1000" AccessLevel="3" DataType="Double">
<DisplayName>ThresholdValue</DisplayName>
<Description>The configured threshold that was exceeded.</Description>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
</References>
</UAVariable>
<UAVariable NodeId="ns=1;i=1002" BrowseName="1:MeasuredValue" ParentNodeId="ns=1;i=1000" AccessLevel="3" DataType="Double">
<DisplayName>MeasuredValue</DisplayName>
<Description>The actual measured temperature at the time of the alarm.</Description>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
</References>
</UAVariable>
<!--ObjectType - 1:TemperatureAlarmType }}}}-->
<!--ObjectType - 1:TemperatureSensorType {{{{ -->
<UAObjectType NodeId="ns=1;i=1003" BrowseName="1:TemperatureSensorType">
<DisplayName>TemperatureSensorType</DisplayName>
<References>
<Reference ReferenceType="HasSubtype" IsForward="false">i=58</Reference>
<Reference ReferenceType="GeneratesEvent">ns=1;i=1000</Reference>
<Reference ReferenceType="HasComponent">ns=1;i=1004</Reference>
</References>
</UAObjectType>
<UAVariable NodeId="ns=1;i=1004" BrowseName="1:Temperature" ParentNodeId="ns=1;i=1003" AccessLevel="3" DataType="Double">
<DisplayName>Temperature</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=63</Reference>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
</References>
</UAVariable>
<!--ObjectType - 1:TemperatureSensorType }}}}-->
<!--VariableTypes-->
<!--Other Nodes-->
</UANodeSet>