Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions beamline_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,8 @@ 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()):
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)
motor_channel_dict[motor_dict[key]] = EpicsMotor(motor_dict[key],name = key)


def initControlPVs():
Expand Down
10 changes: 0 additions & 10 deletions bin/lsdcGui_nyx

This file was deleted.

14 changes: 0 additions & 14 deletions bin/lsdcServer_nyx.cmd

This file was deleted.

19 changes: 6 additions & 13 deletions config_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,40 +85,36 @@ class OnMountAvailOptions(Enum):
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}
DETECTOR_SAFE_DISTANCE = {"fmx": 200.0, "amx": 180.0}
GOVERNOR_TIMEOUT = 120 # seconds for a governor move

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

cryostreamTempPV = {"amx": "XF:17ID1:CS700:TEMP", "fmx": "XF:17ID2:CS700:TEMP", "nyx":"XF:19ID2:CS700:TEMP"}
cryostreamTempPV = {"amx": "XF:17ID1:CS700:TEMP", "fmx": "XF:17ID2:CS700:TEMP"}

VALID_EXP_TIMES = {
"amx": {"min": 0.005, "max": 1, "digits": 3},
"fmx": {"min": 0.01, "max": 10, "digits": 3},
"nyx": {"min": 0.002, "max": 10, "digits": 4},
}
VALID_DET_DIST = {
"amx": {"min": 100, "max": 500, "digits": 3},
"fmx": {"min": 137, "max": 2000, "digits": 2},
"nyx": {"min": 100, "max": 500, "digits": 3},
}
VALID_TOTAL_EXP_TIMES = {
"amx": {"min": 0.005, "max": 300, "digits": 3},
"fmx": {"min": 0.01, "max": 300, "digits": 3},
"nyx": {"min": 0.01, "max": 1000, "digits": 3},
}
VALID_PREFIX_LENGTH = 25 # TODO centralize with spreadsheet validation?
VALID_PREFIX_NAME = "[0-9a-zA-Z-_]{0,%s}" % VALID_PREFIX_LENGTH
VALID_TRANSMISSION = {
"amx": {"min": 0.001, "max": 1.0, "digits": 3},
"fmx": {"min": 0.001, "max": 1.0, "digits": 3},
"nyx": {"min": 0.001, "max": 0.999, "digits": 3},
}

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

LSDC_SERVICE_USERS = ("lsdc-amx", "lsdc-fmx", "lsdc-nyx")
LSDC_SERVICE_USERS = ("lsdc-amx", "lsdc-fmx")
IS_STAFF = (
True
if os.environ.get("STAFF_GROUP") is not None and os.environ["STAFF_GROUP"] in [grp.getgrgid(g).gr_name for g in os.getgroups()]
Expand Down Expand Up @@ -154,8 +150,6 @@ def get_text(cls, enum_value):
}
return text_values.get(enum_value, "\n(Unknown State)")

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

class CollectionProtocols(str, Enum):
STANDARD = "standard"
RASTER = "raster"
Expand All @@ -176,7 +170,6 @@ def get_beamline_options(cls, beamline):
cls.STEP_RASTER, cls.STEP_VECTOR, cls.MULTI_COL, cls.CHARACTERIZE,
cls.EDNA_COL)
beamline_options = {
"nyx": (cls.STANDARD, cls.RASTER, cls.VECTOR),
"amx": all_protocols,
"fmx": all_protocols
}
Expand Down
193 changes: 58 additions & 135 deletions daq_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,60 +659,9 @@ def collectData(currentRequest):
sweep_start = reqObj["sweep_start"]
daq_macros.setTrans(attenuation)

if (reqObj["protocol"] in (CollectionProtocols.CHARACTERIZE, CollectionProtocols.EDNA_COL)):
characterizationParams = reqObj["characterizationParams"]
index_success = daq_macros.dna_execute_collection3(0.0,img_width,2,exposure_period,data_directory_name+"/",file_prefix,1,-89.0,1,currentRequest)
if (index_success):
resultsList = db_lib.getResultsforRequest(currentRequest["uid"]) # because for testing I keep running the same request. Probably not in usual use.
results = None
for i in range(0,len(resultsList)):
if (resultsList[i]['result_type'] == 'characterizationStrategy'):
results = resultsList[i]
break
if (results != None):

