libtcspc.CountDownTo

final class libtcspc.CountDownTo(tick_event_type, fire_event_type, reset_event_type, threshold, limit, initial_count, *, fire_after_tick=False)[source]

Bases: Node

Processor that counts down on a tick event and fires when a threshold is reached.

The mirror of CountUpTo. The internal counter starts at initial_count and is decremented each time a TickEvent is received. limit must be less than initial_count. See CountUpTo for full semantics.

Parameters:
  • tick_event_type (EventType) – Event type that increments (here, decrements) the counter.

  • fire_event_type (EventType) – Event type to emit when the count reaches threshold. Must be brace-initializable with an abstime.

  • reset_event_type (EventType) – Event type that resets the counter to initial_count.

  • threshold (int or Param[int]) – Count value at which FireEvent is emitted.

  • limit (int or Param[int]) – Count value at which the counter is reset to initial_count. Must be less than initial_count.

  • initial_count (int or Param[int]) – Starting and reset value of the counter.

  • fire_after_tick (bool) – If True, the fire event is emitted after the tick event is passed through (after the count is decremented); otherwise it is emitted before. Defaults to False.

Notes

Events handled:

  • tick_event_type: pass through and decrement; emit fire_event_type (before or after, per fire_after_tick) on threshold; reset on limit.

  • reset_event_type: reset counter; pass through.

  • All other event types: pass through unchanged.

  • End of input: pass through.

See also

tcspc::count_down_to()

The underlying C++ factory function.

CountUpTo

The counterpart that counts up to a threshold.