Skip to content
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

Pvi entries for hdf writing #31

Merged
merged 10 commits into from
Sep 4, 2023
60 changes: 52 additions & 8 deletions src/pandablocks_ioc/_hdf_ioc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
from softioc import alarm, builder
from softioc.pythonSoftIoc import RecordWrapper

from ._types import ONAM_STR, ZNAM_STR
from ._pvi import PviGroup, add_pvi_info
from ._types import ONAM_STR, ZNAM_STR, EpicsName


class HDF5RecordController:
Expand Down Expand Up @@ -52,51 +53,76 @@ def __init__(self, client: AsyncioClient, record_prefix: str):

# Create the records, including an uppercase alias for each
# Naming convention and settings (mostly) copied from FSCN2 HDF5 records
file_path_record_name = self._HDF5_PREFIX + ":FilePath"
file_path_record_name = EpicsName(self._HDF5_PREFIX + ":FilePath")
self._file_path_record = builder.longStringOut(
file_path_record_name,
length=path_length,
DESC="File path for HDF5 files",
validate=self._parameter_validate,
)
add_pvi_info(
PviGroup.INPUTS,
self._file_path_record,
file_path_record_name,
builder.longStringOut,
)
self._file_path_record.add_alias(
record_prefix + ":" + file_path_record_name.upper()
)

file_name_record_name = self._HDF5_PREFIX + ":FileName"
file_name_record_name = EpicsName(self._HDF5_PREFIX + ":FileName")
self._file_name_record = builder.longStringOut(
file_name_record_name,
length=filename_length,
DESC="File name prefix for HDF5 files",
validate=self._parameter_validate,
)
add_pvi_info(
PviGroup.INPUTS,
self._file_name_record,
file_name_record_name,
builder.longStringOut,
)
self._file_name_record.add_alias(
record_prefix + ":" + file_name_record_name.upper()
)

num_capture_record_name = self._HDF5_PREFIX + ":NumCapture"
num_capture_record_name = EpicsName(self._HDF5_PREFIX + ":NumCapture")
self._num_capture_record = builder.longOut(
num_capture_record_name,
initial_value=0, # Infinite capture
DESC="Number of frames to capture. 0=infinite",
DRVL=0,
)

add_pvi_info(
PviGroup.INPUTS,
self._num_capture_record,
num_capture_record_name,
builder.longOut,
)
# No validate - users are allowed to change this at any time
self._num_capture_record.add_alias(
record_prefix + ":" + num_capture_record_name.upper()
)

flush_period_record_name = self._HDF5_PREFIX + ":FlushPeriod"
flush_period_record_name = EpicsName(self._HDF5_PREFIX + ":FlushPeriod")
self._flush_period_record = builder.aOut(
flush_period_record_name,
initial_value=1.0,
DESC="Frequency that data is flushed (seconds)",
)
add_pvi_info(
PviGroup.INPUTS,
self._flush_period_record,
flush_period_record_name,
builder.aOut,
)
self._flush_period_record.add_alias(
record_prefix + ":" + flush_period_record_name.upper()
)

capture_control_record_name = self._HDF5_PREFIX + ":Capture"
capture_control_record_name = EpicsName(self._HDF5_PREFIX + ":Capture")
self._capture_control_record = builder.boolOut(
capture_control_record_name,
ZNAM=ZNAM_STR,
Expand All @@ -105,27 +131,45 @@ def __init__(self, client: AsyncioClient, record_prefix: str):
validate=self._capture_validate,
DESC="Start/stop HDF5 capture",
)
add_pvi_info(
PviGroup.INPUTS,
self._capture_control_record,
capture_control_record_name,
builder.boolOut,
)
self._capture_control_record.add_alias(
record_prefix + ":" + capture_control_record_name.upper()
)

status_message_record_name = self._HDF5_PREFIX + ":Status"
status_message_record_name = EpicsName(self._HDF5_PREFIX + ":Status")
self._status_message_record = builder.stringIn(
status_message_record_name,
initial_value="OK",
DESC="Reports current status of HDF5 capture",
)
add_pvi_info(
PviGroup.OUTPUTS,
self._status_message_record,
status_message_record_name,
builder.stringIn,
)
self._status_message_record.add_alias(
record_prefix + ":" + status_message_record_name.upper()
)

