Commit 49d395eb authored by Federico Vaga's avatar Federico Vaga

tst: add trigger time tests

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 4d393cd0
......@@ -50,6 +50,56 @@ class TestAdcTriggerSoftware(object):
adc_simple.retrieve_config(conf)
assert conf.value_get(PyAdcConf.ADC_CONF_BRD_STATE_MACHINE_STATUS) == adc_simple.ADC_CONF_100M14B4CHA_FSM_STATE_IDLE
class TestAdcTriggerTime(object):
def test_adc_trg_tim_disable(self, adc_simple):
conf = PyAdcConf(PyAdcConf.ADC_CONF_TYPE_TRG_TIM, 0)
conf.value_set(PyAdcConf.ADC_CONF_TRG_TIM_ENABLE, 0)
adc_simple.apply_config(conf, 0)
conf = PyAdcConf(PyAdcConf.ADC_CONF_TYPE_BRD, 0)
conf.mask_set(PyAdcConf.ADC_CONF_UTC_TIMING_BASE_S)
adc_simple.retrieve_config(conf)
time_base = conf.value_get(PyAdcConf.ADC_CONF_UTC_TIMING_BASE_S)
conf = PyAdcConf(PyAdcConf.ADC_CONF_TYPE_TRG_TIM, 0)
conf.value_set(PyAdcConf.ADC_CONF_TRG_TIM_SECONDS, time_base + 5)
conf.value_set(PyAdcConf.ADC_CONF_TRG_TIM_NANO_SECONDS, 0)
adc_simple.apply_config(conf, 0)
adc_simple.acq_start(PyFmcAdc100m14b4ch.ADC_F_FLUSH, timeval(0, 0))
with pytest.raises(OSError):
adc_simple.acq_poll(0, timeval(10,0))
@pytest.mark.parametrize("seconds", [2, 3, 4, 5])
@pytest.mark.parametrize("nanoseconds", [10**i for i in range(3, 9)])
def test_adc_trg_tim(self, adc_simple, seconds, nanoseconds):
conf = PyAdcConf(PyAdcConf.ADC_CONF_TYPE_BRD, 0)
conf.mask_set(PyAdcConf.ADC_CONF_UTC_TIMING_BASE_S)
adc_simple.retrieve_config(conf)
time_base = conf.value_get(PyAdcConf.ADC_CONF_UTC_TIMING_BASE_S)
conf = PyAdcConf(PyAdcConf.ADC_CONF_TYPE_TRG_TIM, 0)
conf.value_set(PyAdcConf.ADC_CONF_TRG_TIM_ENABLE, 0)
conf.value_set(PyAdcConf.ADC_CONF_TRG_TIM_SECONDS, time_base + seconds)
conf.value_set(PyAdcConf.ADC_CONF_TRG_TIM_NANO_SECONDS, nanoseconds)
adc_simple.apply_config(conf, 0)
conf = PyAdcConf(PyAdcConf.ADC_CONF_TYPE_TRG_TIM, 0)
conf.value_set(PyAdcConf.ADC_CONF_TRG_TIM_ENABLE, 1)
adc_simple.apply_config(conf, 0)
adc_simple.acq_start(PyFmcAdc100m14b4ch.ADC_F_FLUSH, timeval(0, 0))
adc_simple.acq_poll(0, timeval(seconds + 1,0))
buf_ptr = adc_simple.request_buffer(1024, None, 0)
buf = buf_ptr.contents
adc_simple.fill_buffer(buf_ptr, 0, timeval(10, 0))
assert buf.tstamp.secs == time_base + seconds
ticks_diff = abs(buf.tstamp.ticks - (nanoseconds * 125000000) / 1000000000)
assert ticks_diff < 10 # 80ns margin
assert buf.nsamples == 3
adc_simple.release_buffer(buf_ptr, None)
class TestAdcTriggerThreshold(object):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment