sequencer fixed

This commit is contained in:
2022-06-03 22:18:47 +02:00
parent 494b4a192b
commit 6a8763f9e2
7 changed files with 168 additions and 7 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
try:
from elements.protocols import Adjustable, Detector
from eco.elements.protocols import Adjustable, Detector
except:
print("cannot import Prototypic protocol classes")
from .elements.assembly import Assembly
from eco.elements.assembly import Assembly
+53
View File
@@ -1,4 +1,6 @@
from eco.elements.adjustable import AdjustableFS
# from eco.endstations.bernina_sample_environments import Organic_crystal_breadboard_old
from eco.motion.smaract import SmaractController
from .config import components
from .config import config as config_berninamesp
@@ -387,6 +389,20 @@ namespace.append_obj(
lazy=True,
# lazy=False,
)
namespace.append_obj(
"DigitizerIoxos",
"SARES20-LSCP9-FNS",
name="digitizer_ioxos_user",
module_name="eco.devices_general.digitizers",
lazy=True,
)
namespace.append_obj(
"DigitizerIoxos",
"SLAAR21-LSCP1-FNS",
name="digitizer_ioxos_laser",
module_name="eco.devices_general.digitizers",
lazy=True,
)
namespace.append_obj(
"AxisPTZ",
@@ -936,6 +952,43 @@ namespace.append_obj(
)
class THz_in_air(Assembly):
def __init__(self, name=None):
super().__init__(name=name)
self._append(SmaractRecord, "SARES23:ESB4", name="eos_rot", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB12", name="eos_tilt", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB5", name="crystal_ROT", is_setting=True)
self._append(SmaractRecord, "SARES23:LIC15", name="ir_1_z", is_setting=True)
self._append(SmaractRecord, "SARES23:LIC13", name="ir_1_Ry", is_setting=True)
self._append(SmaractRecord, "SARES23:LIC14", name="ir_1_Rx", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB10", name="ir_2_Rx", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB7", name="ir_2_Ry", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB9", name="para_2_x", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB3", name="thz_mir_x", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB1", name="thz_mir_z", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB8", name="thz_mir_Ry", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB2", name="thz_mir_Rz", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB6", name="focus_x", is_setting=True)
self._append(
MotorRecord,
"SARES20-MF1:MOT_4",
name="focus_y",
is_setting=True,
is_display=True,
)
self._append(SmaractRecord, "SARES23:ESB14", name="focus_z", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB13", name="focus_Rx", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB15", name="focus_Ry", is_setting=True)
self._append(SmaractRecord, "SARES23:ESB11", name="focus_Rz", is_setting=True)
namespace.append_obj(
THz_in_air,
lazy=True,
name="tia",
)
namespace.append_obj(
"SmaractController",
"SARES23:LIC",
+75
View File
@@ -0,0 +1,75 @@
from ..detector.detectors_psi import DetectorBsStream
from eco.elements.assembly import Assembly
from eco.epics.detector import DetectorPvDataStream
from eco.epics.adjustable import AdjustablePv, AdjustablePvEnum
class DigitizerIoxos(Assembly):
def __init__(self, pvbase="SARES20-LSCP9-FNS", name=None):
super().__init__(name=name)
self.pvbase = pvbase
for chno in range(8):
self._append(
DigitizerIoxosBoxcarChannel,
f"{self.pvbase}:CH{chno}",
name=f"channel_{chno:d}",
is_setting=True,
)
class DigitizerIoxosBoxcarChannel(Assembly):
def __init__(self, pvbase, name=None):
super().__init__(name=name)
self.pvbase = pvbase
self._append(DetectorBsStream, self.pvbase + ":VAL_GET", name="value")
self._append(AdjustablePv, self.pvbase + ":VAL_GET.EGU", name="unit", is_setting='auto')
self._append(
DetectorPvDataStream,
self.pvbase + ":WFM",
name="waveform_slow",
is_display=False,
is_status=True,
)
self.status_collection.append(self.waveform_slow, force=True)
self._append(
DetectorPvDataStream,
self.pvbase + ":BOXCAR.VALH",
name="background",
)
self._append(
DetectorPvDataStream,
self.pvbase + ":BOXCAR.VALI",
name="signal",
)
self._append(
DetectorPvDataStream,
self.pvbase + ":BOXCAR.VALG",
name="difference",
)
self._append(
DetectorPvDataStream, self.pvbase + ":BOXCAR.VALO", name="signal_integral"
)
self._append(
DetectorPvDataStream, self.pvbase + ":BOXCAR.VALE", name="signal_average"
)
self._append(
DetectorPvDataStream,
self.pvbase + ":BOXCAR.VALP",
name="background_integral",
)
self._append(
DetectorPvDataStream,
self.pvbase + ":BOXCAR.VALD",
name="background_average", is_setting='auto'
)
self._append(AdjustablePv, self.pvbase + ":BSTART", name="bgregion_start", is_setting='auto')
self._append(AdjustablePv, self.pvbase + ":BEND", name="bgregion_end", is_setting='auto')
self._append(AdjustablePv, self.pvbase + ":START", name="sigregion_start", is_setting='auto')
self._append(AdjustablePv, self.pvbase + ":END", name="sigregion_end", is_setting='auto')
self._append(AdjustablePv, self.pvbase + ":CALIB", name="calibration_gain", is_setting='auto')
self._append(AdjustablePv, self.pvbase + ":OFFS", name="calibration_offset", is_setting='auto')
self._append(AdjustablePvEnum, self.pvbase + ":BOXCAR.SCAN", name="scan_mode", is_setting='auto')
self._append(AdjustablePvEnum, self.pvbase + ":WHICH_CHAN", name="output_mode", is_setting='auto')
def get_current_value(self):
return self.value.get_current_value()
+17 -1
View File
@@ -1,3 +1,8 @@
from tkinter import W
from numpy import isin
from eco.elements.protocols import Detector
from ..aliases import Alias
from tabulate import tabulate
import colorama
@@ -6,6 +11,7 @@ from enum import Enum
import os
import subprocess
from rich.progress import track
from eco import Adjustable, Detector
class Collection:
@@ -87,8 +93,12 @@ class Assembly:
# except:
# print(f'object {name} / {foo_obj_init} not initialized with name/parent')
# self.__dict__[name] = foo_obj_init(*args, **kwargs)
if is_setting == "auto":
is_setting = isinstance(self.__dict__[name], Adjustable)
if is_setting:
self.settings_collection.append(self.__dict__[name], recursive=True)
if is_status == "auto":
is_status = isinstance(self.__dict__[name], Detector)
if is_status:
self.status_collection.append(self.__dict__[name], recursive=True)
if is_display:
@@ -192,13 +202,19 @@ class Assembly:
for to in stats:
name = to.alias.get_full_name(base=self)
value = to.get_current_value()
is_adjustable = isinstance(to, Adjustable)
if is_adjustable:
typechar = "✏️"
else:
typechar = "👁️"
is_detector = isinstance(to, Detector)
if isinstance(value, Enum):
value = f"{value.value} ({value.name})"
try:
unit = to.unit()
except:
unit = None
tab.append([".".join([main_name, name]), value, unit])
tab.append([".".join([main_name, name]), value, unit, typechar])
s = tabulate(tab)
return s
+2 -2
View File
@@ -3,7 +3,7 @@ from typing import Protocol, runtime_checkable
@runtime_checkable
class Adjustable(Protocol):
def get_target_value(self):
def get_current_value(self):
...
def set_target_value(self, value):
@@ -14,5 +14,5 @@ class Adjustable(Protocol):
@runtime_checkable
class Detector(Protocol):
def get_target_value(self):
def get_current_value(self):
...
@@ -354,6 +354,8 @@ class Organic_crystal_breadboard(Assembly):
},
}
### smaract motors ###
for name, config in self.motor_configuration.items():
self._append(
+17 -2
View File
@@ -71,7 +71,7 @@ class CtaSequencer(Assembly):
self._append(
AdjustablePv,
self._pvstr(f"Ser{i}-Data-I"),
element_count=self.max_length.get_current_value(),
# element_count=self.max_length.get_current_value(),
name=f"seq_code{eventcode}",
is_setting=True,
is_display=False,
@@ -104,7 +104,22 @@ class CtaSequencer(Assembly):
)
oldlength = self.length.get_current_value()
newlength = oldlength + step_delay
self.event_code_sequences[code]._value[newlength - 1] = 1
changes = []
for i, ec in self.event_code_sequences.items():
if oldlength == 0:
o = []
else:
o = list(ec.get_current_value())
if i == code:
n = o + [0] * (newlength - oldlength - 1) + [1]
else:
n = o + [0] * (newlength - oldlength)
# print(o, n)
changes.append(ec.set_target_value(n))
for change in changes:
change.wait()
# self.event_code_sequences[code]._value[newlength - 1] = 1
self.length.set_target_value(newlength).wait()