Commit 1daa7c07 authored by Vincent Michel's avatar Vincent Michel

Fix the is_channel_running bug

parent d3c4d57c
Pipeline #983 passed with stages
in 1 minute and 17 seconds
......@@ -150,7 +150,11 @@ def is_channel_running(channel):
running = ffi.new('short *')
code = handel.xiaGetRunData(channel, b'run_active', running)
check_error(code)
return bool(running[0])
# It turns out running contains 2 bits of information
# - bit 0: whether the channel is acquiring
# - bit 1: whether the channel is running (in the start_run/stop_run sense)
# We're interested in the first bit of information here
return bool(running[0] & 0x1)
def is_running():
......
......@@ -226,6 +226,7 @@ def test_get_spectrums(interface):
def test_is_channel_running(interface):
# First test
m = interface.handel.xiaGetRunData
def side_effect(channel, dtype, arg):
......@@ -237,7 +238,23 @@ def test_is_channel_running(interface):
arg = m.call_args[0][2]
m.assert_called_once_with(2, b'run_active', arg)
# Make sure errors have been checked
interface.check_error.assert_called_with(0)
interface.check_error.assert_called_once_with(0)
# Second test
m.reset_mock()
interface.check_error.reset_mock()
def side_effect(channel, dtype, arg):
arg[0] = 2 # 2 is actually a valid value for a non-running channel
return 0
m.side_effect = side_effect
assert interface.is_channel_running(2) is False
arg = m.call_args[0][2]
m.assert_called_once_with(2, b'run_active', arg)
# Make sure errors have been checked
interface.check_error.assert_called_once_with(0)
def test_is_running(interface):
......
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