Sample Files

docker-compose.yml

version: "3.0"

services:
  opcua:
    image: "protocol-adapter-opcua-amd64:latest"
    environment:
      config: "/config/config-opcua.json"
    healthcheck:
      timeout: 5s
      test: exit 0
      retries: 3
      interval: 5s
    networks:
      - predix-edge-broker_net
    deploy:
      restart_policy:
        condition: on-failure

networks:
  predix-edge-broker_net:
    external: true

config.json

This sample config file will:
  • Log in using certificate authentication and simply ignore the username parameter. The password parameter will be used as the passphrase to the private key at private_key/client.key.
  • Use subscriptions to read data from the OPC-UA server.
  • Write the data to the MQTT broker on the topic out.
  • Read data from the MQTT broker on the topic in.
{
  "blocks": {
    "opcua_input": {
      "type": "opcuasubflat",
      "config": {
          "transport_addr": "opc-tcp://<OPCUA_HOST>:<OPCUA_PORT>",
          "log_level": "debug",
          "options": {
            "username": "user",
            "password": "pass",
            "client_cert_path": "/config/client.der",
            "client_private_key_path": "/config/keys/client.key"
          },
          "data_map": [
              {
                "alias": "SampleValue",
                "id": "ns=1;s=SampleValue"
              }
          ]
      }
    },
    "flat_to_timeseries": {
      "type": "flattotimeseries",
      "config": {
        "attributes": {
          "machine_type": "opcua"
        }
      }
    },
    "mqtt_sink": {
      "type": "cdpoutqueue",
      "config": {
        "transport_addr": "mqtt-tcp://<MQTT_HOST>",
        "node_ref": "out",
        "method": "pub",
        "log_level": "debug",
        "log_name": "opcua_mqtt_sink",
        "directory": "/mqtt_store",
        "max_cache_size_units": "%",
        "max_cache_size": 90
      }
    },
    "mqtt_source": {
      "type": "cdpin",
      "config": {
        "transport_addr": "mqtt-tcp://<MQTT_HOST>:<MQTT_PORT>",
        "node_ref": "in",
        "method": "sub",
        "log_name": "gateway_mqtt_source",
        "log_level": "debug"
      }
    },
    "opcua_output": {
      "type": "opcuasinkflat",
      "config": {
        "transport_addr": "opc-tcp://<OPCUA_SOURCE>:<OPCUA_PORT>",
        "log_level": "debug",
        "options": {
          "username": "user",
          "password": "pass",
          "client_cert_path": "/config/client.der",
          "client_private_key_path": "/config/keys/client.key"
        },
        "data_map": {
          "ns=1;s=SampleValue": {
            "type": "int8",
            "aliases": ["SampleValue"]
          }
        }
      }
    }
  }
 },
  "mappings": {
    "opcua_input:output": "flat_to_timeseries:input",
    "flat_to_timeseries:output": "mqtt_sink:input",
    "mqtt_source:output": "opcua_output:input"
 }
}