Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions util/channel_access.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import binascii
import json
import zlib
from builtins import object
from enum import Enum

from genie_python.channel_access_exceptions import ReadAccessException, UnableToConnectToPVException
from genie_python.genie import PVValue
from genie_python.genie_cachannel_wrapper import CaChannelWrapper
from ibex_non_ca_helpers.typing import PVValue

# Some instruments may not be available. If this is the case, we don't want to wait too long
# for the response which will never come (which would slow down the tests)
Expand All @@ -24,25 +23,22 @@ class PvInterestingLevel(Enum):
FACILITY = "FACILITY"


class ChannelAccessUtils(object):
class ChannelAccessUtils:
"""
Class containing utility methods for interacting with a PV
"""

def __init__(self, pv_prefix: str = "") -> None:
self.pv_prefix = pv_prefix

def get_value(self, pv: str, timeout: float = None) -> PVValue:
def get_value(self, pv: str, timeout: float | None = None) -> PVValue:
"""
Gets the value of the PV. Returns None if PV is unavailable.
:return: The PV value as a string, or None if there was an error
"""
try:
return CaChannelWrapper.get_pv_value(
"{}{}".format(
self.pv_prefix,
pv,
),
f"{self.pv_prefix}{pv}",
timeout=timeout or CHANNEL_ACCESS_TIMEOUT,
)
except (UnableToConnectToPVException, ReadAccessException):
Expand Down
Loading