-
Notifications
You must be signed in to change notification settings - Fork 4
Add dropdowns for EPICS mbb records #40
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #40 +/- ##
==========================================
+ Coverage 81.24% 82.78% +1.54%
==========================================
Files 22 23 +1
Lines 869 912 +43
==========================================
+ Hits 706 755 +49
+ Misses 163 157 -6 ☔ View full report in Codecov by Sentry. |
48ee34d
to
e324d66
Compare
This works for APIs that expect to be sent integers for enum options, but we also want to display any parameter that has allowed_values (a limited set of valid values) as an mbb and a combo box. In this case it shouldn't need the mapping. Perhaps Attributes should (optionally) have allowed_values, and then for the case that those allowed values are just integers, it could also have an additional list of string descriptions to override the STA fields and combo box text. |
Trying to think how best to do this. I guess it would be more generic to add a kwargs: Dict[str, Any] member to Attribute that could contain EPICS fields like ZRST, ONST, TWST that get passed into the Widget by _get_write_widget/_get_read_widget and in _get_input_record/_get_output_record as long as they match a list of allowed EPICS field names, and if ZRST, ONST.../ZRVL, ONVL... etc is found it populates a ComboBox/mbb, otherwise a long is used. Could then have the optional allowed_values attribute to handle the string case where we have more than 16 allowed values (as with the element parameter provided by Eiger/SIMPLON), or, and this is possibly uglier, it could be passed in as kwargs["allowed_values"] or kwargs["string_choices"]. |
Also realised in my testing that some logic is needed to ensure that ZRST, ONST etc are not longer than 25 characters, and if shortened should be made unique, though this may be something that is better handled in the adapters/controllers themselves e.g. eiger_fastcs |
3fc0a70
to
0a67b87
Compare
0cfbf5b
to
9ceba1e
Compare
9ceba1e
to
254a54e
Compare
Changes look good to me, appears to work as expected against fastcs-eiger with the tickit sim |
254a54e
to
6912fe7
Compare
6912fe7
to
533efc2
Compare
Just had another look and found a bug, trying to pin it down. When running fastcs-eiger there's an error with the element attribute (which has more than 16 allowed string values), when attr.set is called with the response value (a string), the following gets raised
The error goes away if change the line in
but maybe there's a better way to designate an Attribute as being an enum type. |
Yeah I'm not happy with that either. The trouble is, it having 16 or fewer fields is an EPICS-specific limitation. So, I am not sure how to encode that as a first class property of Attributes in a generic way. |
Add check for enum attributes and perform conversions in pythonSoftIOC wrapper functions. Co-authored-by: Gary Yendell <[email protected]>
Add some type ignores for bugs in mypy. These will be removed when moved to pyright.
506259d
to
dda9e45
Compare
OK I have refactored the enum logic into more helper functions to make it less intrusive to the core logic and added some more tests to get the coverage up. |
Adds enum_mapping attribute for Attribute classes, which expect a mapping of str to int
e.g.
{"string value 0": 0, "string value 1": 1}, and uses these to populate the ZRST, ONST, TWST... fields of an MBBO if enum_mapping is not None.
This implementation may be too specific for the EPICS case however, not sure if Tango etc use enums in other ways.