Skip to content

EventGenerator

EventGenerator emits an event at a fixed rate. The events are generated by a timer, not derived from a signal, so a graph can be tested without acquisition hardware.

The generator sleeps between two events, so it needs a core of its own. Any other processor on that core would wait through each sleep.

Output

Name Carries
output ScheduledEvent events: one each time the period has passed.

The generator has no input.

Option

Option Meaning Default
rate The number of events per second, in Hz. It may be a fraction: a rate of 0.1 gives one event every 10 s. It must be above 0. 1

Schedule

The generator emits its first event when it first runs, at the start of the run. Let r be the rate and t1 the time of the first event. Event n is due at

tn=t1+n−1r

With a rate of 4 Hz:

Event 1 2 3 4 5
Due after the first event (s) 0 0.25 0.5 0.75 1

Each due time is counted from the first event. An event that is emitted late therefore doesn't delay the events after it.

The generator uses the computer's clock, not the clock of an acquisition device. Its events are therefore not aligned with the samples of any stream.

The event

A ScheduledEvent holds its own number, counted from 1. It doesn't belong to a sample, so it has no header. It holds no time either: the time at which event n was due follows from n and the rate.

The events leave the generator's core through a ring. If a full ring drops an event, the gap shows in the numbers of the events that arrive.

A processor that needs an event's sample, such as LatencyBenchmark, can't take a ScheduledEvent.

Limitations

  • How close an event comes to its due time depends on how soon the operating system wakes the generator from its sleep. This is not measured.
  • The generator emits one event each time it runs. At a rate higher than its core can run it, the events fall further behind their schedule as the run goes on.
  • The event's number is a 32-bit value. After event 4,294,967,295 the numbers start again from 0, which a rate of 1 kHz reaches after 49.7 days.
  • The generator notices that a run is being stopped only when its sleep ends. Stopping can therefore take up to one period: up to 10 s at a rate of 0.1 Hz.