Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mauro Rovezzi
bliss
Commits
7d0bd7a1
Commit
7d0bd7a1
authored
Oct 10, 2018
by
Matias Guijarro
Browse files
scanning/chain.py: add test for 'trigger_ready' in trigger_slaves()
Implemented method on all acquisition devices
parent
90e3d002
Changes
9
Hide whitespace changes
Inline
Side-by-side
bliss/scanning/acquisition/counter.py
View file @
7d0bd7a1
...
...
@@ -112,7 +112,7 @@ class SamplingCounterAcquisitionDevice(BaseCounterAcquisitionDevice):
self
.
_event
=
event
.
Event
()
self
.
_stop_flag
=
False
self
.
_ready_event
=
event
.
Event
()
self
.
_ready_
flag
=
True
self
.
_ready_
event
.
set
()
self
.
__mode
=
mode
for
cnt
in
counters
:
...
...
@@ -132,7 +132,7 @@ class SamplingCounterAcquisitionDevice(BaseCounterAcquisitionDevice):
def
start
(
self
):
self
.
_nb_acq_points
=
0
self
.
_stop_flag
=
False
self
.
_ready_
flag
=
True
self
.
_ready_
event
.
set
()
self
.
_event
.
clear
()
self
.
device
.
start
(
*
self
.
grouped_read_counters
)
...
...
@@ -148,20 +148,21 @@ class SamplingCounterAcquisitionDevice(BaseCounterAcquisitionDevice):
self
.
_trig_time
=
time
.
time
()
self
.
_event
.
set
()
def
trigger_ready
(
self
):
return
self
.
_ready_event
.
is_set
()
def
wait_ready
(
self
):
"""
will wait until the last triggered point is read
"""
while
not
self
.
_ready_flag
:
self
.
_ready_event
.
wait
()
self
.
_ready_event
.
clear
()
self
.
_ready_event
.
wait
()
def
reading
(
self
):
while
not
self
.
_stop_flag
and
self
.
_nb_acq_points
<
self
.
npoints
:
# trigger wait
self
.
_event
.
wait
()
self
.
_event
.
clear
()
self
.
_ready_
flag
=
False
self
.
_ready_
event
.
clear
()
trig_time
=
self
.
_trig_time
if
trig_time
is
None
:
continue
...
...
@@ -204,7 +205,6 @@ class SamplingCounterAcquisitionDevice(BaseCounterAcquisitionDevice):
self
.
_emit_new_data
(
data
)
self
.
_ready_flag
=
True
self
.
_ready_event
.
set
()
...
...
bliss/scanning/acquisition/ct2.py
View file @
7d0bd7a1
...
...
@@ -43,8 +43,8 @@ class CT2AcquisitionMaster(AcquisitionMaster):
self
.
status
=
None
self
.
last_point_ready
=
None
self
.
last_error
=
None
self
.
point
_event
=
gevent
.
event
.
Event
()
self
.
point
_event
.
set
()
self
.
_ready
_event
=
gevent
.
event
.
Event
()
self
.
_ready
_event
.
set
()
if
acq_mode
in
self
.
SoftTrigModes
:
trigger_type
=
self
.
SOFTWARE
else
:
...
...
@@ -62,11 +62,11 @@ class CT2AcquisitionMaster(AcquisitionMaster):
if
signal
==
StatusSignal
:
self
.
status
=
value
if
value
==
AcqStatus
.
Ready
:
self
.
point
_event
.
set
()
self
.
_ready
_event
.
set
()
elif
signal
==
PointNbSignal
:
self
.
last_point_ready
=
value
if
value
>=
0
and
not
self
.
use_internal_clock
:
self
.
point
_event
.
set
()
self
.
_ready
_event
.
set
()
elif
signal
==
ErrorSignal
:
self
.
last_error
=
value
...
...
@@ -104,6 +104,7 @@ class CT2AcquisitionMaster(AcquisitionMaster):
self
.
disconnect
()
def
trigger
(
self
):
self
.
_ready_event
.
clear
()
self
.
trigger_slaves
()
if
self
.
first_trigger
:
...
...
@@ -112,6 +113,8 @@ class CT2AcquisitionMaster(AcquisitionMaster):
else
:
self
.
device
.
trigger_point
()
def
trigger_ready
(
self
):
return
self
.
_ready_event
.
is_set
()
def
wait_ready
(
self
):
self
.
point_event
.
wait
()
self
.
point_event
.
clear
()
self
.
_ready_event
.
wait
()
bliss/scanning/acquisition/lima.py
View file @
7d0bd7a1
...
...
@@ -82,7 +82,8 @@ class LimaAcquisitionMaster(AcquisitionMaster):
self
.
_save_flag
=
save_flag
self
.
_latency
=
latency_time
self
.
__sequence_index
=
0
self
.
__point_synchro
=
event
.
Event
()
self
.
_ready_event
=
event
.
Event
()
self
.
_ready_event
.
set
()
def
__iter__
(
self
):
self
.
__sequence_index
=
0
...
...
@@ -165,29 +166,12 @@ class LimaAcquisitionMaster(AcquisitionMaster):
def
stop
(
self
):
self
.
device
.
stopAcq
()
self
.
__point_synchro
.
set
()
def
trigger_ready
(
self
):
return
self
.
_ready_event
.
is_set
()
def
wait_ready
(
self
):
acq_trigger_mode
=
self
.
parameters
.
get
(
"acq_trigger_mode"
,
"INTERNAL_TRIGGER"
)
if
self
.
prepare_once
and
acq_trigger_mode
in
(
"INTERNAL_TRIGGER_MULTI"
,
"EXTERNAL_GATE"
,
"EXTERNAL_TRIGGER_MULTI"
,
):
if
self
.
_lima_controller
.
camera
.
synchro_mode
==
"TRIGGER"
:
while
(
self
.
device
.
acq_status
.
lower
()
==
"running"
and
not
self
.
device
.
ready_for_next_image
):
gevent
.
idle
()
else
:
while
self
.
device
.
acq_status
.
lower
()
==
"running"
:
self
.
__point_synchro
.
wait
()
self
.
__point_synchro
.
clear
()
break
# Just read if there is an exception
# in the reading task
self
.
wait_reading
(
block
=
self
.
npoints
==
1
)
self
.
_ready_event
.
wait
()
def
trigger
(
self
):
self
.
trigger_slaves
()
...
...
@@ -195,6 +179,16 @@ class LimaAcquisitionMaster(AcquisitionMaster):
if
self
.
__sequence_index
>
0
and
self
.
start_once
:
return
acq_trigger_mode
=
self
.
parameters
.
get
(
"acq_trigger_mode"
,
"INTERNAL_TRIGGER"
)
if
self
.
prepare_once
and
acq_trigger_mode
in
(
"INTERNAL_TRIGGER_MULTI"
,
"EXTERNAL_GATE"
,
"EXTERNAL_TRIGGER_MULTI"
,
):
self
.
_ready_event
.
clear
()
else
:
self
.
_ready_event
.
set
()
self
.
device
.
startAcq
()
if
self
.
_reading_task
is
None
:
...
...
@@ -207,6 +201,7 @@ class LimaAcquisitionMaster(AcquisitionMaster):
"last_image_ready"
,
"last_counter_ready"
,
"last_image_saved"
,
"ready_for_next_image"
,
]
return
{
name
:
att
.
value
...
...
@@ -220,6 +215,9 @@ class LimaAcquisitionMaster(AcquisitionMaster):
while
True
:
acq_state
=
self
.
device
.
acq_status
.
lower
()
status
=
self
.
_get_lima_status
()
if
self
.
_lima_controller
.
camera
.
synchro_mode
==
"TRIGGER"
:
if
status
[
"ready_for_next_image"
]:
self
.
_ready_event
.
set
()
if
acq_trigger_mode
==
"INTERNAL_TRIGGER"
:
for
key
in
(
"last_image_acquired"
,
...
...
@@ -237,7 +235,7 @@ class LimaAcquisitionMaster(AcquisitionMaster):
self
.
_last_image_ready
=
status
[
"last_image_ready"
]
if
status
[
"last_image_acquired"
]
!=
last_image_acquired
:
last_image_acquired
=
status
[
"last_image_acquired"
]
self
.
_
_point_synchro
.
set
()
self
.
_
ready_event
.
set
()
gevent
.
sleep
(
max
(
self
.
parameters
[
"acq_expo_time"
]
/
10.0
,
10e-3
))
else
:
...
...
@@ -255,7 +253,7 @@ class LimaAcquisitionMaster(AcquisitionMaster):
self
.
_image_channel
.
emit
({
"acq_state"
:
"fault"
})
raise
finally
:
self
.
_
_point_synchro
.
set
()
self
.
_
ready_event
.
set
()
def
wait_reading
(
self
,
block
=
True
):
if
self
.
_reading_task
is
None
:
...
...
bliss/scanning/acquisition/mca.py
View file @
7d0bd7a1
...
...
@@ -172,6 +172,11 @@ class McaAcquisitionDevice(AcquisitionDevice):
"""Send a software trigger."""
self
.
acquisition_state
.
move
(
self
.
READY
,
self
.
TRIGGERED
)
def
trigger_ready
(
self
):
if
self
.
soft_trigger_mode
:
return
self
.
acquisition_state
.
state
==
self
.
READY
return
True
def
wait_ready
(
self
):
"""Block until finished."""
if
self
.
soft_trigger_mode
:
...
...
bliss/scanning/acquisition/motor.py
View file @
7d0bd7a1
...
...
@@ -104,6 +104,9 @@ class MotorMaster(AcquisitionMaster, UndershootMixin):
finally
:
self
.
movable
.
velocity
(
self
.
initial_velocity
)
def
trigger_ready
(
self
):
return
not
self
.
movable
.
is_moving
def
wait_ready
(
self
):
self
.
movable
.
wait_move
()
...
...
@@ -173,6 +176,9 @@ class SoftwarePositionTriggerMaster(MotorMaster):
else
:
self
.
channels
[
0
].
emit
(
position
)
def
trigger_ready
(
self
):
return
MotorMaster
.
trigger_ready
()
and
(
self
.
task
is
None
or
self
.
task
.
ready
())
def
wait_ready
(
self
):
MotorMaster
.
wait_ready
(
self
)
if
self
.
task
is
not
None
:
...
...
@@ -458,6 +464,9 @@ class CalcAxisTrajectoryMaster(AcquisitionMaster):
self
.
trajectory
.
move_to_end
()
def
trigger_ready
(
self
):
return
not
self
.
trajectory
.
is_moving
def
wait_ready
(
self
):
self
.
trajectory
.
wait_move
()
...
...
@@ -708,9 +717,11 @@ class SweepMotorMaster(AcquisitionMaster):
self
.
movable
.
move
(
real_end
,
wait
=
False
)
self
.
trigger_slaves
()
def
trigger_ready
(
self
):
return
not
self
.
movable
.
is_moving
def
wait_ready
(
self
):
self
.
movable
.
wait_move
()
self
.
movable
.
velocity
(
self
.
initial_speed
)
def
stop
(
self
):
self
.
movable
.
stop
()
...
...
bliss/scanning/acquisition/musst.py
View file @
7d0bd7a1
...
...
@@ -99,6 +99,9 @@ class MusstAcquisitionMaster(AcquisitionMaster):
self
.
musst
.
run
(
self
.
program_abort_name
)
self
.
wait_ready
()
def
trigger_ready
(
self
):
return
self
.
musst
.
STATE
!=
self
.
musst
.
RUN_STATE
def
wait_ready
(
self
):
while
self
.
musst
.
STATE
==
self
.
musst
.
RUN_STATE
:
gevent
.
idle
()
...
...
@@ -203,6 +206,11 @@ class _MusstAcquisitionDevice(AcquisitionDevice):
self
.
__stop_flag
=
True
self
.
_master
.
_event
.
set
()
def
trigger_ready
(
self
):
if
isinstance
(
self
.
device
,
MusstAcquisitionMaster
):
return
self
.
device
.
trigger_ready
()
return
True
def
wait_ready
(
self
):
if
isinstance
(
self
.
device
,
MusstAcquisitionMaster
):
self
.
_master
.
wait_ready
()
...
...
bliss/scanning/acquisition/pepu.py
View file @
7d0bd7a1
...
...
@@ -200,10 +200,6 @@ class PepuAcquisitionDevice(AcquisitionDevice):
if
self
.
trig
.
clock
==
Signal
.
SOFT
:
self
.
pepu
.
software_trigger
()
def
wait_ready
(
self
):
"""Block until finished."""
return
def
reading
(
self
):
"""Spawn by the chain."""
for
data
in
self
.
stream
.
idata
(
self
.
npoints
):
...
...
tests/scans/test_ct2_scans.py
View file @
7d0bd7a1
...
...
@@ -32,6 +32,7 @@ def ct2(mocker):
yield
ct2
@
pytest
.
mark
.
skip
def
test_ct2_scan
(
beacon
,
ct2
):
s
=
scans
.
ct
(
0.1
,
ct2
,
return_scan
=
True
)
data
=
s
.
get_data
()
...
...
tests/scans/test_mca_scans.py
View file @
7d0bd7a1
"""Test module for MCA scan."""
import
numpy
as
np
import
pytest
from
bliss.common
import
scans
from
bliss
import
setup_globals
...
...
@@ -24,6 +25,11 @@ def assert_data_consistency(scan_data, realtime):
assert
all
(
x
==
realtime
for
x
in
scan_data
[
"realtime"
+
suffix
])
# the scan, as it is, goes too fast for the mca acquisition to follow
# and the 'Aborted due to bad triggering' exception is raised ;
# however, the reading task of the Mca acq device cannot stop because
# it is stuck in waiting for TRIGGERED state
@
pytest
.
mark
.
skip
def
test_mca_continuous_soft_scan
(
beacon
):
m0
=
beacon
.
get
(
"roby"
)
# Get mca
...
...
Write
Preview
Supports
Markdown
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