{
  "schemaVersion": 1,
  "metadata": {
    "format": "plcsim.fbd-program",
    "exportedAt": "2026-06-17T11:09:22Z",
    "language": "FBD",
    "nodeCount": 8,
    "connectionCount": 6
  },
  "editorGraph": {
    "id": "graph-main",
    "language": "FBD",
    "version": 1,
    "viewport": {
      "x": 0,
      "y": 0,
      "zoom": 1
    },
    "nodeDefinitions": [
      {
        "id": "def-in",
        "blockType": "IN",
        "displayName": "Input",
        "stateful": false,
        "inputPorts": [],
        "outputPorts": [
          {
            "id": "q",
            "name": "Q",
            "direction": "OUT",
            "signalType": "BOOL",
            "required": true,
            "maxConnections": null
          }
        ]
      },
      {
        "id": "def-out",
        "blockType": "OUT",
        "displayName": "Output",
        "stateful": false,
        "inputPorts": [
          {
            "id": "in",
            "name": "IN",
            "direction": "IN",
            "signalType": "BOOL",
            "required": true,
            "maxConnections": 1
          }
        ],
        "outputPorts": []
      },
      {
        "id": "def-r-trig",
        "blockType": "R_TRIG",
        "displayName": "R_TRIG",
        "stateful": true,
        "inputPorts": [
          {
            "id": "in",
            "name": "IN",
            "direction": "IN",
            "signalType": "BOOL",
            "required": true,
            "maxConnections": 1
          }
        ],
        "outputPorts": [
          {
            "id": "q",
            "name": "Q",
            "direction": "OUT",
            "signalType": "BOOL",
            "required": true,
            "maxConnections": null
          }
        ]
      },
      {
        "id": "def-and",
        "blockType": "AND",
        "displayName": "AND",
        "stateful": false,
        "inputPorts": [
          {
            "id": "in1",
            "name": "IN1",
            "direction": "IN",
            "signalType": "BOOL",
            "required": true,
            "maxConnections": 1
          },
          {
            "id": "in2",
            "name": "IN2",
            "direction": "IN",
            "signalType": "BOOL",
            "required": true,
            "maxConnections": 1
          }
        ],
        "outputPorts": [
          {
            "id": "q",
            "name": "Q",
            "direction": "OUT",
            "signalType": "BOOL",
            "required": true,
            "maxConnections": null
          }
        ]
      },
      {
        "id": "def-ctu",
        "blockType": "CTU",
        "displayName": "CTU",
        "stateful": true,
        "inputPorts": [
          {
            "id": "cu",
            "name": "CU",
            "direction": "IN",
            "signalType": "BOOL",
            "required": true,
            "maxConnections": 1
          },
          {
            "id": "r",
            "name": "R",
            "direction": "IN",
            "signalType": "BOOL",
            "required": true,
            "maxConnections": 1
          }
        ],
        "outputPorts": [
          {
            "id": "q",
            "name": "Q",
            "direction": "OUT",
            "signalType": "BOOL",
            "required": true,
            "maxConnections": null
          }
        ]
      }
    ],
    "nodes": [
      {
        "id": "node-0001",
        "definitionId": "def-in",
        "label": "Part_Sensor",
        "position": {
          "x": 80,
          "y": 80
        },
        "ports": [
          {
            "id": "node-0001:q",
            "nodeId": "node-0001",
            "definitionPortId": "q",
            "name": "Q",
            "direction": "OUT",
            "signalType": "BOOL"
          }
        ],
        "parameterValues": {}
      },
      {
        "id": "node-0002",
        "definitionId": "def-in",
        "label": "Conveyor_Run",
        "position": {
          "x": 80,
          "y": 220
        },
        "ports": [
          {
            "id": "node-0002:q",
            "nodeId": "node-0002",
            "definitionPortId": "q",
            "name": "Q",
            "direction": "OUT",
            "signalType": "BOOL"
          }
        ],
        "parameterValues": {}
      },
      {
        "id": "node-0003",
        "definitionId": "def-in",
        "label": "Batch_Reset",
        "position": {
          "x": 80,
          "y": 360
        },
        "ports": [
          {
            "id": "node-0003:q",
            "nodeId": "node-0003",
            "definitionPortId": "q",
            "name": "Q",
            "direction": "OUT",
            "signalType": "BOOL"
          }
        ],
        "parameterValues": {}
      },
      {
        "id": "node-0004",
        "definitionId": "def-r-trig",
        "label": "Part_Pulse",
        "position": {
          "x": 300,
          "y": 80
        },
        "ports": [
          {
            "id": "node-0004:in",
            "nodeId": "node-0004",
            "definitionPortId": "in",
            "name": "IN",
            "direction": "IN",
            "signalType": "BOOL"
          },
          {
            "id": "node-0004:q",
            "nodeId": "node-0004",
            "definitionPortId": "q",
            "name": "Q",
            "direction": "OUT",
            "signalType": "BOOL"
          }
        ],
        "parameterValues": {}
      },
      {
        "id": "node-0005",
        "definitionId": "def-and",
        "label": "Count_Allowed",
        "position": {
          "x": 500,
          "y": 140
        },
        "ports": [
          {
            "id": "node-0005:in1",
            "nodeId": "node-0005",
            "definitionPortId": "in1",
            "name": "IN1",
            "direction": "IN",
            "signalType": "BOOL"
          },
          {
            "id": "node-0005:in2",
            "nodeId": "node-0005",
            "definitionPortId": "in2",
            "name": "IN2",
            "direction": "IN",
            "signalType": "BOOL"
          },
          {
            "id": "node-0005:q",
            "nodeId": "node-0005",
            "definitionPortId": "q",
            "name": "Q",
            "direction": "OUT",
            "signalType": "BOOL"
          }
        ],
        "parameterValues": {}
      },
      {
        "id": "node-0006",
        "definitionId": "def-ctu",
        "label": "Batch_Counter",
        "position": {
          "x": 720,
          "y": 170
        },
        "ports": [
          {
            "id": "node-0006:cu",
            "nodeId": "node-0006",
            "definitionPortId": "cu",
            "name": "CU",
            "direction": "IN",
            "signalType": "BOOL"
          },
          {
            "id": "node-0006:r",
            "nodeId": "node-0006",
            "definitionPortId": "r",
            "name": "R",
            "direction": "IN",
            "signalType": "BOOL"
          },
          {
            "id": "node-0006:q",
            "nodeId": "node-0006",
            "definitionPortId": "q",
            "name": "Q",
            "direction": "OUT",
            "signalType": "BOOL"
          }
        ],
        "parameterValues": {
          "PV": 10
        }
      },
      {
        "id": "node-0007",
        "definitionId": "def-out",
        "label": "Batch_Complete",
        "position": {
          "x": 980,
          "y": 170
        },
        "ports": [
          {
            "id": "node-0007:in",
            "nodeId": "node-0007",
            "definitionPortId": "in",
            "name": "IN",
            "direction": "IN",
            "signalType": "BOOL"
          }
        ],
        "parameterValues": {}
      },
      {
        "id": "comment-0001",
        "type": "comment",
        "position": {
          "x": 300,
          "y": 410
        },
        "data": {
          "text": "Счётчик деталей на конвейере. Part_Sensor через R_TRIG формирует один импульс на проход детали. AND разрешает счёт только при Conveyor_Run=TRUE. CTU увеличивает счётчик по входу CU; Batch_Reset сбрасывает счётчик по входу R. При достижении PV=10 выход Batch_Complete становится TRUE и сигнализирует завершение партии.",
          "width": 620,
          "height": 130
        }
      }
    ],
    "connections": [
      {
        "id": "edge-0001",
        "sourceNodeId": "node-0001",
        "sourcePortId": "node-0001:q",
        "targetNodeId": "node-0004",
        "targetPortId": "node-0004:in",
        "signalType": "BOOL"
      },
      {
        "id": "edge-0002",
        "sourceNodeId": "node-0004",
        "sourcePortId": "node-0004:q",
        "targetNodeId": "node-0005",
        "targetPortId": "node-0005:in1",
        "signalType": "BOOL"
      },
      {
        "id": "edge-0003",
        "sourceNodeId": "node-0002",
        "sourcePortId": "node-0002:q",
        "targetNodeId": "node-0005",
        "targetPortId": "node-0005:in2",
        "signalType": "BOOL"
      },
      {
        "id": "edge-0004",
        "sourceNodeId": "node-0005",
        "sourcePortId": "node-0005:q",
        "targetNodeId": "node-0006",
        "targetPortId": "node-0006:cu",
        "signalType": "BOOL"
      },
      {
        "id": "edge-0005",
        "sourceNodeId": "node-0003",
        "sourcePortId": "node-0003:q",
        "targetNodeId": "node-0006",
        "targetPortId": "node-0006:r",
        "signalType": "BOOL"
      },
      {
        "id": "edge-0006",
        "sourceNodeId": "node-0006",
        "sourcePortId": "node-0006:q",
        "targetNodeId": "node-0007",
        "targetPortId": "node-0007:in",
        "signalType": "BOOL"
      }
    ]
  }
}
