capva 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
capva-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lin Wang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
capva-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,214 @@
1
+ Metadata-Version: 2.4
2
+ Name: capva
3
+ Version: 0.1.0
4
+ Summary: EPICS PV client supporting both Channel Access and PV Access
5
+ Author: Lin Wang
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/wanglin86769/capva
8
+ Keywords: epics
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: Scientific/Engineering
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: pyepics>=3.5.10
22
+ Requires-Dist: p4p>=4.2.2
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=7.0; extra == "dev"
25
+ Dynamic: license-file
26
+
27
+ # capva
28
+
29
+ Unified Python client for EPICS PVs over **Channel Access (CA)** and **PV Access (PVA)**.
30
+
31
+ capva wraps [pyepics](https://github.com/pyepics/pyepics) and [p4p](https://github.com/epics-base/p4p) behind one API. Reads and monitors return a structured **`PVData`** model; JSON/Web payloads are built with **`PVData.to_dict()`** (optional base64 array encoding).
32
+
33
+ **Developed from the [weiss](https://github.com/weiss-controls/weiss) project** — capva builds on that codebase and refactors the PV client layer into a standalone Python library with a unified CA/PVA API and structured `PVData`.
34
+
35
+ ```mermaid
36
+ flowchart TB
37
+ subgraph capva["capva — standalone PV client library"]
38
+ api["PV, PVPool, tools"]
39
+ prov["CA_PV, PVA_PV"]
40
+ data["pv_parser, PVData"]
41
+ end
42
+
43
+ subgraph drivers["protocol drivers"]
44
+ direction LR
45
+ pyepics["pyepics (CA)"]
46
+ p4p["p4p (PVA)"]
47
+ end
48
+
49
+ epics["EPICS IOC"]
50
+
51
+ prov --> pyepics
52
+ prov --> p4p
53
+ pyepics --> epics
54
+ p4p --> epics
55
+ ```
56
+
57
+ ## Features
58
+
59
+ - **Single API for CA and PVA** — One client for Channel Access and PV Access; capva picks the backend from the PV name so application code does not split into separate CA/PVA paths.
60
+ - **Unified `PVData` model** — Every read and monitor callback returns the same structured snapshot (value, alarm, timeStamp, display, control, …), regardless of protocol.
61
+ - **Public interfaces: `PV`, `PVPool`, and procedural tools** — Use the object API for multi-step work on one connection, `PVPool` when several callers share a PV, or one-shot `pvget` / `pvput` / `pvinfo` / `pvmonitor` when a script only needs a single operation.
62
+ - **Reference-counted `PVPool`** — `getPV` / `releasePV` reuse one connection per PV name; the channel closes when the last reference is released.
63
+ - **Protocol prefixes** — `ca://…` for Channel Access, `pva://…` for PV Access, or no prefix to default to CA.
64
+
65
+ ## Requirements
66
+
67
+ - Python ≥ 3.10
68
+
69
+ ## Installation
70
+
71
+ From [PyPI](https://pypi.org/project/capva/):
72
+
73
+ ```bash
74
+ pip install capva
75
+ ```
76
+
77
+ From a checkout (development):
78
+
79
+ ```bash
80
+ pip install -e .
81
+ ```
82
+
83
+ ## Quick start
84
+
85
+ Examples use `pva://calcExample`; switch to `ca://…` or a bare name (CA default) as needed.
86
+
87
+ ### Procedural API
88
+
89
+ ```python
90
+ import time
91
+
92
+ from capva import PVData, pvget, pvmonitor
93
+
94
+ PV_NAME = "pva://calcExample"
95
+
96
+ data = pvget(PV_NAME)
97
+ print(data.value)
98
+
99
+ def on_update(data: PVData) -> None:
100
+ if data.is_disconnected():
101
+ print(f"{data.pvName} disconnected")
102
+ else:
103
+ print(data.value)
104
+
105
+ session = pvmonitor(PV_NAME, on_update)
106
+ try:
107
+ time.sleep(30)
108
+ finally:
109
+ session.close()
110
+ ```
111
+
112
+ ### Object API
113
+
114
+ ```python
115
+ import time
116
+
117
+ from capva import PV, PVData
118
+
119
+ PV_NAME = "pva://calcExample"
120
+
121
+ pv = PV(PV_NAME)
122
+ handle = None
123
+ try:
124
+ data = pv.get()
125
+ print(data.value)
126
+
127
+ def on_update(data: PVData) -> None:
128
+ if data.is_disconnected():
129
+ print(f"{data.pvName} disconnected")
130
+ else:
131
+ print(data.value)
132
+
133
+ handle = pv.monitor(on_update)
134
+ time.sleep(30)
135
+ finally:
136
+ if handle is not None:
137
+ pv.clear_monitor(handle)
138
+ pv.close()
139
+ ```
140
+
141
+ ### PVPool
142
+
143
+ ```python
144
+ from capva import PVPool
145
+
146
+ PV_NAME = "pva://calcExample"
147
+
148
+ pv1 = PVPool.getPV(PV_NAME)
149
+ pv2 = PVPool.getPV(PV_NAME)
150
+ try:
151
+ print(pv1 is pv2) # same pooled instance
152
+ print(pv1.get().value)
153
+ finally:
154
+ PVPool.releasePV(pv1)
155
+ PVPool.releasePV(pv2)
156
+ ```
157
+
158
+ ### `PVData.to_dict` modes
159
+
160
+ | `mode` | Use case |
161
+ |--------|----------|
162
+ | `"full"` | Complete snapshot (value, alarm, timeStamp, display, control, …) |
163
+ | `"update"` | Monitor/Web push (no metadata fields) |
164
+ | `"metadata"` | display / control / valueAlarm only |
165
+
166
+ Set `base64_encode=True` on `"full"` or `"update"` to emit `b64arr` / `b64dtype` instead of a numeric array `value`.
167
+
168
+ ## Project layout
169
+
170
+ ```
171
+ src/capva/
172
+ pv.py, pv_data.py # Public PV + PVData model
173
+ pv_parser.py # CA/PVA → PVData
174
+ tools.py # pvget, pvput, pvinfo, pvmonitor
175
+ pool.py # PVPool
176
+ providers/ # ca_pv, pva_pv
177
+ examples/
178
+ tool_*.py # Procedural tools (one-shot)
179
+ pv_*.py # PV class API
180
+ pool_*.py # PVPool (shared connections)
181
+ tests/ # Unit tests (mocked; no IOC required)
182
+ ```
183
+
184
+ ## Examples
185
+
186
+ Edit `PV_NAME` at the top of each script, then run against a real IOC:
187
+
188
+ ```bash
189
+ # Procedural tools
190
+ python examples/tool_get.py
191
+ python examples/tool_info.py
192
+ python examples/tool_put.py
193
+ python examples/tool_monitor.py
194
+
195
+ # PV class
196
+ python examples/pv_get.py
197
+ python examples/pv_info.py
198
+ python examples/pv_put.py
199
+ python examples/pv_monitor.py
200
+
201
+ # PVPool
202
+ python examples/pool_get.py
203
+ python examples/pool_info.py
204
+ python examples/pool_put.py
205
+ python examples/pool_monitor.py
206
+
207
+ # Web JSON payload (wfExample waveform PV + Node.js)
208
+ python examples/encode_array.py
209
+ node examples/decode_array.js
210
+ ```
211
+
212
+ ## License
213
+
214
+ MIT — see [LICENSE](LICENSE).
capva-0.1.0/README.md ADDED
@@ -0,0 +1,188 @@
1
+ # capva
2
+
3
+ Unified Python client for EPICS PVs over **Channel Access (CA)** and **PV Access (PVA)**.
4
+
5
+ capva wraps [pyepics](https://github.com/pyepics/pyepics) and [p4p](https://github.com/epics-base/p4p) behind one API. Reads and monitors return a structured **`PVData`** model; JSON/Web payloads are built with **`PVData.to_dict()`** (optional base64 array encoding).
6
+
7
+ **Developed from the [weiss](https://github.com/weiss-controls/weiss) project** — capva builds on that codebase and refactors the PV client layer into a standalone Python library with a unified CA/PVA API and structured `PVData`.
8
+
9
+ ```mermaid
10
+ flowchart TB
11
+ subgraph capva["capva — standalone PV client library"]
12
+ api["PV, PVPool, tools"]
13
+ prov["CA_PV, PVA_PV"]
14
+ data["pv_parser, PVData"]
15
+ end
16
+
17
+ subgraph drivers["protocol drivers"]
18
+ direction LR
19
+ pyepics["pyepics (CA)"]
20
+ p4p["p4p (PVA)"]
21
+ end
22
+
23
+ epics["EPICS IOC"]
24
+
25
+ prov --> pyepics
26
+ prov --> p4p
27
+ pyepics --> epics
28
+ p4p --> epics
29
+ ```
30
+
31
+ ## Features
32
+
33
+ - **Single API for CA and PVA** — One client for Channel Access and PV Access; capva picks the backend from the PV name so application code does not split into separate CA/PVA paths.
34
+ - **Unified `PVData` model** — Every read and monitor callback returns the same structured snapshot (value, alarm, timeStamp, display, control, …), regardless of protocol.
35
+ - **Public interfaces: `PV`, `PVPool`, and procedural tools** — Use the object API for multi-step work on one connection, `PVPool` when several callers share a PV, or one-shot `pvget` / `pvput` / `pvinfo` / `pvmonitor` when a script only needs a single operation.
36
+ - **Reference-counted `PVPool`** — `getPV` / `releasePV` reuse one connection per PV name; the channel closes when the last reference is released.
37
+ - **Protocol prefixes** — `ca://…` for Channel Access, `pva://…` for PV Access, or no prefix to default to CA.
38
+
39
+ ## Requirements
40
+
41
+ - Python ≥ 3.10
42
+
43
+ ## Installation
44
+
45
+ From [PyPI](https://pypi.org/project/capva/):
46
+
47
+ ```bash
48
+ pip install capva
49
+ ```
50
+
51
+ From a checkout (development):
52
+
53
+ ```bash
54
+ pip install -e .
55
+ ```
56
+
57
+ ## Quick start
58
+
59
+ Examples use `pva://calcExample`; switch to `ca://…` or a bare name (CA default) as needed.
60
+
61
+ ### Procedural API
62
+
63
+ ```python
64
+ import time
65
+
66
+ from capva import PVData, pvget, pvmonitor
67
+
68
+ PV_NAME = "pva://calcExample"
69
+
70
+ data = pvget(PV_NAME)
71
+ print(data.value)
72
+
73
+ def on_update(data: PVData) -> None:
74
+ if data.is_disconnected():
75
+ print(f"{data.pvName} disconnected")
76
+ else:
77
+ print(data.value)
78
+
79
+ session = pvmonitor(PV_NAME, on_update)
80
+ try:
81
+ time.sleep(30)
82
+ finally:
83
+ session.close()
84
+ ```
85
+
86
+ ### Object API
87
+
88
+ ```python
89
+ import time
90
+
91
+ from capva import PV, PVData
92
+
93
+ PV_NAME = "pva://calcExample"
94
+
95
+ pv = PV(PV_NAME)
96
+ handle = None
97
+ try:
98
+ data = pv.get()
99
+ print(data.value)
100
+
101
+ def on_update(data: PVData) -> None:
102
+ if data.is_disconnected():
103
+ print(f"{data.pvName} disconnected")
104
+ else:
105
+ print(data.value)
106
+
107
+ handle = pv.monitor(on_update)
108
+ time.sleep(30)
109
+ finally:
110
+ if handle is not None:
111
+ pv.clear_monitor(handle)
112
+ pv.close()
113
+ ```
114
+
115
+ ### PVPool
116
+
117
+ ```python
118
+ from capva import PVPool
119
+
120
+ PV_NAME = "pva://calcExample"
121
+
122
+ pv1 = PVPool.getPV(PV_NAME)
123
+ pv2 = PVPool.getPV(PV_NAME)
124
+ try:
125
+ print(pv1 is pv2) # same pooled instance
126
+ print(pv1.get().value)
127
+ finally:
128
+ PVPool.releasePV(pv1)
129
+ PVPool.releasePV(pv2)
130
+ ```
131
+
132
+ ### `PVData.to_dict` modes
133
+
134
+ | `mode` | Use case |
135
+ |--------|----------|
136
+ | `"full"` | Complete snapshot (value, alarm, timeStamp, display, control, …) |
137
+ | `"update"` | Monitor/Web push (no metadata fields) |
138
+ | `"metadata"` | display / control / valueAlarm only |
139
+
140
+ Set `base64_encode=True` on `"full"` or `"update"` to emit `b64arr` / `b64dtype` instead of a numeric array `value`.
141
+
142
+ ## Project layout
143
+
144
+ ```
145
+ src/capva/
146
+ pv.py, pv_data.py # Public PV + PVData model
147
+ pv_parser.py # CA/PVA → PVData
148
+ tools.py # pvget, pvput, pvinfo, pvmonitor
149
+ pool.py # PVPool
150
+ providers/ # ca_pv, pva_pv
151
+ examples/
152
+ tool_*.py # Procedural tools (one-shot)
153
+ pv_*.py # PV class API
154
+ pool_*.py # PVPool (shared connections)
155
+ tests/ # Unit tests (mocked; no IOC required)
156
+ ```
157
+
158
+ ## Examples
159
+
160
+ Edit `PV_NAME` at the top of each script, then run against a real IOC:
161
+
162
+ ```bash
163
+ # Procedural tools
164
+ python examples/tool_get.py
165
+ python examples/tool_info.py
166
+ python examples/tool_put.py
167
+ python examples/tool_monitor.py
168
+
169
+ # PV class
170
+ python examples/pv_get.py
171
+ python examples/pv_info.py
172
+ python examples/pv_put.py
173
+ python examples/pv_monitor.py
174
+
175
+ # PVPool
176
+ python examples/pool_get.py
177
+ python examples/pool_info.py
178
+ python examples/pool_put.py
179
+ python examples/pool_monitor.py
180
+
181
+ # Web JSON payload (wfExample waveform PV + Node.js)
182
+ python examples/encode_array.py
183
+ node examples/decode_array.js
184
+ ```
185
+
186
+ ## License
187
+
188
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,46 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "capva"
7
+ version = "0.1.0"
8
+ description = "EPICS PV client supporting both Channel Access and PV Access"
9
+ readme = "README.md"
10
+ license = {text = "MIT"}
11
+ requires-python = ">=3.10"
12
+ authors = [
13
+ {name = "Lin Wang"},
14
+ ]
15
+ keywords = ["epics"]
16
+ classifiers = [
17
+ "Development Status :: 4 - Beta",
18
+ "Intended Audience :: Science/Research",
19
+ "Operating System :: OS Independent",
20
+ "Topic :: Scientific/Engineering",
21
+ "License :: OSI Approved :: MIT License",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.10",
24
+ "Programming Language :: Python :: 3.11",
25
+ "Programming Language :: Python :: 3.12",
26
+ ]
27
+
28
+ dependencies = [
29
+ "pyepics>=3.5.10",
30
+ "p4p>=4.2.2",
31
+ ]
32
+
33
+ [project.optional-dependencies]
34
+ dev = [
35
+ "pytest>=7.0",
36
+ ]
37
+
38
+ [project.urls]
39
+ Homepage = "https://github.com/wanglin86769/capva"
40
+
41
+ [tool.setuptools.packages.find]
42
+ where = ["src"]
43
+
44
+ [tool.pytest.ini_options]
45
+ testpaths = ["tests"]
46
+ pythonpath = ["src"]
capva-0.1.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,37 @@
1
+ """
2
+ capva - Unified EPICS Process Variable client (CA + PVA).
3
+
4
+ Supports both Channel Access (CA) and PV Access (PVA) with a single, consistent API.
5
+ Automatically selects the optimal backend: p4p for PVA, pyepics for CA.
6
+ """
7
+
8
+ from .constants import DEFAULT_IO_TIMEOUT
9
+ from .pv import PV
10
+ from .pv_data import PVData
11
+ from .pool import PVPool
12
+ from .monitor_handle import MonitorHandle
13
+ from .tools import MonitorSession, pvget, pvinfo, pvmonitor, pvput
14
+ from .exceptions import (
15
+ EPICSProtocolError,
16
+ EPICSConnectionError,
17
+ EPICSGetError,
18
+ EPICSPutError,
19
+ EPICSTimeoutError,
20
+ )
21
+
22
+ __all__ = [
23
+ "PV",
24
+ "PVData",
25
+ "PVPool",
26
+ "MonitorHandle",
27
+ "pvget",
28
+ "pvput",
29
+ "pvinfo",
30
+ "MonitorSession",
31
+ "pvmonitor",
32
+ "EPICSProtocolError",
33
+ "EPICSConnectionError",
34
+ "EPICSGetError",
35
+ "EPICSPutError",
36
+ "EPICSTimeoutError",
37
+ ]
@@ -0,0 +1,40 @@
1
+ """Numeric array base64 encoding for PV value."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import base64
6
+ from typing import Any, List, Optional, Union
7
+
8
+ import numpy as np
9
+
10
+
11
+ def _numeric_array_to_base64(array: Union[List, np.ndarray], dtype: str) -> str:
12
+ arr = np.asarray(array, dtype=dtype)
13
+ if arr.dtype.byteorder not in ("<", "="):
14
+ arr = arr.astype("<" + arr.dtype.str[1:])
15
+ return base64.b64encode(arr.tobytes()).decode("ascii")
16
+
17
+
18
+ def encode_array(arr: Any) -> tuple[Optional[str], Optional[str]]:
19
+ """Returns (b64arr, b64dtype) for numeric arrays."""
20
+ if arr is None:
21
+ return None, None
22
+
23
+ arr = np.asarray(arr)
24
+ if arr.size == 0:
25
+ return None, None
26
+
27
+ if np.issubdtype(arr.dtype, np.floating):
28
+ return _numeric_array_to_base64(arr, "float64"), "float64"
29
+
30
+ if np.issubdtype(arr.dtype, np.integer):
31
+ min_val, max_val = arr.min(), arr.max()
32
+ if -128 <= min_val <= max_val <= 127:
33
+ dtype = "int8"
34
+ elif -32768 <= min_val <= max_val <= 32767:
35
+ dtype = "int16"
36
+ else:
37
+ dtype = "int32"
38
+ return _numeric_array_to_base64(arr, dtype), dtype
39
+
40
+ return None, None
@@ -0,0 +1,3 @@
1
+ """Shared constants for capva."""
2
+
3
+ DEFAULT_IO_TIMEOUT: float = 5.0
@@ -0,0 +1,26 @@
1
+ """Custom exceptions for capva."""
2
+
3
+
4
+ class EPICSProtocolError(Exception):
5
+ """Raised when protocol detection or selection fails."""
6
+ pass
7
+
8
+
9
+ class EPICSConnectionError(Exception):
10
+ """Raised when connection to PV fails."""
11
+ pass
12
+
13
+
14
+ class EPICSGetError(Exception):
15
+ """Raised when a get operation fails after the PV is reachable."""
16
+ pass
17
+
18
+
19
+ class EPICSPutError(Exception):
20
+ """Raised when a put operation fails after the PV is reachable."""
21
+ pass
22
+
23
+
24
+ class EPICSTimeoutError(Exception):
25
+ """Raised when PV operation times out."""
26
+ pass
@@ -0,0 +1,13 @@
1
+ """Opaque handle for PV monitor subscriptions.
2
+
3
+ MonitorHandle stores two values returned from provider ``monitor()`` calls:
4
+
5
+ - owner: the CAPV or PVAPV instance that created this subscription
6
+ - handle: CA callback index (int) or p4p Subscription, depending on protocol
7
+ """
8
+
9
+
10
+ class MonitorHandle:
11
+ def __init__(self, owner, handle):
12
+ self._owner = owner
13
+ self._handle = handle
@@ -0,0 +1,66 @@
1
+ """Reference-counted pool of PV instances keyed by protocol and name."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+ import threading
7
+ from typing import Dict, List, Tuple
8
+
9
+ from .protocol import pvname_key
10
+ from .pv import PV
11
+
12
+
13
+ def _pool_key_from_pv(pv: PV) -> str:
14
+ return f"{pv.protocol}:{pv.pvname}"
15
+
16
+
17
+ @dataclass
18
+ class _PoolEntry:
19
+ pv: PV
20
+ refs: int = 0
21
+
22
+
23
+ class PVPool:
24
+ _lock = threading.Lock()
25
+ _entries: Dict[str, _PoolEntry] = {}
26
+
27
+ @classmethod
28
+ def getPV(cls, pvname: str) -> PV:
29
+ if not pvname or not pvname.strip():
30
+ raise ValueError("pvname must be a non-empty string")
31
+
32
+ key = pvname_key(pvname)
33
+ with cls._lock:
34
+ entry = cls._entries.get(key)
35
+ if entry is None:
36
+ entry = _PoolEntry(pv=PV(pvname))
37
+ cls._entries[key] = entry
38
+ entry.refs += 1
39
+ return entry.pv
40
+
41
+ @classmethod
42
+ def releasePV(cls, pv: PV) -> None:
43
+ key = _pool_key_from_pv(pv)
44
+ with cls._lock:
45
+ entry = cls._entries.get(key)
46
+ if entry is None:
47
+ return
48
+ entry.refs -= 1
49
+ if entry.refs <= 0:
50
+ entry.pv.close()
51
+ del cls._entries[key]
52
+
53
+ @classmethod
54
+ def getReferenceCount(cls, pvname: str) -> int:
55
+ key = pvname_key(pvname)
56
+ with cls._lock:
57
+ entry = cls._entries.get(key)
58
+ return entry.refs if entry else 0
59
+
60
+ @classmethod
61
+ def getPVReferences(cls) -> List[Tuple[str, PV, int]]:
62
+ with cls._lock:
63
+ return [
64
+ (key, entry.pv, entry.refs)
65
+ for key, entry in cls._entries.items()
66
+ ]
@@ -0,0 +1,20 @@
1
+ """Protocol detection and constants for EPICS PV client."""
2
+
3
+ from typing import Tuple
4
+
5
+ CA = "ca"
6
+ PVA = "pva"
7
+ DEFAULT_PROTOCOL = CA
8
+
9
+
10
+ def parse_protocol(pv_name: str) -> Tuple[str, str]:
11
+ if pv_name.startswith("pva://"):
12
+ return PVA, pv_name[6:]
13
+ elif pv_name.startswith("ca://"):
14
+ return CA, pv_name[5:]
15
+ return DEFAULT_PROTOCOL, pv_name
16
+
17
+
18
+ def pvname_key(pvname: str) -> str:
19
+ protocol, clean_name = parse_protocol(pvname)
20
+ return f"{protocol}:{clean_name}"
@@ -0,0 +1,6 @@
1
+ """PV implementations for CA and PVA protocols."""
2
+
3
+ from .ca_pv import CAPV
4
+ from .pva_pv import PVAPV
5
+
6
+ __all__ = ["CAPV", "PVAPV"]