Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
fcdb7f3f
Commit
fcdb7f3f
authored
3 years ago
by
Jan David Mol
Browse files
Options
Downloads
Plain Diff
Merge branch '
L2SS-666
-fix-clear-poll-cache' into 'master'
L2SS-666
: Fix clear poll cache Closes
L2SS-666
See merge request
!270
parents
069a81d4
c129e52a
No related branches found
No related tags found
1 merge request
!270
L2SS-666: Fix clear poll cache
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
tangostationcontrol/tangostationcontrol/devices/lofar_device.py
+10
-23
10 additions, 23 deletions
...tationcontrol/tangostationcontrol/devices/lofar_device.py
with
10 additions
and
23 deletions
tangostationcontrol/tangostationcontrol/devices/lofar_device.py
+
10
−
23
View file @
fcdb7f3f
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
# PyTango imports
# PyTango imports
from
tango.server
import
attribute
,
command
,
Device
,
DeviceMeta
from
tango.server
import
attribute
,
command
,
Device
,
DeviceMeta
from
tango
import
AttrWriteType
,
DevState
,
DebugIt
,
Attribute
,
DeviceProxy
,
AttrDataFormat
from
tango
import
AttrWriteType
,
DevState
,
DebugIt
,
Attribute
,
DeviceProxy
,
AttrDataFormat
,
DevSource
import
time
import
time
import
math
import
math
import
numpy
import
numpy
...
@@ -83,26 +83,6 @@ class lofar_device(Device, metaclass=DeviceMeta):
...
@@ -83,26 +83,6 @@ class lofar_device(Device, metaclass=DeviceMeta):
return
self
.
get_state
()
in
[
DevState
.
STANDBY
,
DevState
.
ON
,
DevState
.
ALARM
]
return
self
.
get_state
()
in
[
DevState
.
STANDBY
,
DevState
.
ON
,
DevState
.
ALARM
]
def
clear_poll_cache
(
self
):
"""
Remove all attributes from the poll cache, to remove stale entries
once we know the values can be read.
"""
# we use proxy.attribute_query_list(), as proxy.get_attribute_list() will throw if we
# call it too soon when starting everything (database, device) from scratch.
attr_names
=
[
config
.
name
for
config
in
self
.
proxy
.
attribute_list_query
()]
for
attr_name
in
attr_names
:
if
self
.
proxy
.
is_attribute_polled
(
attr_name
):
# save poll period
poll_period
=
self
.
proxy
.
get_attribute_poll_period
(
attr_name
)
try
:
# stop polling to remove cache entry
self
.
proxy
.
stop_poll_attribute
(
attr_name
)
finally
:
# start polling again
self
.
proxy
.
poll_attribute
(
attr_name
,
poll_period
)
@log_exceptions
()
@log_exceptions
()
def
init_device
(
self
):
def
init_device
(
self
):
"""
Instantiates the device in the OFF state.
"""
"""
Instantiates the device in the OFF state.
"""
...
@@ -123,6 +103,7 @@ class lofar_device(Device, metaclass=DeviceMeta):
...
@@ -123,6 +103,7 @@ class lofar_device(Device, metaclass=DeviceMeta):
# we cannot write directly to our attribute, as that would not
# we cannot write directly to our attribute, as that would not
# trigger a write_{name} call. See https://www.tango-controls.org/community/forum/c/development/c/accessing-own-deviceproxy-class/?page=1#post-2021
# trigger a write_{name} call. See https://www.tango-controls.org/community/forum/c/development/c/accessing-own-deviceproxy-class/?page=1#post-2021
self
.
proxy
=
DeviceProxy
(
self
.
get_name
())
self
.
proxy
=
DeviceProxy
(
self
.
get_name
())
self
.
proxy
.
set_source
(
DevSource
.
DEV
)
@log_exceptions
()
@log_exceptions
()
def
delete_device
(
self
):
def
delete_device
(
self
):
...
@@ -163,8 +144,14 @@ class lofar_device(Device, metaclass=DeviceMeta):
...
@@ -163,8 +144,14 @@ class lofar_device(Device, metaclass=DeviceMeta):
self
.
configure_for_initialise
()
self
.
configure_for_initialise
()
# any values read so far are stale. clear the polling cache.
# WARNING: any values read so far are stale.
self
.
clear_poll_cache
()
# Proxies either need to wait for the next poll round, or
# use proxy.set_source(DevSource.DEV) to avoid the cache
# alltogether.
#
# Actually clearing the polling cache runs into performance
# problems if a lot of attributes are polled, and into race
# conditions with the polling thread itself.
self
.
set_state
(
DevState
.
STANDBY
)
self
.
set_state
(
DevState
.
STANDBY
)
self
.
set_status
(
"
Device is in the STANDBY state.
"
)
self
.
set_status
(
"
Device is in the STANDBY state.
"
)
...
...
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