Skip to content

Commit

Permalink
Merge pull request #325 from NSLS-II/2023-2-amxfmx
Browse files Browse the repository at this point in the history
2023 2 amxfmx
  • Loading branch information
JunAishima authored Sep 12, 2023
2 parents 4865dff + d0bb07b commit 8710eab
Show file tree
Hide file tree
Showing 20 changed files with 200 additions and 108 deletions.
2 changes: 1 addition & 1 deletion bin/lsdcGui_amx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export PROJDIR=/nsls2/software/mx/daq/
export CONFIGDIR=${PROJDIR}bnlpx_config/
export LSDCHOME=${PROJDIR}lsdc_amx_prod
export LSDCHOME=${PROJDIR}lsdc_amx

export PATH=/usr/local/bin:/usr/bin:/bin
export PYTHONPATH=".:${CONFIGDIR}:/opt/dectris/albula/4.0/python:${LSDCHOME}"
Expand Down
2 changes: 1 addition & 1 deletion bin/lsdcGui_fmx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export PROJDIR=/nsls2/software/mx/daq/
export CONFIGDIR=${PROJDIR}bnlpx_config/
export LSDCHOME=${PROJDIR}lsdc_fmx_prod
export LSDCHOME=${PROJDIR}lsdc_fmx

export PATH=/usr/local/bin:/usr/bin:/bin
export PYTHONPATH=".:${CONFIGDIR}:/opt/dectris/albula/4.0/python:${LSDCHOME}"
Expand Down
2 changes: 1 addition & 1 deletion bin/lsdcGui_nyx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export PROJDIR=/nsls2/software/mx/daq/
export CONFIGDIR=${PROJDIR}bnlpx_config/
export LSDCHOME=${PROJDIR}lsdc_nyx_prod
export LSDCHOME=${PROJDIR}lsdc_nyx
export EPICS_CA_AUTO_ADDR_LIST=NO
export EPICS_CA_ADDR_LIST=10.67.147.255

Expand Down
2 changes: 1 addition & 1 deletion bin/lsdcRemote_amx.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -l
export PROJDIR=/nsls2/software/mx/daq/
export CONFIGDIR=${PROJDIR}bnlpx_config/
export LSDCHOME=${PROJDIR}lsdc_amx_prod
export LSDCHOME=${PROJDIR}lsdc_amx
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_amx.txt
Expand Down
2 changes: 1 addition & 1 deletion bin/lsdcRemote_fmx.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -l
export PROJDIR=/nsls2/software/mx/daq/
export CONFIGDIR=${PROJDIR}bnlpx_config/
export LSDCHOME=${PROJDIR}lsdc_fmx_prod
export LSDCHOME=${PROJDIR}lsdc_fmx
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.txt
Expand Down
2 changes: 1 addition & 1 deletion bin/lsdcServer_amx.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -l
export PROJDIR=/nsls2/software/mx/daq/
export CONFIGDIR=${PROJDIR}bnlpx_config/
export LSDCHOME=${PROJDIR}lsdc_amx_prod
export LSDCHOME=${PROJDIR}lsdc_amx
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_amx.txt
Expand Down
2 changes: 1 addition & 1 deletion bin/lsdcServer_fmx.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -l
export PROJDIR=/nsls2/software/mx/daq/
export CONFIGDIR=${PROJDIR}bnlpx_config/
export LSDCHOME=${PROJDIR}lsdc_fmx_prod
export LSDCHOME=${PROJDIR}lsdc_fmx
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.txt
Expand Down
2 changes: 1 addition & 1 deletion bin/lsdcServer_nyx.cmd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -l
export PROJDIR=/nsls2/software/mx/daq/
export CONFIGDIR=${PROJDIR}bnlpx_config/
export LSDCHOME=${PROJDIR}lsdc_nyx_prod
export LSDCHOME=${PROJDIR}lsdc_nyx
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
Expand Down
1 change: 1 addition & 0 deletions config_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class RasterStatus(Enum):

HUTCH_TIMER_DELAY = 500
SAMPLE_TIMER_DELAY = 0
SERVER_CHECK_DELAY = 2000

