-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #174 from maffettone/feat-add-pmac-kill-device
feat: add pmac kill signal and switch
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
""" | ||
Ophyd devices and signals for Delta Tau devices, such as Programmable Multi-Axis Controller (PMAC-PC) | ||
""" | ||
|
||
import logging | ||
|
||
from ophyd import Component as Cpt | ||
from ophyd import Device, EpicsSignal, EpicsSignalRO, Kind | ||
|
||
|
||
class PMACStatus(EpicsSignalRO): | ||
""" | ||
A signal to read the status of the PMAC-PC controller by checking the bit 11 of the status register. | ||
""" | ||
|
||
def get(self): | ||
return int(super().get() >> 11 & 1 == 0) | ||
|
||
|
||
class PMACKillSwitch(Device): | ||
""" | ||
A device to kill the PMAC-PC controller. | ||
In the named version of the EPICS record (e.g., XF:23ID1-ES{Dif-Ax:Del}), the status is expected at Sts:4-Sts. | ||
Whereas in the axis numbered version (e.g., XF:23ID1-CT{MC:12-Ax:1}), the status is expected at Sts:1-Sts. | ||
""" | ||
|
||
kill = Cpt(EpicsSignal, "Cmd:Kill-Cmd.PROC", kind=Kind.omitted) | ||
status = Cpt(PMACStatus, "Sts:4-Sts", kind=Kind.normal) | ||
|
||
def set(self, value, *args, **kwargs): | ||
""" | ||
Set the kill switch to the given value | ||
""" | ||
if value != 1: | ||
logging.getLogger(__name__).warning( | ||
"The value of the PMACKiller should only ever be set to 1. " "Changing the setpoint to 1 now." | ||
) | ||
value = 1 | ||
self.kill.set(value, *args, **kwargs) | ||
|
||
def get(self, *args, **kwargs): | ||
""" | ||
Get the value of the kill switch | ||
""" | ||
return self.status.get(*args, **kwargs) |