Skip to content

Commit

Permalink
Merge branch '2023-3-amxfmx'
Browse files Browse the repository at this point in the history
  • Loading branch information
JunAishima committed Jan 19, 2024
2 parents 5c18f76 + 8b049c8 commit cfdd2a0
Show file tree
Hide file tree
Showing 14 changed files with 360 additions and 161 deletions.
122 changes: 0 additions & 122 deletions albulaUtils.py

This file was deleted.

10 changes: 7 additions & 3 deletions config_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ class RasterStatus(Enum):
DETECTOR_OBJECT_TYPE_OPHYD = "ophyd" # instantiated in start_bs, using Bluesky scans
DETECTOR_OBJECT_TYPE = "detectorObjectType"

DETECTOR_SAFE_DISTANCE = 200.0

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}
Expand Down Expand Up @@ -112,6 +111,11 @@ class RasterStatus(Enum):
LSDC_SERVICE_USERS = ("lsdc-amx", "lsdc-fmx", "lsdc-nyx")
IS_STAFF = (
True
if os.environ["STAFF_GROUP"] in [grp.getgrgid(g).gr_name for g in os.getgroups()]
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()]
else False
)

EMBL_SERVER_PV_BASE = {
"amx": "XF:17IDB-ES:AMX{EMBL}",
"fmx": "XF:17IDC-ES:FMX{EMBL}"
}
4 changes: 2 additions & 2 deletions daq_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from bluesky.preprocessors import finalize_wrapper
import bluesky.plan_stubs as bps
import logging
import albulaUtils
from utils import validation
logger = logging.getLogger(__name__)

try:
Expand Down Expand Up @@ -628,7 +628,7 @@ def collectData(currentRequest):
filename = f"{data_directory_name}/{file_prefix}_{seqNum}_master.h5"
logger.info(f"Checking integrity of {filename}")
timeout_index = 0
while not albulaUtils.validate_master_HDF5_file(filename):
while not validation.validate_master_HDF5_file(filename):
timeout_index += 1
time.sleep(3)
if timeout_index > 15:
Expand Down
12 changes: 11 additions & 1 deletion db_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def getContainerByID(container_id):
c = getContainers(filters={'uid': container_id})[0]
return c

def get_dewar_tree_data(dewar_name, beamline):
def get_dewar_tree_data(dewar_name, beamline, get_latest_pucks=False):
"""
returns all data required to show dewar tree data with minimum number of database accesses
"""
Expand All @@ -496,6 +496,16 @@ def get_dewar_tree_data(dewar_name, beamline):
] # removes blank ids
pucks = getContainers(filters={"uid": {"$in": puck_ids}})

if get_latest_pucks:
# If get_latest_pucks is true, get the puck most recently updated in the database
# This is for cases when the excel sheet has been uploaded after puck_to_dewar
# Or when staff manually refreshes the dewar tree
new_pucks = []
for puck in pucks:
all_pucks = getContainers(filters={"name":puck["name"]})
latest_puck = max(all_pucks, key=lambda x: x.get("modified_time", 0.0))
new_pucks.append(latest_puck)
pucks = new_pucks
# Create a mega list of sample ids from puck information
sample_ids = [
sample_id
Expand Down
16 changes: 8 additions & 8 deletions embl_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import top_view
from config_params import TOP_VIEW_CHECK, DETECTOR_SAFE_DISTANCE, MOUNT_SUCCESSFUL, MOUNT_FAILURE,\
MOUNT_UNRECOVERABLE_ERROR, MOUNT_STEP_SUCCESSFUL, UNMOUNT_SUCCESSFUL,\
UNMOUNT_FAILURE, UNMOUNT_STEP_SUCCESSFUL, PINS_PER_PUCK
UNMOUNT_FAILURE, UNMOUNT_STEP_SUCCESSFUL, PINS_PER_PUCK, EMBL_SERVER_PV_BASE
import gov_lib
#from start_bs import gov_human, gov_robot
logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -260,7 +260,7 @@ def mount(self, gov_robot, puckPos,pinPos,sampID,**kwargs):
if (getPvDesc("sampleDetected") == 0): #reverse logic, 0 = true
setPvDesc("boostSelect",1)
else:
robotStatus = beamline_support.get_any_epics_pv("SW:RobotState","VAL")
robotStatus = beamline_support.get_any_epics_pv(f"{EMBL_SERVER_PV_BASE.get(daq_utils.beamline, 'SW')}:RobotState","VAL")
if (robotStatus != "Ready"):
gov_status = gov_lib.setGovRobot(gov_robot, 'SE')
if not gov_status.success:
Expand Down Expand Up @@ -356,8 +356,8 @@ def preUnmount(self, gov_robot, puckPos,pinPos,sampID): #will somehow know where
logger.info("robot online = " + str(robotOnline))
if (robotOnline):
detDist = beamline_lib.motorPosFromDescriptor("detectorDist")
if (detDist<DETECTOR_SAFE_DISTANCE):
gov_lib.set_detz_out(gov_robot, DETECTOR_SAFE_DISTANCE)
if (detDist<DETECTOR_SAFE_DISTANCE[daq_utils.beamline]):
gov_lib.set_detz_out(gov_robot, DETECTOR_SAFE_DISTANCE[daq_utils.beamline])
if daq_utils.beamline == "fmx":
beamline_lib.mvaDescriptor("omega", 0)
daq_lib.setRobotGovState("SE")
Expand Down Expand Up @@ -390,10 +390,10 @@ def preUnmount(self, gov_robot, puckPos,pinPos,sampID): #will somehow know where
logger.error(message)
return UNMOUNT_FAILURE
detDist = beamline_lib.motorPosFromDescriptor("detectorDist")
if (detDist<DETECTOR_SAFE_DISTANCE):
beamline_lib.mvaDescriptor("detectorDist",DETECTOR_SAFE_DISTANCE)
if (beamline_lib.motorPosFromDescriptor("detectorDist") < (DETECTOR_SAFE_DISTANCE - 1.0)):
logger.error(f"ERROR - Detector < {DETECTOR_SAFE_DISTANCE}")
if (detDist<DETECTOR_SAFE_DISTANCE[daq_utils.beamline]):
beamline_lib.mvaDescriptor("detectorDist",DETECTOR_SAFE_DISTANCE[daq_utils.beamline])
if (beamline_lib.motorPosFromDescriptor("detectorDist") < (DETECTOR_SAFE_DISTANCE[daq_utils.beamline] - 1.0)):
logger.error(f"ERROR - Detector < {DETECTOR_SAFE_DISTANCE[daq_utils.beamline]}")
return UNMOUNT_FAILURE
return UNMOUNT_STEP_SUCCESSFUL

Expand Down
Loading

0 comments on commit cfdd2a0

Please sign in to comment.