currently_capturing_record_name = self._HDF5_PREFIX + ":Capturing"
currently_capturing_record_name = EpicsName(self._HDF5_PREFIX + ":Capturing")
self._currently_capturing_record = builder.boolIn(
currently_capturing_record_name,
ZNAM=ZNAM_STR,
ONAM=ONAM_STR,
DESC="If HDF5 file is currently being written",
)
add_pvi_info(
PviGroup.OUTPUTS,
self._currently_capturing_record,
currently_capturing_record_name,
builder.boolIn,
)
self._currently_capturing_record.add_alias(
record_prefix + ":" + currently_capturing_record_name.upper()
)
Expand Down
1 change: 0 additions & 1 deletion src/pandablocks_ioc/_pvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def add_pvi_info(
access = "rw"

else:
# TODO: What value do I write? PandA uses an empty string
component = SignalX(record_name, record_name, value="")
access = "x"
elif writeable:
Expand Down
171 changes: 171 additions & 0 deletions tests/test-bobfiles/HDF5.bob
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<display version="2.0.0">
<name>Display</name>
<x>0</x>
<y>0</y>
<width>426</width>
<height>277</height>
<grid_step_x>4</grid_step_x>
<grid_step_y>4</grid_step_y>
<widget type="label" version="2.0.0">
<name>Title</name>
<class>TITLE</class>
<text>HDF5 - TEST-PREFIX:</text>
<x use_class="true">0</x>
<y use_class="true">0</y>
<width>426</width>
<height>25</height>
<font use_class="true">
<font name="Header 1" family="Liberation Sans" style="BOLD" size="22.0">
</font>
</font>
<foreground_color use_class="true">
<color name="Text" red="0" green="0" blue="0">
</color>
</foreground_color>
<transparent use_class="true">true</transparent>
<horizontal_alignment>1</horizontal_alignment>
</widget>
<widget type="group" version="2.0.0">
<name>INPUTS</name>
<x>5</x>
<y>30</y>
<width>351</width>
<height>156</height>
<transparent>true</transparent>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>HDF5: File Path</text>
<x>0</x>
<y>0</y>
<width>250</width>
<height>20</height>
</widget>
<widget type="textentry" version="3.0.0">
<name>TextEntry</name>
<pv_name>TEST-PREFIX:HDF5:FilePath</pv_name>
<x>255</x>
<y>0</y>
<width>60</width>
<height>20</height>
<horizontal_alignment>1</horizontal_alignment>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>HDF5: File Name</text>
<x>0</x>
<y>25</y>
<width>250</width>
<height>20</height>
</widget>
<widget type="textentry" version="3.0.0">
<name>TextEntry</name>
<pv_name>TEST-PREFIX:HDF5:FileName</pv_name>
<x>255</x>
<y>25</y>
<width>60</width>
<height>20</height>
<horizontal_alignment>1</horizontal_alignment>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>HDF5: Num Capture</text>
<x>0</x>
<y>50</y>
<width>250</width>
<height>20</height>
</widget>
<widget type="textentry" version="3.0.0">
<name>TextEntry</name>
<pv_name>TEST-PREFIX:HDF5:NumCapture</pv_name>
<x>255</x>
<y>50</y>
<width>60</width>
<height>20</height>
<horizontal_alignment>1</horizontal_alignment>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>HDF5: Flush Period</text>
<x>0</x>
<y>75</y>
<width>250</width>
<height>20</height>
</widget>
<widget type="textentry" version="3.0.0">
<name>TextEntry</name>
<pv_name>TEST-PREFIX:HDF5:FlushPeriod</pv_name>
<x>255</x>
<y>75</y>
<width>60</width>
<height>20</height>
<horizontal_alignment>1</horizontal_alignment>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>HDF5: Capture</text>
<x>0</x>
<y>100</y>
<width>250</width>
<height>20</height>
</widget>
<widget type="textentry" version="3.0.0">
<name>TextEntry</name>
<pv_name>TEST-PREFIX:HDF5:Capture</pv_name>
<x>255</x>
<y>100</y>
<width>60</width>
<height>20</height>
<horizontal_alignment>1</horizontal_alignment>
</widget>
</widget>
<widget type="group" version="2.0.0">
<name>OUTPUTS</name>
<x>5</x>
<y>191</y>
<width>416</width>
<height>81</height>
<transparent>true</transparent>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>HDF5: Status</text>
<x>0</x>
<y>0</y>
<width>250</width>
<height>20</height>
</widget>
<widget type="textupdate" version="2.0.0">
<name>TextUpdate</name>
<pv_name>TEST-PREFIX:HDF5:Status</pv_name>
<x>255</x>
<y>0</y>
<width>125</width>
<height>20</height>
<font>
<font name="Default Bold" family="Liberation Sans" style="BOLD" size="14.0">
</font>
</font>
<horizontal_alignment>1</horizontal_alignment>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>HDF5: Capturing</text>
<x>0</x>
<y>25</y>
<width>250</width>
<height>20</height>
</widget>
<widget type="textupdate" version="2.0.0">
<name>TextUpdate</name>
<pv_name>TEST-PREFIX:HDF5:Capturing</pv_name>
<x>255</x>
<y>25</y>
<width>125</width>
<height>20</height>
<font>
<font name="Default Bold" family="Liberation Sans" style="BOLD" size="14.0">
</font>
</font>
<horizontal_alignment>1</horizontal_alignment>
</widget>
</widget>
</display>
14 changes: 11 additions & 3 deletions tests/test-bobfiles/TOP.bob
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<x>0</x>
<y>0</y>
<width>278</width>
<height>105</height>
<height>130</height>
<grid_step_x>4</grid_step_x>
<grid_step_y>4</grid_step_y>
<widget type="label" version="2.0.0">
Expand Down Expand Up @@ -35,18 +35,26 @@
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>SEQ: PVI</text>
<text>HDF5: PVI</text>
<x>23</x>
<y>55</y>
<width>250</width>
<height>20</height>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>PULSE: PVI</text>
<text>SEQ: PVI</text>
<x>23</x>
<y>80</y>
<width>250</width>
<height>20</height>
</widget>
<widget type="label" version="2.0.0">
<name>Label</name>
<text>PULSE: PVI</text>
<x>23</x>
<y>105</y>
<width>250</width>
<height>20</height>
</widget>
</display>
Loading