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
23e2d67e
Commit
23e2d67e
authored
3 years ago
by
Philipp Schmidt
Committed by
sqsonc
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
manager: Show tracked devices as a property
parent
22f5e9e1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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/CalibrationManager.py
+41
-6
41 additions, 6 deletions
src/calng/CalibrationManager.py
with
41 additions
and
6 deletions
src/calng/CalibrationManager.py
+
41
−
6
View file @
23e2d67e
...
@@ -412,6 +412,12 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -412,6 +412,12 @@ class CalibrationManager(DeviceClientBase, Device):
self
.
state
=
State
.
CHANGING
self
.
state
=
State
.
CHANGING
background
(
self
.
_instantiate_pipeline
())
background
(
self
.
_instantiate_pipeline
())
managedDevices
=
VectorString
(
displayedName
=
'
Managed devices
'
,
description
=
'
List of currently managed devices.
'
,
defaultValue
=
[],
accessMode
=
AccessMode
.
READONLY
)
@Slot
(
@Slot
(
displayedName
=
'
Discover managed devices
'
,
displayedName
=
'
Discover managed devices
'
,
description
=
''
,
description
=
''
,
...
@@ -428,7 +434,7 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -428,7 +434,7 @@ class CalibrationManager(DeviceClientBase, Device):
async
def
applyManagedValues
(
self
):
async
def
applyManagedValues
(
self
):
background
(
self
.
_apply_managed_values
())
background
(
self
.
_apply_managed_values
())
managed
=
Node
(
managed
Keys
=
Node
(
ManagedKeysNode
,
ManagedKeysNode
,
displayedName
=
'
Managed keys
'
,
displayedName
=
'
Managed keys
'
,
description
=
'
Properties and slots managed on devices in the pipeline.
'
)
description
=
'
Properties and slots managed on devices in the pipeline.
'
)
...
@@ -464,6 +470,9 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -464,6 +470,9 @@ class CalibrationManager(DeviceClientBase, Device):
# in the same domain and having the specified class ID.
# in the same domain and having the specified class ID.
self
.
_correction_device_ids
=
set
()
self
.
_correction_device_ids
=
set
()
# Task object to update managed devices list.
self
.
_managed_devices_updater
=
None
async
def
onInitialization
(
self
):
async
def
onInitialization
(
self
):
self
.
state
=
State
.
INIT
self
.
state
=
State
.
INIT
...
@@ -482,6 +491,7 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -482,6 +491,7 @@ class CalibrationManager(DeviceClientBase, Device):
if
info
[
'
type
'
]
==
'
device
'
:
if
info
[
'
type
'
]
==
'
device
'
:
self
.
_check_new_device
(
instance_id
,
info
[
'
classId
'
])
self
.
_check_new_device
(
instance_id
,
info
[
'
classId
'
])
self
.
_update_managed_devices
()
@slot
@slot
def
slotInstanceGone
(
self
,
instance_id
,
info
):
def
slotInstanceGone
(
self
,
instance_id
,
info
):
...
@@ -493,6 +503,7 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -493,6 +503,7 @@ class CalibrationManager(DeviceClientBase, Device):
self
.
_daq_device_ids
.
discard
(
instance_id
)
self
.
_daq_device_ids
.
discard
(
instance_id
)
self
.
_domain_device_ids
.
discard
(
instance_id
)
self
.
_domain_device_ids
.
discard
(
instance_id
)
self
.
_correction_device_ids
.
discard
(
instance_id
)
self
.
_correction_device_ids
.
discard
(
instance_id
)
self
.
_update_managed_devices
()
async
def
_async_init
(
self
):
async
def
_async_init
(
self
):
# Populate the device ID sets with what's out there right now.
# Populate the device ID sets with what's out there right now.
...
@@ -523,7 +534,10 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -523,7 +534,10 @@ class CalibrationManager(DeviceClientBase, Device):
elif
device_id
.
startswith
(
self
.
_device_id_root
):
elif
device_id
.
startswith
(
self
.
_device_id_root
):
# This device lives under the same device ID root as this
# This device lives under the same device ID root as this
# manager instance.
# manager instance, but don't add yourself!
if
device_id
==
self
.
deviceId
:
return
self
.
_domain_device_ids
.
add
(
device_id
)
self
.
_domain_device_ids
.
add
(
device_id
)
if
class_id
==
self
.
_correction_class_id
:
if
class_id
==
self
.
_correction_class_id
:
...
@@ -551,6 +565,8 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -551,6 +565,8 @@ class CalibrationManager(DeviceClientBase, Device):
for
device_id
in
devices
:
for
device_id
in
devices
:
self
.
_check_new_device
(
device_id
,
devices
[
device_id
,
'
classId
'
])
self
.
_check_new_device
(
device_id
,
devices
[
device_id
,
'
classId
'
])
self
.
_update_managed_devices
(
True
)
async
def
_discover_managed_devices
(
self
):
async
def
_discover_managed_devices
(
self
):
self
.
_daq_device_ids
.
clear
()
self
.
_daq_device_ids
.
clear
()
self
.
_domain_device_ids
.
clear
()
self
.
_domain_device_ids
.
clear
()
...
@@ -560,6 +576,25 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -560,6 +576,25 @@ class CalibrationManager(DeviceClientBase, Device):
self
.
state
=
State
.
ACTIVE
self
.
state
=
State
.
ACTIVE
async
def
_delayed_managed_devices_update
(
self
):
await
sleep
(
1.0
)
# Throttle updates to at most once a second.
self
.
managedDevices
=
sorted
(
self
.
_domain_device_ids
|
self
.
_daq_device_ids
)
self
.
_managed_devices_updater
=
None
# Clear task again.
def
_update_managed_devices
(
self
,
forced
=
False
):
if
self
.
_managed_devices_updater
is
not
None
:
# Update already in progress, ignore.
return
all_managed_devices
=
self
.
_domain_device_ids
|
self
.
_daq_device_ids
if
forced
or
len
(
all_managed_devices
)
!=
len
(
self
.
managedDevices
):
# Trigger an update either if forced or the number of
# 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.
"""
...
@@ -682,9 +717,9 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -682,9 +717,9 @@ class CalibrationManager(DeviceClientBase, Device):
# The value are then obtained from the Node object again since
# The value are then obtained from the Node object again since
# enums are converted to their values by toSchemaAndAttrs, which
# enums are converted to their values by toSchemaAndAttrs, which
# in turn is not valid for property definition.
# in turn is not valid for property definition.
_
,
attrs
=
Descriptor
.
toSchemaAndAttrs
(
self
.
__class__
.
managed
,
_
,
attrs
=
Descriptor
.
toSchemaAndAttrs
(
self
.
__class__
.
managed
Keys
,
None
,
None
)
None
,
None
)
managed_node_attrs
=
{
key
:
getattr
(
self
.
__class__
.
managed
,
key
)
managed_node_attrs
=
{
key
:
getattr
(
self
.
__class__
.
managed
Keys
,
key
)
for
key
in
attrs
.
keys
()}
for
key
in
attrs
.
keys
()}
# Build a proxy from the managed schema, and create a new node
# Build a proxy from the managed schema, and create a new node
...
@@ -712,7 +747,7 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -712,7 +747,7 @@ class CalibrationManager(DeviceClientBase, Device):
remote_key
=
remote_key
):
remote_key
=
remote_key
):
background
(
self
.
_call_on_corrections
(
remote_key
))
background
(
self
.
_call_on_corrections
(
remote_key
))
_managed_slot_called
.
__name__
=
f
'
managed.
{
local_key
}
'
_managed_slot_called
.
__name__
=
f
'
managed
Keys
.
{
local_key
}
'
descr
.
__call__
(
_managed_slot_called
)
descr
.
__call__
(
_managed_slot_called
)
# Managed slots can only be called in the ACTIVE
# Managed slots can only be called in the ACTIVE
...
@@ -761,7 +796,7 @@ class CalibrationManager(DeviceClientBase, Device):
...
@@ -761,7 +796,7 @@ class CalibrationManager(DeviceClientBase, Device):
_sanitize_node
(
managed_node
,
managed_hash
)
_sanitize_node
(
managed_node
,
managed_hash
)
# Inject the newly prepared node for managed keys.
# Inject the newly prepared node for managed keys.
self
.
__class__
.
managed
=
managed_node
self
.
__class__
.
managed
Keys
=
managed_node
await
self
.
publishInjectedParameters
()
await
self
.
publishInjectedParameters
()
self
.
_managed_keys
=
managed_keys
self
.
_managed_keys
=
managed_keys
...
...
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