refactor(mcs-card): adjust mcs card to only have mca channels. #114

Merged
appel_c merged 9 commits from refactor/mcs_card_refactoring into main 2026-01-26 07:44:43 +01:00
Owner

Summary

This PR revisited and partially rewrote the integration of the MCS card and the DigitalDelayGenerator (DDG) devices at the beamline. Hardware components were extensively tested to navigate and compensate any HW (or IOC) limitations of the individual devices, and integrated them for any software triggered scans running from BEC. The MCS card can now be operated in burst mode (frames_per_trigger >1) and we currently limit acquisitions to <5000Hz.
This limits is currently established on the DelayGenerator as the lowest deadtime, but can be adjusted if needed. The IOC of the MCS card was adjusted to allow 1e5 (or 1e6, to be checked) points. This limits the total number of points within a scan. The card is programmed to buffer all data before it is being read out. It should be checked if continuous readouts is going to be faster (and stable). As discussed, the MCS card now simply exposes the 32 input channels. We will discuss to create virtual devices who will use the channels to calculate new signals, e.g. a 'bpm' device. These virtual devices are not part of this PR.

Documentation

As both device integration are quite complex and are already heavily involved with beamline logic, I have spent additional time to write a documentation for the ophyd classes. This includes comments about HW (or IOC) limitations and obstacles that need to be considered as some operations have unexpected side effects that have to be considered in the integration.

In addition, due to the central timing source (master trigger), different devices share dependencies if certain procedures have to be executed in order. This creates additional complexity in the integration, in particular with the imposed limitations of the HW. All of this is documented as good as possible in README.md files in both modules, as well as directly in the source code of the device integrations.

