pyads-agile 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.
- pyads_agile-0.1.0/ACKNOWLEDGMENTS.md +12 -0
- pyads_agile-0.1.0/LICENSE +21 -0
- pyads_agile-0.1.0/MANIFEST.in +10 -0
- pyads_agile-0.1.0/PKG-INFO +156 -0
- pyads_agile-0.1.0/README.md +117 -0
- pyads_agile-0.1.0/pyproject.toml +124 -0
- pyads_agile-0.1.0/setup.cfg +4 -0
- pyads_agile-0.1.0/setup.py +127 -0
- pyads_agile-0.1.0/src/pyads/__init__.py +121 -0
- pyads_agile-0.1.0/src/pyads/ads.py +466 -0
- pyads_agile-0.1.0/src/pyads/connection.py +1388 -0
- pyads_agile-0.1.0/src/pyads/constants.py +347 -0
- pyads_agile-0.1.0/src/pyads/errorcodes.py +136 -0
- pyads_agile-0.1.0/src/pyads/errorcodes_nc.py +965 -0
- pyads_agile-0.1.0/src/pyads/filetimes.py +77 -0
- pyads_agile-0.1.0/src/pyads/pyads_ex.py +1395 -0
- pyads_agile-0.1.0/src/pyads/structs.py +369 -0
- pyads_agile-0.1.0/src/pyads/symbol.py +406 -0
- pyads_agile-0.1.0/src/pyads/testserver/__init__.py +11 -0
- pyads_agile-0.1.0/src/pyads/testserver/__main__.py +49 -0
- pyads_agile-0.1.0/src/pyads/testserver/advanced_handler.py +548 -0
- pyads_agile-0.1.0/src/pyads/testserver/basic_handler.py +176 -0
- pyads_agile-0.1.0/src/pyads/testserver/handler.py +64 -0
- pyads_agile-0.1.0/src/pyads/testserver/testserver.py +315 -0
- pyads_agile-0.1.0/src/pyads/utils.py +110 -0
- pyads_agile-0.1.0/src/pyads_agile.egg-info/PKG-INFO +156 -0
- pyads_agile-0.1.0/src/pyads_agile.egg-info/SOURCES.txt +28 -0
- pyads_agile-0.1.0/src/pyads_agile.egg-info/dependency_links.txt +1 -0
- pyads_agile-0.1.0/src/pyads_agile.egg-info/requires.txt +18 -0
- pyads_agile-0.1.0/src/pyads_agile.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Acknowledgments
|
|
2
|
+
|
|
3
|
+
`pyads-agile` is based on the upstream `pyads` project created by Stefan Lehmann.
|
|
4
|
+
|
|
5
|
+
- Upstream project: https://github.com/stlehmann/pyads
|
|
6
|
+
- Original author: Stefan Lehmann
|
|
7
|
+
- License: MIT
|
|
8
|
+
|
|
9
|
+
This repository is maintained by Agile Automation Technologies GmbH.
|
|
10
|
+
|
|
11
|
+
We thank Stefan Lehmann and all upstream contributors for creating and maintaining
|
|
12
|
+
the foundation this distribution builds upon.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright © 2015 by Stefan Lehmann
|
|
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
|
|
13
|
+
all 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
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Recipe for extra files to pack for setuptools.
|
|
3
|
+
# MANIFEST.in is a little outdated but the best solution to differentiate files between sdist and wheel builds.
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
graft adslib
|
|
7
|
+
include ACKNOWLEDGMENTS.md
|
|
8
|
+
global-exclude *.a *.o *.obj *.bin *.so
|
|
9
|
+
prune obj
|
|
10
|
+
prune tests
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyads-agile
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Agile-maintained Python wrapper for the TwinCAT ADS library, based on pyads
|
|
5
|
+
Author: Agile Automation Technologies GmbH
|
|
6
|
+
Maintainer: Agile Automation Technologies GmbH
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Project-URL: Upstream, https://github.com/stlehmann/pyads
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
18
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
19
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
20
|
+
Requires-Python: <4,>=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
License-File: LICENSE
|
|
23
|
+
Requires-Dist: setuptools>=82.0.0
|
|
24
|
+
Provides-Extra: docs
|
|
25
|
+
Requires-Dist: sphinx; extra == "docs"
|
|
26
|
+
Requires-Dist: sphinx_rtd_theme; extra == "docs"
|
|
27
|
+
Requires-Dist: recommonmark; extra == "docs"
|
|
28
|
+
Provides-Extra: tests
|
|
29
|
+
Requires-Dist: pytest; extra == "tests"
|
|
30
|
+
Requires-Dist: pytest-cov; extra == "tests"
|
|
31
|
+
Requires-Dist: tox; extra == "tests"
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: build; extra == "dev"
|
|
34
|
+
Requires-Dist: flake8; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest; extra == "dev"
|
|
36
|
+
Requires-Dist: coverage; extra == "dev"
|
|
37
|
+
Requires-Dist: coveralls; extra == "dev"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
pyads-agile
|
|
41
|
+
===========
|
|
42
|
+
|
|
43
|
+
`pyads-agile` is a Python wrapper for the Beckhoff TwinCAT ADS library.
|
|
44
|
+
|
|
45
|
+
This distribution is maintained by Agile Automation Technologies GmbH and is
|
|
46
|
+
based on the excellent upstream `pyads` project created by Stefan Lehmann:
|
|
47
|
+
https://github.com/stlehmann/pyads
|
|
48
|
+
|
|
49
|
+
`pyads-agile` intentionally stays drop-in compatible with `pyads`. The public API,
|
|
50
|
+
module name (`import pyads`), and supported interpreter/OS matrix mirror upstream,
|
|
51
|
+
so existing applications can switch distributions without code changes.
|
|
52
|
+
|
|
53
|
+
## Attribution
|
|
54
|
+
|
|
55
|
+
- Original project: `pyads` by Stefan Lehmann
|
|
56
|
+
- License: MIT
|
|
57
|
+
- This repository keeps upstream credit and license notices as required
|
|
58
|
+
|
|
59
|
+
See [ACKNOWLEDGMENTS.md](ACKNOWLEDGMENTS.md) for details.
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
Install the distribution:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install pyads-agile
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Import stays compatible:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
import pyads
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Versioning
|
|
76
|
+
|
|
77
|
+
`pyads-agile` uses its own independent Semantic Versioning (`MAJOR.MINOR.PATCH`).
|
|
78
|
+
It does not mirror upstream `pyads` version numbers.
|
|
79
|
+
|
|
80
|
+
## Scope
|
|
81
|
+
|
|
82
|
+
This package provides Python APIs for communicating with TwinCAT devices using:
|
|
83
|
+
|
|
84
|
+
- `TcAdsDll.dll` on Windows
|
|
85
|
+
- `adslib.so` on Linux
|
|
86
|
+
|
|
87
|
+
## Agile-specific enhancements
|
|
88
|
+
|
|
89
|
+
Beyond compatibility, this fork currently focuses on improved RPC ergonomics:
|
|
90
|
+
|
|
91
|
+
- **Convenient RPC object proxies.** `Connection.get_object()` exposes TwinCAT
|
|
92
|
+
function blocks as Python objects and lets you configure return and parameter
|
|
93
|
+
types per method:
|
|
94
|
+
|
|
95
|
+
TwinCAT requirement: each callable method must be annotated in PLC code with
|
|
96
|
+
`{attribute 'TcRpcEnable'}` directly above the method declaration.
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
rpc = plc.get_object(
|
|
100
|
+
"GVL.fbTestRemoteMethodCall",
|
|
101
|
+
method_return_types={"m_iSimpleCall": pyads.PLCTYPE_INT},
|
|
102
|
+
)
|
|
103
|
+
result = rpc.m_iSimpleCall()
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
- **Multi-parameter RPC calls with native syntax.** Configure method signatures
|
|
107
|
+
once and then call methods like normal Python methods:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
rpc = plc.get_object(
|
|
111
|
+
"GVL.fbTestRemoteMethodCall",
|
|
112
|
+
method_return_types={"m_iSum": pyads.PLCTYPE_INT},
|
|
113
|
+
method_parameters={"m_iSum": [pyads.PLCTYPE_INT, pyads.PLCTYPE_INT]},
|
|
114
|
+
)
|
|
115
|
+
result = rpc.m_iSum(5, 5)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
You can still use low-level direct calls when needed:
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
result = plc.call_rpc_method(
|
|
122
|
+
"GVL.fbTestRemoteMethodCall#m_iSimpleCall",
|
|
123
|
+
return_type=pyads.PLCTYPE_INT,
|
|
124
|
+
write_value=42,
|
|
125
|
+
write_type=pyads.PLCTYPE_INT,
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Features
|
|
130
|
+
|
|
131
|
+
- connect to remote TwinCAT devices
|
|
132
|
+
- create routes on Linux and on remote PLCs
|
|
133
|
+
- support for TwinCAT 2 and TwinCAT 3
|
|
134
|
+
- read and write values by name or by address
|
|
135
|
+
- read and write DUTs (structures)
|
|
136
|
+
- notification callbacks
|
|
137
|
+
|
|
138
|
+
## Basic usage
|
|
139
|
+
|
|
140
|
+
```python
|
|
141
|
+
import pyads
|
|
142
|
+
|
|
143
|
+
plc = pyads.Connection("127.0.0.1.1.1", pyads.PORT_TC3PLC1)
|
|
144
|
+
plc.open()
|
|
145
|
+
i = plc.read_by_name("GVL.int_val")
|
|
146
|
+
plc.write_by_name("GVL.int_val", i)
|
|
147
|
+
plc.close()
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Contribution Policy
|
|
151
|
+
|
|
152
|
+
This repository is maintained on a best-effort basis for internal and product
|
|
153
|
+
needs.
|
|
154
|
+
|
|
155
|
+
At this time, we do not accept unsolicited pull requests, and we may not be
|
|
156
|
+
able to respond to feature requests or general support issues.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
pyads-agile
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
`pyads-agile` is a Python wrapper for the Beckhoff TwinCAT ADS library.
|
|
5
|
+
|
|
6
|
+
This distribution is maintained by Agile Automation Technologies GmbH and is
|
|
7
|
+
based on the excellent upstream `pyads` project created by Stefan Lehmann:
|
|
8
|
+
https://github.com/stlehmann/pyads
|
|
9
|
+
|
|
10
|
+
`pyads-agile` intentionally stays drop-in compatible with `pyads`. The public API,
|
|
11
|
+
module name (`import pyads`), and supported interpreter/OS matrix mirror upstream,
|
|
12
|
+
so existing applications can switch distributions without code changes.
|
|
13
|
+
|
|
14
|
+
## Attribution
|
|
15
|
+
|
|
16
|
+
- Original project: `pyads` by Stefan Lehmann
|
|
17
|
+
- License: MIT
|
|
18
|
+
- This repository keeps upstream credit and license notices as required
|
|
19
|
+
|
|
20
|
+
See [ACKNOWLEDGMENTS.md](ACKNOWLEDGMENTS.md) for details.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
Install the distribution:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
pip install pyads-agile
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Import stays compatible:
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
import pyads
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Versioning
|
|
37
|
+
|
|
38
|
+
`pyads-agile` uses its own independent Semantic Versioning (`MAJOR.MINOR.PATCH`).
|
|
39
|
+
It does not mirror upstream `pyads` version numbers.
|
|
40
|
+
|
|
41
|
+
## Scope
|
|
42
|
+
|
|
43
|
+
This package provides Python APIs for communicating with TwinCAT devices using:
|
|
44
|
+
|
|
45
|
+
- `TcAdsDll.dll` on Windows
|
|
46
|
+
- `adslib.so` on Linux
|
|
47
|
+
|
|
48
|
+
## Agile-specific enhancements
|
|
49
|
+
|
|
50
|
+
Beyond compatibility, this fork currently focuses on improved RPC ergonomics:
|
|
51
|
+
|
|
52
|
+
- **Convenient RPC object proxies.** `Connection.get_object()` exposes TwinCAT
|
|
53
|
+
function blocks as Python objects and lets you configure return and parameter
|
|
54
|
+
types per method:
|
|
55
|
+
|
|
56
|
+
TwinCAT requirement: each callable method must be annotated in PLC code with
|
|
57
|
+
`{attribute 'TcRpcEnable'}` directly above the method declaration.
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
rpc = plc.get_object(
|
|
61
|
+
"GVL.fbTestRemoteMethodCall",
|
|
62
|
+
method_return_types={"m_iSimpleCall": pyads.PLCTYPE_INT},
|
|
63
|
+
)
|
|
64
|
+
result = rpc.m_iSimpleCall()
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
- **Multi-parameter RPC calls with native syntax.** Configure method signatures
|
|
68
|
+
once and then call methods like normal Python methods:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
rpc = plc.get_object(
|
|
72
|
+
"GVL.fbTestRemoteMethodCall",
|
|
73
|
+
method_return_types={"m_iSum": pyads.PLCTYPE_INT},
|
|
74
|
+
method_parameters={"m_iSum": [pyads.PLCTYPE_INT, pyads.PLCTYPE_INT]},
|
|
75
|
+
)
|
|
76
|
+
result = rpc.m_iSum(5, 5)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
You can still use low-level direct calls when needed:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
result = plc.call_rpc_method(
|
|
83
|
+
"GVL.fbTestRemoteMethodCall#m_iSimpleCall",
|
|
84
|
+
return_type=pyads.PLCTYPE_INT,
|
|
85
|
+
write_value=42,
|
|
86
|
+
write_type=pyads.PLCTYPE_INT,
|
|
87
|
+
)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Features
|
|
91
|
+
|
|
92
|
+
- connect to remote TwinCAT devices
|
|
93
|
+
- create routes on Linux and on remote PLCs
|
|
94
|
+
- support for TwinCAT 2 and TwinCAT 3
|
|
95
|
+
- read and write values by name or by address
|
|
96
|
+
- read and write DUTs (structures)
|
|
97
|
+
- notification callbacks
|
|
98
|
+
|
|
99
|
+
## Basic usage
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
import pyads
|
|
103
|
+
|
|
104
|
+
plc = pyads.Connection("127.0.0.1.1.1", pyads.PORT_TC3PLC1)
|
|
105
|
+
plc.open()
|
|
106
|
+
i = plc.read_by_name("GVL.int_val")
|
|
107
|
+
plc.write_by_name("GVL.int_val", i)
|
|
108
|
+
plc.close()
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Contribution Policy
|
|
112
|
+
|
|
113
|
+
This repository is maintained on a best-effort basis for internal and product
|
|
114
|
+
needs.
|
|
115
|
+
|
|
116
|
+
At this time, we do not accept unsolicited pull requests, and we may not be
|
|
117
|
+
able to respond to feature requests or general support issues.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "pyads-agile"
|
|
3
|
+
description = "Agile-maintained Python wrapper for the TwinCAT ADS library, based on pyads"
|
|
4
|
+
authors = [
|
|
5
|
+
{ name = "Agile Automation Technologies GmbH" },
|
|
6
|
+
]
|
|
7
|
+
maintainers = [
|
|
8
|
+
{ name = "Agile Automation Technologies GmbH" },
|
|
9
|
+
]
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 4 - Beta",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"Programming Language :: Python :: 3.9",
|
|
15
|
+
"Programming Language :: Python :: 3.10",
|
|
16
|
+
"Programming Language :: Python :: 3.11",
|
|
17
|
+
"Programming Language :: Python :: 3.12",
|
|
18
|
+
"Programming Language :: Python :: 3.13",
|
|
19
|
+
"Programming Language :: Python :: 3.14",
|
|
20
|
+
"Topic :: Software Development :: Libraries",
|
|
21
|
+
"Operating System :: Microsoft :: Windows",
|
|
22
|
+
"Operating System :: POSIX :: Linux",
|
|
23
|
+
]
|
|
24
|
+
license = "MIT"
|
|
25
|
+
license-files = ["LICENSE"]
|
|
26
|
+
dynamic = ["version"]
|
|
27
|
+
dependencies = [
|
|
28
|
+
"setuptools>=82.0.0",
|
|
29
|
+
]
|
|
30
|
+
requires-python = ">= 3.9,<4"
|
|
31
|
+
# Outdated Python versions are still included, until they cause problems (after which they will bed dropped)
|
|
32
|
+
# Python 3.8 cannot be used anymore because of a setuptoools minimum version
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
docs = [
|
|
36
|
+
"sphinx",
|
|
37
|
+
"sphinx_rtd_theme",
|
|
38
|
+
"recommonmark",
|
|
39
|
+
]
|
|
40
|
+
tests = [
|
|
41
|
+
"pytest",
|
|
42
|
+
"pytest-cov",
|
|
43
|
+
"tox",
|
|
44
|
+
]
|
|
45
|
+
dev = [
|
|
46
|
+
"build",
|
|
47
|
+
"flake8",
|
|
48
|
+
"pytest",
|
|
49
|
+
"coverage",
|
|
50
|
+
"coveralls",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[project.urls]
|
|
54
|
+
Upstream = "https://github.com/stlehmann/pyads"
|
|
55
|
+
|
|
56
|
+
[build-system]
|
|
57
|
+
requires = ["setuptools >= 77.0.3", "wheel"]
|
|
58
|
+
# ^ Support for new `license` format
|
|
59
|
+
build-backend = "setuptools.build_meta"
|
|
60
|
+
|
|
61
|
+
[tool.setuptools]
|
|
62
|
+
packages = ["pyads", "pyads.testserver"]
|
|
63
|
+
package-dir = { "" = "src" }
|
|
64
|
+
include-package-data = true
|
|
65
|
+
# ^ needed for MANIFEST.in
|
|
66
|
+
|
|
67
|
+
#[tool.setuptools.package-data]
|
|
68
|
+
# Package data (adslib/) is handled by MANIFEST.in instead
|
|
69
|
+
|
|
70
|
+
[tool.setuptools.exclude-package-data]
|
|
71
|
+
pyads = ["adslib/**"]
|
|
72
|
+
# ^ Odd trick, put this excludes the adslib source again from a wheel build and from a pip install
|
|
73
|
+
|
|
74
|
+
[tool.setuptools.dynamic]
|
|
75
|
+
version = {attr = "pyads.__version__"}
|
|
76
|
+
|
|
77
|
+
[tool.cibuildwheel.linux]
|
|
78
|
+
before-all = "apt install -y meson"
|
|
79
|
+
|
|
80
|
+
[tool.tox]
|
|
81
|
+
legacy_tox_ini = """
|
|
82
|
+
[tox]
|
|
83
|
+
envlist = py38, py39, py310, py311, py312, py313, py314
|
|
84
|
+
|
|
85
|
+
[testenv]
|
|
86
|
+
commands = discover
|
|
87
|
+
deps = discover
|
|
88
|
+
changedir = tests
|
|
89
|
+
whitelist_externals=*
|
|
90
|
+
passenv = TWINCAT3DIR
|
|
91
|
+
|
|
92
|
+
[pytest]
|
|
93
|
+
testpaths = tests
|
|
94
|
+
"""
|
|
95
|
+
|
|
96
|
+
[tool.black]
|
|
97
|
+
line-length = 88
|
|
98
|
+
target-version = ['py38', 'py39', 'py310', 'py311', 'py312', 'py313', 'py314']
|
|
99
|
+
include = '\.pyi?$'
|
|
100
|
+
exclude = '''
|
|
101
|
+
(
|
|
102
|
+
/(
|
|
103
|
+
.eggs
|
|
104
|
+
| .git
|
|
105
|
+
| .mypy_cache
|
|
106
|
+
| .tox
|
|
107
|
+
| .venv
|
|
108
|
+
| _build
|
|
109
|
+
| buck-out
|
|
110
|
+
| build
|
|
111
|
+
| dist
|
|
112
|
+
| adslib
|
|
113
|
+
| pyads.egg-info
|
|
114
|
+
)/
|
|
115
|
+
| pyads/__init__.py
|
|
116
|
+
)
|
|
117
|
+
'''
|
|
118
|
+
|
|
119
|
+
[tool.pydocstyle]
|
|
120
|
+
ignore = ["D105", "D213", "D203", "D107"]
|
|
121
|
+
|
|
122
|
+
[tool.coverage.run]
|
|
123
|
+
include = ["pyads/*"]
|
|
124
|
+
omit = ["pyads/testserver/__main__.py"]
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import struct
|
|
3
|
+
import subprocess
|
|
4
|
+
import sys
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from setuptools import setup
|
|
8
|
+
from setuptools.command.bdist_wheel import bdist_wheel, get_platform
|
|
9
|
+
from setuptools.command.build_py import build_py
|
|
10
|
+
from setuptools.command.install import install
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _is_32bit_interpreter() -> bool:
|
|
14
|
+
return struct.calcsize("P") == 4
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
src_folder = Path(__file__).parent.absolute() / "src"
|
|
18
|
+
# ^ This will be on PATH for editable install
|
|
19
|
+
adslib_folder = Path(__file__).parent.absolute() / "adslib/build"
|
|
20
|
+
adslib_file = src_folder / "adslib.so"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class CustomBuildPy(build_py):
|
|
24
|
+
"""Custom command for `build_py`.
|
|
25
|
+
|
|
26
|
+
This command class is used because it is always run, also for an editable install.
|
|
27
|
+
"""
|
|
28
|
+
|
|
29
|
+
@classmethod
|
|
30
|
+
def compile_adslib(cls) -> bool:
|
|
31
|
+
"""Return `True` if adslib was actually compiled."""
|
|
32
|
+
if cls.platform_is_unix():
|
|
33
|
+
cls._clean_library()
|
|
34
|
+
cls._compile_library()
|
|
35
|
+
return True
|
|
36
|
+
|
|
37
|
+
return False
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def _compile_library():
|
|
41
|
+
"""Use `make` to build adslib - build is done in-place."""
|
|
42
|
+
# Produce `adslib.so`:
|
|
43
|
+
subprocess.call(["make", "-C", "adslib"])
|
|
44
|
+
|
|
45
|
+
@staticmethod
|
|
46
|
+
def _clean_library():
|
|
47
|
+
"""Remove all compilation artifacts."""
|
|
48
|
+
patterns = (
|
|
49
|
+
"*.a",
|
|
50
|
+
"**/*.o",
|
|
51
|
+
"*.bin",
|
|
52
|
+
"*.so",
|
|
53
|
+
)
|
|
54
|
+
for pattern in patterns:
|
|
55
|
+
for file in adslib_folder.glob(pattern):
|
|
56
|
+
os.remove(file)
|
|
57
|
+
|
|
58
|
+
if adslib_file.is_file():
|
|
59
|
+
os.remove(adslib_file)
|
|
60
|
+
|
|
61
|
+
@staticmethod
|
|
62
|
+
def platform_is_unix():
|
|
63
|
+
return sys.platform.startswith("linux") or sys.platform.startswith("darwin")
|
|
64
|
+
|
|
65
|
+
def run(self):
|
|
66
|
+
if self.compile_adslib():
|
|
67
|
+
# Move .so file from Git submodule into src/ to have it on PATH:
|
|
68
|
+
self.move_file(
|
|
69
|
+
str(adslib_folder / "adslib.so"),
|
|
70
|
+
str(adslib_file),
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
super().run()
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class CustomInstall(install):
|
|
77
|
+
"""Install compiled adslib (but only for Linux)."""
|
|
78
|
+
|
|
79
|
+
def run(self):
|
|
80
|
+
if CustomBuildPy.platform_is_unix():
|
|
81
|
+
adslib_dest = Path(self.install_lib)
|
|
82
|
+
if not adslib_dest.exists():
|
|
83
|
+
adslib_dest.mkdir(parents=True)
|
|
84
|
+
self.copy_file(
|
|
85
|
+
str(adslib_file),
|
|
86
|
+
str(adslib_dest),
|
|
87
|
+
)
|
|
88
|
+
super().run()
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class CustomBDistWheel(bdist_wheel):
|
|
92
|
+
"""Manually mark our wheel for a specific platform."""
|
|
93
|
+
|
|
94
|
+
def get_tag(self):
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
See https://packaging.python.org/en/latest/specifications/platform-compatibility-tags/
|
|
98
|
+
"""
|
|
99
|
+
impl_tag = "py3" # Same wheel across Python versions
|
|
100
|
+
abi_tag = "none" # Same wheel across ABI versions (not a C-extension)
|
|
101
|
+
|
|
102
|
+
# But we need to differentiate on the platform for the compiled adslib
|
|
103
|
+
|
|
104
|
+
# The following code is copied from `setuptools.command.bdist_wheel.get_tag()`
|
|
105
|
+
plat_name = get_platform(self.bdist_dir)
|
|
106
|
+
|
|
107
|
+
if _is_32bit_interpreter():
|
|
108
|
+
if plat_name in ("linux-x86_64", "linux_x86_64"):
|
|
109
|
+
plat_name = "linux_i686"
|
|
110
|
+
if plat_name in ("linux-aarch64", "linux_aarch64"):
|
|
111
|
+
plat_name = "linux_armv7l"
|
|
112
|
+
|
|
113
|
+
plat_name = (
|
|
114
|
+
plat_name.lower().replace("-", "_").replace(".", "_").replace(" ", "_")
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
return impl_tag, abi_tag, plat_name
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
# noinspection PyTypeChecker
|
|
121
|
+
setup(
|
|
122
|
+
cmdclass={
|
|
123
|
+
"build_py": CustomBuildPy,
|
|
124
|
+
"install": CustomInstall,
|
|
125
|
+
"bdist_wheel": CustomBDistWheel,
|
|
126
|
+
},
|
|
127
|
+
)
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"""The pyads package.
|
|
2
|
+
|
|
3
|
+
:author: Stefan Lehmann <stlm@posteo.de>
|
|
4
|
+
:license: MIT, see license file or https://opensource.org/licenses/MIT
|
|
5
|
+
:created on: 2018-06-11 18:15:53
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
from .structs import AmsAddr, NotificationAttrib
|
|
9
|
+
|
|
10
|
+
from .ads import (
|
|
11
|
+
open_port,
|
|
12
|
+
close_port,
|
|
13
|
+
get_local_address,
|
|
14
|
+
add_route,
|
|
15
|
+
add_route_to_plc,
|
|
16
|
+
delete_route,
|
|
17
|
+
set_local_address,
|
|
18
|
+
set_timeout,
|
|
19
|
+
size_of_structure,
|
|
20
|
+
dict_from_bytes,
|
|
21
|
+
bytes_from_dict,
|
|
22
|
+
StructureDef,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
from .connection import Connection
|
|
26
|
+
|
|
27
|
+
from .pyads_ex import ADSError
|
|
28
|
+
|
|
29
|
+
from .constants import (
|
|
30
|
+
PLCTYPE_BOOL,
|
|
31
|
+
PLCTYPE_BYTE,
|
|
32
|
+
PLCTYPE_DATE,
|
|
33
|
+
PLCTYPE_DINT,
|
|
34
|
+
PLCTYPE_DT,
|
|
35
|
+
PLCTYPE_DWORD,
|
|
36
|
+
PLCTYPE_INT,
|
|
37
|
+
PLCTYPE_LINT,
|
|
38
|
+
PLCTYPE_LREAL,
|
|
39
|
+
PLCTYPE_REAL,
|
|
40
|
+
PLCTYPE_SINT,
|
|
41
|
+
PLCTYPE_STRING,
|
|
42
|
+
PLCTYPE_WSTRING,
|
|
43
|
+
PLCTYPE_TIME,
|
|
44
|
+
PLCTYPE_TOD,
|
|
45
|
+
PLCTYPE_ULINT,
|
|
46
|
+
PLCTYPE_UDINT,
|
|
47
|
+
PLCTYPE_UINT,
|
|
48
|
+
PLCTYPE_USINT,
|
|
49
|
+
PLCTYPE_WORD,
|
|
50
|
+
PLCTYPE_ARR_DINT,
|
|
51
|
+
PLCTYPE_ARR_INT,
|
|
52
|
+
PLCTYPE_ARR_LREAL,
|
|
53
|
+
PLCTYPE_ARR_REAL,
|
|
54
|
+
PLCTYPE_ARR_SHORT,
|
|
55
|
+
PLC_DEFAULT_STRING_SIZE,
|
|
56
|
+
DATATYPE_MAP,
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
from .constants import (
|
|
60
|
+
PORT_EVENTLOGGER,
|
|
61
|
+
PORT_IO,
|
|
62
|
+
PORT_LOGGER,
|
|
63
|
+
PORT_NC,
|
|
64
|
+
PORT_NOCKE,
|
|
65
|
+
PORT_SCOPE,
|
|
66
|
+
PORT_SPECIALTASK1,
|
|
67
|
+
PORT_SPECIALTASK2,
|
|
68
|
+
PORT_SPS1,
|
|
69
|
+
PORT_SPS2,
|
|
70
|
+
PORT_SPS3,
|
|
71
|
+
PORT_SPS4,
|
|
72
|
+
PORT_SYSTEMSERVICE,
|
|
73
|
+
PORT_CAM,
|
|
74
|
+
PORT_TC2PLC1,
|
|
75
|
+
PORT_TC2PLC2,
|
|
76
|
+
PORT_TC2PLC3,
|
|
77
|
+
PORT_TC2PLC4,
|
|
78
|
+
PORT_TC3PLC1,
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
from .constants import (
|
|
82
|
+
INDEXGROUP_MEMORYBYTE,
|
|
83
|
+
INDEXGROUP_MEMORYBIT,
|
|
84
|
+
INDEXGROUP_MEMORYSIZE,
|
|
85
|
+
INDEXGROUP_RETAIN,
|
|
86
|
+
INDEXGROUP_RETAINSIZE,
|
|
87
|
+
INDEXGROUP_DATA,
|
|
88
|
+
INDEXGROUP_DATASIZE,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
from .constants import (
|
|
92
|
+
ADSSTATE_INVALID,
|
|
93
|
+
ADSSTATE_IDLE,
|
|
94
|
+
ADSSTATE_RESET,
|
|
95
|
+
ADSSTATE_INIT,
|
|
96
|
+
ADSSTATE_START,
|
|
97
|
+
ADSSTATE_RUN,
|
|
98
|
+
ADSSTATE_STOP,
|
|
99
|
+
ADSSTATE_SAVECFG,
|
|
100
|
+
ADSSTATE_LOADCFG,
|
|
101
|
+
ADSSTATE_POWERFAILURE,
|
|
102
|
+
ADSSTATE_POWERGOOD,
|
|
103
|
+
ADSSTATE_ERROR,
|
|
104
|
+
ADSSTATE_SHUTDOWN,
|
|
105
|
+
ADSSTATE_SUSPEND,
|
|
106
|
+
ADSSTATE_RESUME,
|
|
107
|
+
ADSSTATE_CONFIG,
|
|
108
|
+
ADSSTATE_RECONFIG,
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
from .constants import (
|
|
112
|
+
ADSTRANS_NOTRANS,
|
|
113
|
+
ADSTRANS_CLIENTCYCLE,
|
|
114
|
+
ADSTRANS_CLIENT1REQ,
|
|
115
|
+
ADSTRANS_SERVERCYCLE,
|
|
116
|
+
ADSTRANS_SERVERONCHA,
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
from .symbol import AdsSymbol
|
|
120
|
+
|
|
121
|
+
__version__ = '0.1.0'
|