pvua 1.0.1__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.
pvua-1.0.1/LICENSE ADDED
@@ -0,0 +1,42 @@
1
+ Copyright (c) 2026, The Board of Trustees of the Leland Stanford
2
+ Junior University, through SLAC National Accelerator Laboratory
3
+ (subject to receipt of any required approvals from the U.S. Dept. of
4
+ Energy). All rights reserved. Redistribution and use in source and
5
+ binary forms, with or without modification, are permitted provided
6
+ that the following conditions are met:
7
+
8
+ (1) Redistributions of source code must retain the above copyright
9
+ notice, this list of conditions and the following disclaimer.
10
+
11
+ (2) Redistributions in binary form must reproduce the above copyright
12
+ notice, this list of conditions and the following disclaimer in the
13
+ documentation and/or other materials provided with the distribution.
14
+
15
+ (3) Neither the name of the Leland Stanford Junior University, SLAC
16
+ National Accelerator Laboratory, U.S. Dept. of Energy nor the names of
17
+ its contributors may be used to endorse or promote products derived
18
+ from this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24
+ OWNER, THE UNITED STATES GOVERNMENT, OR CONTRIBUTORS BE LIABLE FOR ANY
25
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
29
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
31
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
+
33
+ You are under no obligation whatsoever to provide any bug fixes,
34
+ patches, or upgrades to the features, functionality or performance of
35
+ the source code ("Enhancements") to anyone; however, if you choose to
36
+ make your Enhancements available either publicly, or directly to SLAC
37
+ National Accelerator Laboratory, without imposing a separate written
38
+ license agreement for such Enhancements, then you hereby grant the
39
+ following license: a non-exclusive, royalty-free perpetual license to
40
+ install, use, modify, prepare derivative works, incorporate into other
41
+ computer software, distribute, and sublicense such Enhancements or
42
+ derivative works thereof, in binary and source code form.
pvua-1.0.1/PKG-INFO ADDED
@@ -0,0 +1,86 @@
1
+ Metadata-Version: 2.4
2
+ Name: pvua
3
+ Version: 1.0.1
4
+ Summary: A light wrapper around p4p and pyepics.
5
+ Author-email: Laura Lewis <lxlewis@slac.stanford.edu>, Jeremy Lorelli <lorelli@slac.stanford.edu>
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/slac-epics/pvua
8
+ Project-URL: Issues, https://github.com/slac-epics/pvua/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: p4p
15
+ Requires-Dist: pyepics
16
+ Provides-Extra: docs
17
+ Requires-Dist: sphinx; extra == "docs"
18
+ Provides-Extra: test
19
+ Requires-Dist: caproto[standard]; extra == "test"
20
+ Requires-Dist: pytest; extra == "test"
21
+ Dynamic: license-file
22
+
23
+ # PV Unified Access
24
+
25
+ [DOE Code](https://www.osti.gov/doecode/biblio/192186)
26
+
27
+ A light wrapper around p4p and pyepics.
28
+
29
+ ## Installation
30
+
31
+ A package on PyPI will be provided shortly. In the meantime, install with pip using the following command:
32
+
33
+ ```
34
+ python -m pip install git+https://github.com/slac-epics/pvua.git
35
+ ```
36
+
37
+ ## CLI
38
+
39
+ When the package is installed, new commands will be added that call into it.
40
+
41
+ - `pvuaget <PV name> [ca/pva]`
42
+ - `pvuainfo <PV name> [ca/pva]`
43
+ - Currently only Channel Access is supported for the info command.
44
+ - `pvuaput <PV name> <PV value> [ca/pva]`
45
+
46
+ If no provider is specified, both CA and PVA will be tried, with PVA tried first.
47
+
48
+ The following command will run the "universal" interface that the installed commands hook into:
49
+
50
+ ```
51
+ python -m pvua.cli <get/info/put> <ca/pva/unknown> <PV name> <value (if put specified)>
52
+ ```
53
+
54
+ ## Development
55
+
56
+ ### Guidelines
57
+
58
+ Contributors should note the primary focus of the library is supporting PyEPICS functionality relying on both PyEPICS and p4p,
59
+ although features outside this scope will be considered.
60
+
61
+ ### Installation
62
+
63
+ Clone this repository locally, then install an editable copy of the library with test dependencies.
64
+
65
+ ```
66
+ python -m pip install -e .[test]
67
+ ```
68
+
69
+ ### Testing
70
+
71
+ The following command will start a test IOC that serves three commands, which the CLI and library
72
+ can interact with. This requires the test dependencies to be installed.
73
+
74
+ ```
75
+ python -m pvua.test.server
76
+ ```
77
+
78
+ ## Copyright Notice
79
+
80
+ COPYRIGHT © SLAC National Accelerator Laboratory. All rights reserved.
81
+ This work is supported [in part] by the U.S. Department of Energy, Office of Basic Energy Sciences under contract DE-AC02-76SF00515.
82
+
83
+ ## Usage Restrictions
84
+
85
+ Neither the name of the Leland Stanford Junior University, SLAC National Accelerator Laboratory, U.S. Department of Energy
86
+ nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
pvua-1.0.1/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # PV Unified Access
2
+
3
+ [DOE Code](https://www.osti.gov/doecode/biblio/192186)
4
+
5
+ A light wrapper around p4p and pyepics.
6
+
7
+ ## Installation
8
+
9
+ A package on PyPI will be provided shortly. In the meantime, install with pip using the following command:
10
+
11
+ ```
12
+ python -m pip install git+https://github.com/slac-epics/pvua.git
13
+ ```
14
+
15
+ ## CLI
16
+
17
+ When the package is installed, new commands will be added that call into it.
18
+
19
+ - `pvuaget <PV name> [ca/pva]`
20
+ - `pvuainfo <PV name> [ca/pva]`
21
+ - Currently only Channel Access is supported for the info command.
22
+ - `pvuaput <PV name> <PV value> [ca/pva]`
23
+
24
+ If no provider is specified, both CA and PVA will be tried, with PVA tried first.
25
+
26
+ The following command will run the "universal" interface that the installed commands hook into:
27
+
28
+ ```
29
+ python -m pvua.cli <get/info/put> <ca/pva/unknown> <PV name> <value (if put specified)>
30
+ ```
31
+
32
+ ## Development
33
+
34
+ ### Guidelines
35
+
36
+ Contributors should note the primary focus of the library is supporting PyEPICS functionality relying on both PyEPICS and p4p,
37
+ although features outside this scope will be considered.
38
+
39
+ ### Installation
40
+
41
+ Clone this repository locally, then install an editable copy of the library with test dependencies.
42
+
43
+ ```
44
+ python -m pip install -e .[test]
45
+ ```
46
+
47
+ ### Testing
48
+
49
+ The following command will start a test IOC that serves three commands, which the CLI and library
50
+ can interact with. This requires the test dependencies to be installed.
51
+
52
+ ```
53
+ python -m pvua.test.server
54
+ ```
55
+
56
+ ## Copyright Notice
57
+
58
+ COPYRIGHT © SLAC National Accelerator Laboratory. All rights reserved.
59
+ This work is supported [in part] by the U.S. Department of Energy, Office of Basic Energy Sciences under contract DE-AC02-76SF00515.
60
+
61
+ ## Usage Restrictions
62
+
63
+ Neither the name of the Leland Stanford Junior University, SLAC National Accelerator Laboratory, U.S. Department of Energy
64
+ nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
@@ -0,0 +1,43 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 77.0.3"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pvua"
7
+ version = "1.0.1"
8
+ authors = [
9
+ { name="Laura Lewis", email="lxlewis@slac.stanford.edu" },
10
+ { name="Jeremy Lorelli", email="lorelli@slac.stanford.edu" },
11
+ ]
12
+ description = "A light wrapper around p4p and pyepics."
13
+ readme = "README.md"
14
+ requires-python = ">=3.9"
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Operating System :: OS Independent",
18
+ ]
19
+ license = "BSD-3-Clause"
20
+ license-files = ["LICENSE"]
21
+ dependencies = [
22
+ "p4p",
23
+ "pyepics",
24
+ ]
25
+
26
+ [project.optional-dependencies]
27
+ docs = [
28
+ "sphinx",
29
+ ]
30
+ test = [
31
+ "caproto[standard]",
32
+ "pytest",
33
+ ]
34
+
35
+ [project.scripts]
36
+ pvuaget = "pvua.cli:cli_get_entrypoint"
37
+ pvuainfo = "pvua.cli:cli_info_entrypoint"
38
+ pvuaput = "pvua.cli:cli_put_entrypoint"
39
+ pvuamonitor = "pvua.cli:cli_monitor_entrypoint"
40
+
41
+ [project.urls]
42
+ Homepage = "https://github.com/slac-epics/pvua"
43
+ Issues = "https://github.com/slac-epics/pvua/issues"
pvua-1.0.1/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,5 @@
1
+ from pvua.context import Provider, Context
2
+ from pvua.pv import PV
3
+
4
+
5
+ __all__ = ["Provider", "Context", "PV"]
@@ -0,0 +1,80 @@
1
+ from datetime import datetime
2
+ import sys
3
+ import time
4
+
5
+ from .context import Context, Provider
6
+
7
+
8
+ def str_to_provider(provider: str) -> Provider:
9
+ match provider.lower():
10
+ case "pva":
11
+ return Provider.PVA
12
+ case "ca":
13
+ return Provider.CA
14
+ case _:
15
+ return Provider.UNKNOWN
16
+
17
+
18
+ def cli_universal(command: str, provider: Provider, pvname: str, pv_value: str | None = None) -> int:
19
+ ctx = Context()
20
+
21
+ match command:
22
+ case "get":
23
+ timevars = ctx.get_timevars(pvname, provider_override=provider)
24
+ ms, ns = divmod((int(timevars['posixseconds'] * 1_000_000_000) + timevars['nanoseconds']) // 1_000_000, 1_000)
25
+ print(f"{pvname}\t{ctx.get(pvname, provider_override=provider)}\t{datetime.fromtimestamp(ms).strftime(f"%Y:%m:%d %H:%M:%S.{ns:03d}")}")
26
+ case "info":
27
+ if provider == Provider.PVA:
28
+ print("Info command unimplemented for PVA.")
29
+ return 1
30
+ else:
31
+ print(f"{ctx.info_ca(pvname)}")
32
+ case "put":
33
+ ctx.put(pvname, pv_value, provider_override=provider)
34
+ case "monitor":
35
+ ctx.monitor(pvname, callback=lambda **kwargs: print(kwargs["pvname"] + " " + str(kwargs["value"])), provider_override=provider)
36
+ try:
37
+ while True:
38
+ time.sleep(0.25)
39
+ except KeyboardInterrupt:
40
+ pass
41
+ case _:
42
+ print(f"Unknown command: {command}")
43
+ return 1
44
+ return 0
45
+
46
+
47
+ def cli_get_entrypoint() -> int:
48
+ if len(sys.argv) < 2:
49
+ print("Usage: <PV name> [ca/pva]")
50
+ return 1
51
+ return cli_universal("get", str_to_provider(sys.argv[2].strip()) if len(sys.argv) > 2 else Provider.UNKNOWN, sys.argv[1].strip())
52
+
53
+
54
+ def cli_info_entrypoint() -> int:
55
+ if len(sys.argv) < 2:
56
+ print("Usage: <PV name> [ca/pva]")
57
+ return 1
58
+ return cli_universal("info", str_to_provider(sys.argv[2].strip()) if len(sys.argv) > 2 else Provider.UNKNOWN, sys.argv[1].strip())
59
+
60
+
61
+ def cli_put_entrypoint() -> int:
62
+ if len(sys.argv) < 3:
63
+ print("Usage: <PV name> <PV value> [ca/pva]")
64
+ return 1
65
+ return cli_universal("put", str_to_provider(sys.argv[3].strip()) if len(sys.argv) > 3 else Provider.UNKNOWN, sys.argv[1].strip(), sys.argv[2].strip())
66
+
67
+
68
+ def cli_monitor_entrypoint() -> int:
69
+ if len(sys.argv) < 2:
70
+ print("Usage: <PV name> [ca/pva]")
71
+ return 1
72
+ return cli_universal("monitor", str_to_provider(sys.argv[2].strip()) if len(sys.argv) > 2 else Provider.UNKNOWN, sys.argv[1].strip())
73
+
74
+
75
+ if __name__ == "__main__":
76
+ if len(sys.argv) < 4:
77
+ print("Usage: <get/info/put/monitor> <ca/pva/unknown> <PV name> <value (if put specified)>")
78
+ sys.exit(1)
79
+
80
+ sys.exit(cli_universal(sys.argv[1].strip(), str_to_provider(sys.argv[2].strip()), sys.argv[3].strip(), sys.argv[4].strip() if len(sys.argv) > 4 else None))