Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
A
adc-lib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
adc-lib
Commits
471d6db9
Commit
471d6db9
authored
Aug 13, 2020
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tst: add trigger threshold tests
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
3d3786f1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
120 additions
and
1 deletion
+120
-1
test_adc_trigger.py
pytest/fmc-adc-100m14b4cha/test_adc_trigger.py
+120
-1
No files found.
pytest/fmc-adc-100m14b4cha/test_adc_trigger.py
View file @
471d6db9
...
...
@@ -4,7 +4,8 @@ SPDX-FileCopyrightText: 2020 CERN
"""
import
pytest
from
PyAdcLib
import
PyAdcConf
,
PyFmcAdc100m14b4ch
,
timeval
from
PyAdcLib
import
PyAdcConf
,
PyFmcAdc100m14b4ch
,
timeval
,
PyAdcAbstract
,
\
adc_buffer_get_sample
class
TestAdcTriggerSoftware
(
object
):
...
...
@@ -48,3 +49,121 @@ class TestAdcTriggerSoftware(object):
adc_simple
.
trigger_fire
()
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
TestAdcTriggerThreshold
(
object
):
@
pytest
.
mark
.
parametrize
(
"channel"
,
range
(
4
))
def
test_adc_trg_thr_disable
(
self
,
adc_simple
,
channel
):
conf
=
PyAdcConf
(
PyAdcConf
.
ADC_CONF_TYPE_TRG_THR
,
channel
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_TRG_THR_THRESHOLD
,
0x1FFF
)
adc_simple
.
apply_config
(
conf
,
0
)
buf
=
adc_simple
.
request_buffer
(
3
,
None
,
0
)
# adc_simple does 3
adc_simple
.
pattern_data
=
0
adc_simple
.
acq_start
(
PyFmcAdc100m14b4ch
.
ADC_F_FLUSH
,
timeval
(
0
,
0
))
with
pytest
.
raises
(
OSError
):
adc_simple
.
acq_poll
(
0
,
timeval
(
1
,
0
))
adc_simple
.
pattern_data
=
0x3FFF
with
pytest
.
raises
(
OSError
):
adc_simple
.
acq_poll
(
0
,
timeval
(
1
,
0
))
adc_simple
.
pattern_data
=
0
with
pytest
.
raises
(
OSError
):
adc_simple
.
acq_poll
(
0
,
timeval
(
1
,
0
))
@
pytest
.
mark
.
parametrize
(
"channel"
,
range
(
4
))
@
pytest
.
mark
.
parametrize
(
"threshold"
,
[
0xFFC
,
])
def
test_adc_trg_thr_positive
(
self
,
adc_simple
,
channel
,
threshold
):
"""The trigger threshold fire on positive slopes.
Rembember that the ADC raw data is shifted by 2, so we use a
threshold that does not use the last two bits"""
min_value
=
0
adc_simple
.
pattern_data
=
min_value
conf
=
PyAdcConf
(
PyAdcConf
.
ADC_CONF_TYPE_TRG_THR
,
channel
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_TRG_THR_ENABLE
,
1
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_TRG_THR_POLARITY
,
PyAdcAbstract
.
ADC_TRG_POL_POS
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_TRG_THR_DELAY
,
0
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_TRG_THR_THRESHOLD
,
threshold
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_TRG_THR_HYSTERESIS
,
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
(
2
,
0
))
adc_simple
.
pattern_data
=
(
threshold
>>
2
)
-
1
with
pytest
.
raises
(
OSError
):
adc_simple
.
acq_poll
(
0
,
timeval
(
2
,
0
))
adc_simple
.
pattern_data
=
min_value
with
pytest
.
raises
(
OSError
):
adc_simple
.
acq_poll
(
0
,
timeval
(
2
,
0
))
value
=
(
threshold
>>
2
)
+
1
adc_simple
.
pattern_data
=
value
adc_simple
.
acq_poll
(
0
,
timeval
(
0
,
1000
))
buf
=
adc_simple
.
request_buffer
(
3
,
None
,
0
)
adc_simple
.
fill_buffer
(
buf
,
0
,
timeval
(
10
,
0
))
assert
buf
.
contents
.
nsamples
==
3
assert
adc_buffer_get_sample
(
buf
,
channel
,
0
)
==
min_value
,
\
buf
.
contents
.
data
[:
3
*
4
]
assert
adc_buffer_get_sample
(
buf
,
channel
,
1
)
==
value
<<
2
,
\
buf
.
contents
.
data
[:
3
*
4
]
assert
adc_buffer_get_sample
(
buf
,
channel
,
2
)
==
value
<<
2
,
\
buf
.
contents
.
data
[:
3
*
4
]
adc_simple
.
acq_start
(
PyFmcAdc100m14b4ch
.
ADC_F_FLUSH
,
timeval
(
0
,
0
))
adc_simple
.
pattern_data
=
min_value
with
pytest
.
raises
(
OSError
):
adc_simple
.
acq_poll
(
0
,
timeval
(
2
,
0
))
@
pytest
.
mark
.
parametrize
(
"channel"
,
range
(
4
))
@
pytest
.
mark
.
parametrize
(
"threshold"
,
[
0xFFC
,
])
def
test_adc_trg_thr_negative
(
self
,
adc_simple
,
channel
,
threshold
):
"""The trigger threshold fire on negative slopes.
Rembember that the ADC raw data is shifted by 2, so we use a
threshold that does not use the last two bits"""
max_value
=
0x1FFF
adc_simple
.
pattern_data
=
max_value
conf
=
PyAdcConf
(
PyAdcConf
.
ADC_CONF_TYPE_TRG_THR
,
channel
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_TRG_THR_ENABLE
,
1
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_TRG_THR_POLARITY
,
PyAdcAbstract
.
ADC_TRG_POL_NEG
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_TRG_THR_DELAY
,
0
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_TRG_THR_THRESHOLD
,
threshold
)
conf
.
value_set
(
PyAdcConf
.
ADC_CONF_TRG_THR_HYSTERESIS
,
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
(
2
,
0
))
adc_simple
.
pattern_data
=
(
threshold
>>
2
)
+
1
with
pytest
.
raises
(
OSError
):
adc_simple
.
acq_poll
(
0
,
timeval
(
2
,
0
))
adc_simple
.
pattern_data
=
max_value
with
pytest
.
raises
(
OSError
):
adc_simple
.
acq_poll
(
0
,
timeval
(
2
,
0
))
value
=
(
threshold
>>
2
)
-
1
adc_simple
.
pattern_data
=
value
adc_simple
.
acq_poll
(
0
,
timeval
(
0
,
1000
))
buf
=
adc_simple
.
request_buffer
(
3
,
None
,
0
)
adc_simple
.
fill_buffer
(
buf
,
0
,
timeval
(
10
,
0
))
assert
buf
.
contents
.
nsamples
==
3
assert
adc_buffer_get_sample
(
buf
,
channel
,
0
)
==
max_value
<<
2
,
\
buf
.
contents
.
data
[:
3
*
4
]
assert
adc_buffer_get_sample
(
buf
,
channel
,
1
)
==
value
<<
2
,
\
buf
.
contents
.
data
[:
3
*
4
]
assert
adc_buffer_get_sample
(
buf
,
channel
,
2
)
==
value
<<
2
,
\
buf
.
contents
.
data
[:
3
*
4
]
adc_simple
.
acq_start
(
PyFmcAdc100m14b4ch
.
ADC_F_FLUSH
,
timeval
(
0
,
0
))
adc_simple
.
pattern_data
=
max_value
with
pytest
.
raises
(
OSError
):
adc_simple
.
acq_poll
(
0
,
timeval
(
2
,
0
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment