-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set up i24 serial to run on procserv #577
Changes from 15 commits
555a41d
55d3c0a
4387952
a246699
b565424
10b1a28
c467827
d528feb
6d1b54c
309e407
e37376e
597e16a
088786d
44f2c13
75b73bf
12c43db
a67d9c5
22d8b1b
4f10d60
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,10 +56,10 @@ | |
) | ||
from mx_bluesky.beamlines.i24.serial.write_nexus import call_nexgen | ||
|
||
ABORTED = False | ||
|
||
logger = logging.getLogger("I24ssx.fixed_target") | ||
|
||
PMAC_MOVE_TIME = 0.008 # Move time between positions on chip ~ 7-8 ms | ||
|
||
|
||
def setup_logging(): | ||
# Log should now change name daily | ||
|
@@ -85,7 +85,8 @@ def calculate_collection_timeout(parameters: FixedTargetParameters) -> float: | |
Returns: | ||
The estimated collection time, in s. | ||
""" | ||
buffer = 30 | ||
buffer = PMAC_MOVE_TIME * parameters.total_num_images + 2 | ||
# buffer = 30 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean to leave this comment in? It might be explain why we need a buffer for the timeout There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, no, good spot |
||
pump_setting = parameters.pump_repeat | ||
collection_time = parameters.total_num_images * parameters.exposure_time_s | ||
if pump_setting in [ | ||
|
@@ -474,24 +475,8 @@ def start_i24( | |
elif parameters.detector_name == "eiger": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: There is some duplicated code between this file and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that probably won't be fixed until we get around to #62 and we can finish tidying up the code... |
||
logger.info("Using Eiger detector") | ||
|
||
logger.warning( | ||
"""TEMPORARY HACK! | ||
Running a Single image pilatus data collection to create directory.""" | ||
) | ||
num_imgs = 1 | ||
sup.pilatus( | ||
"quickshot-internaltrig", | ||
[filepath, filename, num_imgs, parameters.exposure_time_s], | ||
) | ||
logger.debug("Sleep 2s waiting for pilatus to arm") | ||
sleep(2) | ||
sleep(0.5) | ||
caput(pv.pilat_acquire, "0") # Disarm pilatus | ||
sleep(0.5) | ||
caput(pv.pilat_acquire, "1") # Arm pilatus | ||
logger.debug("Pilatus data collection DONE") | ||
sup.pilatus("return to normal", None) | ||
logger.info("Pilatus back to normal. Single image pilatus data collection DONE") | ||
logger.debug(f"Creating the directory for the collection in {filepath}.") | ||
Path(filepath).mkdir(parents=True) | ||
|
||
logger.info(f"Triggered Eiger setup: filepath {filepath}") | ||
logger.info(f"Triggered Eiger setup: filename {filename}") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
#!/bin/bash | ||
|
||
NO_PROCESERV_TEST=false | ||
|
||
case "$2" in | ||
-t | --test) | ||
echo "Will run serial in test mode without procserv." | ||
NO_PROCESERV_TEST=true | ||
;; | ||
esac | ||
|
||
|
||
# Get edm path from input | ||
edm_path=$1 | ||
|
||
# Get the directory of this script | ||
current=$( realpath "$( dirname "$0" )" ) | ||
if [[ $NO_PROCESERV_TEST == true ]]; then | ||
echo "Start the blueapi sever" | ||
|
||
# Get the directory of this script | ||
current=$( realpath "$( dirname "$0" )" ) | ||
|
||
# Run script to start blueapi serve | ||
. $current/start_blueapi.sh | ||
# Run script to start blueapi serve | ||
. $current/start_blueapi.sh | ||
fi | ||
|
||
# Open the edm screen for an extruder serial collection | ||
echo "Starting extruder edm screen." | ||
edm -x "${edm_path}/EX-gui/DiamondExtruder-I24-py3v1.edl" | ||
|
||
echo "Edm screen closed, bye!" | ||
|
||
pgrep blueapi | xargs kill | ||
echo "Blueapi process killed" | ||
if [[ $NO_PROCESERV_TEST == true ]]; then | ||
# In this case blueapi server needs to be killed. | ||
pgrep blueapi | xargs kill | ||
echo "Blueapi process killed" | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,38 @@ | ||
#!/bin/bash | ||
|
||
NO_PROCESERV_TEST=false | ||
|
||
case "$2" in | ||
-t | --test) | ||
echo "Will run serial in test mode without procserv." | ||
NO_PROCESERV_TEST=true | ||
;; | ||
esac | ||
|
||
# Get edm path from input | ||
edm_path=$1 | ||
|
||
# Export env variable for the stages edm to work properly | ||
export EDMDATAFILES="/dls_sw/prod/R3.14.12.3/support/motor/6-7-1dls14/motorApp/opi/edl" | ||
|
||
# Get the directory of this script | ||
current=$( realpath "$( dirname "$0" )" ) | ||
if [[ $NO_PROCESERV_TEST == true ]]; then | ||
echo "Start the blueapi sever" | ||
|
||
# Get the directory of this script | ||
current=$( realpath "$( dirname "$0" )" ) | ||
|
||
# Run script to start blueapi serve | ||
. $current/start_blueapi.sh | ||
# Run script to start blueapi serve | ||
. $current/start_blueapi.sh | ||
fi | ||
|
||
# Open the edm screen for a fixed target serial collection | ||
echo "Starting fixed target edm screen." | ||
edm -x "${edm_path}/FT-gui/DiamondChipI24-py3v1.edl" | ||
|
||
echo "Edm screen closed, bye!" | ||
|
||
pgrep blueapi | xargs kill | ||
echo "Blueapi process killed" | ||
if [[ $NO_PROCESERV_TEST == true ]]; then | ||
# In this case blueapi server needs to be killed. | ||
pgrep blueapi | xargs kill | ||
echo "Blueapi process killed" | ||
fi |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import argparse | ||
import logging | ||
import subprocess | ||
from os import environ | ||
|
@@ -6,6 +7,13 @@ | |
logger = logging.getLogger("I24ssx.run") | ||
|
||
|
||
def _parse_input(expt: str): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this file is the main entry point, it would be nice to be able to run this file directly, eg with a
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah no, the entry points are the two functions that are being run directly (see in |
||
parser = argparse.ArgumentParser(description=f"Run a {expt} collection.") | ||
parser.add_argument("-t", "--test", action="store_true", help="Run in test mode.") | ||
args = parser.parse_args() | ||
return args | ||
|
||
|
||
def get_location(default: str = "dev") -> str: | ||
return environ.get("BEAMLINE") or default | ||
|
||
|
@@ -19,18 +27,26 @@ | |
|
||
|
||
def run_extruder(): | ||
args = _parse_input("extruder") | ||
loc = get_location() | ||
logger.debug(f"Running on {loc}.") | ||
edm_path = get_edm_path() | ||
filepath = _get_file_path() | ||
test_mode = "--test" if args.test else "" | ||
logger.debug(f"Running {filepath}/run_extruder.sh") | ||
subprocess.run(["sh", filepath / "run_extruder.sh", edm_path.as_posix()]) | ||
subprocess.run( | ||
["bash", filepath / "run_extruder.sh", edm_path.as_posix(), test_mode] | ||
) | ||
|
||
|
||
def run_fixed_target(): | ||
args = _parse_input("fixed target") | ||
loc = get_location() | ||
logger.info(f"Running on {loc}.") | ||
edm_path = get_edm_path() | ||
filepath = _get_file_path() | ||
test_mode = "--test" if args.test else "" | ||
logger.debug(f"Running {filepath}/run_fixed_target.sh") | ||
subprocess.run(["sh", filepath / "run_fixed_target.sh", edm_path.as_posix()]) | ||
subprocess.run( | ||
["bash", filepath / "run_fixed_target.sh", edm_path.as_posix(), test_mode] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# Sources the python environment and starts a blueapi server | ||
# on a python IOC to run serial on I24 with procserv | ||
|
||
# Get the directory of this script | ||
current_directory=$( realpath "$( dirname "$0" )" ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need protection against running this script when the ioc and/or when blueapi is already running? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really... I mean, we could add something but blueAPI will not start and just raise and error if already running - on procserv or otherwise - because the port in the stomp configuration is already occupied. Also, procserv right now can only run on one machine at a time on I24 because the control machine is still on RHEL7 so we've kind of already got two levels of "you shall not run" |
||
# Get the directory with the venv | ||
env_directory=$(dirname $current_directory) | ||
# And where the blueapi config lives | ||
config_directory="${env_directory}/src/mx_bluesky/beamlines/i24/serial" | ||
|
||
# Source modules environment | ||
source /dls_sw/etc/profile | ||
# Activate virtual environment | ||
source $env_directory/.venv/bin/activate | ||
|
||
# Start blueapi server | ||
blueapi -c "${config_directory}/blueapi_config.yaml" serve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be good to have constants like this moved into more organised locations, but perhaps better to wait for me to finish my work on this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. In this case I was also half considering having this constant in
dodal
, but I don't have a strong opinion on this. Will make a note in the code to do this