strategyResults = results["result_obj"]["strategy"]
stratStart = strategyResults["start"]
stratEnd = strategyResults["end"]
stratWidth = strategyResults["width"]
stratExptime = strategyResults["exptime"]
stratTrans = strategyResults["transmission"]
stratDetDist = strategyResults["detDist"]
sampleID = currentRequest["sample"]
tempnewStratRequest = daq_utils.createDefaultRequest(sampleID)
newReqObj = tempnewStratRequest["request_obj"]
newReqObj["sweep_start"] = stratStart
newReqObj["sweep_end"] = stratEnd
newReqObj["img_width"] = stratWidth
newReqObj["exposure_time"] = stratExptime
newReqObj["attenuation"] = stratTrans
newReqObj["detDist"] = stratDetDist
newReqObj["directory"] = data_directory_name
newReqObj["pos_x"] = beamline_lib.motorPosFromDescriptor("sampleX")
newReqObj["pos_y"] = beamline_lib.motorPosFromDescriptor("sampleY")
newReqObj["pos_z"] = beamline_lib.motorPosFromDescriptor("sampleZ")
newReqObj["fastDP"] = True # this is where you might want a "new from old" request to carry over stuff like this.
newReqObj["fastEP"] = reqObj["fastEP"]
newReqObj["dimple"] = reqObj["dimple"]
newReqObj["xia2"] = reqObj["xia2"]
runNum = db_lib.incrementSampleRequestCount(sampleID)
newReqObj["runNum"] = runNum
newStratRequest = db_lib.addRequesttoSample(sampleID,newReqObj["protocol"],daq_utils.owner,newReqObj,priority=0,proposalID=daq_utils.getProposalID())
if (reqObj["protocol"] == CollectionProtocols.EDNA_COL):
logger.info("new strat req = ")
logger.info(newStratRequest)
db_lib.updatePriority(currentRequest["uid"],-1)
refreshGuiTree()
collectData(db_lib.getRequestByID(newStratRequest))
return 1
else: #standard
logger.info("moving omega to start " + str(time.time()))
if daq_utils.beamline == "nyx":
direction = (sweep_end - sweep_start) / abs(sweep_end - sweep_start)
beamline_lib.mvaDescriptor("omega",sweep_start - direction*0.05)
else:
beamline_lib.mvaDescriptor("omega",sweep_start)
collect_detector_seq_hw(sweep_start,range_degrees,img_width,exposure_period,file_prefix,data_directory_name,file_number_start,currentRequest)
logger.info("moving omega to start " + str(time.time()))
beamline_lib.mvaDescriptor("omega",sweep_start)
collect_detector_seq_hw(sweep_start,range_degrees,img_width,exposure_period,file_prefix,data_directory_name,file_number_start,currentRequest)
try:
if (logMe) and prot == CollectionProtocols.RASTER:
logMxRequestParams(currentRequest,wait=False)
Expand All @@ -729,50 +678,49 @@ def collectData(currentRequest):
if reqObj["protocol"] in (CollectionProtocols.STANDARD, CollectionProtocols.VECTOR, CollectionProtocols.RASTER):
send_kafka_message(topic=f'{daq_utils.beamline}.lsdc.documents', event='stop', uuid=currentRequest['uid'], protocol=reqObj["protocol"])
if prot in (CollectionProtocols.VECTOR, CollectionProtocols.STANDARD, CollectionProtocols.STEP_VECTOR):
if daq_utils.beamline != "nyx":
seqNum = flyer.detector.cam.sequence_id.get()
comm_s = os.environ["LSDCHOME"] + "/runSpotFinder4syncW.py " + data_directory_name + " " + file_prefix + " " + str(currentRequest["uid"]) + " " + str(seqNum) + " " + str(currentIspybDCID)+ "&"
logger.info(f"NOT running spotfinding for per-image analysis in Synchweb: {comm_s}")
#os.system(comm_s)
filename = f"{data_directory_name}/{file_prefix}_{seqNum}_master.h5"
logger.info(f"Checking integrity of {filename}")
timeout_index = 0
while not validation.validate_master_HDF5_file(filename):
timeout_index += 1
time.sleep(3)
if timeout_index > 15:
logger.error(f"Unable to verify master file after {timeout_index} tries, not proceeding with processing")
return
if img_width > 0: #no dataset processing in stills mode
if (reqObj["fastDP"]):
if (reqObj["fastEP"]):
fastEPFlag = 1
else:
fastEPFlag = 0
if (reqObj["dimple"]):
dimpleFlag = 1
else:
dimpleFlag = 0
nodeName = "fastDPNode" + str((fastDPNodeCounter%fastDPNodeCount)+1)
fastDPNodeCounter+=1
node = getBlConfig(nodeName)
dimpleNode = getBlConfig("dimpleNode")
if (daq_utils.detector_id == "EIGER-16"):
seqNum = flyer.detector.cam.sequence_id.get()
comm_s = os.environ["LSDCHOME"] + "/runFastDPH5.py " + data_directory_name + " " + str(seqNum) + " " + str(currentRequest["uid"]) + " " + str(fastEPFlag) + " " + node + " " + str(dimpleFlag) + " " + dimpleNode + " " + str(currentIspybDCID)+ "&"
else:
comm_s = os.environ["LSDCHOME"] + "/runFastDP.py " + data_directory_name + " " + file_prefix + " " + str(file_number_start) + " " + str(int(round(range_degrees/img_width))) + " " + str(currentRequest["uid"]) + " " + str(fastEPFlag) + " " + node + " " + str(dimpleFlag) + " " + dimpleNode + "&"
logger.info(f'Running fastdp command: {comm_s}')
if daq_utils.beamline in ("amx", "fmx"):
visitName = daq_utils.getVisitName()
if (not os.path.exists(visitName + "/fast_dp_dir")) or subprocess.run(['pgrep', '-f', 'loop-fdp-dple-populate'], stdout=subprocess.PIPE).returncode == 1: # for pgrep, return of 1 means string not found
os.system("killall -KILL loop-fdp-dple-populate")
logger.info('starting fast dp result gathering script')
os.system("cd " + visitName + ";${LSDCHOME}/bin/loop-fdp-dple-populate.sh&")
os.system(comm_s)
if (reqObj["xia2"]):
comm_s = f"ssh -q xf17id2-srv1 \"{os.environ['MXPROCESSINGSCRIPTSDIR']}xia2.sh {currentRequest['uid']} \"&"
os.system(comm_s)
seqNum = flyer.detector.cam.sequence_id.get()
comm_s = os.environ["LSDCHOME"] + "/runSpotFinder4syncW.py " + data_directory_name + " " + file_prefix + " " + str(currentRequest["uid"]) + " " + str(seqNum) + " " + str(currentIspybDCID)+ "&"
logger.info(f"NOT running spotfinding for per-image analysis in Synchweb: {comm_s}")
#os.system(comm_s)
filename = f"{data_directory_name}/{file_prefix}_{seqNum}_master.h5"
logger.info(f"Checking integrity of {filename}")
timeout_index = 0
while not validation.validate_master_HDF5_file(filename):
timeout_index += 1
time.sleep(3)
if timeout_index > 15:
logger.error(f"Unable to verify master file after {timeout_index} tries, not proceeding with processing")
return
if img_width > 0: #no dataset processing in stills mode
if (reqObj["fastDP"]):
if (reqObj["fastEP"]):
fastEPFlag = 1
else:
fastEPFlag = 0
if (reqObj["dimple"]):
dimpleFlag = 1
else:
dimpleFlag = 0
nodeName = "fastDPNode" + str((fastDPNodeCounter%fastDPNodeCount)+1)
fastDPNodeCounter+=1
node = getBlConfig(nodeName)
dimpleNode = getBlConfig("dimpleNode")
if (daq_utils.detector_id == "EIGER-16"):
seqNum = flyer.detector.cam.sequence_id.get()
comm_s = os.environ["LSDCHOME"] + "/runFastDPH5.py " + data_directory_name + " " + str(seqNum) + " " + str(currentRequest["uid"]) + " " + str(fastEPFlag) + " " + node + " " + str(dimpleFlag) + " " + dimpleNode + " " + str(currentIspybDCID)+ "&"
else:
comm_s = os.environ["LSDCHOME"] + "/runFastDP.py " + data_directory_name + " " + file_prefix + " " + str(file_number_start) + " " + str(int(round(range_degrees/img_width))) + " " + str(currentRequest["uid"]) + " " + str(fastEPFlag) + " " + node + " " + str(dimpleFlag) + " " + dimpleNode + "&"
logger.info(f'Running fastdp command: {comm_s}')
if daq_utils.beamline in ("amx", "fmx"):
visitName = daq_utils.getVisitName()
if (not os.path.exists(visitName + "/fast_dp_dir")) or subprocess.run(['pgrep', '-f', 'loop-fdp-dple-populate'], stdout=subprocess.PIPE).returncode == 1: # for pgrep, return of 1 means string not found
os.system("killall -KILL loop-fdp-dple-populate")
logger.info('starting fast dp result gathering script')
os.system("cd " + visitName + ";${LSDCHOME}/bin/loop-fdp-dple-populate.sh&")
os.system(comm_s)
if (reqObj["xia2"]):
comm_s = f"ssh -q xf17id2-srv1 \"{os.environ['MXPROCESSINGSCRIPTSDIR']}xia2.sh {currentRequest['uid']} \"&"
os.system(comm_s)

