Commit 268b2037 authored by Vincent Michel's avatar Vincent Michel
Browse files

Add set_maximum_pixels_per_buffer to the API

parent 7cbc63e8
Pipeline #1082 passed with stages
in 1 minute and 18 seconds
......@@ -23,6 +23,7 @@ __all__ = ['init', 'init_handel', 'exit',
'get_buffer_length', 'get_raw_buffer', 'get_buffer_data',
'is_buffer_full', 'is_buffer_overrun', 'set_buffer_done',
'get_buffer_current_pixel', 'get_current_pixel',
'any_buffer_overrun', 'all_buffer_full', 'set_all_buffer_done',
'get_all_buffer_data', 'synchronized_poll_data',
'get_baseline_length', 'get_baseline',
......@@ -267,6 +268,18 @@ def set_buffer_done(master, buffer_id):
# Synchronized run
def set_maximum_pixels_per_buffer():
"""Set the maximum number of pixels per buffer.
It makes sure all the modules are configured with the same value,
in order to be able to perform synchronized run.
set_acquisition_value('num_map_pixels_per_buffer', -1)
value = min(get_acquisition_value('num_map_pixels_per_buffer', master)
for master in get_master_channels())
set_acquisition_value('num_map_pixels_per_buffer', value)
def any_buffer_overrun():
"""Return True if an overrun has been detected by the hardware on any
module, False otherwise.
......@@ -450,6 +450,23 @@ def test_set_buffer_done(interface):
# Synchronized run
def test_set_maximum_pixels_per_buffer(interface):
with mock.patch('handel.interface.set_acquisition_value') as m1:
with mock.patch('handel.interface.get_acquisition_value') as m2:
with mock.patch('handel.interface.get_master_channels') as m3:
m1.return_value = None
m2.side_effect = lambda x, y: 400 if y == 7 else 100
m3.return_value = [0, 3, 7]
assert interface.set_maximum_pixels_per_buffer() is None
assert m1.call_args_list == [
(('num_map_pixels_per_buffer', -1),),
(('num_map_pixels_per_buffer', 100),)]
assert m2.call_args_list == [
(('num_map_pixels_per_buffer', 0),),
(('num_map_pixels_per_buffer', 3),),
(('num_map_pixels_per_buffer', 7),)]
def test_any_buffer_overrun(interface):
with mock.patch('handel.interface.get_master_channels') as m1:
with mock.patch('handel.interface.is_buffer_overrun') as m2:
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