OpenSMI-Core 0.1__py3-none-any.whl
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.
- opensmi/core/__init__.py +21 -0
- opensmi/core/async_task_mixin.py +55 -0
- opensmi/core/base_server.py +75 -0
- opensmi/core/base_ua_object.py +120 -0
- opensmi/core/config.py +92 -0
- opensmi/core/enums.py +24 -0
- opensmi/core/errors.py +67 -0
- opensmi/core/frozen.py +26 -0
- opensmi/core/hook.py +22 -0
- opensmi/core/lifecycle_mixin.py +275 -0
- opensmi/core/logging.py +161 -0
- opensmi/core/meta.py +51 -0
- opensmi/core/mixin_helpers.py +19 -0
- opensmi/core/protocols.py +32 -0
- opensmi/core/repr_mixin.py +33 -0
- opensmi/core/signal.py +36 -0
- opensmi/core/subscription_manager.py +190 -0
- opensmi/core/ua.py +17 -0
- opensmi/core/ua_enums.py +93 -0
- opensmi/core/ua_node_util.py +239 -0
- opensmi/core/unit_all.py +2187 -0
- opensmi/core/unit_base.py +71 -0
- opensmi/core/unset.py +22 -0
- opensmi_core-0.1.dist-info/METADATA +32 -0
- opensmi_core-0.1.dist-info/RECORD +28 -0
- opensmi_core-0.1.dist-info/WHEEL +5 -0
- opensmi_core-0.1.dist-info/licenses/LICENSE +18 -0
- opensmi_core-0.1.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 OpenSMI Contributors
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
"""Base class for all autogenerated units, see `Unit`."""
|
|
6
|
+
|
|
7
|
+
from enum import Enum
|
|
8
|
+
from typing import Self
|
|
9
|
+
|
|
10
|
+
from asyncua import ua
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class BaseUnit(Enum):
|
|
14
|
+
"""Base class for all autogenerated units, see `Unit`."""
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def symbol(self) -> str:
|
|
18
|
+
"""Symbol of the Unit, e.g. ``cm`` for centimeters."""
|
|
19
|
+
return self.value[0]
|
|
20
|
+
|
|
21
|
+
@classmethod
|
|
22
|
+
def from_ua_unit_id(cls, ua_unit_id: int) -> Self:
|
|
23
|
+
"""Return the unique unit corresponding to given OPC UA unit ID."""
|
|
24
|
+
for unit in cls:
|
|
25
|
+
if unit.ua_unit_id == ua_unit_id:
|
|
26
|
+
return unit
|
|
27
|
+
|
|
28
|
+
msg = f"Unknown OPC UA unit ID: {ua_unit_id}"
|
|
29
|
+
raise ValueError(msg)
|
|
30
|
+
|
|
31
|
+
@classmethod
|
|
32
|
+
def from_symbol(cls, symbol: str) -> Self:
|
|
33
|
+
"""Return the unique unit corresponding to given symbol.
|
|
34
|
+
|
|
35
|
+
:raises ValueError: if the symbol is not valid or ambiguous.
|
|
36
|
+
"""
|
|
37
|
+
matches = [unit for unit in cls if unit.symbol == symbol]
|
|
38
|
+
|
|
39
|
+
if not matches:
|
|
40
|
+
msg = f"Unknown Unit symbol: {symbol}"
|
|
41
|
+
raise ValueError(msg)
|
|
42
|
+
|
|
43
|
+
if len(matches) > 1:
|
|
44
|
+
ua_unit_ids = ", ".join(str(unit.ua_unit_id) for unit in matches)
|
|
45
|
+
msg = f"Ambiguous Unit symbol {symbol!r}; unit IDs: {ua_unit_ids}"
|
|
46
|
+
raise ValueError(msg)
|
|
47
|
+
|
|
48
|
+
return matches[0]
|
|
49
|
+
|
|
50
|
+
@property
|
|
51
|
+
def ua_unit_id(self) -> int:
|
|
52
|
+
"""OPC UA Unit ID for the unit."""
|
|
53
|
+
return self.value[1]
|
|
54
|
+
|
|
55
|
+
@property
|
|
56
|
+
def ua_eu_information(self) -> ua.EUInformation:
|
|
57
|
+
"""Return the OPC UA EU information."""
|
|
58
|
+
return ua.EUInformation(
|
|
59
|
+
NamespaceUri="http://www.opcfoundation.org/UA/units/un/cefact", # type: ignore
|
|
60
|
+
UnitId=ua.Int32(self.ua_unit_id), # type: ignore
|
|
61
|
+
DisplayName=ua.LocalizedText(self.symbol),
|
|
62
|
+
Description=ua.LocalizedText(self.name),
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
def __str__(self) -> str:
|
|
66
|
+
"""Symbol of the Unit."""
|
|
67
|
+
return self.symbol
|
|
68
|
+
|
|
69
|
+
def __repr__(self) -> str:
|
|
70
|
+
"""Descriptive string representation of the Unit."""
|
|
71
|
+
return f"{type(self).__name__}.{self.name}(symbol={self.symbol!r}, ua_unit_id={self.ua_unit_id!r})"
|
opensmi/core/unset.py
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 OpenSMI Contributors
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
|
|
5
|
+
"""Sentinel to distinguish unset values from ``None`` values."""
|
|
6
|
+
|
|
7
|
+
from typing import Final, TypeGuard, TypeVar
|
|
8
|
+
|
|
9
|
+
_T = TypeVar("_T")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Unset:
|
|
13
|
+
"""Sentinel to distinguish unset values from ``None`` values."""
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
UNSET: Final = Unset()
|
|
17
|
+
"""Singleton instance to signal unset values."""
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def is_set(value: _T | Unset) -> TypeGuard[_T]:
|
|
21
|
+
"""Return ``True`` if given ``value`` is set."""
|
|
22
|
+
return value is not UNSET
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: OpenSMI-Core
|
|
3
|
+
Version: 0.1
|
|
4
|
+
Summary: Smart Machine Interface core functionality for server and client applications.
|
|
5
|
+
Author-email: Carsten Harms <Carsten.Harms@dfki.de>, Simon Jungbluth <Simon.Jungbluth@smartfactory.de>
|
|
6
|
+
Classifier: Development Status :: 4 - Beta
|
|
7
|
+
Classifier: Intended Audience :: Developers
|
|
8
|
+
Classifier: Intended Audience :: Information Technology
|
|
9
|
+
Classifier: Intended Audience :: Manufacturing
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
16
|
+
Classifier: Topic :: Communications
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Interface Engine/Protocol Translator
|
|
19
|
+
Classifier: Topic :: Software Development :: Embedded Systems
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
21
|
+
Classifier: Typing :: Typed
|
|
22
|
+
Requires-Python: >=3.11
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: asyncua<3,>=2.0.1
|
|
25
|
+
Requires-Dist: structlog>=26
|
|
26
|
+
Requires-Dist: typing-extensions>=4.16.0
|
|
27
|
+
Provides-Extra: rich
|
|
28
|
+
Requires-Dist: rich>=15.0.0; extra == "rich"
|
|
29
|
+
Requires-Dist: colorama>=0.4; sys_platform == "win32" and extra == "rich"
|
|
30
|
+
Provides-Extra: json
|
|
31
|
+
Requires-Dist: orjson<4,>=3; extra == "json"
|
|
32
|
+
Dynamic: license-file
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
opensmi/core/__init__.py,sha256=myy_q8shptZwUKBXa8ayckKTzY7VzzeRKvHPWz1mKIs,800
|
|
2
|
+
opensmi/core/async_task_mixin.py,sha256=wZEGutRM1s15Qblk-qb_2AhIupOYiNarcj-pstM5GcI,1576
|
|
3
|
+
opensmi/core/base_server.py,sha256=FYlR_06yusIGp03TrBTu-_mdEKeq-WrTbTgjwXX9e14,2781
|
|
4
|
+
opensmi/core/base_ua_object.py,sha256=E8ymdpUn21hGtGlo7Vjvg8aBcaO2nPPdxk_afdPxCjI,3752
|
|
5
|
+
opensmi/core/config.py,sha256=Q2fevnPE_F6nRG8Mz_5aIi3L9ioDf97WJmlrQREokiA,3183
|
|
6
|
+
opensmi/core/enums.py,sha256=UStae4GL9s_kEl3ZGFWAWOU_0_EQdIyYe_98t6RnGxQ,915
|
|
7
|
+
opensmi/core/errors.py,sha256=V8QNFsnTZP7dLVSrHN8yPWrqLIy6vwsFQQH3A_-pKks,1981
|
|
8
|
+
opensmi/core/frozen.py,sha256=tH9Owkg_olSCZB4Y_Qhv9yYQKrovJCKFP2xKXa4-oW0,781
|
|
9
|
+
opensmi/core/hook.py,sha256=nCBB26Y-QNn3oUVLe8fl-X72ujQcrPmC2nor12Nz_jA,685
|
|
10
|
+
opensmi/core/lifecycle_mixin.py,sha256=Oswjdf4EPGFnx6EImK9SlwcyIB5mIMhhhugckVKYNNU,11158
|
|
11
|
+
opensmi/core/logging.py,sha256=k6T_lg8uyc7n-s5o4ZQp5Fb-w_FB0xvzyc8FsbhklqM,5262
|
|
12
|
+
opensmi/core/meta.py,sha256=TYQuohKPX8b7Dnjdf4mfa3HiRPQr9tZNCQlrYFOb-Kw,1575
|
|
13
|
+
opensmi/core/mixin_helpers.py,sha256=iAIGTrG_C_6wGRHgAoiXKTMvGuGUoqUlQyMsvS3q9Oo,498
|
|
14
|
+
opensmi/core/protocols.py,sha256=A4pQx3eCDbe4GFQr2wcL2e6eIbOSPVuIjxuMZFVIYSY,700
|
|
15
|
+
opensmi/core/repr_mixin.py,sha256=rbeuNKziv8VGJg3ZP9R6bCc1z8V4kiOKFZ-5UfdIddI,1127
|
|
16
|
+
opensmi/core/signal.py,sha256=vQLtVuGCB_W3i0mkjTSgh8P8BA5g5WYsz-v7ewwRpMs,1170
|
|
17
|
+
opensmi/core/subscription_manager.py,sha256=OulHPIVFzewZWa5tV5T35g91Cqb8dmLHKYXLtoR2SxE,8461
|
|
18
|
+
opensmi/core/ua.py,sha256=0HsWOsZwbjvt6EXhq7YLEbsi7Rmz0Dq2BCiVDirlL54,328
|
|
19
|
+
opensmi/core/ua_enums.py,sha256=WkcGXFZJXOJaTUiq1T8inC18uQeQFTnycalUikscQ6c,3902
|
|
20
|
+
opensmi/core/ua_node_util.py,sha256=6r0D7fBXX2LJx3l12hVo5fkxeDIeziXFmzGgD2QtlH8,9496
|
|
21
|
+
opensmi/core/unit_all.py,sha256=V_Q9VjEFxm_KyU2NY7aduGmjOOT1d8YLtzApbaMn2qY,102964
|
|
22
|
+
opensmi/core/unit_base.py,sha256=xY1EYy1sw-34FHr5I1-XxZ2ASE2iH8Zf8RmX1WWi_04,2240
|
|
23
|
+
opensmi/core/unset.py,sha256=ki6fQ6QEvyIHz4oDKMs2O9nAYRS6rXoMsblurvHZhVI,508
|
|
24
|
+
opensmi_core-0.1.dist-info/licenses/LICENSE,sha256=3OGTGWBqU2ALHuARh4vkKHT1dXxm5TXYO7OL0k7JUuI,1078
|
|
25
|
+
opensmi_core-0.1.dist-info/METADATA,sha256=I8VrRtEXSHSy5rvfxevVTzGU6R2E8gm2Bi7F-gYI5-M,1423
|
|
26
|
+
opensmi_core-0.1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
27
|
+
opensmi_core-0.1.dist-info/top_level.txt,sha256=RNwRHgN-Y6DKEdMS39Fx2JG5UVX9gQ0t2Cw8X8hmIqM,8
|
|
28
|
+
opensmi_core-0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 OpenSMI Contributors.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
6
|
+
associated documentation files (the "Software"), to deal in the Software without restriction, including
|
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
|
|
9
|
+
following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial
|
|
12
|
+
portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
|
|
15
|
+
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
|
|
16
|
+
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
18
|
+
USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
opensmi
|