Skip to content

Commit

Permalink
Merge branch 'master' into mounting-status-indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
vshekar authored Oct 30, 2024
2 parents 2ec7892 + d71d41f commit 6ddb04e
Show file tree
Hide file tree
Showing 30 changed files with 2,812 additions and 637 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
18 changes: 10 additions & 8 deletions config_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,9 @@ 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

ROBOT_MIN_DISTANCE = 200.0
ROBOT_DISTANCE_TOLERANCE = 0.050

FAST_DP_MIN_NODES = 4
SPOT_MIN_NODES = 8
MOUNT_SUCCESSFUL = 1
Expand All @@ -84,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 @@ -137,6 +135,7 @@ class OnMountAvailOptions(Enum):
"L": ["V1", "H1"]
}


class MountState(Enum):
CURRENTLY_MOUNTING = "cm"
FAILED_MOUNTING = "fm"
Expand All @@ -153,4 +152,7 @@ def get_text(cls, enum_value):
cls.CURRENTLY_UNMOUNTING: "\n(Currently Unmounting)",
cls.FAILED_UNMOUNTING: "\n(Failed Unmounting)"
}
return text_values.get(enum_value, "\n(Unknown State)")
return text_values.get(enum_value, "\n(Unknown State)")

OPHYD_COLLECTIONS = {"amx": False, "fmx": False, "nyx": True}

60 changes: 42 additions & 18 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"]
# Set status as currently unmounting
Expand Down Expand Up @@ -401,7 +401,7 @@ def runDCQueue(): #maybe don't run rasters from here???
logger.info("processing request " + str(time.time()))
reqObj = currentRequest["request_obj"]
gov_lib.set_detz_in(gov_robot, reqObj["detDist"])
if (reqObj["detDist"] >= ROBOT_MIN_DISTANCE and getBlConfig("HePath") == 0):
if (reqObj["detDist"] >= DETECTOR_SAFE_DISTANCE[daq_utils.beamline] and getBlConfig("HePath") == 0):
gov_lib.set_detz_out(gov_robot, reqObj["detDist"])
sampleID = currentRequest["sample"]
mountedSampleDict = db_lib.beamlineInfo(daq_utils.beamline, 'mountedSample')
Expand Down Expand Up @@ -724,22 +724,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 @@ -791,6 +799,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 6ddb04e

Please sign in to comment.