Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cfel-sc-public
Kamzik3
Commits
46260b05
Commit
46260b05
authored
May 16, 2022
by
Philipp Middendorf
Browse files
Merge branch 'bug_limits' into 'master'
attributeDeviceDisplayWidget.py: fix bug with soft limits See merge request
!35
parents
c20d2b1e
c5eb0044
Pipeline
#28225
passed with stages
in 10 minutes and 53 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
kamzik3/gui/attributeDeviceDisplayWidget.py
View file @
46260b05
import
time
from
collections
import
deque
import
pint
from
PyQt5.QtCore
import
pyqtSignal
,
pyqtSlot
from
pint
import
DimensionalityError
from
typing
import
Dict
,
Tuple
...
...
@@ -138,25 +139,40 @@ class AttributeDeviceDisplayWidget(DeviceWidget, AttributeDisplayWidget):
)
def
on_value_set
(
self
,
value
):
if
isinstance
(
value
,
units
.
Quantity
):
self
.
_add_in_setpoint_history
(
value
)
self
.
logger
.
info
(
"Set {} to {}"
.
format
(
self
.
initial_attribute
,
value
))
value
=
value
.
to
(
self
.
attribute
[
UNIT
])
value
=
value
.
m
elif
self
.
attribute
.
numerical
and
self
.
get_unit
()
is
not
None
:
try
:
value
=
units
.
Quantity
(
value
,
self
.
get_unit
())
if
isinstance
(
value
,
units
.
Quantity
)
or
(
self
.
attribute
.
numerical
and
self
.
get_unit
()
is
not
None
):
if
not
isinstance
(
value
,
units
.
Quantity
):
try
:
value
=
units
.
Quantity
(
value
,
self
.
get_unit
())
value
=
value
.
to
(
self
.
attribute
[
UNIT
])
except
(
AttributeError
,
pint
.
UndefinedUnitError
,
pint
.
DefinitionSyntaxError
,
):
value
=
units
.
Quantity
(
value
)
else
:
value
=
value
.
to
(
self
.
attribute
[
UNIT
])
if
self
.
attribute
.
within_limits
(
value
):
value
=
value
.
m
self
.
_add_in_setpoint_history
(
value
)
self
.
logger
.
info
(
"Set {} to {}"
.
format
(
self
.
initial_attribute
,
value
))
value
=
value
.
to
(
self
.
attribute
[
UNIT
]).
m
except
AttributeError
:
pass
self
.
logger
.
info
(
"Set {} to {} {}"
.
format
(
self
.
initial_attribute
,
value
,
self
.
attribute
[
UNIT
]
)
)
else
:
self
.
logger
.
info
(
f
"Can't set value
{
value
}
, out of limits"
)
value
=
self
.
attribute
.
value
().
m
# set value back to what it was before
elif
self
.
attribute
[
TYPE
]
==
TYPE_LIST
:
value
=
self
.
get_widget_value
()
try
:
self
.
device
.
set_attribute
(
self
.
initial_attribute
+
[
VALUE
],
self
.
initial_attribute
+
[
VALUE
],
# e.g. ['Position', 'Value']
self
.
attribute_widget
.
attribute_type_cast
(
value
),
callback
=
self
.
sigErrorCheck
.
emit
,
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment