Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects

Two solutions for combined EPICS PVs

Merged mohacsi_i requested to merge feat-combined-channels into master
@@ -8,6 +8,7 @@ IMPORTANT: Virtual monochromator axes should be implemented already in EPICS!!!
"""
import numpy as np
import time
from math import isclose, tan, atan, sqrt, sin, asin
from ophyd import (
EpicsSignal,
@@ -16,8 +17,9 @@ from ophyd import (
PseudoPositioner,
PseudoSingle,
PVPositioner,
Device,
Device, Signal,
Component,
DynamicDeviceComponent,
Kind,
)
from ophyd.pseudopos import pseudo_position_argument, real_position_argument
@@ -202,3 +204,40 @@ class EnergyKev(VirtualEpicsSignalRO):
)
E_keV = -self._mono_hce / self._mono_2d2 / sin(theta2_deg / 180.0 * 3.14152)
return E_keV
class CurrentSum(Signal):
"""Adds up four current signals from the parent"""
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.parent.ch1.subscribe(self._emit_value)
def _emit_value(self, **kwargs):
timestamp = kwargs.pop("timestamp", time.time())
self.wait_for_connection()
self._run_subs(sub_type='value', timestamp=timestamp, obj=self)
def get(self, *args, **kwargs):
total = self.parent.ch1.get() + self.parent.ch2.get() + self.parent.ch3.get() + self.parent.ch4.get()
return total
class Bpm4i(Device):
SUB_VALUE = "value"
_default_sub = SUB_VALUE
ch1 = Component(EpicsSignalRO, "S2", auto_monitor=True, kind=Kind.omitted, name="ch1")
ch2 = Component(EpicsSignalRO, "S3", auto_monitor=True, kind=Kind.omitted, name="ch2")
ch3 = Component(EpicsSignalRO, "S4", auto_monitor=True, kind=Kind.omitted, name="ch3")
ch4 = Component(EpicsSignalRO, "S5", auto_monitor=True, kind=Kind.omitted, name="ch4")
sum = Component(CurrentSum, kind=Kind.hinted, name="sum", )
if __name__ == "__main__":
dut = Bpm4i("X12SA-OP1-SCALER.", name="bpm4")
dut.wait_for_connection()
print(dut.read())
print(dut.describe())
Loading