Skip to content

Commit 9029084

Browse files
authored
Merge pull request #152 from BCDA-APS/MotorEnable-151
fixes #151
2 parents f6540db + 94aeddb commit 9029084

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

apstools/devices.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
~AxisTunerMixin
3535
~EpicsDescriptionMixin
3636
~EpicsMotorDialMixin
37+
~EpicsMotorEnableMixin
3738
~EpicsMotorLimitsMixin
3839
~EpicsMotorRawMixin
3940
~EpicsMotorServoMixin
@@ -1056,6 +1057,46 @@ class myEpicsMotor(EpicsMotorDialMixin, EpicsMotor): pass
10561057

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

1060+
1061+
class EpicsMotorEnableMixin(DeviceMixinBase):
1062+
"""
1063+
mixin providing access to motor enable/disable
1064+
1065+
EXAMPLE::
1066+
1067+
from ophyd import EpicsMotor
1068+
from apstools.devices import EpicsMotorEnableMixin
1069+
1070+
class MyEpicsMotor(EpicsMotorEnableMixin, EpicsMotor): ...
1071+
1072+
m1 = MyEpicsMotor('xxx:m1', name='m1')
1073+
print(m1.enabled)
1074+
1075+
In a bluesky plan::
1076+
1077+
yield from bps.mv(m1.enable_disable, m1.MOTOR_DISABLE)
1078+
# ... other activities
1079+
yield from bps.mv(m1.enable_disable, m1.MOTOR_ENABLE)
1080+
1081+
"""
1082+
enable_disable = Component(EpicsSignal, "_able", kind='omitted')
1083+
1084+
# constants for internal use
1085+
MOTOR_ENABLE = 0
1086+
MOTOR_DISABLE = 1
1087+
1088+
@property
1089+
def enabled(self):
1090+
return self.enable_disable.value in (self.MOTOR_ENABLE, "Enabled")
1091+
1092+
def enable_motor(self):
1093+
"""BLOCKING call to enable motor axis"""
1094+
self.enable_disable.put(self.MOTOR_ENABLE)
1095+
1096+
def disable_motor(self):
1097+
"""BLOCKING call to disable motor axis"""
1098+
self.enable_disable.put(self.MOTOR_DISABLE)
1099+
10591100

10601101
class EpicsMotorLimitsMixin(DeviceMixinBase):
10611102
"""

0 commit comments

Comments
 (0)