Skip to content

Commit

Permalink
reorder initial actions
Browse files Browse the repository at this point in the history
  • Loading branch information
meguiraun committed Oct 2, 2024
1 parent 850c5d8 commit d602877
Showing 1 changed file with 34 additions and 31 deletions.
65 changes: 34 additions & 31 deletions mxcubecore/HardwareObjects/MAXIV/BioMAX/BIOMAXContinuousScan.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
from numpy import arange
from mxcubecore.HardwareObjects.abstract.AbstractEnergyScan import AbstractEnergyScan
from mxcubecore.TaskUtils import cleanup
from mxcubecore.BaseHardwareObjects import HardwareObject
from mxcubecore import HardwareRepository as HWR
import numpy as np
import traceback
Expand Down Expand Up @@ -132,6 +131,31 @@ def calculate_emission_and_edge_energy(self, element=None, edge=None):
)
return (edge_energy, emission)

def energy_scan_hook(self, energy_scan_parameters):
""" """
self.initial_transmission_value = HWR.beamline.transmission.get_att_factor()
self.initial_energy_value = HWR.beamline.energy.get_current_energy()

# ensure proper MD3 phase
if HWR.beamline.diffractometer.get_current_phase() != "DataCollection":
HWR.beamline.diffractometer.set_phase("DataCollection", wait=True)

# and move to the centred positions after phase change
if self.cpos:
logging.getLogger("HWR").info("Moving to centring position")
try:
HWR.beamline.diffractometer.move_to_motors_positions(
self.cpos.as_dict(), wait=True
)
except ValueError as ex:
logging.getLogger("HWR").warning(
"Could not move to centring position, {}".format(ex)
)
else:
logging.getLogger("HWR").warning("Valid centring position not found")

HWR.beamline.diffractometer.move_fluo_in()

def prepare_detector(self, emission):
"""
Preparing Xspress3mini detector
Expand Down Expand Up @@ -406,35 +430,6 @@ def escan_prepare(self):
"""
Set the nesessary equipment in position for the scan. No need to know the escan paramets.
"""

self.initial_transmission_value = HWR.beamline.transmission.get_att_factor()
self.initial_energy_value = HWR.beamline.energy.get_current_energy()

# ensure proper MD3 phase
if HWR.beamline.diffractometer.get_current_phase() != "DataCollection":
HWR.beamline.diffractometer.set_phase("DataCollection", wait=True)

# and move to the centred positions after phase change
if self.cpos:
logging.getLogger("HWR").info("Moving to centring position")
try:
HWR.beamline.diffractometer.move_to_motors_positions(
self.cpos.as_dict(), wait=True
)
except ValueError as ex:
logging.getLogger("HWR").warning(
"Could not move to centring position, {}".format(ex)
)

else:
logging.getLogger("HWR").warning("Valid centring position not found")

try:
HWR.beamline.collect.open_safety_shutter()
except Exception as ex:
logging.getLogger("HWR").error("Open safety shutter: error %s" % str(ex))

HWR.beamline.diffractometer.move_fluo_in()
element = self.energy_scan_parameters["element"]
edge = self.energy_scan_parameters["edge"]

Expand Down Expand Up @@ -683,7 +678,6 @@ def store_energy_scan(self):
"Storing EnergyScan info in ISPYB %r", self.energy_scan_parameters
)


blsampleid = self.energy_scan_parameters.get("blSampleId", None)
if blsampleid:
self.energy_scan_parameters.pop("blSampleId")
Expand Down Expand Up @@ -953,3 +947,12 @@ def get_elements(self):
except IndexError:
pass
return elements

def open_safety_shutter(self, timeout):
"""
Open the safety shutter. Give a timeout [s] if needed.
"""
try:
HWR.beamline.collect.open_safety_shutter()
except Exception as ex:
logging.getLogger("HWR").error("Open safety shutter: error {}".format(ex))

0 comments on commit d602877

Please sign in to comment.