Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bliss
python-handel
Commits
1daa7c07
Commit
1daa7c07
authored
Sep 14, 2017
by
Vincent Michel
Browse files
Fix the is_channel_running bug
parent
d3c4d57c
Pipeline
#983
passed with stages
in 1 minute and 17 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
handel/interface.py
View file @
1daa7c07
...
...
@@ -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
():
...
...
tests/test_interface.py
View file @
1daa7c07
...
...
@@ -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
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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