Repository navigation
Add Perkin Elmer PE1/PE2 as continuous-acquisition detectors #6
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
Merged
Anthony Sligar (sligara7)
merged 2 commits into
NSLS2:pdf-profile-conversion
from
sligara7:pdf-conv-03b-perkin-elmer
Oct 23, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import datetime | ||
| from pathlib import PurePosixPath, PureWindowsPath | ||
|
|
||
| import bluesky.plans as bp | ||
| import pytest | ||
| from bluesky.run_engine import RunEngine | ||
| from nslsii.ophyd_async.providers import NSLS2PathProvider | ||
| from ophyd_async.core import ( | ||
| callback_on_mock_put, | ||
| get_mock_put, | ||
| init_devices, | ||
| set_mock_value, | ||
| ) | ||
| from ophyd_async.epics.adcore import ( | ||
| ADBaseDataType, | ||
| ADImageMode, | ||
| ADWriterFactory, | ||
| ContAcqDetector, | ||
| ) | ||
|
|
||
|
|
||
| def test_perkin_elmer_count_sums_in_proc_and_writes_tiff_to_windows_share( | ||
| RE: RunEngine, monkeypatch: pytest.MonkeyPatch | ||
| ): | ||
| # As the profile sets it: a count keeps the frame count summed in the IOC's Proc1. | ||
| monkeypatch.setenv("OPHYD_ASYNC_PRESERVE_DETECTOR_STATE", "YES") | ||
| RE.md.update({"cycle": "2026-3", "data_session": "pass-123456"}) | ||
| path_provider = NSLS2PathProvider( | ||
| RE.md, | ||
| base_data_dir=PurePosixPath("/nsls2/data/pdf/proposals"), | ||
| base_write_dir=PureWindowsPath("J:\\proposals"), | ||
| separator="/", | ||
| ) | ||
| with init_devices(mock=True): | ||
| pe = ContAcqDetector( | ||
| "TEST:PE2:", | ||
| ADWriterFactory.tiff(path_provider), | ||
| name="pe2", | ||
| proc_suffix="Proc1:", | ||
| ) | ||
| set_mock_value(pe.driver.image_mode, ADImageMode.CONTINUOUS) | ||
| set_mock_value(pe.driver.acquire, True) | ||
| set_mock_value(pe.driver.array_size_x, 4) | ||
| set_mock_value(pe.driver.array_size_y, 3) | ||
| set_mock_value(pe.driver.data_type, ADBaseDataType.UINT16) | ||
| set_mock_value(pe.tiff.file_path_exists, True) # pyright: ignore[reportAttributeAccessIssue] | ||
| set_mock_value(pe.proc.enable_filter, True) # pyright: ignore[reportAttributeAccessIssue] | ||
| set_mock_value(pe.proc.num_filter, 5) # pyright: ignore[reportAttributeAccessIssue] | ||
|
|
||
| def _on_cb_trigger(value, **kwargs): | ||
| if value: | ||
| set_mock_value(pe.tiff.num_captured, 1) # pyright: ignore[reportAttributeAccessIssue] | ||
| return False | ||
|
|
||
| callback_on_mock_put(pe.cb.trigger_, _on_cb_trigger) # pyright: ignore[reportAttributeAccessIssue] | ||
|
|
||
| docs: dict[str, list] = {} | ||
| RE(bp.count([pe]), lambda name, doc: docs.setdefault(name, []).append(doc)) | ||
|
|
||
| written_to = get_mock_put(pe.tiff.file_path).call_args.args[0] # pyright: ignore[reportAttributeAccessIssue] | ||
| assert written_to.startswith("J:\\proposals\\2026-3\\pass-123456\\") | ||
| sres = docs["stream_resource"][0] | ||
| assert sres["mimetype"] == "multipart/related;type=image/tiff" | ||
| # The read side is POSIX: no Windows separators may leak in from the write root. | ||
| today = datetime.date.today() | ||
| assert sres["uri"] == ( | ||
| "file://localhost/nsls2/data/pdf/proposals/2026-3/pass-123456/" | ||
| f"assets/pe2/{today:%Y/%m/%d}/" | ||
| ) | ||
| get_mock_put(pe.proc.num_filter).assert_called_with(5) # pyright: ignore[reportAttributeAccessIssue] | ||
| desc = docs["descriptor"][0]["data_keys"]["pe2"] | ||
| assert desc["shape"] == [1, 3, 4] | ||
| assert desc["dtype_numpy"] == "<u2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.