OpenSMI-Server 0.1__tar.gz → 0.2__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.
- opensmi_server-0.2/.github/workflows/api-docs.yml +58 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/PKG-INFO +9 -1
- {opensmi_server-0.1 → opensmi_server-0.2}/README.md +7 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/dummy_machine.py +3 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/pyproject.toml +2 -1
- {opensmi_server-0.1 → opensmi_server-0.2}/src/OpenSMI_Server.egg-info/PKG-INFO +9 -1
- {opensmi_server-0.1 → opensmi_server-0.2}/src/OpenSMI_Server.egg-info/SOURCES.txt +1 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/OpenSMI_Server.egg-info/scm_file_list.json +1 -0
- opensmi_server-0.2/src/OpenSMI_Server.egg-info/scm_version.json +8 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/_server.py +35 -6
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/base_callable.py +14 -2
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/base_machinery_item.py +1 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/base_method.py +1 -4
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/mixins/ua_object_container_mixins.py +1 -1
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/mixins/ua_variable_container_mixins.py +110 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/ua_variable.py +2 -1
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/ua_variable_containers.py +25 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/tools/auto_generate_nodesets.py +5 -6
- opensmi_server-0.1/src/OpenSMI_Server.egg-info/scm_version.json +0 -8
- {opensmi_server-0.1 → opensmi_server-0.2}/.github/workflows/python-publish.yml +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/.gitignore +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/LICENSE +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/LICENSES/CC0-1.0.txt +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/LICENSES/MIT.txt +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/MANIFEST.in +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/docs/development.md +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/docs/faq.md +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/docs/machinery_item.md +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/docs/methods.md +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/docs/migration.md +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/docs/skills.md +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/__init__.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/composite_skill.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/config.toml +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/continuous_skill.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/continuous_skill_self_halting.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/dummy_component.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/dummy_method.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/dummy_skill.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/dummy_skill_resources.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/dummy_skill_simple.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/main.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/resources.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/startup_skill.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/dummy/suspendable_dummy_skill.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/examples/quick_start/main.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/setup.cfg +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/OpenSMI_Server.egg-info/dependency_links.txt +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/OpenSMI_Server.egg-info/requires.txt +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/OpenSMI_Server.egg-info/top_level.txt +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/__init__.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/access_control.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/base_feasibility_check.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/base_machine.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/base_precondition_check.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/base_skill.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/base_startup_skill.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/common.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/config.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/interfaces.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/lock.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/mixins/__init__.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/mixins/lockable_mixin.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/mixins/notification_mixins.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/mixins/parent_mixin.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/mixins/requirements_mixin.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/mixins/skill_logic_mixins.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/mixins/spatial_object_mixin.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/Opc.Ua.Di.NodeSet2.xml +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/Opc.Ua.Machinery.NodeSet2.xml +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/Opc.Ua.RSL.NodeSet2.xml +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/Opc.Ua.SmartFactory.MachineSet.NodeSet2.xml +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/Opc.Ua.SmartFactory.SkillSet.NodeSet2.xml +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/__init__.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/di.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/machinery.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/rsl.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/smart_factory_machine_set.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/smart_factory_skill_set.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/notification.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/protocols.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/resource.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/spatial_object.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/ua_fsm.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/ua_object.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/ua_object_containers.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/user.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/tools/create_password.py +0 -0
- {opensmi_server-0.1 → opensmi_server-0.2}/tools/nodeset.py.template +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Simple workflow for deploying static content to GitHub Pages
|
|
2
|
+
name: Publish API doc to Pages
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
# Runs on pushes targeting the default branch
|
|
6
|
+
push:
|
|
7
|
+
branches: ["main"]
|
|
8
|
+
|
|
9
|
+
# Allows you to run this workflow manually from the Actions tab
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
pages: write
|
|
16
|
+
id-token: write
|
|
17
|
+
|
|
18
|
+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
19
|
+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
20
|
+
concurrency:
|
|
21
|
+
group: "pages"
|
|
22
|
+
cancel-in-progress: false
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
# Single deploy job since we're just deploying
|
|
26
|
+
deploy:
|
|
27
|
+
environment:
|
|
28
|
+
name: github-pages
|
|
29
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
30
|
+
runs-on: ubuntu-latest
|
|
31
|
+
steps:
|
|
32
|
+
- name: Checkout
|
|
33
|
+
uses: actions/checkout@v4
|
|
34
|
+
|
|
35
|
+
- name: Set up Python
|
|
36
|
+
uses: actions/setup-python@v6
|
|
37
|
+
with:
|
|
38
|
+
python-version: "3.13"
|
|
39
|
+
|
|
40
|
+
- name: Install dependencies
|
|
41
|
+
run: |
|
|
42
|
+
pip install pydoctor
|
|
43
|
+
|
|
44
|
+
- name: Generate API documentation
|
|
45
|
+
run: |
|
|
46
|
+
pydoctor
|
|
47
|
+
|
|
48
|
+
- name: Setup Pages
|
|
49
|
+
uses: actions/configure-pages@v5
|
|
50
|
+
|
|
51
|
+
- name: Upload artifact
|
|
52
|
+
uses: actions/upload-pages-artifact@v3
|
|
53
|
+
with:
|
|
54
|
+
path: './apidocs'
|
|
55
|
+
|
|
56
|
+
- name: Deploy to GitHub Pages
|
|
57
|
+
id: deployment
|
|
58
|
+
uses: actions/deploy-pages@v5
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: OpenSMI-Server
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2
|
|
4
4
|
Summary: Asynchronous Python framework for building Smart Machine Interface-compliant OPC UA servers.
|
|
5
5
|
Author-email: Carsten Harms <Carsten.Harms@dfki.de>, Simon Jungbluth <Simon.Jungbluth@smartfactory.de>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Project-URL: Repository, https://github.com/SmartFactory-KL/opensmi-server
|
|
8
|
+
Project-URL: Documentation, https://smartfactory-kl.github.io/opensmi-server/
|
|
8
9
|
Classifier: Development Status :: 4 - Beta
|
|
9
10
|
Classifier: Framework :: AsyncIO
|
|
10
11
|
Classifier: Intended Audience :: Developers
|
|
@@ -37,6 +38,13 @@ Provides-Extra: json
|
|
|
37
38
|
Requires-Dist: orjson<4,>=3; extra == "json"
|
|
38
39
|
Dynamic: license-file
|
|
39
40
|
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
[](https://smartfactory-kl.github.io/opensmi-server/)
|
|
44
|
+
[](https://pypi.org/project/opensmi-server/)
|
|
45
|
+
[](https://pypi.org/project/opensmi-server/)
|
|
46
|
+
[](LICENSE)
|
|
47
|
+
|
|
40
48
|
# OpenSMI Server
|
|
41
49
|
|
|
42
50
|
**Open Smart Machine Interface (SMI)** provides an abstract, standardized, vendor-neutral way to interact safely
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
[](https://smartfactory-kl.github.io/opensmi-server/)
|
|
4
|
+
[](https://pypi.org/project/opensmi-server/)
|
|
5
|
+
[](https://pypi.org/project/opensmi-server/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
|
|
1
8
|
# OpenSMI Server
|
|
2
9
|
|
|
3
10
|
**Open Smart Machine Interface (SMI)** provides an abstract, standardized, vendor-neutral way to interact safely
|
|
@@ -84,6 +84,9 @@ class DummyMachine(
|
|
|
84
84
|
# Components
|
|
85
85
|
await self.add_component(DummyComponent(name="DummyComponent", param=42))
|
|
86
86
|
|
|
87
|
+
# add component Monitoring variable to our own Monitoring
|
|
88
|
+
await self.monitoring.add(self.components.DummyComponent.monitoring.RandomValue)
|
|
89
|
+
|
|
87
90
|
# Methods
|
|
88
91
|
await self.add_method(DummyMethod(name="DummyMethod"))
|
|
89
92
|
|
|
@@ -47,6 +47,7 @@ dependencies = [
|
|
|
47
47
|
|
|
48
48
|
[project.urls]
|
|
49
49
|
Repository = "https://github.com/SmartFactory-KL/opensmi-server"
|
|
50
|
+
Documentation = "https://smartfactory-kl.github.io/opensmi-server/"
|
|
50
51
|
|
|
51
52
|
[project.optional-dependencies]
|
|
52
53
|
rich = [
|
|
@@ -182,5 +183,5 @@ add-package = ["src/opensmi/server"]
|
|
|
182
183
|
docformat = "restructuredtext"
|
|
183
184
|
theme = "readthedocs"
|
|
184
185
|
# verbose = 1
|
|
185
|
-
warnings-as-errors = true
|
|
186
|
+
# warnings-as-errors = true
|
|
186
187
|
intersphinx = ["https://opcua-asyncio.readthedocs.io/en/latest/objects.inv"] # TODO(CaHa): does not work
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: OpenSMI-Server
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2
|
|
4
4
|
Summary: Asynchronous Python framework for building Smart Machine Interface-compliant OPC UA servers.
|
|
5
5
|
Author-email: Carsten Harms <Carsten.Harms@dfki.de>, Simon Jungbluth <Simon.Jungbluth@smartfactory.de>
|
|
6
6
|
License-Expression: MIT
|
|
7
7
|
Project-URL: Repository, https://github.com/SmartFactory-KL/opensmi-server
|
|
8
|
+
Project-URL: Documentation, https://smartfactory-kl.github.io/opensmi-server/
|
|
8
9
|
Classifier: Development Status :: 4 - Beta
|
|
9
10
|
Classifier: Framework :: AsyncIO
|
|
10
11
|
Classifier: Intended Audience :: Developers
|
|
@@ -37,6 +38,13 @@ Provides-Extra: json
|
|
|
37
38
|
Requires-Dist: orjson<4,>=3; extra == "json"
|
|
38
39
|
Dynamic: license-file
|
|
39
40
|
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+
[](https://smartfactory-kl.github.io/opensmi-server/)
|
|
44
|
+
[](https://pypi.org/project/opensmi-server/)
|
|
45
|
+
[](https://pypi.org/project/opensmi-server/)
|
|
46
|
+
[](LICENSE)
|
|
47
|
+
|
|
40
48
|
# OpenSMI Server
|
|
41
49
|
|
|
42
50
|
**Open Smart Machine Interface (SMI)** provides an abstract, standardized, vendor-neutral way to interact safely
|
|
@@ -10,7 +10,9 @@ import sys
|
|
|
10
10
|
import time
|
|
11
11
|
import warnings
|
|
12
12
|
from collections.abc import AsyncGenerator, Iterator
|
|
13
|
+
from dataclasses import dataclass
|
|
13
14
|
from enum import IntEnum, auto
|
|
15
|
+
from importlib.resources import files
|
|
14
16
|
from pathlib import Path
|
|
15
17
|
from typing import TYPE_CHECKING, Self
|
|
16
18
|
|
|
@@ -80,6 +82,16 @@ def _create_key_and_certificate(config: UaServerConfiguration) -> None:
|
|
|
80
82
|
f.write(cert.public_bytes(serialization.Encoding.DER))
|
|
81
83
|
|
|
82
84
|
|
|
85
|
+
@dataclass(slots=True, frozen=True)
|
|
86
|
+
class NodesetReference:
|
|
87
|
+
"""A pointer to an XML asset. Resolved lazily via ``importlib.resources``."""
|
|
88
|
+
|
|
89
|
+
package: str
|
|
90
|
+
"""The package the nodeset lives in."""
|
|
91
|
+
namespace: type[NamespaceProvider]
|
|
92
|
+
"""The namespace provider of the nodeset."""
|
|
93
|
+
|
|
94
|
+
|
|
83
95
|
class ServerState(IntEnum):
|
|
84
96
|
"""Operating states of the `Server`."""
|
|
85
97
|
|
|
@@ -108,6 +120,8 @@ class Server(
|
|
|
108
120
|
self._state = ServerState.STOPPED
|
|
109
121
|
self._ua_enums: dict[type[IntEnum], ua.NodeId] = {}
|
|
110
122
|
"""Maps created custom enums to OPC UA type nodes."""
|
|
123
|
+
self._ua_nodesets_xml: dict[str, NodesetReference] = {}
|
|
124
|
+
"""Maps nodeset XML URIs to information how to load the corresponding XML file."""
|
|
111
125
|
if config_path:
|
|
112
126
|
self.load_config(config_path)
|
|
113
127
|
else:
|
|
@@ -156,6 +170,10 @@ class Server(
|
|
|
156
170
|
|
|
157
171
|
await self._setup_ua_server()
|
|
158
172
|
|
|
173
|
+
# register our nodesets
|
|
174
|
+
for namespace in NODE_SETS.values():
|
|
175
|
+
self.ua_register_nodeset_xml(namespace=namespace, package="opensmi.server.nodesets")
|
|
176
|
+
|
|
159
177
|
# Import Nodeset (and its required nodesets)
|
|
160
178
|
await self.ua_import_nodeset(SmartFactoryMachineSetNodeIds)
|
|
161
179
|
|
|
@@ -170,16 +188,26 @@ class Server(
|
|
|
170
188
|
def access_control(self) -> AccessControl:
|
|
171
189
|
return self._access_control
|
|
172
190
|
|
|
173
|
-
|
|
191
|
+
def ua_register_nodeset_xml(self, *, namespace: type[NamespaceProvider], package: str) -> None:
|
|
192
|
+
"""Register the given nodeset XML file living in `package`. Overrides existing nodesets based on URI."""
|
|
193
|
+
self._ua_nodesets_xml[namespace.URI] = NodesetReference(
|
|
194
|
+
package=package,
|
|
195
|
+
namespace=namespace,
|
|
196
|
+
)
|
|
197
|
+
self.logger.debug("Registered nodeset XML", package=package, uri=namespace.URI)
|
|
198
|
+
|
|
199
|
+
async def ua_import_xml(self, *, path: Path | None = None, xml_string: str | None = None) -> int:
|
|
174
200
|
"""Import XML nodeset from given ``path``. Returns the namespace index on success."""
|
|
175
201
|
time_start = time.monotonic()
|
|
176
|
-
nodes = await self.ua_server.import_xml(
|
|
202
|
+
nodes = await self.ua_server.import_xml(
|
|
203
|
+
path=path, # pyright: ignore[reportArgumentType]
|
|
204
|
+
xmlstring=xml_string,
|
|
205
|
+
)
|
|
177
206
|
idx = nodes[0].NamespaceIndex
|
|
178
207
|
namespace_array = await self.ua_server.get_namespace_array()
|
|
179
208
|
uri: str = namespace_array[idx]
|
|
180
209
|
self.logger.info(
|
|
181
210
|
"Imported nodes from XML node set!",
|
|
182
|
-
file_name=path.name,
|
|
183
211
|
uri=uri,
|
|
184
212
|
ns_idx=idx,
|
|
185
213
|
no_of_nodes=len(nodes),
|
|
@@ -201,11 +229,12 @@ class Server(
|
|
|
201
229
|
if index is not None:
|
|
202
230
|
return index
|
|
203
231
|
|
|
204
|
-
|
|
205
|
-
for uri in namespace.REQUIRED_URIS: # import all requirements first (transitive)
|
|
232
|
+
ref: NodesetReference = self._ua_nodesets_xml[uri]
|
|
233
|
+
for uri in ref.namespace.REQUIRED_URIS: # import all requirements first (transitive)
|
|
206
234
|
await self.ua_import_nodeset(uri)
|
|
207
235
|
|
|
208
|
-
|
|
236
|
+
xml_string = files(ref.package).joinpath(ref.namespace.FILE_NAME).read_text(encoding="utf-8")
|
|
237
|
+
index = await self.ua_import_xml(xml_string=xml_string)
|
|
209
238
|
|
|
210
239
|
# update our namespace mapping
|
|
211
240
|
for ns_idx, namespace in enumerate(await self.ua_server.get_namespace_array()):
|
|
@@ -12,7 +12,9 @@ from collections.abc import AsyncGenerator
|
|
|
12
12
|
from asyncua import ua
|
|
13
13
|
from asyncua.common.node import Node
|
|
14
14
|
from asyncua.crypto.permission_rules import UserRole
|
|
15
|
+
from asyncua.ua.uaerrors import BadNoMatch
|
|
15
16
|
from opensmi.core.lifecycle_mixin import lifecycle
|
|
17
|
+
from opensmi.core.ua_node_util import get_node_id
|
|
16
18
|
from typing_extensions import override
|
|
17
19
|
|
|
18
20
|
from opensmi.server.interfaces import AbstractCallable
|
|
@@ -66,8 +68,18 @@ class BaseCallable(UaObject, NotificationForwarderMixin, AbstractCallable):
|
|
|
66
68
|
self._ua_sub_node = await self._get_sub_node()
|
|
67
69
|
assert self._ua_sub_node is not None
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
ua_min_access_level_browse_name = f"{ns}:MinAccessLevel"
|
|
72
|
+
try:
|
|
73
|
+
ua_min_access_level_node = await self._ua_sub_node.get_child(ua_min_access_level_browse_name)
|
|
74
|
+
await ua_min_access_level_node.write_value(ua.Int32(self.minimum_access_level))
|
|
75
|
+
except BadNoMatch: # optional in nodeset
|
|
76
|
+
node_id = get_node_id(self._ua_sub_node, name=ua_min_access_level_browse_name, ns_idx=None)
|
|
77
|
+
await self._ua_sub_node.add_variable(
|
|
78
|
+
node_id,
|
|
79
|
+
ua_min_access_level_browse_name,
|
|
80
|
+
ua.Int32(self.minimum_access_level),
|
|
81
|
+
)
|
|
82
|
+
|
|
71
83
|
yield
|
|
72
84
|
# no shutdown
|
|
73
85
|
|
|
@@ -399,6 +399,7 @@ class BaseMachineryItem(UaObject, AbstractUaLogger):
|
|
|
399
399
|
AttributesMixin.lifecycle_attributes,
|
|
400
400
|
MonitoringMixin.lifecycle_monitoring,
|
|
401
401
|
ParameterSetMixin.lifecycle_parameter_set,
|
|
402
|
+
IdentificationMixin.lifecycle_identification,
|
|
402
403
|
)
|
|
403
404
|
)
|
|
404
405
|
async def lifecycle_machinery_item(self) -> AsyncGenerator[None]:
|
|
@@ -24,10 +24,7 @@ class BaseMethod(BaseCallable, AbstractMethod):
|
|
|
24
24
|
|
|
25
25
|
@override
|
|
26
26
|
async def _get_definition(self) -> UaObjectDefinition:
|
|
27
|
-
return UaObjectDefinition(
|
|
28
|
-
object_type=SmartFactorySkillSetNodeIds.BaseMethodType,
|
|
29
|
-
instantiate_optional=True, # TODO(CaHa): instantiate only what is actually needed
|
|
30
|
-
)
|
|
27
|
+
return UaObjectDefinition(object_type=SmartFactorySkillSetNodeIds.BaseMethodType)
|
|
31
28
|
|
|
32
29
|
@override
|
|
33
30
|
async def _get_sub_node(self) -> Node:
|
{opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/mixins/ua_object_container_mixins.py
RENAMED
|
@@ -45,7 +45,7 @@ class ResourcesMixin:
|
|
|
45
45
|
async def _init_resources(self) -> None:
|
|
46
46
|
pass
|
|
47
47
|
|
|
48
|
-
@lifecycle
|
|
48
|
+
@lifecycle(before=BaseMachineryItem.lifecycle_machinery_item)
|
|
49
49
|
async def lifecycle_resources(self) -> AsyncGenerator[None]:
|
|
50
50
|
"""Initialize the resources `UaObjectContainer`."""
|
|
51
51
|
self.resources.parent = self # pyright: ignore[reportAttributeAccessIssue]
|
{opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/mixins/ua_variable_container_mixins.py
RENAMED
|
@@ -10,6 +10,7 @@ from typing import Any, Generic, cast
|
|
|
10
10
|
|
|
11
11
|
import structlog
|
|
12
12
|
from asyncua import ua
|
|
13
|
+
from asyncua.common.node import Node
|
|
13
14
|
from opensmi.core.errors import ValidationError
|
|
14
15
|
from opensmi.core.lifecycle_mixin import lifecycle
|
|
15
16
|
from opensmi.core.meta import resolve_generic_arguments
|
|
@@ -74,6 +75,33 @@ class AttributesMixin(Generic[AttributesType]):
|
|
|
74
75
|
get_logger(self, _LOGGER).debug("Instantiated Container", type=type_)
|
|
75
76
|
return self.__attributes
|
|
76
77
|
|
|
78
|
+
@deprecated("Please use a typed Attributes subclass instead!")
|
|
79
|
+
async def add_attribute_variable(
|
|
80
|
+
self,
|
|
81
|
+
name: str,
|
|
82
|
+
val: Any,
|
|
83
|
+
*,
|
|
84
|
+
varianttype: ua.VariantType | None = None,
|
|
85
|
+
datatype: ua.NodeId | int | None = None,
|
|
86
|
+
historize: bool = False,
|
|
87
|
+
unit: str | int | None = None,
|
|
88
|
+
_range: tuple[float, float] | None = None,
|
|
89
|
+
) -> Node:
|
|
90
|
+
"""Add a new monitoring variable to this UaObject."""
|
|
91
|
+
if datatype is not None:
|
|
92
|
+
raise NotImplementedError
|
|
93
|
+
if varianttype is not None:
|
|
94
|
+
val = ua.Variant(val, varianttype)
|
|
95
|
+
variable = UaVariable(
|
|
96
|
+
initial_value=val,
|
|
97
|
+
name=name,
|
|
98
|
+
historize=historize,
|
|
99
|
+
unit=unit,
|
|
100
|
+
range=_range,
|
|
101
|
+
)
|
|
102
|
+
await self.attributes.add(variable, exist_ok=True)
|
|
103
|
+
return variable.ua_node
|
|
104
|
+
|
|
77
105
|
def __init_subclass__(cls, **kwargs) -> None:
|
|
78
106
|
"""Extract type for attributes."""
|
|
79
107
|
super().__init_subclass__(**kwargs)
|
|
@@ -114,6 +142,33 @@ class MonitoringMixin(Generic[MonitoringType]):
|
|
|
114
142
|
"""
|
|
115
143
|
return await self.monitoring.read_all()
|
|
116
144
|
|
|
145
|
+
@deprecated("Please use a typed Monitoring subclass instead!")
|
|
146
|
+
async def add_monitoring_variable(
|
|
147
|
+
self,
|
|
148
|
+
name: str,
|
|
149
|
+
val: Any,
|
|
150
|
+
*,
|
|
151
|
+
varianttype: ua.VariantType | None = None,
|
|
152
|
+
datatype: ua.NodeId | int | None = None,
|
|
153
|
+
historize: bool = False,
|
|
154
|
+
unit: str | int | None = None,
|
|
155
|
+
_range: tuple[float, float] | None = None,
|
|
156
|
+
) -> Node:
|
|
157
|
+
"""Add a new monitoring variable to this UaObject."""
|
|
158
|
+
if datatype is not None:
|
|
159
|
+
raise NotImplementedError
|
|
160
|
+
if varianttype is not None:
|
|
161
|
+
val = ua.Variant(val, varianttype)
|
|
162
|
+
variable = UaVariable(
|
|
163
|
+
initial_value=val,
|
|
164
|
+
name=name,
|
|
165
|
+
historize=historize,
|
|
166
|
+
unit=unit,
|
|
167
|
+
range=_range,
|
|
168
|
+
)
|
|
169
|
+
await self.monitoring.add(variable, exist_ok=True)
|
|
170
|
+
return variable.ua_node
|
|
171
|
+
|
|
117
172
|
def __init_subclass__(cls, **kwargs) -> None:
|
|
118
173
|
"""Extract type for monitoring."""
|
|
119
174
|
super().__init_subclass__(**kwargs)
|
|
@@ -175,6 +230,34 @@ class ParameterSetMixin(Generic[ParameterSetType]):
|
|
|
175
230
|
"""Write given value to parameter with given name."""
|
|
176
231
|
await self.parameter_set[name].write(value)
|
|
177
232
|
|
|
233
|
+
@deprecated("Please use a typed ParameterSet subclass instead!")
|
|
234
|
+
async def add_parameter_variable(
|
|
235
|
+
self,
|
|
236
|
+
name: str,
|
|
237
|
+
val: Any,
|
|
238
|
+
*,
|
|
239
|
+
varianttype: ua.VariantType | None = None,
|
|
240
|
+
datatype: ua.NodeId | int | None = None,
|
|
241
|
+
historize: bool = False,
|
|
242
|
+
unit: str | int | None = None,
|
|
243
|
+
_range: tuple[float, float] | None = None,
|
|
244
|
+
) -> Node:
|
|
245
|
+
"""Add a new parameter variable to this UaObject."""
|
|
246
|
+
if datatype is not None:
|
|
247
|
+
raise NotImplementedError
|
|
248
|
+
if varianttype is not None:
|
|
249
|
+
val = ua.Variant(val, varianttype)
|
|
250
|
+
variable = UaVariable(
|
|
251
|
+
initial_value=val,
|
|
252
|
+
name=name,
|
|
253
|
+
historize=historize,
|
|
254
|
+
unit=unit,
|
|
255
|
+
range=_range,
|
|
256
|
+
writable=True,
|
|
257
|
+
)
|
|
258
|
+
await self.parameter_set.add(variable, exist_ok=True)
|
|
259
|
+
return variable.ua_node
|
|
260
|
+
|
|
178
261
|
def __init_subclass__(cls, **kwargs) -> None:
|
|
179
262
|
"""Extract type for monitoring."""
|
|
180
263
|
super().__init_subclass__(**kwargs)
|
|
@@ -217,6 +300,33 @@ class FinalResultDataMixin(Generic[FinalResultDataType]):
|
|
|
217
300
|
"""Read all results and provide them as a mapping from result name to value."""
|
|
218
301
|
return await self.final_result_data.read_all()
|
|
219
302
|
|
|
303
|
+
@deprecated("Please use a typed FinalResultData subclass instead!")
|
|
304
|
+
async def add_result_variable(
|
|
305
|
+
self,
|
|
306
|
+
name: str,
|
|
307
|
+
val: Any,
|
|
308
|
+
*,
|
|
309
|
+
varianttype: ua.VariantType | None = None,
|
|
310
|
+
datatype: ua.NodeId | int | None = None,
|
|
311
|
+
historize: bool = False,
|
|
312
|
+
unit: str | int | None = None,
|
|
313
|
+
_range: tuple[float, float] | None = None,
|
|
314
|
+
) -> Node:
|
|
315
|
+
"""Add a new parameter variable to this UaObject."""
|
|
316
|
+
if datatype is not None:
|
|
317
|
+
raise NotImplementedError
|
|
318
|
+
if varianttype is not None:
|
|
319
|
+
val = ua.Variant(val, varianttype)
|
|
320
|
+
variable = UaVariable(
|
|
321
|
+
initial_value=val,
|
|
322
|
+
name=name,
|
|
323
|
+
historize=historize,
|
|
324
|
+
unit=unit,
|
|
325
|
+
range=_range,
|
|
326
|
+
)
|
|
327
|
+
await self.final_result_data.add(variable, exist_ok=True)
|
|
328
|
+
return variable.ua_node
|
|
329
|
+
|
|
220
330
|
def __init_subclass__(cls, **kwargs) -> None:
|
|
221
331
|
"""Extract type for monitoring."""
|
|
222
332
|
super().__init_subclass__(**kwargs)
|
|
@@ -100,6 +100,7 @@ class UaVariable(UaObject, ParentMixin[UaObject], Generic[_VariableType]):
|
|
|
100
100
|
bypass_lock: bool = False,
|
|
101
101
|
variable_type: type[_VariableType] | None = None,
|
|
102
102
|
optional_ok: bool = False,
|
|
103
|
+
name: str | None = None,
|
|
103
104
|
**kwargs,
|
|
104
105
|
) -> None:
|
|
105
106
|
"""*Cooperative* constructor for a new variable instance.
|
|
@@ -117,7 +118,7 @@ class UaVariable(UaObject, ParentMixin[UaObject], Generic[_VariableType]):
|
|
|
117
118
|
:param variable_type: The Python type of the variable. Is only required if type cannot be determined from
|
|
118
119
|
``initial_value``, i.e. when ``None`` is provided.
|
|
119
120
|
"""
|
|
120
|
-
super().__init__(minimum_access_level=minimum_access_level, bypass_lock=bypass_lock, **kwargs)
|
|
121
|
+
super().__init__(minimum_access_level=minimum_access_level, bypass_lock=bypass_lock, name=name, **kwargs)
|
|
121
122
|
|
|
122
123
|
self._initial_value, self._initial_value_type = _get_initial_value_and_type(initial_value, variable_type)
|
|
123
124
|
assert self._initial_value.VariantType != ua.VariantType.Null
|
|
@@ -152,6 +152,31 @@ class UaVariableContainer(UaObject, ParentMixin[UaObject]):
|
|
|
152
152
|
await variable.init()
|
|
153
153
|
yield
|
|
154
154
|
|
|
155
|
+
async def add(
|
|
156
|
+
self,
|
|
157
|
+
variable: UaVariable,
|
|
158
|
+
*,
|
|
159
|
+
exist_ok: bool = False,
|
|
160
|
+
remove_existing: bool = False,
|
|
161
|
+
) -> None:
|
|
162
|
+
"""Add the given ``variable`` to the container. Can be used to add existing variables to other containers.
|
|
163
|
+
|
|
164
|
+
If the variable is not initialized yet, it will be initialized with this container as parent.
|
|
165
|
+
|
|
166
|
+
:param variable: UaVariable to add to the container.
|
|
167
|
+
:param exist_ok: Whether to reuse an existing OPC UA variable node if found during initialization.
|
|
168
|
+
:param remove_existing: Whether to remove existing OPC UA variable node if found during initialization.
|
|
169
|
+
"""
|
|
170
|
+
setattr(self, variable.name, variable)
|
|
171
|
+
if not variable.is_initialized:
|
|
172
|
+
self.logger.debug("Initializing variable", variable=variable)
|
|
173
|
+
variable.parent = self
|
|
174
|
+
await variable.ua_create_node(self.ua_node, exist_ok=exist_ok, remove_existing=remove_existing)
|
|
175
|
+
await variable.init()
|
|
176
|
+
else:
|
|
177
|
+
self.logger.debug("Referencing variable!", variable=variable)
|
|
178
|
+
await self.ua_node.add_reference(variable.ua_node, reftype=ua.object_ids.ObjectIds.HasComponent)
|
|
179
|
+
|
|
155
180
|
# @override
|
|
156
181
|
# async def _after_init(self) -> None:
|
|
157
182
|
# await super()._after_init()
|
|
@@ -14,8 +14,8 @@ from typing import Final
|
|
|
14
14
|
|
|
15
15
|
from asyncua.ua import NodeId
|
|
16
16
|
|
|
17
|
-
NODESET_PATH: Final[Path] = Path("../src/opensmi/server/nodesets")
|
|
18
|
-
OUTPUT_PATH: Final[Path] = Path("../src/opensmi/server/nodesets")
|
|
17
|
+
# NODESET_PATH: Final[Path] = Path("../src/opensmi/server/nodesets")
|
|
18
|
+
# OUTPUT_PATH: Final[Path] = Path("../src/opensmi/server/nodesets")
|
|
19
19
|
TYPE_TAGS: Final[set[str]] = {"UAObjectType", "UADataType", "UAVariableType"}
|
|
20
20
|
TEMPLATE: Final[Template] = Template(Path("nodeset.py.template").read_text(encoding="utf-8"))
|
|
21
21
|
|
|
@@ -60,8 +60,7 @@ def _write(parsed: _ParsedNodeSet) -> tuple[str, Path]:
|
|
|
60
60
|
f" {entry} = NodeIdDefinition(URI, ua.Int32({parsed.entries[entry]!r}))" for entry in sorted(parsed.entries)
|
|
61
61
|
)
|
|
62
62
|
|
|
63
|
-
path =
|
|
64
|
-
|
|
63
|
+
path = Path(f"{_snake_case(parsed.name)}.py")
|
|
65
64
|
with path.open("w") as file:
|
|
66
65
|
file.write(
|
|
67
66
|
TEMPLATE.substitute(
|
|
@@ -80,7 +79,7 @@ def _write(parsed: _ParsedNodeSet) -> tuple[str, Path]:
|
|
|
80
79
|
|
|
81
80
|
|
|
82
81
|
def _write__init__(files: list[_ProcessModelEntry]) -> None:
|
|
83
|
-
path =
|
|
82
|
+
path = Path(".") / "__init__.py"
|
|
84
83
|
with path.open("w") as file:
|
|
85
84
|
file.write("# SPDX-FileCopyrightText: 2026 OpenSMI Contributors\n")
|
|
86
85
|
file.write("#\n")
|
|
@@ -182,7 +181,7 @@ def _parse_nodeset_xml(path: Path) -> _ParsedNodeSet:
|
|
|
182
181
|
|
|
183
182
|
def main() -> None: # noqa: D103
|
|
184
183
|
files = []
|
|
185
|
-
for src_path in
|
|
184
|
+
for src_path in Path(".").glob("*.NodeSet2.xml"):
|
|
186
185
|
parsed = _parse_nodeset_xml(src_path)
|
|
187
186
|
class_name, dest_path = _write(parsed)
|
|
188
187
|
files.append(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/Opc.Ua.Di.NodeSet2.xml
RENAMED
|
File without changes
|
{opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/Opc.Ua.Machinery.NodeSet2.xml
RENAMED
|
File without changes
|
{opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/Opc.Ua.RSL.NodeSet2.xml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/smart_factory_machine_set.py
RENAMED
|
File without changes
|
{opensmi_server-0.1 → opensmi_server-0.2}/src/opensmi/server/nodesets/smart_factory_skill_set.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|