Skip to content

Commit

Permalink
Merge branch 'master' into optimized-autoraster
Browse files Browse the repository at this point in the history
  • Loading branch information
vshekar authored Apr 29, 2024
2 parents 973088d + eaaa2f3 commit 62d2649
Show file tree
Hide file tree
Showing 22 changed files with 874 additions and 452 deletions.
122 changes: 0 additions & 122 deletions albulaUtils.py

This file was deleted.

16 changes: 12 additions & 4 deletions config_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
BEAM_CHECK = "beamCheck"
UNMOUNT_COLD_CHECK = "unmountColdCheck"
ON_MOUNT_OPTION = "onMountOption"
SET_ENERGY_CHECK = "setEnergyCheck"


# raster request status updates
class RasterStatus(Enum):
Expand Down Expand Up @@ -85,14 +87,13 @@ class OnMountAvailOptions(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}
PUCKS_PER_DEWAR_SECTOR = {"amx": 3, "fmx": 3, "nyx": 3}

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

VALID_EXP_TIMES = {
"amx": {"min": 0.005, "max": 1, "digits": 3},
Expand All @@ -117,9 +118,16 @@ class OnMountAvailOptions(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
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 @@ -631,7 +631,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
39 changes: 19 additions & 20 deletions daq_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
from config_params import ON_MOUNT_OPTION, OnMountAvailOptions
from mxbluesky.plans import detect_loop, topview_optimized

from setenergy_lsdc import setELsdc


try:
import ispybLib
except Exception as e:
Expand Down Expand Up @@ -90,6 +93,22 @@ def abortBS():
RE.abort()
except super_state_machine.errors.TransitionError:
logger.error("caught BS")

def set_energy(energy):
try:
daq_lib.set_field("program_state","Setting Energy")
RE(setELsdc(energy))
except Exception as e:
logger.error(f"Exception while running set_energy: {e}")
daq_lib.set_field("program_state","Program Ready")

def move_omega(omega, relative=True):
"""Moves omega by a certain amount"""
if gov_robot.state.get() == "SA":
if relative:
RE(bps.mvr(samplexyz.omega, omega))
else:
RE(bps.mv(samplexyz.omega, omega))

def changeImageCenterLowMag(x,y,czoom):
zoom = int(czoom)
Expand Down Expand Up @@ -4078,10 +4097,6 @@ def vertRasterOff():
"""vertRasterOff() : only raster vertically for single-column (line) rasters"""
setBlConfig("vertRasterOn",0)

def newVisit():
"""newVisit() : Trick LSDC into creating a new visit on the next request creation"""
setBlConfig("proposal",987654) #a kludge to cause the next collection to generate a new visit


def logMe():
"""logMe() : Edwin asked for this"""
Expand All @@ -4106,18 +4121,6 @@ def emptyQueue():
reqList = list(db_lib.getQueue(daq_utils.beamline))
for i in range (0,len(reqList)):
db_lib.deleteRequest(reqList[i]["uid"])

def addPersonToProposal(personLogin,propNum):
"""addPersonToProposal(personLogin,propNum) : add person to ISPyB proposal - personLogin must be quoted, proposal number is a number (not quoted)"""
ispybLib.addPersonToProposal(personLogin,propNum)

def createPerson(firstName,lastName,loginName):
"""createPerson(firstName,lastName,loginName) : create person for ISPyB - be sure to quote all arguments"""
ispybLib.createPerson(firstName,lastName,loginName)

def createProposal(propNum,PI_login="boaty"):
"""createProposal(propNum,PI_login) : create proposal for ISPyB - be sure to quote the login name, Proposal number is a number (not quoted)"""
ispybLib.createProposal(propNum,PI_login)


def topViewCheckOn():
Expand Down Expand Up @@ -4193,12 +4196,8 @@ def lsdcHelp():
print(enableMount.__doc__)
print(vertRasterOn.__doc__)
print(vertRasterOff.__doc__)
print(newVisit.__doc__)
print(emptyQueue.__doc__)
print(logMe.__doc__)
print(addPersonToProposal.__doc__)
print(createPerson.__doc__)
print(createProposal.__doc__)
print(setAttenBCU.__doc__)
print(setAttenRI.__doc__)
print(unlockGUI.__doc__)
Expand Down
14 changes: 13 additions & 1 deletion daq_main_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,19 @@ def setGovState(state):
setSlit1X,
setSlit1Y,
testRobot,
setGovState]
setGovState,
move_omega,
lockGUI,
unlockGUI,
DewarAutoFillOff,
DewarAutoFillOn,
logMe,
unlatchGov,
backoffDetector,
enableMount,
robotOn,
set_energy
]

whitelisted_functions: "Dict[str, Callable]" = {
func.__name__: func for func in functions
Expand Down
2 changes: 1 addition & 1 deletion daq_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def init_environment():
if varname in os.environ:
detectorOffline = int(os.environ[varname])
setBlConfig(BEAM_CHECK,1)
setBlConfig(UNMOUNT_COLD_CHECK,0)
setBlConfig(UNMOUNT_COLD_CHECK,1)

def calc_reso(det_radius,detDistance,wave,theta):

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
25 changes: 25 additions & 0 deletions docs/source/developer_notes/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,31 @@
Release History
=================

2.0.3 (2024-01-22, a.k.a. 2024-1)
=================================

Fixes and other changes
-----------------------

* GUI

* For users, do not show pucks that do not belong to their proposal
* Speed up dewar tree refresh
* Refresh dewar tree button
* Albula now running in a separate instance
* No more automatic pre-fill of parameters upon request click - user option to do the pre-fill
* Moved unmount cold to the button panel. Added "End Visit" button, only unmounts warm currently

* Server

* Datapath fix
* Fix ISPyB processing population and crystal snapshot creation problems
* Remove population of ISPyB database while infrastructure to update user proposal membership for SynchWeb is being developed

* Server and GUI security improvements

* White-listing functions that can be called on the server to prevent execution of arbitrary code

2.0.2 (2023-09-12, a.k.a. 2023-3)
=================================

Expand Down
Loading

0 comments on commit 62d2649

Please sign in to comment.