Skip to content

Commit

Permalink
Change write_dir and file_name PV types to CHAR and fix the relev…
Browse files Browse the repository at this point in the history
…ant test
  • Loading branch information
mrakitin committed Feb 22, 2024
1 parent ab77f7f commit def5ded
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/srx_caproto_iocs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ class CaprotoSaveIOC(PVGroup):
value="/tmp",
doc="The directory to write data to. It support datetime formatting, e.g. '/tmp/det/%Y/%m/%d/'",
string_encoding="utf-8",
report_as_string=True,
dtype=ChannelType.CHAR,
max_length=255,
)
file_name = pvproperty(
value="test.h5",
doc="The file name of the file to write to. It support <str>.format() based formatting, e.g. 'scan_{num:06d}.h5'",
string_encoding="utf-8",
report_as_string=True,
dtype=ChannelType.CHAR,
max_length=255,
)
full_file_path = pvproperty(
Expand Down
7 changes: 6 additions & 1 deletion tests/test_base_ophyd.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ def test_base_ophyd_templates(
date = now(as_object=True)
write_dir_root = Path(tmpdirname)
dir_template = f"{write_dir_root}/{date_template}"
write_dir = Path(date.strftime(dir_template))

# We pre-create the test directory in advance as the IOC is not supposed to create one.
# The assumption for the IOC is that the directory will exist before saving a file to that.
# We need to replace the blank spaces below for it to work, as the IOC will replace
# any blank spaces in `full_file_path` before returning the value.
write_dir = Path(date.strftime(dir_template).replace(" ", "_"))
write_dir.mkdir(parents=True, exist_ok=True)

file_template = "scan_{num:06d}_{uid}.hdf5"
Expand Down

0 comments on commit def5ded

Please sign in to comment.