def test_constant_variable_ca(ca_server): # COMMENTING OUT BELOW LEADS TO FAILED TEST, HANGING, AND ERROR MESSAGES: # CAC TCP socket linger set error was Invalid argument # CAC TCP socket shutdown error was Socket is not connected os.environ["PYEPICS_LIBCA"] = get_lib('ca') val = epics.caget("test:pv1", timeout=5.0) assert val == 1.0
def test_constant_variable_ca(value, prefix, server, model): os.environ["PYEPICS_LIBCA"] = get_lib('ca') # check constant variable assignment for _, variable in model.input_variables.items(): pvname = f"{prefix}:{variable.name}" if variable.variable_type == "scalar": epics.caput(pvname, value, timeout=1) for _, variable in model.input_variables.items(): if variable.variable_type == "scalar": pvname = f"{prefix}:{variable.name}" val = epics.caget(pvname, timeout=1) if variable.is_constant: assert val != value else: assert val == value
def _libca_path(load_libca_path): # We look for libca in a variety of different places, searched in order: # # 1. Firstly if CATOOLS_LIBCA_PATH is set in the environment we take that as # gospel. This allows the remaining search to be overridden. # 2. If epicscorelibs is installed, allow it to provide libca. # 3. If the libca_path module is present we accept the value it defines. # 4. Finally check for EPICS_BASE and compute appropriate architecture. # First allow a forced override libca_path = os.environ.get('CATOOLS_LIBCA_PATH') if libca_path: return libca_path # If epicscorelibs is installed, use the bundled libca. try: from epicscorelibs.path import get_lib return get_lib('ca') except ImportError: pass # Next import from configuration file if present, unless this has been # disabled. if load_libca_path: try: # If libca_path has been defined go with that from .libca_path import libca_path return libca_path except ImportError: pass # If no libca_path, how about local copies of the files? libca_path = os.path.abspath(os.path.dirname(__file__)) if os.path.isfile(os.path.join(libca_path, lib_files[-1])): # Yes, there seems to be something locally installed. return libca_path # No local install, no local configuration, no override. Try for standard # environment variable configuration instead. epics_base = os.environ['EPICS_BASE'] return os.path.join(epics_base, 'lib', epics_host_arch)
# Event type notification codes for camonitor 'DBE_VALUE', # Notify normal value changes 'DBE_LOG', # Notify archival value changes 'DBE_ALARM', # Notify alarm state changes 'DBE_PROPERTY', # Notify property change events (3.14.11 and later) ] import ctypes from epicscorelibs import path from . import py23 if path.OS_CLASS == "WIN32": # On windows, use stdcall calling convention for libca libca = ctypes.WinDLL(path.get_lib("ca"), ctypes.RTLD_GLOBAL) else: libca = ctypes.CDLL(path.get_lib("ca"), ctypes.RTLD_GLOBAL) # ----------------------------------------------------------------------------- # Enumeration and error code definitions. # Flags used to identify notification events to request for subscription. DBE_VALUE = 1 DBE_LOG = 2 DBE_ALARM = 4 DBE_PROPERTY = 8 # Connection state as passed to connection handler CA_OP_CONN_UP = 6 CA_OP_CONN_DOWN = 7
import os, epics from epicscorelibs.path import get_lib # Works regardless of whether the below line is commented out os.environ["PYEPICS_LIBCA"] = get_lib('ca') val = epics.caget("test:pv1", timeout=5.0) if val: print(f"Successful, test:pv1 is {val}") print(epics.ca.find_libca())
"EPICS_PVAS_BEACON_PERIOD": "15", "EPICS_PVAS_BROADCAST_PORT": "60858", "EPICS_PVAS_INTF_ADDR_LIST": "127.0.0.1:0", "EPICS_PVAS_MAX_ARRAY_BYTES": "16384", "EPICS_PVAS_PROVIDER_NAMES": "3a7aff4f-8fd4-4f9f-b696-bd9f5f6f13ed", "EPICS_PVAS_SERVER_PORT": "61192", "EPICS_PVA_ADDR_LIST": "127.0.0.1", "EPICS_PVA_AUTO_ADDR_LIST": "NO", "EPICS_PVA_BEACON_PERIOD": "15", "EPICS_PVA_BROADCAST_PORT": "60858", "EPICS_PVA_MAX_ARRAY_BYTES": "16384", "EPICS_PVA_SERVER_PORT": "61192", } os.environ.update(PVA_CONFIG) os.environ["PYEPICS_LIBCA"] = get_lib("ca") @pytest.fixture(scope="session", autouse=True) def rootdir(): package_path = abspath(dirname(dirname(dirname(__file__)))) return package_path def clear_loggers(): """ Remove handlers from all loggers """ import logging loggers = [logging.getLogger()] + list(