Skip to content

Commit

Permalink
Merge pull request #378 from mskinner5278/md2-raster-2024-2
Browse files Browse the repository at this point in the history
Md2 raster 2024 2
  • Loading branch information
mskinner5278 authored Sep 23, 2024
2 parents 8058bc7 + cb86a04 commit d71d41f
Show file tree
Hide file tree
Showing 25 changed files with 2,236 additions and 380 deletions.
7 changes: 6 additions & 1 deletion beamline_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,14 @@ def read_db():

def init_motors():
global motor_channel_dict
md2_motors = ["omega","sampleX","sampleY","sampleZ", "finex", "finey", "finez"]

for key in list(motor_dict.keys()):
motor_channel_dict[motor_dict[key]] = EpicsMotor(motor_dict[key],name = key)
if beamline_designation == "XF:19ID" and key in md2_motors:
from mxbluesky.devices.md2 import MD2Positioner
motor_channel_dict[motor_dict[key]] = MD2Positioner(motor_dict[key],name = key)
else:
motor_channel_dict[motor_dict[key]] = EpicsMotor(motor_dict[key],name = key)


def initControlPVs():
Expand Down
2 changes: 1 addition & 1 deletion bin/lsdcServer_nyx.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
export PROJDIR=/nsls2/software/mx/daq/
export CONFIGDIR=${PROJDIR}bnlpx_config/
export LSDCHOME=${PROJDIR}lsdc_nyx
export EPICS_CA_AUTO_ADDR_LIST=NO
#export EPICS_CA_AUTO_ADDR_LIST=NO
export PYTHONPATH=".:${CONFIGDIR}:/usr/lib64/edna-mx/mxv1/src:/usr/lib64/edna-mx/kernel/src:${LSDCHOME}:${PROJDIR}/RobotControlLib"
export PATH=/usr/local/bin:/usr/bin:/bin:${PROJDIR}/software/bin:/opt/ccp4/bin
source ${CONFIGDIR}daq_env_nyx.txt
Expand Down
12 changes: 7 additions & 5 deletions config_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class OnMountAvailOptions(Enum):
AUTO_RASTER = 2 # Mounts, centers and takes 2 orthogonal rasters

HUTCH_TIMER_DELAY = 500
SAMPLE_TIMER_DELAY = 0
SAMPLE_TIMER_DELAY = 40
SERVER_CHECK_DELAY = 2000

FAST_DP_MIN_NODES = 4
Expand All @@ -81,16 +81,17 @@ class OnMountAvailOptions(Enum):
PINS_PER_PUCK = 16

DETECTOR_OBJECT_TYPE_LSDC = "lsdc" # using det_lib
DETECTOR_OBJECT_TYPE_NO_INIT = "no init" # skip epics detector init
DETECTOR_OBJECT_TYPE_OPHYD = "ophyd" # instantiated in start_bs, using Bluesky scans
DETECTOR_OBJECT_TYPE = "detectorObjectType"

DETECTOR_SAFE_DISTANCE = {"fmx": 200.0, "amx": 180.0, "nyx": 200.0}
GOVERNOR_TIMEOUT = 120 # seconds for a governor move

DEWAR_SECTORS = {"amx": 8, "fmx": 8, "nyx": 5}
PUCKS_PER_DEWAR_SECTOR = {"amx": 3, "fmx": 3, "nyx": 3}
DEWAR_SECTORS = {'amx':8, 'fmx':8, 'nyx':8}
PUCKS_PER_DEWAR_SECTOR = {'amx':3, 'fmx':3, 'nyx':3}

cryostreamTempPV = {"amx": "XF:17IDB-ES:AMX{CS:1}SAMPLE_TEMP_RBV", "fmx": "FMX:cs700:gasT-I"}
cryostreamTempPV = {"amx": "XF:17IDB-ES:AMX{CS:1}SAMPLE_TEMP_RBV", "fmx": "FMX:cs700:gasT-I", "nyx":"XF:19ID2:CS700:TEMP"}

