Spectra::was_injection()

This function is intended to be used at automatic beamshutter beamlines. It detects an injection and waits for the beam.

$ret = Spectra::was_injection( "c_id", "t_id", "sample_time", "counts_min", "wait_time");

Alias: wi()

counts_min: minimum count rate per second
wait_time: heat-up time

The timer t_id is opened for sample_time seconds. The function returns 0, if the beam was not lost in the meantime.

Counter c_id (gated by t_id) is used to monitor the beam. It is read after time intervals of 1 second, until sample_time is reached. The counter is never resetted by this function as long as the beam stays.

If the count rate falls below counts_min, Online waits for the beam (rate > counts_min). After a sufficient intensity was found, Online waits for wait_time seconds before control is returned. This allows the optical components to heat up.

The function returns 1, if there was an injection.

The user may interrupt the wait states by pressing the space bar. In this case Online sets INTERRUPT_SCAN to 1 and sets the abort flag causing command files to be exited.

If Online detects that the contents of c_id is 0 when wi() is called, it resets all counters after the beam is back and repeats wi().