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
02aebda9
Commit
02aebda9
authored
1 year ago
by
David Hammer
Browse files
Options
Downloads
Patches
Plain Diff
Allow selecting one train from range and adding offset to PPU
parent
693698c2
No related branches found
Branches containing commit
No related tags found
1 merge request
!53
Train picker arbiter kernel
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/calng/PickyBoi.py
+50
-11
50 additions, 11 deletions
src/calng/PickyBoi.py
with
50 additions
and
11 deletions
src/calng/PickyBoi.py
+
50
−
11
View file @
02aebda9
...
...
@@ -21,6 +21,7 @@ from karabo.bound import (
ChannelMetaData
,
Epochstamp
,
ImageData
,
Hash
,
PythonDevice
,
Schema
,
State
,
...
...
@@ -76,12 +77,35 @@ class PickyBoi(PythonDevice):
.
reconfigurable
()
.
commit
(),
INT64_ELEMENT
(
expected
)
.
key
(
"
indexOfTrainToForward
"
)
.
description
(
"
If this value is negative, all numberOfTrainsToCatch starting from
"
"
nextTrainToCatch are forwarded. If non-negative, this is used as an
"
"
index in this range of trains instead i.e. only the train with ID
"
"
nextTrainToCatch + min(indexOfTrainToForward, numberOfTrainsToCatch-1)
"
"
will be forwarded. This is relevant for previewing in Karabo GUI.
"
)
.
assignmentOptional
()
.
defaultValue
(
-
1
)
.
commit
(),
STRING_ELEMENT
(
expected
)
.
key
(
"
ppuDevice
"
)
.
assignmentOptional
()
.
defaultValue
(
""
)
.
commit
(),
INT64_ELEMENT
(
expected
)
.
key
(
"
ppuTrainOffset
"
)
.
description
(
"
Offset added to trainTrigger.sequenceStart gotten from watched PPU
"
"
device. Should be 0 unless there are timing issues.
"
)
.
assignmentOptional
()
.
defaultValue
(
0
)
.
commit
(),
DOUBLE_ELEMENT
(
expected
)
.
key
(
"
ratioOfRecentTrainsReceived
"
)
.
description
(
...
...
@@ -189,7 +213,7 @@ class PickyBoi(PythonDevice):
conf
.
has
(
"
trainTrigger.numberOfTrains
"
)
or
conf
.
has
(
"
trainTrigger.sequenceStart
"
)
):
self
.
_update_target
()
self
.
_update_target
(
offset
=
self
.
get
(
"
ppuTrainOffset
"
)
)
def
input_handler
(
self
,
data
,
meta
):
if
not
self
.
_schema_is_set
:
...
...
@@ -253,12 +277,23 @@ class PickyBoi(PythonDevice):
self
.
updateState
(
State
.
PASSIVE
)
self
.
_previous_tid
=
current_tid
def
_update_target
(
self
):
# assumes nextTrainToCatch and numberOfTrainsToCatch have been set
new_target_tid
=
self
.
get
(
"
nextTrainToCatch
"
)
self
.
_trains_to_get
=
set
(
range
(
new_target_tid
,
new_target_tid
+
self
.
get
(
"
numberOfTrainsToCatch
"
))
)
def
_update_target
(
self
,
offset
=
0
):
# assumes nextTrainToCatch and numberOfTrainsToCatch etc. have been set
new_target_tid
=
self
.
get
(
"
nextTrainToCatch
"
)
+
offset
if
(
index_to_forward
:
=
self
.
get
(
"
indexOfTrainToForward
"
))
<
0
:
self
.
_trains_to_get
=
set
(
range
(
new_target_tid
,
new_target_tid
+
self
.
get
(
"
numberOfTrainsToCatch
"
)
)
)
else
:
self
.
_trains_to_get
=
set
(
(
new_target_tid
+
min
(
self
.
get
(
"
numberOfTrainsToCatch
"
)
-
1
,
index_to_forward
),
)
)
if
self
.
_previous_tid
>=
new_target_tid
:
self
.
log
.
INFO
(
f
"
Moved target train to
{
new_target_tid
}
even though last seen was
"
...
...
@@ -273,7 +308,6 @@ class PickyBoi(PythonDevice):
)
self
.
updateState
(
State
.
MONITORING
)
def
_update_trackers
(
self
):
if
self
.
get
(
"
trainId
"
)
!=
self
.
_previous_tid
:
self
.
set
(
...
...
@@ -297,11 +331,16 @@ class PickyBoi(PythonDevice):
self
.
log
.
WARN
(
"
postReconfigure update caching trick failed
"
)
return
if
(
self
.
_cached_update
.
has
(
"
nextTrainToCatch
"
)
or
self
.
_cached_update
.
has
(
"
numberOfTrainsToCatch
"
)
if
any
(
self
.
_cached_update
.
has
(
thing
)
for
thing
in
(
"
nextTrainToCatch
"
,
"
numberOfTrainsToCatch
"
,
"
indexOfTrainToForward
"
,
)
):
self
.
_update_target
()
del
self
.
_cached_update
def
hash_to_schema
(
h
,
root
=
None
,
prefix
=
""
):
...
...
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