VALID_EXP_TIMES = {
"amx": {"min": 0.005, "max": 1, "digits": 3},
Expand Down Expand Up @@ -132,4 +133,5 @@ class OnMountAvailOptions(Enum):
BEAMSIZE_OPTIONS = {
"S": ["V0", "H0"],
"L": ["V1", "H1"]
}
}
OPHYD_COLLECTIONS = {"amx": False, "fmx": False, "nyx": True}
58 changes: 41 additions & 17 deletions daq_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ def mountSample(sampID):
setPvDesc("robotZWorkPos",getPvDesc("robotZMountPos"))
setPvDesc("robotOmegaWorkPos",90.0)
logger.info("done setting work pos")
if (currentMountedSampleID != ""): #then unmount what's there
if (sampID!=currentMountedSampleID and not robot_lib.multiSampleGripper()):
if (currentMountedSampleID != "" and not robot_lib.multiSampleGripper()): #then unmount what's there
if (sampID!=currentMountedSampleID):
puckPos = mountedSampleDict["puckPos"]
pinPos = mountedSampleDict["pinPos"]
if robot_lib.unmountRobotSample(gov_robot, puckPos,pinPos,currentMountedSampleID):
Expand Down Expand Up @@ -701,22 +701,30 @@ def collect_detector_seq_hw(sweep_start,range_degrees,image_width,exposure_perio
file_prefix_minus_directory = file_prefix_minus_directory[file_prefix_minus_directory.rindex("/")+1:len(file_prefix_minus_directory)]
except ValueError:
pass

logger.info("collect %f degrees for %f seconds %d images exposure_period = %f exposure_time = %f" % (range_degrees,range_seconds,number_of_images,exposure_period,exposure_time))
if (protocol == "standard" or protocol == "characterize" or protocol == "ednaCol" or protocol == "burn"):
logger.info("vectorSync " + str(time.time()))
daq_macros.vectorSync()
logger.info("zebraDaq " + str(time.time()))

vector_params = daq_macros.gatherStandardVectorParams()
logger.debug(f"vector_params: {vector_params}")
RE(daq_macros.standard_plan(flyer,angleStart,number_of_images,range_degrees,image_width,exposure_period,file_prefix_minus_directory,data_directory_name,file_number, vector_params, file_prefix_minus_directory))

elif (protocol == "vector"):
RE(daq_macros.vectorZebraScan(currentRequest))
elif (protocol == "stepVector"):
daq_macros.vectorZebraStepScan(currentRequest)
else:
pass

if OPHYD_COLLECTIONS[daq_utils.beamline]:
logger.info("ophyd collections enabled")
if (protocol == "standard"):
RE(daq_macros.standard_plan_wrapped(currentRequest))
elif (protocol == "vector"):
RE(daq_macros.vector_plan_wrapped(currentRequest))
else:
if (protocol == "standard" or protocol == "characterize" or protocol == "ednaCol" or protocol == "burn"):
logger.info("vectorSync " + str(time.time()))
daq_macros.vectorSync()
logger.info("zebraDaq " + str(time.time()))

vector_params = daq_macros.gatherStandardVectorParams()
logger.debug(f"vector_params: {vector_params}")
RE(daq_macros.standard_zebra_plan(flyer,angleStart,number_of_images,range_degrees,image_width,exposure_period,file_prefix_minus_directory,data_directory_name,file_number, vector_params, file_prefix_minus_directory))
elif (protocol == "vector"):
RE(daq_macros.vectorZebraScan(currentRequest))
elif (protocol == "stepVector"):
daq_macros.vectorZebraStepScan(currentRequest)
else:
pass
return


Expand Down Expand Up @@ -768,6 +776,22 @@ def checkC2C_X(x,fovx): # this is to make sure the user doesn't make too much of
def center_on_click(x,y,fovx,fovy,source="screen",maglevel=0,jog=0,viewangle=daq_utils.CAMERA_ANGLE_BEAM): #maglevel=0 means lowmag, high fov, #1 = himag with digizoom option,
#source=screen = from screen click, otherwise from macro with full pixel dimensions
#viewangle=daq_utils.CAMERA_ANGLE_BEAM, default camera angle is in-line with the beam

if daq_utils.beamline == "nyx":
logger.info("center_on_click: %s" % str((x,y)))
lsdc_x = daq_utils.screenPixX
lsdc_y = daq_utils.screenPixY
md2_x = getPvDesc("md2CenterPixelX") * 2
md2_y = getPvDesc("md2CenterPixelY") * 2
scale_x = md2_x / lsdc_x
scale_y = md2_y / lsdc_y
x = x * scale_x
y = y * scale_y
str_coords = f'{x} {y}'
logger.info(f'center_on_click: {str_coords}')
setPvDesc("MD2C2C", str_coords)
return

if (getBlConfig('robot_online')): #so that we don't move things when robot moving?
robotGovState = (getPvDesc("robotSaActive") or getPvDesc("humanSaActive"))
if (not robotGovState):
Expand Down
Loading

0 comments on commit d71d41f

Please sign in to comment.