Skip to content

Commit

Permalink
Complete finish test
Browse files Browse the repository at this point in the history
  • Loading branch information
noemifrisina committed Jul 17, 2024
1 parent 44d5a28 commit dc5afcb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -538,21 +538,21 @@ def finish_i24(
):
logger.info(f"Finish I24 data collection with {parameters.detector_name} detector.")

filename = parameters.filename
complete_filename: str
transmission = float(caget(pv.pilat_filtertrasm))
wavelength = float(caget(pv.dcm_lambda))

if parameters.detector_name == "pilatus":
logger.debug("Finish I24 Pilatus")
filename = filename + "_" + caget(pv.pilat_filenum)
complete_filename = f"{parameters.filename}_{caget(pv.pilat_filenum)}"
yield from reset_zebra_when_collection_done_plan(zebra)
sup.pilatus("return-to-normal")
sleep(0.2)
elif parameters.detector_name == "eiger":
logger.debug("Finish I24 Eiger")
yield from reset_zebra_when_collection_done_plan(zebra)
sup.eiger("return-to-normal")
filename = cagetstring(pv.eiger_ODfilenameRBV)
complete_filename = cagetstring(pv.eiger_ODfilenameRBV) # type: ignore

# Detector independent moves
logger.info("Move chip back to home position by setting PMAC_STRING pv.")
Expand All @@ -564,7 +564,7 @@ def finish_i24(
logger.debug("Collection end time %s" % end_time)

# Write a record of what was collected to the processing directory
write_userlog(parameters, filename, transmission, wavelength)
write_userlog(parameters, complete_filename, transmission, wavelength)
sleep(0.5)

return end_time
Expand Down
6 changes: 6 additions & 0 deletions src/mx_bluesky/I24/serial/parameters/experiment_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ class SerialExperiment(BaseModel):
detector_distance_mm: float
detector_name: Literal["eiger", "pilatus"]

@validator("visit", pre=True)
def _parse_visit(cls, visit: str | Path):
if isinstance(visit, str):
return Path(visit)
return visit

@property
def collection_directory(self) -> Path:
return Path(self.visit) / self.directory
Expand Down
9 changes: 8 additions & 1 deletion tests/I24/serial/fixed_target/test_ft_collect.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,14 @@ def test_finish_i24(
):
fake_caget.side_effect = [0.0, 0.6]
RE(finish_i24(zebra, pmac, shutter, dummy_params_without_pp))
# TODO FINISH ME!

fake_sup.eiger.assert_called_once_with("return-to-normal")

mock_pmac_string = get_mock_put(pmac.pmac_string)
mock_pmac_string.assert_has_calls([call("!x0y0z0", wait=True, timeout=ANY)])

mock_shutter = get_mock_put(shutter.control)
mock_shutter.assert_has_calls([call("Close", wait=True, timeout=ANY)])


def test_run_aborted_plan(pmac: PMAC, RE):
Expand Down

0 comments on commit dc5afcb

Please sign in to comment.