libtcspc.CountUpTo

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

Bases: Node

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

The internal counter starts at initial_count and is incremented each time a TickEvent is received and passed through. When the counter equals threshold, fire_event_type is emitted (just before or just after the tick, controlled by fire_after_tick) with its abstime set to that of the triggering tick. When the counter equals limit, it is reset to initial_count. A ResetEvent resets the counter explicitly.

Parameters:
  • tick_event_type (EventType) – Event type that increments the counter. Must have an abstime field.

  • fire_event_type (EventType) – Event type to emit on 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 greater 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 incremented); otherwise it is emitted before. Defaults to False.

Notes

Events handled:

  • tick_event_type: pass through and increment; 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_up_to()

The underlying C++ factory function.

CountDownTo

The counterpart that counts down to a threshold.