Skip to content

Commit

Permalink
fixes #151
Browse files Browse the repository at this point in the history
  • Loading branch information
prjemian authored May 22, 2019
1 parent f6540db commit 94aeddb
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions apstools/devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
~AxisTunerMixin
~EpicsDescriptionMixin
~EpicsMotorDialMixin
~EpicsMotorEnableMixin
~EpicsMotorLimitsMixin
~EpicsMotorRawMixin
~EpicsMotorServoMixin
Expand Down Expand Up @@ -1056,6 +1057,46 @@ class myEpicsMotor(EpicsMotorDialMixin, EpicsMotor): pass

dial = Component(EpicsSignal, ".DRBV", write_pv=".DVAL")


class EpicsMotorEnableMixin(DeviceMixinBase):
"""
mixin providing access to motor enable/disable
EXAMPLE::
from ophyd import EpicsMotor
from apstools.devices import EpicsMotorEnableMixin
class MyEpicsMotor(EpicsMotorEnableMixin, EpicsMotor): ...
m1 = MyEpicsMotor('xxx:m1', name='m1')
print(m1.enabled)
In a bluesky plan::
yield from bps.mv(m1.enable_disable, m1.MOTOR_DISABLE)
# ... other activities
yield from bps.mv(m1.enable_disable, m1.MOTOR_ENABLE)
"""
enable_disable = Component(EpicsSignal, "_able", kind='omitted')

# constants for internal use
MOTOR_ENABLE = 0
MOTOR_DISABLE = 1

@property
def enabled(self):
return self.enable_disable.value in (self.MOTOR_ENABLE, "Enabled")

def enable_motor(self):
"""BLOCKING call to enable motor axis"""
self.enable_disable.put(self.MOTOR_ENABLE)

def disable_motor(self):
"""BLOCKING call to disable motor axis"""
self.enable_disable.put(self.MOTOR_DISABLE)


class EpicsMotorLimitsMixin(DeviceMixinBase):
"""
Expand Down

0 comments on commit 94aeddb

Please sign in to comment.