ROBOT_MIN_DISTANCE = 200.0
ROBOT_DISTANCE_TOLERANCE = 0.050
Expand Down
2 changes: 1 addition & 1 deletion daq_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -3207,7 +3207,7 @@ def loop_center_xrec():
pic_prefix = "findloop"
output_file = 'xrec_result.txt'
clean_up_files(pic_prefix, output_file)
zebraCamDaq(0,360,40,.4,pic_prefix,os.getcwd(),0)
zebraCamDaq(0,360,40,.4,pic_prefix,getBlConfig("visitDirectory"),0)
comm_s = f'xrec {os.environ["CONFIGDIR"]}/xrec_360_40Fast.txt {output_file}'
logger.info(comm_s)
try:
Expand Down
12 changes: 3 additions & 9 deletions daq_main2.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import sys
import os
from daq_main_common import pybass_init, run_server
from config_params import LSDC_SERVICE_USERS

from utils.healthcheck import perform_server_checks
#TODO understand why imports are required here - GUI requires imports in daq_main_common
from daq_macros import *
from daq_lib import *
Expand Down Expand Up @@ -36,13 +35,8 @@
logger.addHandler(handler1)
logger.addHandler(handler2)

if not getpass.getuser() in LSDC_SERVICE_USERS:
message = "LSDC server not being started by a LSDC service user account, aborting!"
print(message)
logger.error(message)
sys.exit(1)
else:
print(f"continuing as we are using a service user: {getpass.getuser()}")
perform_server_checks()
setBlConfig("visitDirectory", os.getcwd())
sitefilename = ""
global command_list,immediate_command_list,z
command_list = []
Expand Down
38 changes: 15 additions & 23 deletions daq_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def createDefaultRequest(sample_id,createVisit=True):
setProposalID(propNum,createVisit)
screenDist, screenEnergy, screenExptime, screenPhiend, screenPhist, screenReso, screenTransmissionPercent, screenWidth, screenbeamHeight, screenbeamWidth = getScreenDefaultParams()
sampleName = str(db_lib.getSampleNamebyID(sample_id))
basePath = os.getcwd()
basePath = getBlConfig("visitDirectory")
runNum = db_lib.getSampleRequestCount(sample_id)
(puckPosition,samplePositionInContainer,containerID) = db_lib.getCoordsfromSampleID(beamline,sample_id)
request = {"sample": sample_id}
Expand Down Expand Up @@ -284,7 +284,7 @@ def create_filename(prefix,number):
else:
tmp_filename = "%s_%05d.cbf" % (prefix,int(number))
if (prefix[0] != "/"):
cwd = os.getcwd()
cwd = getBlConfig("visitDirectory")
filename = "%s/%s" % (cwd,tmp_filename)
else:
filename = tmp_filename
Expand Down Expand Up @@ -364,27 +364,19 @@ def readPVDesc():
counter_inf = line.split()
counter_dict[counter_inf[1]] = beamline_designation + counter_inf[0]

def createVisitNameRaw(proposalName, maxNumber=None):
if maxNumber:
number = maxNumber + 1
else:
number = 1
return f'mx{proposalName}-{number}', number

def createVisitName(proposalName, maxNumber=None):
return createVisitNameRaw(proposalName, maxNumber)

def setProposalID(proposalID,createVisit=True): # TODO JA proposalID implies a database ID, which it is not (just proposal number). Misleading
if (getProposalID() != proposalID): #proposalID changed - create a new visit.
logger.info("you changed proposals! " + str(proposalID))
logger.info('ignoring createVisit for now - ISPyB required to properly account for visit numbers')
try:
visitName, visitNum = createVisitName(proposalID)
db_lib.setBeamlineConfigParam(beamline,"proposal",proposalID)
except Exception as e:
visitName = "999999-1234"
logger.error("error in set proposal. Error: %s" % e)
setVisitName(visitName)
def setProposalID(proposalID,createVisit=True):
if (getProposalID() != proposalID): #proposalID changed - create a new visit.
logger.info("you changed proposals! " + str(proposalID))
try:
if (createVisit):
visitName = ispybLib.createVisit(proposalID)
db_lib.setBeamlineConfigParam(beamline,"proposal",proposalID)
else:
visitName, visitNum = ispybLib.createVisitName(proposalID)
except Exception as e:
visitName = "999999-1234"
logger.error("ispyb error in set proposal. Error: %s" % e)
setVisitName(visitName)

