{
  "version": 2,
  "name": "Analog Tank Level Control",
  "exported": "2026-09-16T00:00:00.000Z",
  "notes": "Generic example (not tied to one scene). AX1 = tank level 0-4095 (0-100%). Fill starts below 20% (819) and stops above 85% (3481). AY1 = inlet valve position. Y3 = high-level alarm above 95% (3890). CT1 counts fill cycles; Y4 = service due after 5 fills; X3 resets the count.",
  "program": [
    {"id": 1, "rn": 0,
     "comment": "FILL REQUEST ON — level below 20% (819) and Stop OK",
     "elements": [
       {"id":101,"kind":"compare","type":"LES","addr":"AX1","cmp":819},
       {"id":102,"kind":"contact","type":"XIC","addr":"X2"},
       {"id":103,"kind":"output","type":"OTL","addr":"C101"}
     ]},
    {"id": 2, "rn": 1,
     "comment": "FILL REQUEST OFF — level above 85% (3481) OR Stop pressed (compare inside a branch)",
     "elements": [
       {"id":106,"kind":"parallel","type":"XIC","addr":"","branches":[
         [
           {"id":104,"kind":"compare","type":"GRT","addr":"AX1","cmp":3481}
         ],
         [
           {"id":105,"kind":"contact","type":"XIO","addr":"X2"}
         ]
       ]},
       {"id":107,"kind":"output","type":"OTU","addr":"C101"}
     ]},
    {"id": 3, "rn": 2,
     "comment": "Y1 INLET VALVE — open while filling",
     "elements": [
       {"id":108,"kind":"contact","type":"XIC","addr":"C101"},
       {"id":109,"kind":"output","type":"OTE","addr":"Y1"}
     ]},
    {"id": 4, "rn": 3,
     "comment": "AY1 VALVE FULL OPEN — MOV constant 4095 while filling",
     "elements": [
       {"id":110,"kind":"contact","type":"XIC","addr":"C101"},
       {"id":111,"kind":"block","type":"MOV","addr":"AY1","src":"4095","pre":0}
     ]},
    {"id": 5, "rn": 4,
     "comment": "AY1 VALVE CLOSED — MOV constant 0 when not filling (MOV holds its last value, so both states need a rung)",
     "elements": [
       {"id":112,"kind":"contact","type":"XIO","addr":"C101"},
       {"id":113,"kind":"block","type":"MOV","addr":"AY1","src":"0","pre":0}
     ]},
    {"id": 6, "rn": 5,
     "comment": "Y3 HIGH LEVEL ALARM — level at or above 95% (3890)",
     "elements": [
       {"id":114,"kind":"compare","type":"GEQ","addr":"AX1","cmp":3890},
       {"id":115,"kind":"output","type":"OTE","addr":"Y3"}
     ]},
    {"id": 7, "rn": 6,
     "comment": "FILL CYCLE COUNTER — counts each OFF-to-ON of the fill request",
     "elements": [
       {"id":116,"kind":"contact","type":"XIC","addr":"C101"},
       {"id":117,"kind":"block","type":"CTU","addr":"CT1","pre":5}
     ]},
    {"id": 8, "rn": 7,
     "comment": "Y4 SERVICE DUE — counter done (5 fills)",
     "elements": [
       {"id":118,"kind":"contact","type":"XIC","addr":"CT1"},
       {"id":119,"kind":"output","type":"OTE","addr":"Y4"}
     ]},
    {"id": 9, "rn": 8,
     "comment": "COUNTER RESET — Service Reset PB clears CT1",
     "elements": [
       {"id":120,"kind":"contact","type":"XIC","addr":"X3"},
       {"id":121,"kind":"block","type":"RES","addr":"CT1","pre":0}
     ]}
  ],
  "comments": {
    "X2": "Stop PB N.C.",
    "X3": "Service Reset PB",
    "AX1": "Tank Level 0-4095",
    "AY1": "Inlet Valve Position",
    "Y1": "Inlet Valve Open",
    "Y3": "High Level Alarm",
    "Y4": "Service Due",
    "C101": "Fill Request",
    "CT1": "Fill Cycle Count"
  }
}
