Aller au contenu principal

Interfaces

Defining an Interface

An interface in OPC UA Modeler is defined using the interfaceTypes keyword. Each interface can have multiple components, each with a browseName, dataType, and modellingRule.

Here is an example of defining an interface called IVendorPlateType:

interfaceTypes:
- browseName: IVendorPlateType
components:
- browseName: Manufacturer
dataType: ua:LocalizedText
modellingRule: Mandatory
- browseName: SerialNumber
dataType: ua:String
modellingRule: Mandatory
- browseName: Revision
dataType: ua:LocalizedText
modellingRule: Optional

Implementing an Interface at the Object Type Level

To implement an interface at the object type level, you use the implementedInterfaces keyword within the objectTypes definition.

Here is an example of defining an object type called MySensorType that implements the IVendorPlateType interface:

objectTypes:
- browseName: MySensorType
subtypeOf: di:ComponentType
implementedInterfaces:
- browseName: IVendorPlateType

Implementing an Interface at the Component Level

Interfaces can also be implemented at the component level, meaning that the component itself implements the interface. This is done using the implementedInterfaces keyword within the components definition.

Here is an example of defining an object type called MySensorType with a component called Identification that implements the IVendorPlateType interface:

objectTypes:
- browseName: MySensorType
subtypeOf: di:ComponentType
components:
- browseName: Identification
typeDefinition: ua:FolderType
implementedInterfaces:
- browseName: IVendorPlateType

Promoting Optional Members to Mandatory at the interface implementation level

For advanced use, it is possible to promote some optional members of the original interface to mandatory. This is done using the promotedToMandatory keyword within the implementedInterfaces definition.

Here is an example of promoting the Revision member to mandatory:

objectTypes:
- browseName: MySensorType
subtypeOf: di:ComponentType
components:
- browseName: Identification
typeDefinition: ua:FolderType
implementedInterfaces:
- browseName: IVendorPlateType
promotedToMandatory:
- Revision

implementing an interface from another namespace

Obviously, you can also implement an interface that has been defined into a other namespace by prefixing the browseName with the namespace alias.

namespaces:
- di # import the device integration namespace
objectTypes:
- browseName: MySensorType
subtypeOf: di:ComponentType
implementedInterfaces:
# implement the IVendorPlateType interface from the di namespace
- browseName: di:IVendorNameplateType
# and turn the optional property of IVendorPlateType into mandatory in
# our implementation
promitedToMandatory:
- di:Revision
- di:Manufacturer
- di:SerialNumber