def getProposalID():
return getBlConfig("proposal")
Expand Down
7 changes: 3 additions & 4 deletions embl_robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def preMount(self, gov_robot, puckPos, pinPos, sampID, **kwargs):
prefix90 = sampName + "_" + str(puckPos) + "_" + str(pinPos) + "_" + str(reqCount) + "_PA_90"
kwargs['prefix1'] = prefix1
kwargs['prefix90'] = prefix90
top_view.topViewSnap(prefix1,os.getcwd()+"/pinAlign",1,acquire=0)
top_view.topViewSnap(prefix1,getBlConfig("visitDirectory")+"/pinAlign",1,acquire=0)
except Exception as e:
e_s = str(e)
message = "TopView check ERROR, will continue: " + e_s
Expand Down Expand Up @@ -262,9 +262,6 @@ def mount(self, gov_robot, puckPos,pinPos,sampID,**kwargs):
else:
robotStatus = beamline_support.get_any_epics_pv("SW:RobotState","VAL")
if (robotStatus != "Ready"):
if (daq_utils.beamline == "fmx"):
daq_macros.homePins()
time.sleep(3.0)
gov_status = gov_lib.setGovRobot(gov_robot, 'SE')
if not gov_status.success:
return MOUNT_FAILURE
Expand Down Expand Up @@ -361,6 +358,8 @@ def preUnmount(self, gov_robot, puckPos,pinPos,sampID): #will somehow know where
detDist = beamline_lib.motorPosFromDescriptor("detectorDist")
if (detDist<DETECTOR_SAFE_DISTANCE):
gov_lib.set_detz_out(gov_robot, DETECTOR_SAFE_DISTANCE)
if daq_utils.beamline == "fmx":
beamline_lib.mvaDescriptor("omega", 0)
daq_lib.setRobotGovState("SE")
logger.info("unmounting " + str(puckPos) + " " + str(pinPos) + " " + str(sampID))
logger.info("absPos = " + str(absPos))
Expand Down
47 changes: 22 additions & 25 deletions gui/control_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from qtpy import QtCore, QtGui, QtWidgets
from qtpy.QtCore import QModelIndex, QRectF, Qt, QTimer
from qtpy.QtGui import QIntValidator
from qtpy.QtWidgets import QCheckBox, QFrame, QGraphicsPixmapItem
from qtpy.QtWidgets import QCheckBox, QFrame, QGraphicsPixmapItem, QApplication

import albulaUtils
import daq_utils
Expand All @@ -26,6 +26,7 @@
from config_params import (
CRYOSTREAM_ONLINE,
HUTCH_TIMER_DELAY,
SERVER_CHECK_DELAY,
RASTER_GUI_XREC_FILL_DELAY,
SAMPLE_TIMER_DELAY,
VALID_DET_DIST,
Expand All @@ -50,14 +51,9 @@
)
from gui.raster import RasterCell, RasterGroup
from QPeriodicTable import QPeriodicTable
from threads import RaddoseThread, VideoThread
from threads import RaddoseThread, VideoThread, ServerCheckThread

logger = logging.getLogger()
try:
import ispybLib
except Exception as e:
logger.error("lsdcGui: ISPYB import error, %s" % e)


