[
  {
    "id": "tab-modpackqt-demo",
    "type": "tab",
    "label": "ModPackQT — Modbus + Bytes Demo",
    "info": "End-to-end demo combining node-red-contrib-modbus-modpackqt with node-red-contrib-bytes-modpackqt.\n\nMake sure BOTH palettes are installed:\n  npm install node-red-contrib-modbus-modpackqt node-red-contrib-bytes-modpackqt\n\nUpdate Target Host on the master nodes to your real PLC, OR just deploy as-is — the bottom slave-loop section works without any external device.\n\nFlows included:\n  1) Read float32 temperature from a PLC, decode, debug\n  2) Inject a setpoint, encode float32, write to PLC\n  3) Read a 16-bit status register, expand to 8 booleans\n  4) Read an 8-register UTF-8 serial number string\n  5) Embedded slave loop — encode int32 → write to local slave → read back → decode\n  6) Passive Modbus traffic monitor (free, no PLC needed)"
  },
  {
    "id": "config-modpackqt-runtime",
    "type": "modpackqt-config",
    "name": "ModPackQT runtime",
    "masterMode": "tcp",
    "serialPort": "",
    "baudRate": 9600,
    "parity": "none",
    "dataBits": 8,
    "stopBits": 1,
    "timeoutMs": 3000,
    "slaveEnabled": true,
    "slaveHost": "0.0.0.0",
    "slavePort": 1502
  },

  { "id": "c1-comment", "type": "comment", "z": "tab-modpackqt-demo",
    "name": "1) Temperature: PLC float32 @100 → decode → debug",
    "info": "Most common Modbus pattern. If the float looks wrong, try LE_SWAP on the decoder.",
    "x": 220, "y": 40, "wires": [] },
  { "id": "i-temp", "type": "inject", "z": "tab-modpackqt-demo",
    "name": "Poll every 5s", "props": [{ "p": "payload" }], "repeat": "5",
    "once": true, "payloadType": "date", "x": 130, "y": 80,
    "wires": [["mr-temp"]] },
  { "id": "mr-temp", "type": "modpackqt-master-read", "z": "tab-modpackqt-demo",
    "name": "Read FC3 @100 qty=2", "server": "config-modpackqt-runtime",
    "targetHost": "192.168.1.10", "targetPort": 502, "unitId": 1,
    "functionCode": "3", "address": 100, "quantity": 2, "pollInterval": 0,
    "x": 360, "y": 80, "wires": [["dec-temp"]] },
  { "id": "dec-temp", "type": "decode-float32", "z": "tab-modpackqt-demo",
    "name": "decode float32 BE", "endian": "BE", "sourceType": "registers",
    "x": 600, "y": 80, "wires": [["d-temp"]] },
  { "id": "d-temp", "type": "debug", "z": "tab-modpackqt-demo",
    "name": "Temperature (°C)", "active": true, "complete": "payload",
    "x": 820, "y": 80, "wires": [] },

  { "id": "c2-comment", "type": "comment", "z": "tab-modpackqt-demo",
    "name": "2) Setpoint: number → encode float32 → PLC write",
    "info": "Click inject — sends 23.5 to PLC holding @200 (2 registers).",
    "x": 230, "y": 160, "wires": [] },
  { "id": "i-sp", "type": "inject", "z": "tab-modpackqt-demo",
    "name": "Inject 23.5", "props": [{ "p": "payload", "v": "23.5", "vt": "num" }],
    "x": 130, "y": 200, "wires": [["enc-sp"]] },
  { "id": "enc-sp", "type": "encode-float32", "z": "tab-modpackqt-demo",
    "name": "encode float32 BE", "endian": "BE",
    "x": 360, "y": 200, "wires": [["mw-sp"]] },
  { "id": "mw-sp", "type": "modpackqt-master-write", "z": "tab-modpackqt-demo",
    "name": "Write FC16 @200", "server": "config-modpackqt-runtime",
    "targetHost": "192.168.1.10", "targetPort": 502, "unitId": 1,
    "functionCode": "16", "address": 200,
    "x": 600, "y": 200, "wires": [["d-sp"]] },
  { "id": "d-sp", "type": "debug", "z": "tab-modpackqt-demo",
    "name": "Setpoint result", "active": true, "complete": "true",
    "x": 820, "y": 200, "wires": [] },

  { "id": "c3-comment", "type": "comment", "z": "tab-modpackqt-demo",
    "name": "3) Status bits: 1 register → 8 booleans",
    "info": "Wire to a switch node next to act on individual bits.",
    "x": 200, "y": 280, "wires": [] },
  { "id": "i-status", "type": "inject", "z": "tab-modpackqt-demo",
    "name": "Read status", "props": [{ "p": "payload" }],
    "x": 130, "y": 320, "wires": [["mr-status"]] },
  { "id": "mr-status", "type": "modpackqt-master-read", "z": "tab-modpackqt-demo",
    "name": "Read FC3 @50 qty=1", "server": "config-modpackqt-runtime",
    "targetHost": "192.168.1.10", "targetPort": 502, "unitId": 1,
    "functionCode": "3", "address": 50, "quantity": 1, "pollInterval": 0,
    "x": 360, "y": 320, "wires": [["dec-status"]] },
  { "id": "dec-status", "type": "decode-bitmask", "z": "tab-modpackqt-demo",
    "name": "decode bitmask 8 bits", "sourceType": "registers", "bits": 8,
    "x": 600, "y": 320, "wires": [["d-status"]] },
  { "id": "d-status", "type": "debug", "z": "tab-modpackqt-demo",
    "name": "Status bits", "active": true, "complete": "payload",
    "x": 820, "y": 320, "wires": [] },

  { "id": "c4-comment", "type": "comment", "z": "tab-modpackqt-demo",
    "name": "4) Serial number: 8 registers → UTF-8 string",
    "info": "Many devices store nameplate text starting at register 10.",
    "x": 230, "y": 400, "wires": [] },
  { "id": "i-sn", "type": "inject", "z": "tab-modpackqt-demo",
    "name": "Read serial", "props": [{ "p": "payload" }],
    "x": 130, "y": 440, "wires": [["mr-sn"]] },
  { "id": "mr-sn", "type": "modpackqt-master-read", "z": "tab-modpackqt-demo",
    "name": "Read FC3 @10 qty=8", "server": "config-modpackqt-runtime",
    "targetHost": "192.168.1.10", "targetPort": 502, "unitId": 1,
    "functionCode": "3", "address": 10, "quantity": 8, "pollInterval": 0,
    "x": 360, "y": 440, "wires": [["dec-sn"]] },
  { "id": "dec-sn", "type": "decode-string", "z": "tab-modpackqt-demo",
    "name": "decode string utf8", "endian": "BE", "sourceType": "registers",
    "encoding": "utf8", "trim": true,
    "x": 600, "y": 440, "wires": [["d-sn"]] },
  { "id": "d-sn", "type": "debug", "z": "tab-modpackqt-demo",
    "name": "Serial number", "active": true, "complete": "payload",
    "x": 820, "y": 440, "wires": [] },

  { "id": "c5-comment", "type": "comment", "z": "tab-modpackqt-demo",
    "name": "5) Local slave loop (no PLC needed): encode int32 → slave write → slave read → decode",
    "info": "Demonstrates the embedded slave server. Connect any external Modbus master to <host>:1502, unit 1, FC3, address 0, qty 2 — you'll read the same value.",
    "x": 360, "y": 520, "wires": [] },
  { "id": "i-slave", "type": "inject", "z": "tab-modpackqt-demo",
    "name": "Inject 1234567", "props": [{ "p": "payload", "v": "1234567", "vt": "num" }],
    "x": 130, "y": 560, "wires": [["enc-slave"]] },
  { "id": "enc-slave", "type": "encode-int32", "z": "tab-modpackqt-demo",
    "name": "encode int32 BE", "endian": "BE",
    "x": 340, "y": 560, "wires": [["sw-slave"]] },
  { "id": "sw-slave", "type": "modpackqt-slave-write", "z": "tab-modpackqt-demo",
    "name": "slave write @0", "server": "config-modpackqt-runtime",
    "registerType": "holding", "address": 0,
    "x": 540, "y": 560, "wires": [["sr-slave"]] },
  { "id": "sr-slave", "type": "modpackqt-slave-read", "z": "tab-modpackqt-demo",
    "name": "slave read @0 qty=2", "server": "config-modpackqt-runtime",
    "registerType": "holding", "address": 0, "quantity": 2, "pollInterval": 0,
    "x": 760, "y": 560, "wires": [["dec-slave"]] },
  { "id": "dec-slave", "type": "decode-int32", "z": "tab-modpackqt-demo",
    "name": "decode int32 BE", "endian": "BE", "sourceType": "registers",
    "x": 980, "y": 560, "wires": [["d-slave"]] },
  { "id": "d-slave", "type": "debug", "z": "tab-modpackqt-demo",
    "name": "Round-trip value", "active": true, "complete": "payload",
    "x": 1180, "y": 560, "wires": [] },

  { "id": "c6-comment", "type": "comment", "z": "tab-modpackqt-demo",
    "name": "6) Traffic monitor — sees ALL Modbus ops above (free, no input wire)",
    "info": "Wire to the Debug pane to watch every read/write happen in real time. Filter by direction, function code, or target.",
    "x": 320, "y": 640, "wires": [] },
  { "id": "traffic-mon", "type": "modpackqt-traffic", "z": "tab-modpackqt-demo",
    "name": "All ops", "server": "config-modpackqt-runtime",
    "filterDirection": "any", "filterKind": "any", "filterFc": "any",
    "filterTarget": "", "format": "object", "alsoLog": false,
    "x": 130, "y": 680, "wires": [["d-traffic"]] },
  { "id": "d-traffic", "type": "debug", "z": "tab-modpackqt-demo",
    "name": "Modbus traffic", "active": true, "complete": "payload",
    "x": 360, "y": 680, "wires": [] }
]
