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