Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions nslsii/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@

_time_fmtstr = '%Y-%m-%d %H:%M:%S'


class TwoButtonShutter(Device):
# TODO: this needs to be fixed in EPICS as these names make no sense
# the value coming out of the PV does not match what is shown in CSS
class TwoButtonActuator(Device):
RETRY_PERIOD = 0.5
MAX_ATTEMPTS = 10
open_cmd = Cpt(EpicsSignal, 'Cmd:Opn-Cmd', string=True)
Expand Down Expand Up @@ -97,17 +94,6 @@ def cmd_retry_cb(value, timestamp, **kwargs):

return st

def stop(self, *, success=False):
import time
prev_st = self._set_st
if prev_st is not None:
while not prev_st.done:
time.sleep(.1)
self._was_open = (self.open_val == self.status.get())
st = self.set('Close')
while not st.done:
time.sleep(.5)

def resume(self):
import time
prev_st = self._set_st
Expand All @@ -128,3 +114,21 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._set_st = None
self.read_attrs = ['status']


class TwoButtonActuatorAutoClose(TwoButtonActuator):
def stop(self, *, success=False):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This now does not close despite the name.

The default stop method is a no-op so we should move the stop from the other class to this one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I am not sure if I just made it worse.

import time
prev_st = self._set_st
if prev_st is not None:
while not prev_st.done:
time.sleep(.1)
self._was_open = (self.open_val == self.status.get())
st = self.set('Close')
while not st.done:
time.sleep(.5)

class TwoButtonShutter(TwoButtonActuatorAutoClose):
def stop(self, *, success=False):
# overide the stop method to always close the shutter
...