fix(xbpms): generalize describe method of sum,diff signals
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from ophyd import Component as Cpt
|
from ophyd import Component as Cpt
|
||||||
from ophyd import Device, EpicsSignalRO, Signal
|
from ophyd import Device, EpicsSignalRO, Signal
|
||||||
|
|
||||||
@@ -22,10 +23,10 @@ class SumSignal(Signal):
|
|||||||
|
|
||||||
def describe(self):
|
def describe(self):
|
||||||
source = [
|
source = [
|
||||||
self.parent.current1.pvname,
|
self.parent.current1.describe()[self.parent.current1.name]["source"],
|
||||||
self.parent.current2.pvname,
|
self.parent.current2.describe()[self.parent.current2.name]["source"],
|
||||||
self.parent.current3.pvname,
|
self.parent.current3.describe()[self.parent.current3.name]["source"],
|
||||||
self.parent.current4.pvname,
|
self.parent.current4.describe()[self.parent.current4.name]["source"],
|
||||||
]
|
]
|
||||||
source = " / ".join(source)
|
source = " / ".join(source)
|
||||||
desc = {
|
desc = {
|
||||||
@@ -33,7 +34,9 @@ class SumSignal(Signal):
|
|||||||
"dtype": "number",
|
"dtype": "number",
|
||||||
"source": f"PV: {source}",
|
"source": f"PV: {source}",
|
||||||
"units": "",
|
"units": "",
|
||||||
"precision": self.parent.current1.precision,
|
"precision": (
|
||||||
|
self.parent.current1.precision if hasattr(self.parent.current1, "precision") else 0
|
||||||
|
),
|
||||||
}
|
}
|
||||||
return desc
|
return desc
|
||||||
|
|
||||||
@@ -64,23 +67,36 @@ class DiffXYSignal(Signal):
|
|||||||
return (summed_1 - summed_2) / _sum
|
return (summed_1 - summed_2) / _sum
|
||||||
|
|
||||||
def describe(self):
|
def describe(self):
|
||||||
source = [getattr(self.parent, signal).pvname for signal in self.sum1 + self.sum2]
|
source = [
|
||||||
|
getattr(self.parent, signal).describe()[getattr(self.parent, signal).name]["source"]
|
||||||
|
for signal in self.sum1 + self.sum2
|
||||||
|
]
|
||||||
source = " / ".join(source)
|
source = " / ".join(source)
|
||||||
desc = {
|
desc = {
|
||||||
"shape": [],
|
"shape": [],
|
||||||
"dtype": "number",
|
"dtype": "number",
|
||||||
"source": f"PV: {source}",
|
"source": f"PV: {source}",
|
||||||
"units": "",
|
"units": "",
|
||||||
"precision": self.parent.current1.precision,
|
"precision": (
|
||||||
|
self.parent.current1.precision if hasattr(self.parent.current1, "precision") else 0
|
||||||
|
),
|
||||||
}
|
}
|
||||||
return desc
|
return desc
|
||||||
|
|
||||||
|
|
||||||
class BPMDevice(Device):
|
class BPMDevice(Device):
|
||||||
current1 = Cpt(EpicsSignalRO, ":Current1:MeanValue_RBV", kind="normal", doc="Current 1", auto_monitor=True)
|
current1 = Cpt(
|
||||||
current2 = Cpt(EpicsSignalRO, ":Current2:MeanValue_RBV", kind="normal", doc="Current 2", auto_monitor=True)
|
EpicsSignalRO, ":Current1:MeanValue_RBV", kind="normal", doc="Current 1", auto_monitor=True
|
||||||
current3 = Cpt(EpicsSignalRO, ":Current3:MeanValue_RBV", kind="normal", doc="Current 3", auto_monitor=True)
|
)
|
||||||
current4 = Cpt(EpicsSignalRO, ":Current4:MeanValue_RBV", kind="normal", doc="Current 4", auto_monitor=True)
|
current2 = Cpt(
|
||||||
|
EpicsSignalRO, ":Current2:MeanValue_RBV", kind="normal", doc="Current 2", auto_monitor=True
|
||||||
|
)
|
||||||
|
current3 = Cpt(
|
||||||
|
EpicsSignalRO, ":Current3:MeanValue_RBV", kind="normal", doc="Current 3", auto_monitor=True
|
||||||
|
)
|
||||||
|
current4 = Cpt(
|
||||||
|
EpicsSignalRO, ":Current4:MeanValue_RBV", kind="normal", doc="Current 4", auto_monitor=True
|
||||||
|
)
|
||||||
sum = Cpt(SumSignal, kind="hinted", doc="Sum of all currents")
|
sum = Cpt(SumSignal, kind="hinted", doc="Sum of all currents")
|
||||||
x = Cpt(
|
x = Cpt(
|
||||||
DiffXYSignal,
|
DiffXYSignal,
|
||||||
|
|||||||
Reference in New Issue
Block a user