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
Benoit Rousselle
bliss
Commits
a512be70
Commit
a512be70
authored
Oct 20, 2017
by
Alejandro Homs Puron
Browse files
Merge branch 'fix-154-backport' into 'bliss-0.1'
Fix 154 backport See merge request
!493
parents
4239db77
29a6f8ae
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
bliss/controllers/ct2/ct2.py
View file @
a512be70
This diff is collapsed.
Click to expand it.
bliss/controllers/ct2/device.py
View file @
a512be70
...
...
@@ -181,6 +181,9 @@ class BaseCT2Device(object):
def
trigger_point
(
self
):
self
.
_device
.
trigger_point
()
def
dump_memory
(
self
):
return
self
.
_device
.
dump_memory
()
@
property
def
counters
(
self
):
return
self
.
_device
.
counters
...
...
@@ -232,16 +235,10 @@ class CT2Device(BaseCT2Device):
AcqMode
.
ExtTrigMulti
,
]
ExtStartModes
=
[
AcqMode
.
ExtTrigSingle
,
AcqMode
.
ExtTrigMulti
,
AcqMode
.
ExtGate
,
AcqMode
.
ExtTrigReadout
,
]
ExtTrigModes
=
[
AcqMode
.
ExtTrigMulti
,
AcqMode
.
ExtGate
,
AcqMode
.
ExtTrigReadout
,
]
ExtExpModes
=
[
...
...
@@ -640,7 +637,7 @@ class CT2Device(BaseCT2Device):
return
self
.
acq_mode
in
self
.
IntExpModes
def
__has_ext_start
(
self
):
return
self
.
acq_mode
in
self
.
ExtStartModes
return
not
self
.
__has_soft_start
()
def
__has_ext_trig
(
self
):
return
self
.
acq_mode
in
self
.
ExtTrigModes
...
...
@@ -648,6 +645,10 @@ class CT2Device(BaseCT2Device):
def
__has_ext_exp
(
self
):
return
self
.
acq_mode
in
self
.
ExtExpModes
def
__has_ext_sync
(
self
):
return
(
self
.
__has_ext_start
()
or
self
.
__has_ext_trig
()
or
self
.
__has_ext_exp
())
def
__in_ext_trig_readout
(
self
):
return
self
.
acq_mode
==
AcqMode
.
ExtTrigReadout
...
...
@@ -666,7 +667,7 @@ class CT2Device(BaseCT2Device):
raise
ValueError
(
'Acq. point period must be greater than expo.'
)
elif
has_period
:
raise
ValueError
(
'Acq. point period only allowed in %s'
%
mode_str
)
if
self
.
__has_ext_
trig
()
and
not
self
.
in_channel
:
if
self
.
__has_ext_
sync
()
and
not
self
.
in_channel
:
raise
ValueError
(
'Must provide in_config in ext-trig modes'
)
self
.
stop_acq
()
...
...
@@ -729,7 +730,7 @@ class CT2Device(BaseCT2Device):
if
self
.
acq_status
!=
AcqStatus
.
Running
:
raise
ValueError
(
'No acquisition is running'
)
elif
self
.
__has_soft_start
()
and
not
self
.
__soft_started
:
self
.
__soft_started
=
True
pass
elif
self
.
__has_int_trig
():
raise
ValueError
(
'Cannot trigger point in int-trig modes'
)
...
...
@@ -739,15 +740,22 @@ class CT2Device(BaseCT2Device):
point_nb_ct
=
self
.
internal_point_nb_counter
point_nb
=
self
.
card
.
get_counter_value
(
point_nb_ct
)
self
.
card
.
stop_counters_software
(
counters
)
restart
=
(
point_nb
<
self
.
acq_nb_points
-
1
)
start
=
not
self
.
__soft_started
restart
=
start
or
(
point_nb
<
self
.
acq_nb_points
-
1
)
elif
self
.
acq_mode
==
AcqMode
.
IntTrigMulti
:
counters_status
=
self
.
card
.
get_counters_status
()
if
counters_status
[
counters
[
0
]][
'run'
]:
raise
RuntimeError
(
'Counter still running'
)
if
self
.
__has_soft_start
():
self
.
__soft_started
=
True
if
restart
:
self
.
card
.
start_counters_software
(
counters
)
def
dump_memory
(
self
):
return
self
.
card
.
dump_memory
()
@
property
def
acq_mode
(
self
):
return
self
.
__acq_mode
...
...
bliss/tango/clients/ct2.py
View file @
a512be70
...
...
@@ -20,20 +20,19 @@ class CT2Device(BaseCT2Device):
Helper for a remote TANGO device CT2 card (P201/C208).
"""
def
__init__
(
self
):
def
__init__
(
self
,
device_name
):
BaseCT2Device
.
__init__
(
self
)
device_name
=
self
.
card_config
[
'tango name'
]
self
.
__tango_device
=
PyTango
.
gevent
.
DeviceProxy
(
device_name
)
self
.
__tango_device
.
subscribe_event
(
"acq_status"
,
PyTango
.
EventType
.
CHANGE_EVENT
,
self
.
__on_status
)
self
.
__tango_device
.
subscribe_event
(
"last_point_nb"
,
PyTango
.
EventType
.
CHANGE_EVENT
,
self
.
__on_point_nb
)
self
.
__tango_device
.
subscribe_event
(
"last_error"
,
PyTango
.
EventType
.
CHANGE_EVENT
,
self
.
__on_error
)
#
self.__tango_device.subscribe_event("acq_status",
#
PyTango.EventType.CHANGE_EVENT,
#
self.__on_status)
#
self.__tango_device.subscribe_event("last_point_nb",
#
PyTango.EventType.CHANGE_EVENT,
#
self.__on_point_nb)
#
self.__tango_device.subscribe_event("last_error",
#
PyTango.EventType.CHANGE_EVENT,
#
self.__on_error)
def
__on_status
(
self
,
event
):
self
.
_send_status
(
AcqStatus
[
event
.
attr_value
.
value
])
...
...
@@ -57,3 +56,6 @@ class CT2Device(BaseCT2Device):
if
data
is
None
:
data
=
numpy
.
array
([[]],
dtype
=
numpy
.
uint32
)
return
data
def
dump_memory
(
self
):
return
bytes
(
super
(
CT2Device
,
self
).
dump_memory
().
data
)
bliss/tango/servers/ct2_ds/ct2_ds.py
View file @
a512be70
...
...
@@ -14,6 +14,7 @@ __all__ = ["CT2", "main"]
import
time
import
numpy
import
gevent
from
gevent
import
select
...
...
@@ -192,6 +193,13 @@ class CT2(Device):
def
data
(
self
):
return
self
.
device
.
read_data
()
@
attribute
(
dtype
=
(
int
,),
max_dim_x
=
12
)
def
counters_status
(
self
):
status
=
self
.
device
.
card
.
get_counters_status
()
return
[
int
(
status
[
i
].
enable
)
|
(
int
(
status
[
i
].
run
)
<<
1
)
for
i
in
self
.
device
.
card
.
COUNTERS
]
@
command
def
apply_config
(
self
):
# first, empty FIFO
...
...
@@ -226,6 +234,11 @@ class CT2(Device):
def
trigger_point
(
self
):
self
.
device
.
trigger_point
()
@
command
(
dtype_out
=
'DevVarCharArray'
)
def
dump_memory
(
self
):
data
=
self
.
device
.
dump_memory
()
return
numpy
.
ndarray
(
shape
=
(
len
(
data
),),
dtype
=
numpy
.
uint8
,
buffer
=
data
)
@
property
def
card
(
self
):
return
self
.
device
.
card
...
...
spec/ct2.mac
View file @
a512be70
...
...
@@ -82,6 +82,23 @@ def ct2_cmd(cnum, key, p1, p2) '{
}
}'
def ct2_par(cnum, key, action, p1) '{
local ctrl_dev chan val[] int_cnt
ctrl_dev = ct2_ADDR
if (cnum != "..")
chan = counter_par(cnum, "channel")
if (key == "status") {
tango_get(ctrl_dev, "counters_status", val)
int_cnt = CT2_MAC_HDW[ctrl_dev]["int_cnt"]
cnt_idx = (chan ? chan : int_cnt) - 1
return val[cnt_idx]
}
}'
def ct2_get(cnum, key, val_arr) '{
local ctrl_dev arr_keys
...
...
@@ -94,7 +111,7 @@ def ct2_get(cnum, key, val_arr) '{
return
}
arr_keys = " acq_channels counters latches data "
arr_keys = " acq_channels counters latches data
counters_status
"
if (index(arr_keys, sprintf(" %s ", key)) > 0) {
return tango_get(ctrl_dev, key, val_arr)
} else {
...
...
tests/controllers/test_ct2_device.py
View file @
a512be70
...
...
@@ -260,7 +260,8 @@ def main():
parser
.
add_argument
(
'--acq_timeout'
,
default
=
''
,
type
=
str
,
help
=
'Timeout aborting acquisition sequence'
)
parser
.
add_argument
(
'--all_tests'
,
default
=
1
,
type
=
int
,
help
=
'Execute all tests: 1=Int+Soft, 2=Int+Soft+Ext'
)
help
=
'Execute all tests: 1=Int+Soft, 2=Ext, '
'3=Int+Soft+Ext'
)
parser
.
add_argument
(
'--sleep_time'
,
default
=
2
,
type
=
float
,
help
=
'Sleep time between test'
)
...
...
@@ -296,14 +297,17 @@ def main():
if
args
.
all_tests
&
1
:
mode_lists
=
((
False
,
[
'IntTrigReadout'
,
'SoftTrigReadout'
]),
(
True
,
[
'IntTrigSingle'
,
'IntTrigMulti'
]))
strict_multi_point_modes
=
[
'IntTrigMulti'
]
for
has_point_period
,
mode_list
in
mode_lists
:
point_period
=
args
.
point_period
if
has_point_period
else
0
for
acq_mode
in
mode_list
:
# multi-point acquisitions
test
(
dev
,
acq_mode
,
args
.
expo_time
,
point_period
,
args
.
acq_nb_points
,
args
.
nb_acqs
,
args
.
sleep_time
)
acq_mode
=
mode_list
[
0
]
test
(
dev
,
acq_mode
,
args
.
expo_time
,
point_period
,
1
,
args
.
acq_nb_points
*
args
.
nb_acqs
,
args
.
sleep_time
)
# multiple single-point acquisitions
if
acq_mode
not
in
strict_multi_point_modes
:
test
(
dev
,
acq_mode
,
args
.
expo_time
,
point_period
,
1
,
args
.
acq_nb_points
*
args
.
nb_acqs
,
args
.
sleep_time
)
if
args
.
all_tests
&
2
:
for
acq_mode
in
ExtTrigModes
:
...
...
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