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
36f9fd0b
Commit
36f9fd0b
authored
11 months ago
by
Philipp Schmidt
Committed by
David Hammer
11 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Ping managed devices to check whether they're still alive
parent
b8a7b338
No related branches found
No related tags found
1 merge request
!92
Ping managed devices to check whether they're still alive
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/calng/CalibrationManager.py
+26
-31
26 additions, 31 deletions
src/calng/CalibrationManager.py
with
26 additions
and
31 deletions
src/calng/CalibrationManager.py
+
26
−
31
View file @
36f9fd0b
...
@@ -465,14 +465,6 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -465,14 +465,6 @@ class CalibrationManager(DeviceClientBase, Device):
defaultValue
=
[],
defaultValue
=
[],
accessMode
=
AccessMode
.
READONLY
)
accessMode
=
AccessMode
.
READONLY
)
@Slot
(
displayedName
=
'
Discover managed devices
'
,
description
=
''
,
allowedStates
=
[
State
.
ACTIVE
])
async
def
discoverManagedDevices
(
self
):
self
.
state
=
State
.
CHANGING
background
(
self
.
_discover_managed_devices
())
@Slot
(
@Slot
(
displayedName
=
'
Apply managed values
'
,
displayedName
=
'
Apply managed values
'
,
description
=
'
Set all managed keys to the values currently active on
'
description
=
'
Set all managed keys to the values currently active on
'
...
@@ -581,7 +573,6 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -581,7 +573,6 @@ class CalibrationManager(DeviceClientBase, Device):
if
info
[
'
type
'
]
==
'
device
'
:
if
info
[
'
type
'
]
==
'
device
'
:
self
.
_check_new_device
(
instance_id
,
info
[
'
serverId
'
],
self
.
_check_new_device
(
instance_id
,
info
[
'
serverId
'
],
info
[
'
classId
'
])
info
[
'
classId
'
])
self
.
_update_managed_devices
()
@slot
@slot
def
slotInstanceGone
(
self
,
instance_id
,
info
):
def
slotInstanceGone
(
self
,
instance_id
,
info
):
...
@@ -590,12 +581,7 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -590,12 +581,7 @@ class CalibrationManager(DeviceClientBase, Device):
super
().
slotInstanceGone
(
instance_id
,
info
)
super
().
slotInstanceGone
(
instance_id
,
info
)
if
info
[
'
type
'
]
==
'
device
'
:
if
info
[
'
type
'
]
==
'
device
'
:
self
.
_daq_device_ids
.
discard
(
instance_id
)
self
.
_remove_managed_device
(
instance_id
)
self
.
_domain_device_ids
.
discard
(
instance_id
)
self
.
_managed_device_ids
.
discard
(
instance_id
)
self
.
_correction_device_ids
.
discard
(
instance_id
)
self
.
_assembler_device_ids
.
discard
(
instance_id
)
self
.
_update_managed_devices
()
async
def
_async_init
(
self
):
async
def
_async_init
(
self
):
# Set-up Tornado.
# Set-up Tornado.
...
@@ -651,6 +637,16 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -651,6 +637,16 @@ class CalibrationManager(DeviceClientBase, Device):
# This device is also an assembler
# This device is also an assembler
self
.
_assembler_device_ids
.
add
(
device_id
)
self
.
_assembler_device_ids
.
add
(
device_id
)
self
.
_update_managed_devices
()
def
_remove_managed_device
(
self
,
device_id
):
self
.
_daq_device_ids
.
discard
(
device_id
)
self
.
_domain_device_ids
.
discard
(
device_id
)
self
.
_managed_device_ids
.
discard
(
device_id
)
self
.
_correction_device_ids
.
discard
(
device_id
)
self
.
_assembler_device_ids
.
discard
(
device_id
)
self
.
_update_managed_devices
()
async
def
_check_topology
(
self
):
async
def
_check_topology
(
self
):
for
i
in
range
(
10
):
for
i
in
range
(
10
):
try
:
try
:
...
@@ -673,34 +669,30 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -673,34 +669,30 @@ class CalibrationManager(DeviceClientBase, Device):
self
.
_check_new_device
(
device_id
,
devices
[
device_id
,
'
serverId
'
],
self
.
_check_new_device
(
device_id
,
devices
[
device_id
,
'
serverId
'
],
devices
[
device_id
,
'
classId
'
])
devices
[
device_id
,
'
classId
'
])
self
.
_update_managed_devices
(
True
)
async
def
_ping_managed_devices
(
self
):
device_ids
=
sorted
(
self
.
_managed_device_ids
)
async
def
_discover_managed_devices
(
self
):
self
.
_daq_device_ids
.
clear
()
self
.
_domain_device_ids
.
clear
()
self
.
_managed_device_ids
.
clear
()
self
.
_correction_device_ids
.
clear
()
self
.
_assembler_device_ids
.
clear
()
await
self
.
_check_topology
()
device_infos
=
await
gather
(
*
[
wait_for
(
getInstanceInfo
(
device_id
),
timeout
=
5
)
for
device_id
in
device_ids
],
return_exceptions
=
True
)
self
.
state
=
State
.
ACTIVE
for
device_id
,
device_info
in
zip
(
device_ids
,
device_infos
):
if
isinstance
(
device_info
,
AsyncTimeoutError
):
self
.
_remove_managed_device
(
device_id
)
async
def
_delayed_managed_devices_update
(
self
):
async
def
_delayed_managed_devices_update
(
self
):
await
sleep
(
1.0
)
# Throttle updates to at most once a second.
await
sleep
(
1.0
)
# Throttle updates to at most once a second.
self
.
managedDevices
=
sorted
(
self
.
_managed_device_ids
)
self
.
managedDevices
=
sorted
(
self
.
_managed_device_ids
)
self
.
_managed_devices_updater
=
None
# Clear task again.
self
.
_managed_devices_updater
=
None
# Clear task again.
def
_update_managed_devices
(
self
,
forced
=
False
):
def
_update_managed_devices
(
self
):
if
self
.
_managed_devices_updater
is
not
None
:
if
self
.
_managed_devices_updater
is
not
None
:
# Update already in progress, ignore.
# Update already in progress, ignore.
return
return
if
forced
or
len
(
self
.
_managed_device_ids
)
!=
len
(
self
.
managedDevices
):
self
.
_managed_devices_updater
=
background
(
# Trigger an update either if forced or the number of
self
.
_delayed_managed_devices_update
())
# devices changed.
self
.
_managed_devices_updater
=
background
(
self
.
_delayed_managed_devices_update
())
async
def
_get_shared_keys
(
self
,
device_ids
,
keys
):
async
def
_get_shared_keys
(
self
,
device_ids
,
keys
):
"""
Find the most common property values on devices.
"""
"""
Find the most common property values on devices.
"""
...
@@ -1277,6 +1269,9 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -1277,6 +1269,9 @@ class CalibrationManager(DeviceClientBase, Device):
'
listed in the device servers
'
'
listed in the device servers
'
'
configuration
'
)
'
configuration
'
)
# Ping all known managed devices to make sure they're alive.
await
self
.
_ping_managed_devices
()
# Instantiate modules.
# Instantiate modules.
modules_by_group
=
defaultdict
(
list
)
modules_by_group
=
defaultdict
(
list
)
correct_device_id_by_module
=
{}
correct_device_id_by_module
=
{}
...
...
This diff is collapsed.
Click to expand it.
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