-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
282-standardise-handling-of-read-config-and-hinted-signals-for-standa…
- Loading branch information
1 parent
158f4ef
commit a794b1b
Showing
8 changed files
with
378 additions
and
121 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,63 @@ | ||
from typing import Sequence | ||
from xml.etree import cElementTree as ET | ||
|
||
import bluesky.plan_stubs as bps | ||
|
||
from ophyd_async.core._device import Device | ||
from ophyd_async.epics.adcore._core_io import NDArrayBaseIO | ||
from ophyd_async.epics.adcore._utils import ( | ||
NDAttributeDataType, | ||
NDAttributeParam, | ||
NDAttributePv, | ||
) | ||
|
||
|
||
def setup_ndattributes( | ||
device: NDArrayBaseIO, ndattributes: Sequence[NDAttributePv | NDAttributeParam] | ||
): | ||
xml_text = ET.Element("Attributes") | ||
|
||
for ndattribute in ndattributes: | ||
if isinstance(ndattribute, NDAttributeParam): | ||
ET.SubElement( | ||
xml_text, | ||
"Attribute", | ||
name=ndattribute.name, | ||
type="PARAM", | ||
source=ndattribute.param, | ||
addr=str(ndattribute.addr), | ||
datatype=ndattribute.datatype.value, | ||
description=ndattribute.description, | ||
) | ||
elif isinstance(ndattribute, NDAttributePv): | ||
ET.SubElement( | ||
xml_text, | ||
"Attribute", | ||
name=ndattribute.name, | ||
type="EPICS_PV", | ||
source=ndattribute.signal.source.split("ca://")[-1], | ||
dbrtype=ndattribute.dbrtype.value, | ||
description=ndattribute.description, | ||
) | ||
else: | ||
raise ValueError( | ||
f"Invalid type for ndattributes: {type(ndattribute)}. " | ||
"Expected NDAttributePv or NDAttributeParam." | ||
) | ||
yield from bps.mv(device.nd_attributes_file, xml_text) | ||
|
||
|
||
def setup_ndstats_sum(detector: Device): | ||
yield from ( | ||
setup_ndattributes( | ||
detector.hdf, | ||
[ | ||
NDAttributeParam( | ||
name=f"{detector.name}-sum", | ||
param="NDPluginStatsTotal", | ||
datatype=NDAttributeDataType.DOUBLE, | ||
description="Sum of the array", | ||
) | ||
], | ||
) | ||
) |
Oops, something went wrong.