To Do's

  • Check if buffering large amounts of data (~1e5-1e6 points) limits the speed of operation. Check if continuous/passiv readout of the card is feasible. We postpone this, issue is created (#132)
  • Test latest integration with HW once SLS 2.0 IT infrastructure is up and running again
  • Review documentation of README.md and in-line comments in the device integration.
  • Issue created to investigate in future the occasion crashes (#131)
# Summary This PR revisited and partially rewrote the integration of the MCS card and the DigitalDelayGenerator (DDG) devices at the beamline. Hardware components were extensively tested to navigate and compensate any HW (or IOC) limitations of the individual devices, and integrated them for any software triggered scans running from BEC. The MCS card can now be operated in burst mode (frames_per_trigger >1) and we currently limit acquisitions to <5000Hz. This limits is currently established on the DelayGenerator as the lowest deadtime, but can be adjusted if needed. The IOC of the MCS card was adjusted to allow 1e5 (or 1e6, to be checked) points. This limits the total number of points within a scan. The card is programmed to buffer all data before it is being read out. It should be checked if continuous readouts is going to be faster (and stable). As discussed, the MCS card now simply exposes the 32 input channels. We will discuss to create virtual devices who will use the channels to calculate new signals, e.g. a 'bpm' device. These virtual devices are not part of this PR. ## Documentation As both device integration are quite complex and are already heavily involved with beamline logic, I have spent additional time to write a documentation for the ophyd classes. This includes comments about HW (or IOC) limitations and obstacles that need to be considered as some operations have unexpected side effects that have to be considered in the integration. In addition, due to the central timing source (master trigger), different devices share dependencies if certain procedures have to be executed in order. This creates additional complexity in the integration, in particular with the imposed limitations of the HW. All of this is documented as good as possible in README.md files in both modules, as well as directly in the source code of the device integrations. ## To Do's - [x] Check if buffering large amounts of data (~1e5-1e6 points) limits the speed of operation. Check if continuous/passiv readout of the card is feasible. We postpone this, issue is created (https://gitea.psi.ch/bec/csaxs_bec/issues/132) - [x] Test latest integration with HW once SLS 2.0 IT infrastructure is up and running again - [x] Review documentation of README.md and in-line comments in the device integration. - [x] Issue created to investigate in future the occasion crashes (https://gitea.psi.ch/bec/csaxs_bec/issues/131)
appel_c added 1 commit 2025-12-08 17:39:38 +01:00
refactor(mcs-card): adjust mcs card to only have mca channels.
Some checks failed
CI for csaxs_bec / test (push) Failing after 32s
CI for csaxs_bec / test (pull_request) Failing after 35s
dc6cfea050
appel_c added 1 commit 2025-12-09 09:58:54 +01:00
fix(ddg): adapt DDG, remove mcs.readytoread
Some checks failed
CI for csaxs_bec / test (push) Failing after 36s
CI for csaxs_bec / test (pull_request) Failing after 37s
d7e74797de
appel_c added 1 commit 2025-12-09 10:00:23 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 31s
CI for csaxs_bec / test (push) Failing after 38s
d97c293bc3
appel_c added 2 commits 2025-12-09 10:03:24 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 31s
CI for csaxs_bec / test (push) Failing after 37s
e21d0e16fa
appel_c added 1 commit 2025-12-09 10:08:58 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 31s
CI for csaxs_bec / test (push) Failing after 39s
35a923e381
appel_c added 1 commit 2025-12-09 10:15:45 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 31s
CI for csaxs_bec / test (push) Failing after 37s
52e85ab946
appel_c added 1 commit 2025-12-09 10:21:46 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 33s
CI for csaxs_bec / test (push) Failing after 37s
b324bb2bac
appel_c added 1 commit 2025-12-09 10:35:33 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 32s
CI for csaxs_bec / test (push) Failing after 37s
bdbf179cbb
appel_c added 1 commit 2025-12-09 10:38:30 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 32s
CI for csaxs_bec / test (push) Failing after 37s
419026ac15
appel_c added 2 commits 2025-12-09 16:33:20 +01:00
wip thread
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 32s
CI for csaxs_bec / test (push) Failing after 36s
3ea64a48b4
appel_c added 1 commit 2025-12-09 18:28:44 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 35s
CI for csaxs_bec / test (pull_request) Failing after 37s
4f877d2dae
appel_c added 1 commit 2025-12-09 18:32:07 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 33s
CI for csaxs_bec / test (pull_request) Failing after 37s
a37f07d76a
appel_c added 1 commit 2025-12-09 18:35:08 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 33s
CI for csaxs_bec / test (push) Failing after 34s
617c306224
appel_c added 1 commit 2025-12-09 21:13:18 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 34s
CI for csaxs_bec / test (push) Failing after 1m34s
cfe51c30c4
appel_c added 1 commit 2025-12-09 21:18:51 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 36s
CI for csaxs_bec / test (pull_request) Failing after 36s
7247ea1250
appel_c added 1 commit 2025-12-09 21:20:50 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 32s
CI for csaxs_bec / test (push) Failing after 36s
e77a120cd5
appel_c added 1 commit 2025-12-09 21:21:29 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 33s
CI for csaxs_bec / test (push) Failing after 37s
e3d5be44c5
appel_c added 1 commit 2025-12-09 21:28:53 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 32s
CI for csaxs_bec / test (push) Failing after 38s
8853cc94a4
appel_c added 1 commit 2025-12-10 07:05:07 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 33s
CI for csaxs_bec / test (pull_request) Failing after 37s
970fa9bcd3
appel_c added 1 commit 2025-12-10 07:19:05 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 32s
CI for csaxs_bec / test (push) Failing after 38s
e70974d254
appel_c added 1 commit 2025-12-10 07:25:44 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 34s
CI for csaxs_bec / test (push) Failing after 36s
b0193f8df9
appel_c added 1 commit 2025-12-10 07:28:29 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 33s
CI for csaxs_bec / test (push) Failing after 35s
10d7e638b7
appel_c added 1 commit 2025-12-10 07:29:51 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 34s
CI for csaxs_bec / test (push) Failing after 37s
a06c2bfc5d
appel_c added 1 commit 2025-12-15 16:49:32 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 1m3s
CI for csaxs_bec / test (pull_request) Failing after 1m4s
f95007059a
bec_bl_push-gitea added 1 commit 2025-12-16 08:20:42 +01:00
fix: mcs card fixes
Some checks failed
CI for csaxs_bec / test (push) Failing after 58s
CI for csaxs_bec / test (pull_request) Failing after 1m4s
7556e14e26
appel_c added 1 commit 2025-12-16 08:53:01 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 1m3s
CI for csaxs_bec / test (pull_request) Failing after 1m6s
8c8e988460
appel_c added 1 commit 2025-12-16 08:58:50 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 1m3s
CI for csaxs_bec / test (pull_request) Failing after 1m5s
1aab3a47f9
appel_c added 1 commit 2025-12-16 09:00:19 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 1m2s
CI for csaxs_bec / test (pull_request) Failing after 1m6s
3063767868
appel_c added 1 commit 2025-12-16 09:03:46 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 1m0s
CI for csaxs_bec / test (push) Failing after 1m3s
01b2e2ea52
bec_bl_push-gitea added 1 commit 2025-12-16 09:30:27 +01:00
wip
Some checks failed
CI for csaxs_bec / test (push) Failing after 58s
CI for csaxs_bec / test (pull_request) Failing after 1m2s
370de68c64
appel_c added 1 commit 2025-12-16 09:40:26 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 58s
CI for csaxs_bec / test (pull_request) Failing after 1m4s
3feea8a11e
appel_c added 1 commit 2025-12-16 10:56:44 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 59s
CI for csaxs_bec / test (push) Failing after 1m5s
3b40cc2a71
appel_c added 1 commit 2025-12-16 11:04:32 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 1m0s
CI for csaxs_bec / test (pull_request) Failing after 1m3s
c45221e3b2
appel_c added 1 commit 2025-12-16 11:20:47 +01:00
wip args in statusbitscompare
Some checks failed
CI for csaxs_bec / test (push) Failing after 59s
CI for csaxs_bec / test (pull_request) Failing after 1m3s
2edcab9a5e
appel_c added 1 commit 2025-12-16 11:23:17 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 59s
CI for csaxs_bec / test (pull_request) Failing after 1m4s
c6cf3200d0
appel_c added 1 commit 2025-12-16 11:34:07 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 1m0s
CI for csaxs_bec / test (pull_request) Failing after 1m3s
1f02d9ad18
bec_bl_push-gitea added 2 commits 2025-12-19 08:34:23 +01:00
add comments from the beamline
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 1m4s
CI for csaxs_bec / test (push) Failing after 1m11s
4cb7549d7d
bec_bl_push-gitea added 1 commit 2025-12-19 08:39:42 +01:00
wip
Some checks failed
CI for csaxs_bec / test (push) Failing after 1m1s
CI for csaxs_bec / test (pull_request) Failing after 1m10s
10fa6d032d
appel_c added 1 commit 2025-12-19 14:17:39 +01:00
docs(mcs-card-csaxs): Add documentation to MCS card implementation
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 1m1s
CI for csaxs_bec / test (push) Failing after 1m11s
4b47846d56
appel_c added 3 commits 2026-01-05 13:42:47 +01:00
docs: DelayGenerator DDG2 docs
Some checks failed
CI for csaxs_bec / test (push) Failing after 1m2s
CI for csaxs_bec / test (pull_request) Failing after 1m2s
be5c0d870b
appel_c force-pushed refactor/mcs_card_refactoring from be5c0d870b to 077359d63e 2026-01-05 13:47:31 +01:00 Compare
appel_c force-pushed refactor/mcs_card_refactoring from 077359d63e to e7f18db24a 2026-01-05 13:48:54 +01:00 Compare
appel_c self-assigned this 2026-01-05 13:49:03 +01:00
appel_c added 1 commit 2026-01-06 09:29:26 +01:00
tests: fix tests for ddg and mcs integrations
All checks were successful
CI for csaxs_bec / test (push) Successful in 1m45s
CI for csaxs_bec / test (pull_request) Successful in 1m44s
e046412eb8
appel_c requested review from holler 2026-01-06 10:35:48 +01:00
appel_c requested review from perl_d 2026-01-06 10:35:48 +01:00
appel_c requested review from wakonig_k 2026-01-06 10:35:48 +01:00
appel_c requested review from wyzula_j 2026-01-06 10:35:49 +01:00
appel_c requested review from menzel 2026-01-06 10:35:54 +01:00
appel_c requested review from diaz 2026-01-06 10:36:00 +01:00
appel_c force-pushed refactor/mcs_card_refactoring from e046412eb8 to 47ff1c6699 2026-01-07 11:58:54 +01:00 Compare
appel_c added 1 commit 2026-01-15 08:36:56 +01:00
w
All checks were successful
CI for csaxs_bec / test (push) Successful in 1m31s
CI for csaxs_bec / test (pull_request) Successful in 1m34s
5e0d3277d1
appel_c added 1 commit 2026-01-15 10:03:38 +01:00
w
All checks were successful
CI for csaxs_bec / test (push) Successful in 1m26s
CI for csaxs_bec / test (pull_request) Successful in 1m29s
49a4700cb0
appel_c added 1 commit 2026-01-15 10:13:00 +01:00
w
All checks were successful
CI for csaxs_bec / test (pull_request) Successful in 1m26s
CI for csaxs_bec / test (push) Successful in 1m29s
01e7fc03ef
appel_c added 1 commit 2026-01-15 10:30:33 +01:00
w
All checks were successful
CI for csaxs_bec / test (push) Successful in 1m25s
CI for csaxs_bec / test (pull_request) Successful in 1m32s
51fc140150
appel_c added 1 commit 2026-01-15 10:34:46 +01:00
w
All checks were successful
CI for csaxs_bec / test (pull_request) Successful in 1m27s
CI for csaxs_bec / test (push) Successful in 1m30s
a7367cb561
appel_c added 1 commit 2026-01-15 10:37:36 +01:00
w
All checks were successful
CI for csaxs_bec / test (pull_request) Successful in 1m28s
CI for csaxs_bec / test (push) Successful in 1m30s
4a1346d618
bec_bl_push-gitea added 1 commit 2026-01-22 15:31:12 +01:00
wip fix mcs card from csaxs
Some checks failed
CI for csaxs_bec / test (push) Failing after 39s
CI for csaxs_bec / test (pull_request) Failing after 1m26s
876dfd542b
appel_c added 1 commit 2026-01-22 20:21:47 +01:00
remove logger wip
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 1m25s
CI for csaxs_bec / test (push) Failing after 1m28s
c8c440c259
appel_c added 1 commit 2026-01-22 22:33:03 +01:00
wip add debug tools initial commit
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 1m24s
CI for csaxs_bec / test (push) Failing after 1m29s
b7ee2e2f91
appel_c added 1 commit 2026-01-23 08:40:46 +01:00
wip
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 1m24s
CI for csaxs_bec / test (push) Failing after 1m30s
b642c0ef35
appel_c added 1 commit 2026-01-23 08:45:38 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 1m23s
CI for csaxs_bec / test (push) Failing after 1m30s
fcb6b5635e
appel_c added 1 commit 2026-01-23 08:50:33 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 1m25s
CI for csaxs_bec / test (push) Failing after 1m28s
ed3440f68d
appel_c added 2 commits 2026-01-23 09:53:21 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 1m23s
CI for csaxs_bec / test (push) Failing after 1m37s
f11c06b184
bec_bl_push-gitea added 1 commit 2026-01-23 10:33:43 +01:00
fix debug tools beamline, adjust port for eigers
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 1m24s
CI for csaxs_bec / test (push) Failing after 1m26s
092f791feb
appel_c added 1 commit 2026-01-23 13:09:15 +01:00
wip debugging
Some checks failed
CI for csaxs_bec / test (push) Failing after 1m30s
CI for csaxs_bec / test (pull_request) Failing after 1m28s
8452f4bc76
appel_c added 1 commit 2026-01-23 13:11:40 +01:00
w
Some checks failed
CI for csaxs_bec / test (push) Failing after 1m28s
CI for csaxs_bec / test (pull_request) Failing after 1m27s
a4b89bbd7d
appel_c added 1 commit 2026-01-23 13:16:03 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Failing after 1m22s
CI for csaxs_bec / test (push) Failing after 1m25s
b9a9b5302f
appel_c force-pushed refactor/mcs_card_refactoring from b9a9b5302f to b5369682de 2026-01-23 13:21:18 +01:00 Compare
appel_c force-pushed refactor/mcs_card_refactoring from b5369682de to 351e7a0e3d 2026-01-23 13:29:45 +01:00 Compare
wakonig_k reviewed 2026-01-23 14:22:07 +01:00
wakonig_k left a comment
Owner

looks good! - Only some minor comments.

looks good! - Only some minor comments.
@@ -0,0 +28,4 @@
bec: BECClient # type: ignore[no-redef]
gui: BECGuiClient # type: ignore[no-redef]
Owner

as discussed offline, gui is not a builtin. It is better to access it through bec.gui

as discussed offline, gui is not a builtin. It is better to access it through bec.gui
appel_c marked this conversation as resolved
@@ -0,0 +49,4 @@
name = re.sub(r"[^a-zA-Z0-9_]", "", name)
if not name:
return "_"
Owner

I guess if there is no valid name, it should raise, no?

I guess if there is no valid name, it should raise, no?
appel_c marked this conversation as resolved
@@ -0,0 +60,4 @@
class DebugTools:
"""A collection of debugging tools for the BEC IPython client at cSAXS."""
_PURPOSE = " ".join(
Owner

I don't understand why this is a joined list of strings. Why not just a single string?

I don't understand why this is a joined list of strings. Why not just a single string?
appel_c marked this conversation as resolved
@@ -0,0 +113,4 @@
if "mcs" not in dev:
raise RuntimeError("MCS device is not loaded in the current active BEC session.")
def _check_if_ddg_is_loaded(self):
Owner

probably worth merging these methods into a single one. Something along the lines of

def device_is_loaded(device_name: str):
    if device_name not in dev:
        raise RuntimeError(f"Device {device_name} was not found in the currently active BEC session") 

Also, I would suggest to print the exact name in the error message of the device, not capitalized. Otherwise one might be tempted to add a device "MCS" rather than "mcs"

probably worth merging these methods into a single one. Something along the lines of ```python def device_is_loaded(device_name: str): if device_name not in dev: raise RuntimeError(f"Device {device_name} was not found in the currently active BEC session") ``` Also, I would suggest to print the exact name in the error message of the device, not capitalized. Otherwise one might be tempted to add a device "MCS" rather than "mcs"
appel_c marked this conversation as resolved
@@ -0,0 +137,4 @@
self._check_if_ddg_is_loaded()
if mode == "high_frame":
burst_frames = np.random.randint(10000, 100000) # between 10000 and 100000
Owner

just a minor hint: you can set separators for large numbers, e.g. 10_000 instead of 10000. Could make it easier to read. See https://peps.python.org/pep-0515/

just a minor hint: you can set separators for large numbers, e.g. 10_000 instead of 10000. Could make it easier to read. See https://peps.python.org/pep-0515/
appel_c marked this conversation as resolved
@@ -0,0 +246,4 @@
return False
def open_it_service_page(self):
"""Open the overview of IT services hosted by Science IT (Leo Sala) for cSAXS."""
Owner

let's remove the personal name

let's remove the personal name
appel_c marked this conversation as resolved
@@ -210,3 +278,1 @@
if mapped_signal_name == "count_time":
value = value / self._mcs_clock
value = float(value.mean())
value = value.tolist() # Convert numpy array to list
Owner

I guess it can only be numpy, single value or list? Maybe put it as type hint to the signature

I guess it can only be numpy, single value or list? Maybe put it as type hint to the signature
appel_c marked this conversation as resolved
appel_c force-pushed refactor/mcs_card_refactoring from 351e7a0e3d to 11c887b078 2026-01-23 15:01:39 +01:00 Compare
appel_c added 1 commit 2026-01-23 15:16:21 +01:00
cleanup
All checks were successful
CI for csaxs_bec / test (pull_request) Successful in 1m27s
CI for csaxs_bec / test (push) Successful in 1m33s
b48b27114d
appel_c added 1 commit 2026-01-23 15:26:38 +01:00
w
Some checks failed
CI for csaxs_bec / test (pull_request) Successful in 1m30s
CI for csaxs_bec / test (push) Has been cancelled
6647140d43
appel_c merged commit 6647140d43 into main 2026-01-26 07:44:43 +01:00
Sign in to join this conversation.
No Label
3 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: bec/csaxs_bec#114