Designing a Flow Charge Up Macro

I am looking to create a macro that has the following characteristics:

  1. A continuous flow input that is (somewhere in the body of the macro) prevented from passing to output until a specified time has passed (essentially a charge up mechanism). Interruption of the continuous flow (for a single frame or more) is to immediately reset the charge of the macro to zero.
  2. A pulse input that, when fired, will reset the charge to zero.
  3. A variable output that indicates the charge of the macro (0.00 means the “timer” hasn’t started while 1.00 means the “timer” has finished).

I’m no programmer so I may be going about this completely the wrong way, but so far I have created the following macro which, in simple cases, works:

Essentially, the local float acts as the timer with the flow input continuously checking to see if it can pass through to the output while also updating the local float.

The main issue I have is in resetting the local float back to zero once the flow stops. Currently I have an On Flow Stop macro that looks like this:

It’s not pretty, but in theory, the retriggerable delay is supposed to reset every frame (assuming a stable framerate), and will only fire its output once the input flow has ceased.

While this all works in simple situations, if I convert it to macro form, and call it more than a handful of times it seems to run into issues with the retriggerable delay not firing at all.

So I was wondering if there was a more effective way of creating an “On Flow Stop” macro or if there is a better way of going about creating this macro.

Any ideas?