def get_request_object_escan(
reqObj,
Expand Down Expand Up @@ -1395,21 +1391,25 @@ def createSampleTab(self):
self.vidActionRasterDefRadio.setDisabled(True)
self.vidActionDefineCenterRadio.setDisabled(True)

hutchCornerCamThread = VideoThread(
self.hutchCornerCamThread = VideoThread(
parent=self, delay=HUTCH_TIMER_DELAY, url=getBlConfig("hutchCornerCamURL")
)
hutchCornerCamThread.frame_ready.connect(
self.hutchCornerCamThread.frame_ready.connect(
lambda frame: self.updateCam(self.pixmap_item_HutchCorner, frame)
)
hutchCornerCamThread.start()
self.hutchCornerCamThread.start()

hutchTopCamThread = VideoThread(
self.hutchTopCamThread = VideoThread(
parent=self, delay=HUTCH_TIMER_DELAY, url=getBlConfig("hutchTopCamURL")
)
hutchTopCamThread.frame_ready.connect(
self.hutchTopCamThread.frame_ready.connect(
lambda frame: self.updateCam(self.pixmap_item_HutchTop, frame)
)
hutchTopCamThread.start()
self.hutchTopCamThread.start()
serverCheckThread = ServerCheckThread(
parent=self, delay=SERVER_CHECK_DELAY)
serverCheckThread.visit_dir_changed.connect(QApplication.instance().quit)
serverCheckThread.start()

def updateCam(self, pixmapItem: "QGraphicsPixmapItem", frame):
pixmapItem.setPixmap(frame)
Expand Down Expand Up @@ -1703,20 +1703,16 @@ def saveVidSnapshotCB(
if reqID != None:
filePrefix = db_lib.getRequestByID(reqID)["request_obj"]["file_prefix"]
imagePath = (
os.getcwd() + "/snapshots/" + filePrefix + str(int(now)) + ".jpg"
f"{getBlConfig('visitDirectory')}/snapshots/{filePrefix}{int(now)}.jpg"
)
else:
if self.dataPathGB.prefix_ledit.text() != "":
imagePath = (
os.getcwd()
+ "/snapshots/"
+ str(self.dataPathGB.prefix_ledit.text())
+ str(int(now))
+ ".jpg"
f"{getBlConfig('visitDirectory')}/snapshots/{self.dataPathGB.prefix_ledit.text()}{int(now)}.jpg"
)
else:
imagePath = (
os.getcwd() + "/snapshots/capture" + str(int(now)) + ".jpg"
f"{getBlConfig('visitDirectory')}/snapshots/capture{int(now)}.jpg"
)
else:
imagePath = rasterHeatJpeg
Expand Down Expand Up @@ -3116,10 +3112,7 @@ def takeRasterSnapshot(self, rasterReq):
reqID=rasterReq["uid"],
rasterHeatJpeg=jpegImageFilename,
)
try:
ispybLib.insertRasterResult(rasterReq, visitName)
except Exception as e:
logger.error(f"Exception while writing raster result: {e}")
self.send_to_server(f"ispybLib.insertRasterResult('{rasterReq['uid']}', '{visitName}')")

def reFillPolyRaster(self):
rasterEvalOption = str(self.rasterEvalComboBox.currentText())
Expand Down Expand Up @@ -4984,7 +4977,11 @@ def popStaffDialogCB(self):
self.popupServerMessage("You don't have control")

def closeAll(self):
QtWidgets.QApplication.closeAllWindows()
self.hutchCornerCamThread.stop()
self.hutchTopCamThread.stop()
self.hutchCornerCamThread.wait()
self.hutchTopCamThread.wait()
QtWidgets.QApplication.instance().quit()

def initCallbacks(self):
self.beamSizeSignal.connect(self.processBeamSize)
Expand Down
4 changes: 2 additions & 2 deletions gui/data_loc_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def __init__(self, parent: "ControlMain"):
self.vBoxDPathParams1 = QtWidgets.QVBoxLayout()
self.hBoxDPathParams1 = QtWidgets.QHBoxLayout()
self.basePathLabel = QtWidgets.QLabel("Base Path:")
self.base_path_ledit = QtWidgets.QLabel() # leave editable for now
self.base_path_ledit.setText(os.getcwd())
self.base_path_ledit = QtWidgets.QLabel()
self.base_path_ledit.setText(daq_utils.getBlConfig("visitDirectory"))
self.base_path_ledit.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse)
# self.base_path_ledit.textChanged[str].connect(self.basePathTextChanged)
self.browseBasePathButton = QtWidgets.QPushButton("Browse...")
Expand Down
Loading

0 comments on commit 8710eab

Please sign in to comment.