-
Notifications
You must be signed in to change notification settings - Fork 74
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
ByteIndicator Does not display negative numbers #970
Comments
Hello, The PyDM team is assessing which route to approach this change and were wondering if something like this new widget request #922 work for your needs? |
Hi, I dont' think a new widget would be necessary to solve the issue. But if there is something that would prohibit the use of a negative value, then sure. Otherwise just allowing the byte indicator to display the bits of a value without limiting the value to be positive would be great. |
Hi, initial draft up here: #1025 if we want to err on the side of caution, we could enable this feature with a QtDesigner option for the widget. Something like "displayNegatives" that is toggled off by default. |
What do you expect that the bits of a negative value should be in your application? I think the ByteIndicator doesn't support (negative) signed values because they don't make much sense from the perspective of displaying a bit mask as a string of on/off LEDs. For a bit of background - when it comes to representing negative numbers on a computer, it could be through one's/two's complement or even just the most significant bit could represent the sign (see here). Additionally, there's a matter of the bit width - if we are to sign extend the negative number to show it in the byte indicator, are we talking 32-bit integers in every case? Most likely not. PyDM (to my recollection) doesn't retain the bit width of integer values from the control system, so does the byte indicator need a bit width setting for negative numbers? |
hi, agree that two's complement for negative numbers doesn't make much sense here, not super familiar with all the use cases of this widget, but seems reasonable to drop the sign and display the absolute value of negative numbers. (what i interpreted jozamudi's ask to be, but please clarify if not), especially if added as toggleable option for the widget (off by default) and possibly some visual indication that its displaying negative. currently negative numbers display nothing in the widget, so think that toggle adds additional functionality without compromising original usage. |
Describe the bug
When the value of the ByteIndicator widget is a negative the byte indicator displays all bits are off.
Expected behavior
The byteIndicator should display the bits regardless if the value is signed or unsigned.
Steps to Reproduce
Set the value of the ByteIndicator negative.
Possible Solution
In the ByteIndicator class, the function update_indicators. There is an 'if' statement that sets the value to zero if the value is negative. Removing this 'if' statement fixes the issue.
My Platform
Additional context
The text was updated successfully, but these errors were encountered: