Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
AttributeWrapper
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review 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
AttributeWrapper
Commits
0d2650e9
Commit
0d2650e9
authored
Jan 15, 2024
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-1650
: Allow Tango threads during read/write
parent
95128caa
Branches
Branches containing commit
No related tags found
1 merge request
!4
L2SS-1650: Allow Tango threads during read/write
Pipeline
#68888
failed
Jan 15, 2024
Stage: image
Stage: lint
Stage: test
Stage: package
Stage: integration
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
attribute_wrapper/attribute_wrapper.py
+21
-11
21 additions, 11 deletions
attribute_wrapper/attribute_wrapper.py
with
21 additions
and
11 deletions
attribute_wrapper/attribute_wrapper.py
+
21
−
11
View file @
0d2650e9
...
...
@@ -4,8 +4,9 @@
import
logging
from
functools
import
reduce
from
operator
import
mul
from
contextlib
import
nullcontext
from
tango
import
AttrWriteType
,
AttReqType
from
tango
import
AttrWriteType
,
AttReqType
,
AutoTangoAllowThreads
from
tango.server
import
attribute
from
attribute_wrapper.attribute_io
import
AttributeIO
...
...
@@ -26,6 +27,7 @@ class AttributeWrapper(attribute):
datatype
=
None
,
dims
=
(
1
,),
access
=
AttrWriteType
.
READ
,
allow_threads
=
True
,
**
kwargs
,
):
"""
...
...
@@ -41,6 +43,8 @@ class AttributeWrapper(attribute):
datatype: any numpy datatype
dims: dimensions of the attribute as a tuple, or (1,) for a scalar.
init_value: value
allow_threads: if True, release Tango device lock during I/O, allowing other Tango
threads to execute.
"""
# ensure the type is a numpy array.
...
...
@@ -62,6 +66,8 @@ class AttributeWrapper(attribute):
self
.
datatype
=
datatype
self
.
io_context
=
AutoTangoAllowThreads
if
allow_threads
else
nullcontext
if
dims
==
(
1
,):
# scalar
# Tango defines a scalar as having dimensions (1,0), see
...
...
@@ -109,6 +115,7 @@ class AttributeWrapper(attribute):
try
:
io
=
self
.
get_attribute_io
(
device
)
with
self
.
io_context
(
device
):
return
io
.
cached_write_function
(
value
)
except
Exception
as
e
:
raise
e
.
__class__
(
...
...
@@ -129,6 +136,7 @@ class AttributeWrapper(attribute):
try
:
io
=
self
.
get_attribute_io
(
device
)
with
self
.
io_context
(
device
):
return
io
.
cached_read_function
()
except
Exception
as
e
:
raise
e
.
__class__
(
...
...
@@ -154,6 +162,7 @@ class AttributeWrapper(attribute):
try
:
io
=
self
.
get_attribute_io
(
device
)
with
AutoTangoAllowThreads
(
device
):
return
io
.
read_function
()
except
Exception
as
e
:
raise
e
.
__class__
(
...
...
@@ -182,14 +191,15 @@ class AttributeWrapper(attribute):
**
kwargs
,
)
def
get
_attribute_io
(
self
,
device
)
:
"""
Returns the attribute I/O functions from
device
"""
def
make
_attribute_io
(
self
,
device
:
Device
)
->
AttributeIO
:
"""
Creates and returns a new AttributeIO object for a given
device
"""
try
:
return
device
.
_attribute_wrapper_io
[
self
]
except
KeyError
:
device
.
_attribute_wrapper_io
[
self
]
=
AttributeIO
(
device
,
self
)
return
device
.
_attribute_wrapper_io
[
self
]
return
AttributeIO
(
device
,
self
)
def
get_attribute_io
(
self
,
device
:
Device
)
->
AttributeIO
:
"""
Returns the (cached) attribute I/O functions from device
"""
return
device
.
_attribute_wrapper_io
.
setdefault
(
self
,
self
.
make_attribute_io
(
device
))
def
set_comm_client
(
self
,
device
,
client
):
"""
Takes communication client with
'
get_mapping
'
function
...
...
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