Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
calng
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
calng
Commits
4db44ada
Commit
4db44ada
authored
1 year ago
by
Danilo Ferreira de Lima
Browse files
Options
Downloads
Plain Diff
Merged.
parents
91232763
e3d4a37f
No related branches found
No related tags found
2 merge requests
!59
Interface CrystFEL with Karabo and allow automatic parameter tunning with rcrystfel
,
!53
Train picker arbiter kernel
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/calng/PickyBoi.py
+40
-28
40 additions, 28 deletions
src/calng/PickyBoi.py
with
40 additions
and
28 deletions
src/calng/PickyBoi.py
+
40
−
28
View file @
4db44ada
import
re
import
numpy
as
np
from
karabo.bound
import
(
BOOL_ELEMENT
,
...
...
@@ -66,7 +68,10 @@ class PickyBoi(PythonDevice):
BOOL_ELEMENT
(
expected
)
.
key
(
"
breakStreamAfterEnd
"
)
.
description
(
"
If active, end the output stream after the range of selected train IDs has been forwarded.
"
)
.
description
(
"
If active, end the output stream after the range of selected train
"
"
IDs has been forwarded.
"
)
.
assignmentOptional
()
.
defaultValue
(
False
)
.
reconfigurable
()
...
...
@@ -120,6 +125,17 @@ class PickyBoi(PythonDevice):
.
reconfigurable
()
.
commit
(),
STRING_ELEMENT
(
expected
)
.
key
(
"
sourceFilterRegex
"
)
.
assignmentOptional
()
.
defaultValue
(
""
)
.
description
(
"
If set, only data from sources matching this regex will be forwarded.
"
"
If not set, all sources are forwarded.
"
)
.
reconfigurable
()
.
commit
(),
INT64_ELEMENT
(
expected
)
.
key
(
"
ppuTrainOffset
"
)
.
description
(
...
...
@@ -149,17 +165,6 @@ class PickyBoi(PythonDevice):
.
initialValue
(
0
)
.
commit
(),
STRING_ELEMENT
(
expected
)
.
key
(
"
sourceRegexp
"
)
.
description
(
"
Regular expression to be used to filter the source value of the data.
"
"
If left empty, no filtering is performed.
"
)
.
assignmentOptional
()
.
defaultValue
(
""
)
.
reconfigurable
()
.
commit
(),
SLOT_ELEMENT
(
expected
)
.
key
(
"
toggleFollowPpu
"
)
.
allowedStates
(
State
.
MONITORING
,
State
.
PASSIVE
,
State
.
ERROR
)
...
...
@@ -254,20 +259,20 @@ class PickyBoi(PythonDevice):
def
input_handler
(
self
,
input_channel
):
all_metadata
=
input_channel
.
getMetaData
()
have_written_something
=
False
regexp
=
self
.
unsafe_get
(
"
sourceRegex
p
"
)
if
len
(
regexp
)
>
0
:
regexp
=
re
.
compile
(
regexp
)
source_re
=
self
.
unsafe_get
(
"
source
Filter
Regex
"
)
if
len
(
source_re
)
>
0
:
source_re
=
re
.
compile
(
source_re
)
else
:
regexp
=
None
source_re
=
None
for
input_index
in
range
(
input_channel
.
size
()):
state
=
self
.
get
(
"
state
"
)
data
=
input_channel
.
read
(
input_index
)
meta
=
all_metadata
[
input_index
]
source
=
meta
.
get
(
"
source
"
)
if
regexp
is
not
None
:
if
not
regexp
.
match
(
source
):
continue
if
source_re
is
not
None
and
not
source_re
.
match
(
source
)
:
continue
current_tid
=
Timestamp
.
fromHashAttributes
(
meta
.
getAttributes
(
"
timestamp
"
)
).
getTrainId
()
...
...
@@ -323,10 +328,11 @@ class PickyBoi(PythonDevice):
# if breakStreamAfterEnd is set, end the stream
# and stop acquiring
if
(
self
.
get
(
"
breakStreamAfterEnd
"
)
and
state
is
State
.
ACQUIRING
):
if
self
.
get
(
"
breakStreamAfterEnd
"
)
and
state
is
State
.
ACQUIRING
:
self
.
signalEndOfStream
(
"
output
"
)
self
.
log
.
INFO
(
"
End of stream reached, following setting breakStreamAfterEnd.
"
)
self
.
log
.
INFO
(
"
End of stream reached, following setting breakStreamAfterEnd.
"
)
self
.
updateState
(
State
.
PASSIVE
)
elif
target_tid
>
current_tid
:
# wait
...
...
@@ -337,14 +343,20 @@ class PickyBoi(PythonDevice):
# if breakStreamAfterEnd is set, end the stream
# and stop acquiring
last_train_to_get
=
(
max
(
self
.
_trains_to_get
)
if
len
(
self
.
_trains_to_get
)
>
0
else
current_tid
)
if
(
self
.
get
(
"
breakStreamAfterEnd
"
)
last_train_to_get
=
(
max
(
self
.
_trains_to_get
)
if
len
(
self
.
_trains_to_get
)
>
0
else
current_tid
)
if
(
self
.
get
(
"
breakStreamAfterEnd
"
)
and
current_tid
>
last_train_to_get
and
state
is
State
.
ACQUIRING
):
and
state
is
State
.
ACQUIRING
):
self
.
signalEndOfStream
(
"
output
"
)
self
.
log
.
INFO
(
"
End of stream reached, following setting breakStreamAfterEnd.
"
)
self
.
log
.
INFO
(
"
End of stream reached, following setting breakStreamAfterEnd.
"
)
self
.
updateState
(
State
.
PASSIVE
)
state
=
self
.
get
(
"
state
"
)
...
...
This diff is collapsed.
Click to expand it.
David Hammer
@hammerd
mentioned in commit
3944f163
·
1 year ago
mentioned in commit
3944f163
mentioned in commit 3944f1635711303a5efda425309be87d8c8fd88a
Toggle commit list
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment