Skip to content
Open
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
22 changes: 22 additions & 0 deletions startup/02-nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@


class NanoMotor(EpicsMotor):
tolerance = Cpt(Signal, value=0, kind="config")

if type(EpicsMotor._default_configuration_attrs) in [list]:
epics_config_attrs = EpicsMotor._default_configuration_attrs
else:
Expand All @@ -27,6 +29,26 @@ class NanoMotor(EpicsMotor):
stat = Cpt(EpicsSignal, '.STAT') #alarm status
oplp = Cpt(EpicsSignal, '.STOP') #USING .STOP to open control loop. normal .STOP should not do this

def move(self, position, wait=True, **kwargs):
status = super().move(position, wait=False, **kwargs)
setpoint = position
tolerance = self.tolerance.get()

def check_within_tolerance(value, timestamp, **kwargs):
if abs(value - setpoint) < tolerance:
status.set_finished()
self.clear_sub(check_within_tolerance, event_type=self.SUB_READBACK)

self.subscribe(check_within_tolerance, event_type=self.SUB_READBACK)
try:
if wait:
status_wait(status)
except KeyboardInterrupt:
self.stop()
raise

return status


class NanoMotorOpenLoop(EpicsMotor): #TODO unverified for v3 asmbly epics
#_default_configuration_attrs = (
Expand Down