logger.info('processing should be triggered')
db_lib.updatePriority(currentRequest["uid"],-1)
Expand Down Expand Up @@ -810,28 +758,18 @@ def collect_detector_seq_hw(sweep_start,range_degrees,image_width,exposure_perio

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 OPHYD_COLLECTIONS[daq_utils.beamline]:
logger.info("ophyd collections enabled")
if (protocol == CollectionProtocols.STANDARD):
RE(daq_macros.standard_plan_wrapped(currentRequest))
elif (protocol == CollectionProtocols.VECTOR):
RE(daq_macros.vector_plan_wrapped(currentRequest))
else:
if (protocol in (CollectionProtocols.STANDARD, CollectionProtocols.CHARACTERIZE,
CollectionProtocols.EDNA_COL, CollectionProtocols.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 == CollectionProtocols.VECTOR):
RE(daq_macros.vectorZebraScan(currentRequest))
elif (protocol == CollectionProtocols.STEP_VECTOR):
daq_macros.vectorZebraStepScan(currentRequest)
else:
pass
if (protocol in (CollectionProtocols.STANDARD, CollectionProtocols.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 == CollectionProtocols.VECTOR):
RE(daq_macros.vectorZebraScan(currentRequest))
elif (protocol == CollectionProtocols.STEP_VECTOR):
daq_macros.vectorZebraStepScan(currentRequest)
return


Expand Down Expand Up @@ -884,21 +822,6 @@ def center_on_click(x,y,fovx,fovy,source="screen",maglevel=0,jog=0,viewangle=daq
#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