libtcspc.CustomEvent

class libtcspc.CustomEvent(name, *, abstime=False, traits=None)[source]

Bases: EventType

A user-defined event type.

Use this to declare a simple event type of your own, for use as a timing marker or other signal in a processing graph (for example, pixel/line/frame clock edges or control signals such as histogram reset).

Only two shapes are supported: an empty event (no fields), and a timestamped event carrying a single abstime field (selected with abstime=True). The latter is compatible with the processors that drive or match on timing markers (for example, Generate, CheckAlternating, ClusterBinIncrements, Route, and Match).

Parameters:
  • name (str) – A name for the event. Must be a valid C++ identifier. It is what the struct’s operator<< prints. Re-declaring the same name with a different shape or traits yields a distinct event type rather than an error; declaring it identically yields an equivalent type.

  • abstime (bool, optional) – If True, the event carries a single abstime field; if False (the default), the event is empty.

  • traits (NumericTraits or None, optional) – The numeric traits determining the type of the abstime field. Required if (and only if) abstime is True.

Notes

The emitted C++ struct provides a defaulted operator== and an operator<< that prints the event name (and, for the timestamped form, the abstime value).

Constructing and inspecting individual event values from Python is intended for debugging and learning only and is extremely slow; production graphs process events in compiled C++ and exchange bulk data via buckets.

Examples

>>> reset = CustomEvent("reset_event")
>>> nt = NumericTraits()
>>> pixel_start = CustomEvent("pixel_start_event", abstime=True, traits=nt)
>>> pixel_start.value(abstime=0)