OPC UA Connector Schemas#

OPC UA Connector Schemas

This module provides Pydantic models to define and validate configuration schemas for OPC UA devices within OpenFactory.

Key Models:#

  • OPCUAServerConfig: Configuration for the OPC UA server, including the endpoint URI and namespace URI.

  • OPCUADeviceConfig: Configuration for a device on the OPC UA server. Allows specifying the device either by a hierarchical path or a NodeId. Variables and methods are optional.

  • OPCUAConnectorSchema: Wrapper schema that encapsulates the server and device configurations.

Validation Features:#

  • Ensures that either ‘path’ or ‘node_id’ is provided for a device.

  • Variables and methods are optional, providing flexibility for different server setups.

  • Forbids unknown fields to ensure strict schema conformance.

YAML Example:#

type: opcua

server:
  uri: opc.tcp://127.0.0.1:4840/freeopcua/server/
  namespace_uri: http://examples.openfactory.local/opcua

device:
  path: Sensors/TemperatureSensor_1
  variables:
    temp: Temperature
    hum: Humidity
  methods:
    calibrate: Calibrate

See also

The runtime class of the class OPCUAConnectorSchema schema is openfactory.connectors.opcua.opcua_connector.OPCUAConnector.

class openfactory.schemas.connectors.opcua.OPCUAConnectorSchema(**data)[source]#

Bases: BaseModel

OPC UA Connector schema wrapping the server and device configuration.

The type field is a discriminator for Pydantic to select this schema.

See also

The runtime class of the class OPCUAConnectorSchema schema is openfactory.connectors.opcua.opcua_connector.OPCUAConnector.

device: OPCUADeviceConfig#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

server: OPCUAServerConfig#
type: Literal['opcua']#
class openfactory.schemas.connectors.opcua.OPCUADeviceConfig(**data)[source]#

Bases: BaseModel

OPC UA Device configuration.

identifier: Optional[str]#
identifier_type: Optional[str]#
methods: Optional[Dict[str, str]]#
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

namespace_index: Optional[int]#
node_id: Optional[str]#
path: Optional[str]#
classmethod validate_and_parse_node_id(values)[source]#

Ensure that exactly one of ‘path’ or ‘node_id’ is provided. If node_id is provided, validate its format and parse namespace_index, identifier_type, and identifier.

Return type:

dict

variables: Optional[Dict[str, str]]#
class openfactory.schemas.connectors.opcua.OPCUAServerConfig(**data)[source]#

Bases: BaseModel

OPC UA Server configuration.

model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

namespace_uri: str#
uri: str#