Skip to content

Commit

Permalink
Merge pull request #174 from maffettone/feat-add-pmac-kill-device
Browse files Browse the repository at this point in the history
feat: add pmac kill signal and switch
  • Loading branch information
maffettone authored Jun 3, 2024
2 parents cdbf140 + d69ee8f commit e03dbea
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions nslsii/motors/delta_tau.py
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)

0 comments on commit e03dbea

Please sign in to comment.