Skip to content

Commit

Permalink
Merge pull request #371 from vshekar/prevent-tiny-rasters
Browse files Browse the repository at this point in the history
Step size reduced in an interactive raster if the number of steps is less than 6
  • Loading branch information
vshekar authored Apr 22, 2024
2 parents c42c50b + eaff8ad commit 55861f4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
5 changes: 4 additions & 1 deletion config_params.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import grp
import os
from enum import Enum
import os, grp

# BlConfig parameter variable names

Expand Down Expand Up @@ -108,6 +109,8 @@ class RasterStatus(Enum):
"nyx": {"min": 0.001, "max": 0.999, "digits": 3},
}

MINIMUM_RASTER_SIZE = {"amx": 6, "fmx": 6, "nyx": 2}

LSDC_SERVICE_USERS = ("lsdc-amx", "lsdc-fmx", "lsdc-nyx")
IS_STAFF = (
True
Expand Down
22 changes: 19 additions & 3 deletions gui/control_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
VALID_TRANSMISSION,
RasterStatus,
cryostreamTempPV,
MINIMUM_RASTER_SIZE
)
from daq_utils import getBlConfig, setBlConfig
from element_info import element_info
Expand Down Expand Up @@ -2888,9 +2889,25 @@ def drawInteractiveRasterCB(self): # any polygon for now, interactive or from x
center_y = int(self.polyBoundingRect.center().y())
stepsizeXPix = self.screenXmicrons2pixels(float(self.rasterStepEdit.text()))
stepsizeYPix = self.screenYmicrons2pixels(float(self.rasterStepEdit.text()))
numsteps_w = raster_w/stepsizeXPix
numsteps_h = raster_h/stepsizeYPix
stepsize = float(self.rasterStepEdit.text())

while (numsteps_w < MINIMUM_RASTER_SIZE[daq_utils.beamline] and numsteps_h < MINIMUM_RASTER_SIZE[daq_utils.beamline]):
logger.info(f"{numsteps_h=}, {numsteps_w=}, {stepsize=}, {stepsizeXPix=}, {stepsizeYPix=}")
if stepsize == 1:
logger.error("Cannot add raster request, stepsize must be 1 micron with a minimum width or height of 5 cells")
return
stepsize -= 1
stepsizeXPix = self.screenXmicrons2pixels(stepsize)
stepsizeYPix = self.screenYmicrons2pixels(stepsize)

numsteps_w = raster_w/stepsizeXPix
numsteps_h = raster_h/stepsizeYPix

self.click_positions = []
self.definePolyRaster(
raster_w, raster_h, stepsizeXPix, stepsizeYPix, center_x, center_y
raster_w, raster_h, stepsizeXPix, stepsizeYPix, center_x, center_y, stepsize
)

def measurePolyCB(self):
Expand Down Expand Up @@ -3280,11 +3297,10 @@ def screenYmicrons2pixels(self, microns):
return int(round(microns * (daq_utils.screenPixY / fovY)))

def definePolyRaster(
self, raster_w, raster_h, stepsizeXPix, stepsizeYPix, point_x, point_y
self, raster_w, raster_h, stepsizeXPix, stepsizeYPix, point_x, point_y, stepsize
): # all come in as pixels, raster_w and raster_h are bounding box of drawn graphic
# raster status - 0=nothing done, 1=run, 2=displayed
stepTime = float(self.exp_time_ledit.text())
stepsize = float(self.rasterStepEdit.text())
if (stepsize / 1000.0) / stepTime > 2.0:
self.popupServerMessage(
"Stage speed exceeded. Increase exposure time, or decrease step size. Limit is 2mm/s."
Expand Down

0 comments on commit 55861f4

Please sign in to comment.