DAQ/GUI: Fixes during pre-beamtime test (2)
Build and Publish / build (push) Successful in 22s

This commit is contained in:
2025-06-17 10:44:50 +02:00
parent 7aeee1a029
commit a126f7ccb4
6 changed files with 45 additions and 17 deletions
+6
View File
@@ -28,6 +28,12 @@ class SampleGeometryModel(BaseModel):
def beam_size_pxl(self) -> Coordinate:
return self.beam_size_mm / self.pixel_in_mm
def smargon_z(self, pic_y: float) -> Coordinate:
y_mm = (pic_y - self.beam_location_pxl.y) * self.pixel_in_mm
print("Moving by ", y_mm, "mm in z direction.")
return self.smargon.sh_mm + self.smargon_nudge(Coordinate(z=y_mm))
# This goes from image coordinates to relative beam coordinates in image plane
def picture_to_sample(self, pic_pxl: Coordinate) -> Coordinate:
# Relative to beam location
+13
View File
@@ -46,6 +46,8 @@ class BeamlineDevices:
self.bsx = MyMotor(f"{BEAMLINE}-ES-BS:TRX1")
self.bsy = MyMotor(f"{BEAMLINE}-ES-BS:TRY1")
self.__collimator = PV(f"{BEAMLINE}-ES-COL:TRY1")
self.aerotech = aerotech.Abr(beamline)
self.aerotech.reload_programs()
@@ -170,6 +172,17 @@ class BeamlineDevices:
def zoom_sync(self, value: float):
self.__zoom.move(value, wait=True)
@property
def collimator_up(self) -> bool:
return bool(abs(self.__collimator.value - 92.979) < 0.01)
@collimator_up.setter
def collimator_up(self, value: bool):
if value:
self.__collimator.put(92.979, wait=True)
else:
self.__collimator.put(42.979, wait=True)
@property
def reflector_up(self) -> bool:
return bool(self.__reflector.position_is("measure"))
+7 -4
View File
@@ -141,7 +141,7 @@ def sa2dc(devs: BeamlineDevices, cfg: BeamlineConfig):
_cryo = hub.cryojet_in_use
cryo_meas = hub.cryojet_measurement_position
# devs.reflector = False
devs.reflector_up = False
if _cryo:
devs.cryo.move(cryo_meas)
@@ -149,6 +149,8 @@ def sa2dc(devs: BeamlineDevices, cfg: BeamlineConfig):
#devs.reflector.wait("park")
devs.beamstop_stage_up = True
devs.dtz.move(cfg.dtz, wait=True)
devs.collimator_up = True
pv_wait(devs.dtz, None, tolerance=1.0)
wait_for_dc_devices(devs)
@@ -170,14 +172,15 @@ def dc2se(devs: BeamlineDevices, cfg: BeamlineConfig):
if devs.dtz.position < _dtzpark:
devs.dtz.move(_dtzpark)
devs.collimator_up = False
devs.reflector_up = True
def dc2sa(devs: BeamlineDevices, cfg: BeamlineConfig):
hub = cfg.settings
devs.collimator_up = False
devs.reflector_up = True
devs.gmz.move(cfg.abr_meas_pos.z, wait=True)
# devs.gmz.move(cfg.abr_meas_pos.z, wait=True)
def sa2xrf(devs: BeamlineDevices, cfg: BeamlineConfig):
+1
View File
@@ -132,6 +132,7 @@ class MainWindow(QMainWindow):
self.daq.update.connect(self.beamline.smargon_panel.update_daq_status)
self.daq.update.connect(self.data_collection.update_daq_status)
self.daq.update.connect(self.beamline.illumination_panel.update_daq_status)
self.daq.update.connect(self.raster.update_daq_status)
self.daq.update.connect(self.status_panel.update_daq_status)
self.daq.update.connect(self.camera_image.update_daq_status)
self.daq.update.connect(self.tell_samples.update_daq_status)
@@ -266,12 +266,17 @@ class RasterGridManager(QObject):
if values is not None:
painter.setPen(Qt.PenStyle.NoPen)
min_value = min((x for x in values if not math.isnan(x)), default=0)
max_value = max((x for x in values if not math.isnan(x)), default=1)
min_value = min((x for x in values if not None and not math.isnan(x)), default=0)
max_value = max((x for x in values if not None and not math.isnan(x)), default=1)
if min_value == max_value:
diff = 1
else:
diff = min_value - max_value
else:
painter.setPen(QPen(QColor(114, 159, 207), 2, Qt.PenStyle.SolidLine))
min_value = 0
max_value = 1
diff = 1
g = grid.grid_size_pxl(self.__geom)
c0 = grid.start_pxl(self.__geom)
@@ -281,7 +286,7 @@ class RasterGridManager(QObject):
if values is None or len(values) <= pxl or math.isnan(values[pxl]) or values[pxl] < 0:
painter.setBrush(Qt.BrushStyle.NoBrush)
else:
painter.setBrush(QBrush(float_to_viridis_brush((values[pxl] - min_value) / (max_value - min_value), alpha=alpha)))
painter.setBrush(QBrush(float_to_viridis_brush((values[pxl] - min_value) / diff, alpha=alpha)))
c = self.__geom.sample_to_picture(c0 + Coordinate(x=x * grid.grid_size_mm.x, y=y * grid.grid_size_mm.y))
painter.drawRect(QRect(round(c.x), round(c.y), round(g.x), round(g.y)))
+9 -9
View File
@@ -307,15 +307,15 @@ class SampleCameraImageLabel(QGraphicsView):
def __left_single_click(self, event):
match self.__state:
case SampleCameraImageState.IDLE:
self.end_point = self.mapToScene(event.pos())
sample_coord = self.__geom.picture_to_sample(
Coordinate(x=self.end_point.x(), y=self.end_point.y())
)
smargon_coord = SmargonCoordinate(
sh_mm=self.__geom.beamline_to_smargon(sample_coord)
)
self.smargon.emit(smargon_coord)
point = self.mapToScene(event.pos())
if event.modifiers() & Qt.KeyboardModifier.ShiftModifier:
self.smargon.emit(self.__geom.smargon_z(point.y()))
else:
sample_coord = self.__geom.picture_to_sample(Coordinate(x=point.x(), y=point.y()))
smargon_coord = SmargonCoordinate(
sh_mm=self.__geom.beamline_to_smargon(sample_coord)
)
self.smargon.emit(smargon_coord)
def __draw_beam_center(self, painter: QPainter):
beam_size_pxl = self.__geom.beam_size_pxl