|
3 | 3 |
|
4 | 4 | from ophyd_async.core import ( |
5 | 5 | DatasetDescriber, |
| 6 | + DeviceVector, |
6 | 7 | EnableDisable, |
7 | 8 | SignalR, |
8 | 9 | SignalRW, |
@@ -88,6 +89,56 @@ class NDPluginStatsIO(NDPluginBaseIO): |
88 | 89 | hist_max: A[SignalRW[float], PvSuffix.rbv("HistMax")] |
89 | 90 |
|
90 | 91 |
|
| 92 | +class NDROIStatIO(NDPluginBaseIO): |
| 93 | + """Plugin for calculating basic statistics for multiple ROIs. |
| 94 | +
|
| 95 | + Each ROI is implemented as an instance of NDROIStatNIO, |
| 96 | + and the collection of ROIs is held as a DeviceVector. |
| 97 | +
|
| 98 | + See HTML docs at https://areadetector.github.io/areaDetector/ADCore/NDPluginROIStat.html |
| 99 | + """ |
| 100 | + |
| 101 | + def __init__(self, prefix, num_channels=8, with_pvi=False, name=""): |
| 102 | + self.channels = DeviceVector( |
| 103 | + {i: NDROIStatNIO(f"{prefix}{i}:") for i in range(1, num_channels + 1)} |
| 104 | + ) |
| 105 | + super().__init__(prefix, with_pvi, name) |
| 106 | + |
| 107 | + |
| 108 | +class NDROIStatNIO(EpicsDevice): |
| 109 | + """Defines the parameters for a single ROI used for statistics calculation. |
| 110 | +
|
| 111 | + Each instance represents a single ROI, with attributes for its position |
| 112 | + (min_x, min_y) and size (size_x, size_y), as well as a name and use status. |
| 113 | +
|
| 114 | + See definition in ADApp/pluginSrc/NDPluginROIStat.h in https://github.com/areaDetector/ADCore. |
| 115 | +
|
| 116 | + Attributes: |
| 117 | + name: The name of the ROI. |
| 118 | + use: Flag indicating whether the ROI is used. |
| 119 | + min_x: The start X-coordinate of the ROI. |
| 120 | + min_y: The start Y-coordinate of the ROI. |
| 121 | + size_x: The width of the ROI. |
| 122 | + size_y: The height of the ROI. |
| 123 | + min_value: Minimum count value in the ROI. |
| 124 | + max_value: Maximum count value in the ROI. |
| 125 | + mean_value: Mean counts value in the ROI. |
| 126 | + total: Total counts in the ROI. |
| 127 | + """ |
| 128 | + |
| 129 | + name_: A[SignalRW[str], PvSuffix("Name")] |
| 130 | + use: A[SignalRW[bool], PvSuffix.rbv("Use")] |
| 131 | + min_x: A[SignalRW[int], PvSuffix.rbv("MinX")] |
| 132 | + min_y: A[SignalRW[int], PvSuffix.rbv("MinY")] |
| 133 | + size_x: A[SignalRW[int], PvSuffix.rbv("SizeX")] |
| 134 | + size_y: A[SignalRW[int], PvSuffix.rbv("SizeY")] |
| 135 | + # stats |
| 136 | + min_value: A[SignalR[float], PvSuffix("MinValue_RBV")] |
| 137 | + max_value: A[SignalR[float], PvSuffix("MaxValue_RBV")] |
| 138 | + mean_value: A[SignalR[float], PvSuffix("MeanValue_RBV")] |
| 139 | + total: A[SignalR[float], PvSuffix("Total_RBV")] |
| 140 | + |
| 141 | + |
91 | 142 | class ADState(StrictEnum): |
92 | 143 | """Default set of states of an AreaDetector driver. |
93 | 144 |
|
|
0 commit comments