Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: PyDMSlider out of bounds bug #1084

Merged
merged 7 commits into from
Jul 10, 2024
Merged

Conversation

phys-cgarnier
Copy link
Contributor

The PyDMSlider has a bug(s) when the channel it is connected to is a certain type of PV (epics record). If the record is an analog out (ao), and it does not have the record fields DRVH and DRVL set, then the slider is not forced to be within the bounds of the minimum and maximum properties. Since the default values of DRVH and DRVL are both zero, the slider wouldn't have a range of allowed values outside of "0".

This can cause two bugs. The first was calculated step size becomes 0, which would essentially form a never ending while loop of allowed positions when the slider value was out of bounds. The second bug is PV values could be out of the slider bounds.

These bugs only occur when both DRVH and DRVL were at default values. If either was set it would not occur. This PR has code to catch these edges and then raise value errors since we neither want a unending loop or a slider with values existing out of bounds.

@@ -538,7 +543,9 @@ def calc_step_size(self):
Given max, min, and num steps calculate step size
"""
self.step_size = (self.maximum - self.minimum) / self.num_steps
Copy link
Collaborator

@nstelter-slac nstelter-slac Jun 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we check for 0-division here?

could self.num_steps be 0 here if self.maximum == self.minimum?

self.num_steps = (self.maximum - self.minimum) / self._step_size

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it could. I'll put another check there.

@YektaY YektaY changed the title PyDMSlider out of bounds bug FIX: PyDMSlider out of bounds bug Jun 26, 2024
@nstelter-slac nstelter-slac merged commit ea25d55 into slaclab:master Jul 10, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants