-
Notifications
You must be signed in to change notification settings - Fork 62
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
Refactor States Devices #434
Comments
I'd wager you're already thinking of using string enums, but regardless a few points in favor of refactoring using them: In [3]: class StateEnum(str, enum.Enum):
...: state_a = 'state_a'
...: state_b = 'state_b'
...:
In [4]: StateEnum.state_a == 'state_a'
Out[4]: True
In [5]: StateEnum['state_a']
Out[5]: <StateEnum.state_a: 'state_a'> Raises |
That's neat, I didn't know there were specialized |
Case insensitive option would be interesting, hmm |
How does this apply to #412? The zoom and focus motors (at least for now) are not set up as StatePositioners. |
I picked the wrong issue by accident, fixed |
Case insensitivity would be used for something like: |
The refactored solution should ensure #406 is addressed, with the exception text reproduced here: [2020-03-31 14:20:34,112] [ERROR ] - Subscription meta callback exception (EpicsSignal(read_pv='IM1L0:XTES:MMS:STATE:GET_RBV', name='im1l0_y_states_state', parent='im1l0_y_states', value=4, timestamp=1585229929.895677, auto_monitor=False, string=False, write_pv='IM1L0:XTES:MMS:STATE:SET', limits=False, put_complete=False))
Traceback (most recent call last):
File "/reg/g/pcds/pyps/apps/dev/pythonpath/ophyd/ophydobj.py", line 471, in inner
cb(*args, **kwargs)
File "/reg/g/pcds/pyps/apps/dev/pythonpath/pcdsdevices/state.py", line 108, in _late_state_init
self._state_init()
File "/reg/g/pcds/pyps/apps/dev/pythonpath/ophyd/device.py", line 1607, in wrapped
ret = func(self, *args, **kwargs)
File "/reg/g/pcds/pyps/apps/dev/pythonpath/pcdsdevices/state.py", line 544, in _state_init
super()._state_init()
File "/reg/g/pcds/pyps/apps/dev/pythonpath/ophyd/device.py", line 1607, in wrapped
ret = func(self, *args, **kwargs)
File "/reg/g/pcds/pyps/apps/dev/pythonpath/pcdsdevices/inout.py", line 73, in _state_init
self._extend_trans_enum(self.out_states, 1)
File "/reg/g/pcds/pyps/apps/dev/pythonpath/pcdsdevices/inout.py", line 124, in _extend_trans_enum
index = self.states_list.index(state)
ValueError: 'OUT' is not in list and summarizing per @ZLLentz in that issue:
(the case sensitivity considerations mentioned above) |
Expected Behavior
Current Behavior
Possible Solution
Context
(even after much effort today/yesterday)
The text was updated successfully, but these errors were encountered: