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
3dcad0a5
Commit
3dcad0a5
authored
3 years ago
by
David Hammer
Browse files
Options
Downloads
Patches
Plain Diff
Make SimpleAssembler ask for geometry on init
parent
4683ca2f
No related branches found
No related tags found
1 merge request
!12
Snapshot: field test deployed version as of end of run 202201
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/calng/SimpleAssembler.py
+33
-0
33 additions, 0 deletions
src/calng/SimpleAssembler.py
with
33 additions
and
0 deletions
src/calng/SimpleAssembler.py
+
33
−
0
View file @
3dcad0a5
import
functools
import
pickle
import
re
import
threading
import
time
import
numpy
as
np
from
karabo.bound
import
(
...
...
@@ -127,6 +129,7 @@ class SimpleAssembler(TrainMatcher.TrainMatcher):
self
.
KARABO_ON_DATA
(
"
geometryInput
"
,
self
.
receive_geometry
)
self
.
KARABO_SLOT
(
self
.
requestScene
)
self
.
ask_for_geometry
()
self
.
start
()
def
requestScene
(
self
,
params
):
...
...
@@ -156,8 +159,38 @@ class SimpleAssembler(TrainMatcher.TrainMatcher):
def
receive_geometry
(
self
,
data
,
metadata
):
self
.
log
.
INFO
(
"
Received a new geometry
"
)
self
.
geometry
=
pickle
.
loads
(
data
.
get
(
"
pickledGeometry
"
))
# TODO: allow multiple memory cells (extra geom notion of extra dimensions)
self
.
input_buffer
=
np
.
zeros
(
self
.
geometry
.
expected_data_shape
)
def
ask_for_geometry
(
self
):
def
runner
():
self
.
log
.
INFO
(
"
Will ask around for a geometry
"
)
max_tries
=
10
for
i
in
range
(
max_tries
):
time
.
sleep
(
np
.
random
.
random
()
*
10
)
if
self
.
geometry
is
None
:
missing_connections
=
set
(
self
.
get
(
"
geometryInput.missingConnections
"
)
)
# note: connectedOutputChannels not necessarily connected...
geometry_device_list
=
[
channel
for
channel
in
self
.
get
(
"
geometryInput.connectedOutputChannels
"
)
if
channel
not
in
missing_connections
]
if
not
geometry_device_list
:
self
.
log
.
INFO
(
"
No geometry device connected
"
)
continue
geometry_device
=
geometry_device_list
[
0
].
split
(
"
:
"
)[
0
]
self
.
log
.
INFO
(
f
"
Asking
{
geometry_device
}
for a geometry
"
)
self
.
signalSlotable
.
call
(
geometry_device
,
"
pleaseSendYourGeometry
"
)
time
.
sleep
(
1
)
if
self
.
geometry
is
not
None
:
return
self
.
log
.
INFO
(
f
"
Failed to get geometry in
{
max_tries
}
tries, need help
"
)
threading
.
Thread
(
target
=
runner
,
daemon
=
True
).
start
()
def
_send
(
self
,
train_id
,
sources
):
# TODO: adapt to appropriate hook for new TrainMatcher (no _send)
if
self
.
geometry
is
None
:
...
...
This diff is collapsed.
Click to expand it.
David Hammer
@hammerd
mentioned in commit
3566342d
·
2 years ago
mentioned in commit
3566342d
mentioned in commit 3566342d031db1bb435b6430f100afdbaaa6c4bf
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