From 49e95dab664271f4993a3cfe7bac207a7c4680ac Mon Sep 17 00:00:00 2001 From: Zachary Lentz Date: Thu, 14 Nov 2024 15:33:10 -0800 Subject: [PATCH] FIX: slight discrepencies in epics string parsing --- beams/bin/gen_test_ioc_main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/beams/bin/gen_test_ioc_main.py b/beams/bin/gen_test_ioc_main.py index 0c9460e..c7104b3 100644 --- a/beams/bin/gen_test_ioc_main.py +++ b/beams/bin/gen_test_ioc_main.py @@ -23,6 +23,9 @@ class PVInfoForJ2: @classmethod def from_result(cls: type[PVInfoForJ2], pvname: str, response: ReadNotifyResponse) -> PVInfoForJ2: + value = response.data if response.data_count > 1 else response.data[0] + if isinstance(value, bytes): + value = value.decode("utf-8") try: enum_strings = response.metadata.enum_strings except AttributeError: @@ -34,8 +37,8 @@ def from_result(cls: type[PVInfoForJ2], pvname: str, response: ReadNotifyRespons return cls( python_name=pvname.lower().replace(":", "_").replace(".", "_"), pvname=pvname, - value=response.data if response.data_count > 1 else response.data[0], - dtype=response.data_type.name.removeprefix("CTRL_"), + value=value, + dtype=response.data_type.name.removeprefix("CTRL_").removeprefix("TIME_"), enum_strings=[bt.decode("utf8") for bt in enum_strings], precision=precision, )