pcdshub / typhos

Automatic-yet-customizable Graphical User Interface Generation for Ophyd Devices
http://pcdshub.github.io/typhos
Other
16 stars 26 forks source link

FIX: metadata handling for enums #616

Closed ZLLentz closed 3 months ago

ZLLentz commented 3 months ago

Description

Fix three issues related to enum/metadata handling in the SignalConnection part of the SignalPlugin and implement simplified unit tests for these cases.

Motivation and Context

closes #605 closes #608

How Has This Been Tested?

Unit tests were added. I originally tried to make a larger unit test where I instantiated real/fake EpicsSignal instances and connected them to the combobox widgets as reported in the issues, but I couldn't get this to work properly in a unit testing context. Rather than dump additional dev hours into this, I came up with simpler tests, possibly these could be better.

I will need to test with a real EPICS PV too.

Where Has This Been Documented?

I need to write some release notes

Pre-merge checklist

ZLLentz commented 3 months ago

Interactively, applying this fixed the mix-up between the enum values for putting to a ("1", "2", "5") enum signal but it actually increased the number of error messages I got at startup...

Before:

[2024-06-24 18:02:00,325] [ERROR   ] - Can not change value to '5'. Not an option in PyDMComboBox
[2024-06-24 18:02:00,326] [ERROR   ] - Can not change value to '5'. Not an option in PyDMComboBox

After:

[2024-06-24 18:03:02,868] [ERROR   ] - Can not change value to '1'. Not an option in PyDMComboBox
[2024-06-24 18:03:02,869] [ERROR   ] - Can not change value to '1'. Not an option in PyDMComboBox
[2024-06-24 18:03:02,869] [ERROR   ] - Can not change value to '1'. Not an option in PyDMComboBox
ZLLentz commented 3 months ago

Scratch that- the extra spam errors come from the signal not being fully connected when the widget comes online. Waiting for connection resolves the spam. This isn't something to overlook but it's unrelated to the problem the PR is fixing.

ZLLentz commented 3 months ago

Locally at LCLS we hadn't hit this yet for a couple reasons:

ZLLentz commented 3 months ago

Interestingly, as I was testing this, I found that there was also an equivalent issue for string=False signals, but whether this caused an issue depended on the precise implementation of the widget that we're connecting to. In the case of PyDM's combobox the values are sent through as integers, so the int-native signal was unaffected and the string-native signal was broken. A widget which sent the values through as strings would have broken int-native signals in the same way.