Sample Files

docker-compose.yml
version: "3.0"
 
services:
  modbus:
    image: "dtr.predix.io/predix-edge/protocol-adapter-modbus:amd64-1.1.0"
    environment:
      config: "/config/config-modbus.json"
    deploy: 
      restart_policy:
        condition: on-failure
        delay: 5s
        max_attempts: 5
        window: 30s
    networks:
      - predix-edge-broker_net
       
networks:
  predix-edge-broker_net:
    external: true

config.json

This sample configuration file as written will:
  • read from a Modbus TCP connection at the configured host and port, polling every 1000 milliseconds, assuming the Modbus source is configured for reverse byte order within two-byte words.
  • write to a Modbus RTU connection mounted as a file into the container, with the order of two-byte words inside 32-byte chunks reversed.
  • write the data to the MQTT broker on the topic out.
  • read data from the MQTT broker on the topic in.
{
  "blocks": {
    "modbus_input": {
      "type": "modbusflat",
      "config": {
        "transport_addr": "modbus-tcp://<MODBUS_TCP_HOST>:<MODBUS_TCP_PORT>",
        "log_level": "debug",
        "interval": 1000,
        "default_byte_order": false,
        "data_map": [
          {
            "alias": "modbus_byte",
            "reg_type": "input",
            "address": 0,
            "type": "int8"
          },
          {
            "alias": "modbus_bool",
            "reg_type": "holding",
            "address": 4,
            "type": "bool",
            "bit_offset": 9
          }
        ]
      }
    },
    "flat_to_timeseries": {
      "type": "flattotimeseries",
      "config": {
        "attributes": {
          "machine_type": "modbus"
        }
      }
    },
    "mqtt_sink": {
      "type": "cdpoutqueue",
      "config": {
        "transport_addr": "mqtt-tcp://<MQTT_HOST>:<MQTT_PORT>",
        "node_ref": "predix_historian",
        "method": "pub",
        "log_level": "debug",
        "directory": "/mqtt_store",
        "max_cache_size_units": "%",
        "max_cache_size": 90
      }
    },
    "modbus_output": {
      "type": "modbussinkflat",
      "config": {
        "transport_addr": "modbus-rtu://<PATH_TO_DEVICE_FILE>",
        "log_level": "debug",
        "interval": 1000,
        "first_16_bit_low": false,
        "data_map": [
          {
            "aliases": [
              "modbus_byte"
            ],
            "address": 0,
            "type": "int8"
          },
          {
            "aliases": [
              "modbus_string"
            ],
            "address": 4,
            "type": "string",
            "count": 10
          }
        ]
      }
    },
    "mqtt_source": {
      "type": "cdpin",
      "config": {
        "transport_addr": "mqtt-tcp://<MQTT_HOST>:<MQTT_PORT>",
        "node_ref": "in",
        "method": "sub",
        "log_level": "debug"
      }
    }
  },
  "mappings": {
    "modbus_input:output": "flat_to_timeseries:input",
    "flat_to_timeseries:output": "mqtt_sink:input",
    "mqtt_output:output": "modbus_output:input"
  }
}