libtcspc.CustomEvent¶
- class libtcspc.CustomEvent(name, *, abstime=False, traits=None)[source]¶
Bases:
EventTypeA 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
abstimefield (selected withabstime=True). The latter is compatible with the processors that drive or match on timing markers (for example,Generate,CheckAlternating,ClusterBinIncrements,Route, andMatch).- 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 samenamewith a different shape ortraitsyields a distinct event type rather than an error; declaring it identically yields an equivalent type.abstime (bool, optional) – If
True, the event carries a singleabstimefield; ifFalse(the default), the event is empty.traits (NumericTraits or None, optional) – The numeric traits determining the type of the
abstimefield. Required if (and only if)abstimeisTrue.
Notes
The emitted C++ struct provides a defaulted
operator==and anoperator<<that prints the event name (and, for the timestamped form, theabstimevalue).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)