Global Counters --------------- A global counter ends an infinite loop when 5 `Port1In` events occur. `Port1In` events acquired in the first state are deliberately not counted. .. image:: global_counters.svg :align: center .. tab-set:: .. tab-item:: Python .. literalinclude:: ../../../../examples/global_counters.py :language: python :start-at: from bpod_core. .. tab-item:: JSON .. code-block:: json { "states": { "InitialDelay": { "timer": 2.0, "transitions": { "Tup": "ResetGlobalCounter" }, "actions": { "PWM2": 255 } }, "ResetGlobalCounter": { "transitions": { "Tup": "Port1Light" }, "actions": { "GlobalCounterReset": 1 } }, "Port1Light": { "timer": 0.25, "transitions": { "Tup": "Port3Light", "GlobalCounter1_End": ">exit" }, "actions": { "PWM1": 255 } }, "Port3Light": { "timer": 0.25, "transitions": { "Tup": "Port1Light", "GlobalCounter1_End": ">exit" }, "actions": { "PWM3": 255 } } }, "global_counters": { "1": { "event": "Port1High", "threshold": 5 } } } .. tab-item:: YAML .. code-block:: yaml states: InitialDelay: timer: 2.0 transitions: Tup: ResetGlobalCounter actions: PWM2: 255 ResetGlobalCounter: transitions: Tup: Port1Light actions: GlobalCounterReset: 1 Port1Light: timer: 0.25 transitions: Tup: Port3Light GlobalCounter1_End: '>exit' actions: PWM1: 255 Port3Light: timer: 0.25 transitions: Tup: Port1Light GlobalCounter1_End: '>exit' actions: PWM3: 255 global_counters: 1: event: Port1High threshold: 5