sgr-commhandler 0.4.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.
- sgr_commhandler-0.4.0/LICENSE.md +14 -0
- sgr_commhandler-0.4.0/PKG-INFO +111 -0
- sgr_commhandler-0.4.0/README.md +84 -0
- sgr_commhandler-0.4.0/pyproject.toml +53 -0
- sgr_commhandler-0.4.0/setup.cfg +4 -0
- sgr_commhandler-0.4.0/setup.py +5 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/__init__.py +0 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/api/__init__.py +29 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/api/configuration_parameter.py +71 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/api/data_point_api.py +339 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/api/data_types.py +15 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/api/device_api.py +215 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/api/dynamic_parameter.py +103 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/api/functional_profile_api.py +97 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/declaration_library.py +45 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/device_builder.py +339 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/__init__.py +0 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/contact/__init__.py +7 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/contact/contact_interface_async.py +193 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/generic/__init__.py +7 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/generic/generic_interface_async.py +191 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/messaging/__init__.py +7 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/messaging/messaging_client_async.py +104 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/messaging/messaging_filter.py +105 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/messaging/messaging_interface_async.py +400 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/modbus/__init__.py +7 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/modbus/modbus_client_async.py +345 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/modbus/modbus_interface_async.py +586 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/modbus/payload_decoder.py +118 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/modbus/shared_client.py +113 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/rest/__init__.py +7 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/rest/authentication.py +237 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/rest/request.py +114 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/driver/rest/restapi_interface_async.py +478 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/utils/__init__.py +1 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/utils/jmespath_mapping.py +311 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/utils/template.py +22 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/utils/value_util.py +39 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/validators/__init__.py +3 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/validators/resolver.py +71 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler/validators/validator.py +179 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler.egg-info/PKG-INFO +111 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler.egg-info/SOURCES.txt +44 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler.egg-info/dependency_links.txt +1 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler.egg-info/requires.txt +10 -0
- sgr_commhandler-0.4.0/src/sgr_commhandler.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Copyright(c) 2022 Verein SmartGridready Switzerland
|
|
2
|
+
|
|
3
|
+
This Open Source Software is BSD 3 clause licensed:
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
6
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in
|
|
7
|
+
the documentation and/or other materials provided with the distribution.
|
|
8
|
+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from
|
|
9
|
+
this software without specific prior written permission.
|
|
10
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
11
|
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
12
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
13
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
14
|
+
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: sgr-commhandler
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: SmartGridready CommHandler Library
|
|
5
|
+
Author: Robin Schoch, Matthias Krebs
|
|
6
|
+
Maintainer: Matthias Krebs
|
|
7
|
+
License-Expression: BSD-3-Clause
|
|
8
|
+
Project-URL: Homepage, https://www.smartgridready.ch/
|
|
9
|
+
Project-URL: Documentation, https://smartgridready.github.io/SGrPython/docs/commhandler/
|
|
10
|
+
Project-URL: Repository, https://github.com/SmartGridready/SGrPython.git
|
|
11
|
+
Project-URL: Issues, https://github.com/SmartGridready/SGrPython/issues
|
|
12
|
+
Project-URL: Changelog, https://github.com/SmartGridready/SGrPython/blob/master/commhandler/CHANGELOG.md
|
|
13
|
+
Requires-Python: >=3.9
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE.md
|
|
16
|
+
Requires-Dist: Jinja2<4.0.0,>=3.1.0
|
|
17
|
+
Requires-Dist: jmespath<2.0.0,>=1.0.0
|
|
18
|
+
Requires-Dist: pymodbus<3.8.0,>=3.7.0
|
|
19
|
+
Requires-Dist: gmqtt<1.0.0,>=0.7.0
|
|
20
|
+
Requires-Dist: xsdata<26.0.0,>=25.0.0
|
|
21
|
+
Requires-Dist: xmlschema<5.0.0,>=4.1.0
|
|
22
|
+
Requires-Dist: aiohttp<4.0.0,>=3.12.0
|
|
23
|
+
Requires-Dist: certifi
|
|
24
|
+
Requires-Dist: cachetools<7.0.0,>=6.2.0
|
|
25
|
+
Requires-Dist: sgr-specification<3.0.0,>=2.1.0
|
|
26
|
+
Dynamic: license-file
|
|
27
|
+
|
|
28
|
+
# SmartGridready CommHandler
|
|
29
|
+
|
|
30
|
+
The _commhandler_ library provides the interfaces and drivers to access devices.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Contents
|
|
34
|
+
|
|
35
|
+
- [Directory Structure](#directory-structure)
|
|
36
|
+
- [Build Instructions](#build-instructions)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
## Directory Structure
|
|
40
|
+
|
|
41
|
+
- `pyproject.toml` is the main project configuration file.
|
|
42
|
+
- `setup.py` is used to build the library package using _setuptools_.
|
|
43
|
+
- `requirements.txt` contains the dependencies required to use the library.
|
|
44
|
+
- `requirements-dev.txt` contains the dependencies required to run tests.
|
|
45
|
+
- `src/sgr_commhandler` contains the source code of the library, with _sgr_commhandler_ being the root of the namespace.
|
|
46
|
+
- `tests` contains unit and integration tests.
|
|
47
|
+
- `examples` contains basic examples of using the library.
|
|
48
|
+
See [SGrPythonSamples](https://github.com/SmartGridready/SGrPythonSamples) for more detailed examples.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## Build Instructions
|
|
52
|
+
|
|
53
|
+
### Prerequisites
|
|
54
|
+
|
|
55
|
+
Check out the [SGrPython](https://github.com/SmartGridready/SGrPython) repository, e.g. in `SGrPython`.
|
|
56
|
+
|
|
57
|
+
Create and activate virtual environment:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
cd SGrPython
|
|
61
|
+
python -m venv .venv
|
|
62
|
+
|
|
63
|
+
# On Linux call this:
|
|
64
|
+
source ./.venv/bin/activate
|
|
65
|
+
|
|
66
|
+
# On Windows call this:
|
|
67
|
+
.\.venv\Scripts\Activate.ps1
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Make sure you have the _specification_ library `sgr-specification` installed in your virtual environment.
|
|
71
|
+
See [specification](../specification/README.md) for instructions.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
### Run Tests
|
|
75
|
+
|
|
76
|
+
You can run tests using `pytest` while in virtual environment.
|
|
77
|
+
|
|
78
|
+
It is not necessary to install the package locally, if you only want to run tests.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
cd SGrPython/commhandler
|
|
82
|
+
pip install -r requirements-dev.txt
|
|
83
|
+
|
|
84
|
+
pytest
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
### Build and Use Package
|
|
89
|
+
|
|
90
|
+
Build package and install in virtual environment:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
cd SGrPython/commhandler
|
|
94
|
+
pip install -e .
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
You can use the package `sgr-commhandler` from within the virtual environment now.
|
|
98
|
+
|
|
99
|
+
**Note:**
|
|
100
|
+
The designated package name `sgr-commhandler` must not be used until the _PyPI_ administrators have
|
|
101
|
+
approved a SmartGridready organization account!
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
### Clean Up
|
|
105
|
+
|
|
106
|
+
Deactivate the virtual environment after use:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
cd SGrPython
|
|
110
|
+
deactivate
|
|
111
|
+
```
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# SmartGridready CommHandler
|
|
2
|
+
|
|
3
|
+
The _commhandler_ library provides the interfaces and drivers to access devices.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Contents
|
|
7
|
+
|
|
8
|
+
- [Directory Structure](#directory-structure)
|
|
9
|
+
- [Build Instructions](#build-instructions)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
## Directory Structure
|
|
13
|
+
|
|
14
|
+
- `pyproject.toml` is the main project configuration file.
|
|
15
|
+
- `setup.py` is used to build the library package using _setuptools_.
|
|
16
|
+
- `requirements.txt` contains the dependencies required to use the library.
|
|
17
|
+
- `requirements-dev.txt` contains the dependencies required to run tests.
|
|
18
|
+
- `src/sgr_commhandler` contains the source code of the library, with _sgr_commhandler_ being the root of the namespace.
|
|
19
|
+
- `tests` contains unit and integration tests.
|
|
20
|
+
- `examples` contains basic examples of using the library.
|
|
21
|
+
See [SGrPythonSamples](https://github.com/SmartGridready/SGrPythonSamples) for more detailed examples.
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Build Instructions
|
|
25
|
+
|
|
26
|
+
### Prerequisites
|
|
27
|
+
|
|
28
|
+
Check out the [SGrPython](https://github.com/SmartGridready/SGrPython) repository, e.g. in `SGrPython`.
|
|
29
|
+
|
|
30
|
+
Create and activate virtual environment:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
cd SGrPython
|
|
34
|
+
python -m venv .venv
|
|
35
|
+
|
|
36
|
+
# On Linux call this:
|
|
37
|
+
source ./.venv/bin/activate
|
|
38
|
+
|
|
39
|
+
# On Windows call this:
|
|
40
|
+
.\.venv\Scripts\Activate.ps1
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Make sure you have the _specification_ library `sgr-specification` installed in your virtual environment.
|
|
44
|
+
See [specification](../specification/README.md) for instructions.
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Run Tests
|
|
48
|
+
|
|
49
|
+
You can run tests using `pytest` while in virtual environment.
|
|
50
|
+
|
|
51
|
+
It is not necessary to install the package locally, if you only want to run tests.
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
cd SGrPython/commhandler
|
|
55
|
+
pip install -r requirements-dev.txt
|
|
56
|
+
|
|
57
|
+
pytest
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### Build and Use Package
|
|
62
|
+
|
|
63
|
+
Build package and install in virtual environment:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
cd SGrPython/commhandler
|
|
67
|
+
pip install -e .
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
You can use the package `sgr-commhandler` from within the virtual environment now.
|
|
71
|
+
|
|
72
|
+
**Note:**
|
|
73
|
+
The designated package name `sgr-commhandler` must not be used until the _PyPI_ administrators have
|
|
74
|
+
approved a SmartGridready organization account!
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
### Clean Up
|
|
78
|
+
|
|
79
|
+
Deactivate the virtual environment after use:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
cd SGrPython
|
|
83
|
+
deactivate
|
|
84
|
+
```
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "sgr-commhandler"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "SmartGridready CommHandler Library"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = "BSD-3-Clause"
|
|
12
|
+
authors = [
|
|
13
|
+
{ name = "Robin Schoch" },
|
|
14
|
+
{ name = "Matthias Krebs" }
|
|
15
|
+
]
|
|
16
|
+
maintainers = [
|
|
17
|
+
{ name = "Matthias Krebs" }
|
|
18
|
+
]
|
|
19
|
+
dependencies = [
|
|
20
|
+
"Jinja2>=3.1.0,<4.0.0",
|
|
21
|
+
"jmespath>=1.0.0,<2.0.0",
|
|
22
|
+
"pymodbus>=3.7.0,<3.8.0",
|
|
23
|
+
"gmqtt>=0.7.0,<1.0.0",
|
|
24
|
+
"xsdata>=25.0.0,<26.0.0",
|
|
25
|
+
"xmlschema>=4.1.0,<5.0.0",
|
|
26
|
+
"aiohttp>=3.12.0,<4.0.0",
|
|
27
|
+
"certifi",
|
|
28
|
+
"cachetools>=6.2.0,<7.0.0",
|
|
29
|
+
"sgr-specification>=2.1.0,<3.0.0"
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
Homepage = "https://www.smartgridready.ch/"
|
|
34
|
+
Documentation = "https://smartgridready.github.io/SGrPython/docs/commhandler/"
|
|
35
|
+
Repository = "https://github.com/SmartGridready/SGrPython.git"
|
|
36
|
+
Issues = "https://github.com/SmartGridready/SGrPython/issues"
|
|
37
|
+
Changelog = "https://github.com/SmartGridready/SGrPython/blob/master/commhandler/CHANGELOG.md"
|
|
38
|
+
|
|
39
|
+
[tool.setuptools]
|
|
40
|
+
package-dir = {"" = "src"}
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.packages.find]
|
|
43
|
+
where = ["src"]
|
|
44
|
+
|
|
45
|
+
[tool.pyright]
|
|
46
|
+
exclude = ["**/node_modules", "**/__pycache__", "examples"]
|
|
47
|
+
|
|
48
|
+
[tool.pytest.ini_options]
|
|
49
|
+
pythonpath = [ "src" ]
|
|
50
|
+
asyncio_default_fixture_loop_scope = "session"
|
|
51
|
+
asyncio_mode = "strict"
|
|
52
|
+
log_cli = true
|
|
53
|
+
log_cli_level = "DEBUG"
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
__all__ = [
|
|
2
|
+
"SGrBaseInterface",
|
|
3
|
+
"FunctionalProfile",
|
|
4
|
+
"DataPoint",
|
|
5
|
+
"DataPointProtocol",
|
|
6
|
+
"DataPointValidator",
|
|
7
|
+
"DeviceInformation",
|
|
8
|
+
"ConfigurationParameter",
|
|
9
|
+
"DynamicParameter",
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
from sgr_commhandler.api.configuration_parameter import (
|
|
13
|
+
ConfigurationParameter
|
|
14
|
+
)
|
|
15
|
+
from sgr_commhandler.api.dynamic_parameter import (
|
|
16
|
+
DynamicParameter
|
|
17
|
+
)
|
|
18
|
+
from sgr_commhandler.api.data_point_api import (
|
|
19
|
+
DataPoint,
|
|
20
|
+
DataPointProtocol,
|
|
21
|
+
DataPointValidator,
|
|
22
|
+
)
|
|
23
|
+
from sgr_commhandler.api.device_api import (
|
|
24
|
+
DeviceInformation,
|
|
25
|
+
SGrBaseInterface
|
|
26
|
+
)
|
|
27
|
+
from sgr_commhandler.api.functional_profile_api import (
|
|
28
|
+
FunctionalProfile
|
|
29
|
+
)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
from sgr_specification.v0.product import (
|
|
4
|
+
ConfigurationList,
|
|
5
|
+
ConfigurationListElement,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def build_configuration_parameters(params: Optional[ConfigurationList]) -> list['ConfigurationParameter']:
|
|
10
|
+
"""
|
|
11
|
+
Constructs a configuration parameter list.
|
|
12
|
+
|
|
13
|
+
Parameters
|
|
14
|
+
----------
|
|
15
|
+
params : Optional[ConfigurationList]
|
|
16
|
+
The configuration list of an EID
|
|
17
|
+
|
|
18
|
+
Returns
|
|
19
|
+
-------
|
|
20
|
+
list[ConfigurationParameter]
|
|
21
|
+
a list of configuration parameters
|
|
22
|
+
"""
|
|
23
|
+
if params is None:
|
|
24
|
+
return []
|
|
25
|
+
return [
|
|
26
|
+
ConfigurationParameter(x) for x in params.configuration_list_element
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ConfigurationParameter:
|
|
31
|
+
"""
|
|
32
|
+
Implements an EID configuration parameter.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def __init__(self, parameter: ConfigurationListElement):
|
|
36
|
+
"""
|
|
37
|
+
Constructs a configuration parameter.
|
|
38
|
+
|
|
39
|
+
Parameters
|
|
40
|
+
----------
|
|
41
|
+
parameter : ConfigurationListElement
|
|
42
|
+
A configuration list element of the SGr specification
|
|
43
|
+
"""
|
|
44
|
+
translation = parameter.configuration_description
|
|
45
|
+
self.label = translation[0].label
|
|
46
|
+
self.name = parameter.name
|
|
47
|
+
self.type = parameter.data_type
|
|
48
|
+
self.description = translation[0].text_element
|
|
49
|
+
self.default_value = parameter.default_value
|
|
50
|
+
|
|
51
|
+
def __str__(self) -> str:
|
|
52
|
+
"""
|
|
53
|
+
Converts to string.
|
|
54
|
+
|
|
55
|
+
Returns
|
|
56
|
+
----------
|
|
57
|
+
str
|
|
58
|
+
A string
|
|
59
|
+
"""
|
|
60
|
+
return f'{self.label} - {self.name}'
|
|
61
|
+
|
|
62
|
+
def __repr__(self):
|
|
63
|
+
"""
|
|
64
|
+
Gets an object description as string.
|
|
65
|
+
|
|
66
|
+
Returns
|
|
67
|
+
----------
|
|
68
|
+
str
|
|
69
|
+
A string
|
|
70
|
+
"""
|
|
71
|
+
return f'<ConfigurationParameter={self.name}>'
|