OpenSMI-Server 0.1__tar.gz → 0.3__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.
Files changed (106) hide show
  1. opensmi_server-0.3/.github/workflows/api-docs.yml +58 -0
  2. opensmi_server-0.3/.github/workflows/checks.yml +72 -0
  3. {opensmi_server-0.1 → opensmi_server-0.3}/.github/workflows/python-publish.yml +6 -1
  4. opensmi_server-0.3/.pre-commit +0 -0
  5. opensmi_server-0.3/.pre-commit-config.yaml +15 -0
  6. {opensmi_server-0.1 → opensmi_server-0.3}/PKG-INFO +17 -12
  7. {opensmi_server-0.1 → opensmi_server-0.3}/README.md +14 -10
  8. opensmi_server-0.3/docs/migration.md +141 -0
  9. opensmi_server-0.3/examples/check/main.py +132 -0
  10. opensmi_server-0.3/examples/dictionary_entries/main.py +55 -0
  11. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/composite_skill.py +11 -9
  12. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/continuous_skill.py +17 -13
  13. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/continuous_skill_self_halting.py +10 -9
  14. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/dummy_component.py +9 -1
  15. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/dummy_machine.py +8 -0
  16. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/dummy_method.py +10 -21
  17. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/dummy_skill.py +10 -5
  18. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/dummy_skill_resources.py +10 -2
  19. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/dummy_skill_simple.py +10 -5
  20. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/main.py +1 -1
  21. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/resources.py +2 -2
  22. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/startup_skill.py +2 -0
  23. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/suspendable_dummy_skill.py +7 -4
  24. {opensmi_server-0.1 → opensmi_server-0.3}/examples/quick_start/main.py +12 -6
  25. opensmi_server-0.3/examples/rsl/main.py +97 -0
  26. {opensmi_server-0.1 → opensmi_server-0.3}/pyproject.toml +9 -12
  27. {opensmi_server-0.1 → opensmi_server-0.3}/src/OpenSMI_Server.egg-info/PKG-INFO +17 -12
  28. {opensmi_server-0.1 → opensmi_server-0.3}/src/OpenSMI_Server.egg-info/SOURCES.txt +11 -14
  29. {opensmi_server-0.1 → opensmi_server-0.3}/src/OpenSMI_Server.egg-info/requires.txt +1 -1
  30. {opensmi_server-0.1 → opensmi_server-0.3}/src/OpenSMI_Server.egg-info/scm_file_list.json +25 -14
  31. opensmi_server-0.3/src/OpenSMI_Server.egg-info/scm_version.json +8 -0
  32. opensmi_server-0.3/src/opensmi/server/_history.py +128 -0
  33. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/_server.py +192 -42
  34. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/access_control.py +58 -53
  35. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/base_callable.py +19 -5
  36. opensmi_server-0.3/src/opensmi/server/base_feasibility_check.py +27 -0
  37. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/base_machine.py +14 -16
  38. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/base_machinery_item.py +27 -15
  39. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/base_method.py +6 -5
  40. opensmi_server-0.3/src/opensmi/server/base_precondition_check.py +27 -0
  41. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/base_skill.py +95 -46
  42. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/base_startup_skill.py +3 -3
  43. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/config.py +1 -1
  44. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/interfaces.py +13 -2
  45. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/lock.py +25 -8
  46. opensmi_server-0.3/src/opensmi/server/mixins/__init__.py +75 -0
  47. opensmi_server-0.3/src/opensmi/server/mixins/description_mixin.py +31 -0
  48. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/mixins/lockable_mixin.py +1 -2
  49. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/mixins/notification_mixins.py +9 -2
  50. opensmi_server-0.3/src/opensmi/server/mixins/parent_mixin.py +222 -0
  51. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/mixins/requirements_mixin.py +9 -8
  52. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/mixins/skill_logic_mixins.py +10 -17
  53. opensmi_server-0.3/src/opensmi/server/mixins/spatial_object_mixin.py +110 -0
  54. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/mixins/ua_object_container_mixins.py +7 -8
  55. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/mixins/ua_variable_container_mixins.py +107 -0
  56. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/notification.py +18 -28
  57. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/protocols.py +4 -1
  58. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/resource.py +9 -7
  59. opensmi_server-0.3/src/opensmi/server/spatial_object.py +492 -0
  60. opensmi_server-0.3/src/opensmi/server/ua_dictionary_entry.py +91 -0
  61. opensmi_server-0.3/src/opensmi/server/ua_fsm.py +117 -0
  62. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/ua_object.py +29 -2
  63. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/ua_object_containers.py +45 -24
  64. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/ua_variable.py +82 -9
  65. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/ua_variable_containers.py +100 -9
  66. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/user.py +34 -14
  67. {opensmi_server-0.1 → opensmi_server-0.3}/tools/create_password.py +5 -3
  68. opensmi_server-0.1/docs/migration.md +0 -308
  69. opensmi_server-0.1/src/OpenSMI_Server.egg-info/scm_version.json +0 -8
  70. opensmi_server-0.1/src/opensmi/server/base_feasibility_check.py +0 -18
  71. opensmi_server-0.1/src/opensmi/server/base_precondition_check.py +0 -20
  72. opensmi_server-0.1/src/opensmi/server/mixins/__init__.py +0 -22
  73. opensmi_server-0.1/src/opensmi/server/mixins/parent_mixin.py +0 -79
  74. opensmi_server-0.1/src/opensmi/server/mixins/spatial_object_mixin.py +0 -88
  75. opensmi_server-0.1/src/opensmi/server/nodesets/Opc.Ua.Di.NodeSet2.xml +0 -5719
  76. opensmi_server-0.1/src/opensmi/server/nodesets/Opc.Ua.Machinery.NodeSet2.xml +0 -1713
  77. opensmi_server-0.1/src/opensmi/server/nodesets/Opc.Ua.RSL.NodeSet2.xml +0 -601
  78. opensmi_server-0.1/src/opensmi/server/nodesets/Opc.Ua.SmartFactory.MachineSet.NodeSet2.xml +0 -2886
  79. opensmi_server-0.1/src/opensmi/server/nodesets/Opc.Ua.SmartFactory.SkillSet.NodeSet2.xml +0 -856
  80. opensmi_server-0.1/src/opensmi/server/nodesets/__init__.py +0 -26
  81. opensmi_server-0.1/src/opensmi/server/nodesets/di.py +0 -74
  82. opensmi_server-0.1/src/opensmi/server/nodesets/machinery.py +0 -36
  83. opensmi_server-0.1/src/opensmi/server/nodesets/rsl.py +0 -31
  84. opensmi_server-0.1/src/opensmi/server/nodesets/smart_factory_machine_set.py +0 -52
  85. opensmi_server-0.1/src/opensmi/server/nodesets/smart_factory_skill_set.py +0 -32
  86. opensmi_server-0.1/src/opensmi/server/spatial_object.py +0 -328
  87. opensmi_server-0.1/src/opensmi/server/ua_fsm.py +0 -261
  88. opensmi_server-0.1/tools/auto_generate_nodesets.py +0 -205
  89. opensmi_server-0.1/tools/nodeset.py.template +0 -27
  90. {opensmi_server-0.1 → opensmi_server-0.3}/.gitignore +0 -0
  91. {opensmi_server-0.1 → opensmi_server-0.3}/LICENSE +0 -0
  92. {opensmi_server-0.1 → opensmi_server-0.3}/LICENSES/CC0-1.0.txt +0 -0
  93. {opensmi_server-0.1 → opensmi_server-0.3}/LICENSES/MIT.txt +0 -0
  94. {opensmi_server-0.1 → opensmi_server-0.3}/MANIFEST.in +0 -0
  95. {opensmi_server-0.1 → opensmi_server-0.3}/docs/development.md +0 -0
  96. {opensmi_server-0.1 → opensmi_server-0.3}/docs/faq.md +0 -0
  97. {opensmi_server-0.1 → opensmi_server-0.3}/docs/machinery_item.md +0 -0
  98. {opensmi_server-0.1 → opensmi_server-0.3}/docs/methods.md +0 -0
  99. {opensmi_server-0.1 → opensmi_server-0.3}/docs/skills.md +0 -0
  100. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/__init__.py +0 -0
  101. {opensmi_server-0.1 → opensmi_server-0.3}/examples/dummy/config.toml +0 -0
  102. {opensmi_server-0.1 → opensmi_server-0.3}/setup.cfg +0 -0
  103. {opensmi_server-0.1 → opensmi_server-0.3}/src/OpenSMI_Server.egg-info/dependency_links.txt +0 -0
  104. {opensmi_server-0.1 → opensmi_server-0.3}/src/OpenSMI_Server.egg-info/top_level.txt +0 -0
  105. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/__init__.py +0 -0
  106. {opensmi_server-0.1 → opensmi_server-0.3}/src/opensmi/server/common.py +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
@@ -0,0 +1,72 @@
1
+ name: Checks
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ workflow_call: # lets the publishing workflow reuse this one
8
+ secrets:
9
+ CODECOV_TOKEN:
10
+ required: false
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ lint:
17
+ name: Ruff and basedpyright
18
+ runs-on: ubuntu-latest
19
+
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+
23
+ - uses: astral-sh/setup-uv@v7
24
+ with:
25
+ python-version: "3.12"
26
+ enable-cache: true
27
+
28
+ - name: Install dependencies
29
+ run: uv sync --group dev
30
+
31
+ # - name: Ruff lint
32
+ # run: uv run ruff check .
33
+
34
+ - name: Ruff format check
35
+ run: uv run ruff format --check .
36
+
37
+ - name: basedpyright
38
+ run: uv run basedpyright
39
+
40
+ test:
41
+ runs-on: ubuntu-latest
42
+ strategy:
43
+ fail-fast: false
44
+ matrix:
45
+ python-version: [ "3.11", "3.12", "3.13", "3.14" ]
46
+
47
+ steps:
48
+ - uses: actions/checkout@v4
49
+
50
+ - uses: astral-sh/setup-uv@v7
51
+ with:
52
+ python-version: ${{ matrix.python-version }}
53
+ enable-cache: true
54
+
55
+ - name: Install dependencies
56
+ run: uv sync --group dev
57
+
58
+ - name: Run tests with coverage
59
+ run: >
60
+ uv run pytest
61
+ -n auto
62
+ --cov
63
+ --cov-report=term-missing
64
+ --cov-report=xml
65
+
66
+ - name: Upload coverage to Codecov
67
+ uses: codecov/codecov-action@v5
68
+ with:
69
+ token: ${{ secrets.CODECOV_TOKEN }}
70
+ files: coverage.xml
71
+ flags: py${{ matrix.python-version }}
72
+ fail_ci_if_error: false # don't block on Codecov outages or fork PRs without the token
@@ -10,13 +10,18 @@ name: Upload Python Package
10
10
 
11
11
  on:
12
12
  release:
13
- types: [published]
13
+ types: [ published ]
14
14
 
15
15
  permissions:
16
16
  contents: read
17
17
 
18
18
  jobs:
19
+ checks:
20
+ uses: ./.github/workflows/checks.yml
21
+ secrets: inherit # passes CODECOV_TOKEN through
22
+
19
23
  release-build:
24
+ needs: [ checks ]
20
25
  runs-on: ubuntu-latest
21
26
 
22
27
  steps:
File without changes
@@ -0,0 +1,15 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.17.3
4
+ hooks:
5
+ # - id: ruff-check
6
+ # args: [ --fix ]
7
+ - id: ruff-format
8
+ - repo: local
9
+ hooks:
10
+ - id: basedpyright
11
+ name: basedpyright
12
+ entry: uv run basedpyright
13
+ language: system
14
+ types: [ python ]
15
+ pass_filenames: false # check the whole project, like CI
@@ -1,10 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: OpenSMI-Server
3
- Version: 0.1
3
+ Version: 0.3
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
@@ -25,7 +26,7 @@ Classifier: Typing :: Typed
25
26
  Requires-Python: >=3.11
26
27
  Description-Content-Type: text/markdown
27
28
  License-File: LICENSES/MIT.txt
28
- Requires-Dist: OpenSMI-Core>=0.1
29
+ Requires-Dist: OpenSMI-Core<0.8,>=0.7
29
30
  Requires-Dist: asyncua<3,>=2.0.1
30
31
  Requires-Dist: transitions<1,>=0.9
31
32
  Requires-Dist: structlog>=26
@@ -37,6 +38,13 @@ Provides-Extra: json
37
38
  Requires-Dist: orjson<4,>=3; extra == "json"
38
39
  Dynamic: license-file
39
40
 
41
+ ![OpenSMI Logo](https://smartfactory.de/wp-content/uploads/2026/09/Logo_OpenSMI.png)
42
+
43
+ [![Docs](https://img.shields.io/badge/docs-online-blue)](https://smartfactory-kl.github.io/opensmi-server/)
44
+ [![PyPI version](https://img.shields.io/pypi/v/opensmi-server.svg)](https://pypi.org/project/opensmi-server/)
45
+ [![Python versions](https://img.shields.io/pypi/pyversions/opensmi-server.svg)](https://pypi.org/project/opensmi-server/)
46
+ [![License](https://img.shields.io/badge/license-MIT-blue)](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
@@ -88,8 +96,8 @@ from opensmi.server.mixins import FinalResultDataMixin, ParameterSetMixin, Paren
88
96
  class ExampleSkillParameterSet(ParameterSet):
89
97
  """Parameters of the example skill."""
90
98
 
91
- x = UaVariable(0, unit=Unit.NANOAMPERE, range=(0, 10))
92
- y = UaVariable(0, unit="nA", range=(0, 10))
99
+ X = UaVariable(0, unit=Unit.NANOAMPERE, range=(0, 10))
100
+ Y = UaVariable(0, unit="nA", range=(0, 10))
93
101
 
94
102
 
95
103
  class ExampleSkillSimpleFinalResultData(BaseSkillFinalResultData):
@@ -99,7 +107,6 @@ class ExampleSkillSimpleFinalResultData(BaseSkillFinalResultData):
99
107
 
100
108
 
101
109
  class ExampleSkill(
102
- ParentMixin["ExampleMachine"], # provides type-checkable parent type
103
110
  ParameterSetMixin[ExampleSkillParameterSet], # provides type-checkable parameters
104
111
  FinalResultDataMixin[ExampleSkillSimpleFinalResultData], # provides type-checkable results
105
112
  BaseSkillFinite, # provides finite skill logic etc.
@@ -108,8 +115,8 @@ class ExampleSkill(
108
115
  # define logic that is executed in the RUNNING state
109
116
 
110
117
  # read our parameters
111
- x = await self.parameter_set.x.read()
112
- y = await self.parameter_set.y.read()
118
+ x = await self.parameter_set.X.read()
119
+ y = await self.parameter_set.Y.read()
113
120
 
114
121
  # simulate long-running calculation etc.
115
122
  await asyncio.sleep(1)
@@ -127,9 +134,7 @@ class ExampleMachine(BaseMachine):
127
134
  async def _write_identification(self) -> None:
128
135
  # These identification variables must be set for machines
129
136
  await self.identification.SerialNumber.write("1234-56789-abc")
130
- await self.identification.ProductInstanceUri.write(
131
- "urn:smartfactory.de-model:snr-1234-56789-abc"
132
- )
137
+ await self.identification.ProductInstanceUri.write("urn:smartfactory.de-model:snr-1234-56789-abc")
133
138
  await self.identification.Manufacturer.write(
134
139
  ua.LocalizedText("Technologie-Initiative SmartFactory-KL e. V.", "de-DE")
135
140
  )
@@ -155,7 +160,7 @@ if __name__ == "__main__":
155
160
  write parameters or call skill methods.
156
161
  4. Navigate to `ExampleMachine/SkillSet/ExampleSkill/SkillExecution`. This is where the skill's `ParameterSet`,
157
162
  `StateMachine`, and `FinalResultData` etc. live.
158
- 5. Under `ParameterSet`, write values for `x` and `y`.
163
+ 5. Under `ParameterSet`, write values for `X` and `Y`.
159
164
  6. Under `StateMachine`, call `Reset()`. Skills start in the `Halted` state and must be reset to `Ready` before
160
165
  they can run.
161
166
  7. Call `Start()`. The skill moves through `Starting` → `Running` → `Completing` → `Completed`.
@@ -167,7 +172,7 @@ Or simply use our [OpenSMI-Client](https://github.com/SmartFactory-KL/opensmi-cl
167
172
  **Explore the safety features:**
168
173
 
169
174
  - Try writing parameters or calling skill methods *without* holding the Lock — it will be rejected.
170
- - Try writing `x` or `y` outside their allowed range — it will be rejected.
175
+ - Try writing `X` or `Y` outside their allowed range — it will be rejected.
171
176
  - Try acquiring the Lock while authenticated as user `visitor` with password `visitor` — it will be rejected.
172
177
 
173
178
  See [here](examples) for more OpenSMI server examples.
@@ -1,3 +1,10 @@
1
+ ![OpenSMI Logo](https://smartfactory.de/wp-content/uploads/2026/09/Logo_OpenSMI.png)
2
+
3
+ [![Docs](https://img.shields.io/badge/docs-online-blue)](https://smartfactory-kl.github.io/opensmi-server/)
4
+ [![PyPI version](https://img.shields.io/pypi/v/opensmi-server.svg)](https://pypi.org/project/opensmi-server/)
5
+ [![Python versions](https://img.shields.io/pypi/pyversions/opensmi-server.svg)](https://pypi.org/project/opensmi-server/)
6
+ [![License](https://img.shields.io/badge/license-MIT-blue)](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
@@ -49,8 +56,8 @@ from opensmi.server.mixins import FinalResultDataMixin, ParameterSetMixin, Paren
49
56
  class ExampleSkillParameterSet(ParameterSet):
50
57
  """Parameters of the example skill."""
51
58
 
52
- x = UaVariable(0, unit=Unit.NANOAMPERE, range=(0, 10))
53
- y = UaVariable(0, unit="nA", range=(0, 10))
59
+ X = UaVariable(0, unit=Unit.NANOAMPERE, range=(0, 10))
60
+ Y = UaVariable(0, unit="nA", range=(0, 10))
54
61
 
55
62
 
56
63
  class ExampleSkillSimpleFinalResultData(BaseSkillFinalResultData):
@@ -60,7 +67,6 @@ class ExampleSkillSimpleFinalResultData(BaseSkillFinalResultData):
60
67
 
61
68
 
62
69
  class ExampleSkill(
63
- ParentMixin["ExampleMachine"], # provides type-checkable parent type
64
70
  ParameterSetMixin[ExampleSkillParameterSet], # provides type-checkable parameters
65
71
  FinalResultDataMixin[ExampleSkillSimpleFinalResultData], # provides type-checkable results
66
72
  BaseSkillFinite, # provides finite skill logic etc.
@@ -69,8 +75,8 @@ class ExampleSkill(
69
75
  # define logic that is executed in the RUNNING state
70
76
 
71
77
  # read our parameters
72
- x = await self.parameter_set.x.read()
73
- y = await self.parameter_set.y.read()
78
+ x = await self.parameter_set.X.read()
79
+ y = await self.parameter_set.Y.read()
74
80
 
75
81
  # simulate long-running calculation etc.
76
82
  await asyncio.sleep(1)
@@ -88,9 +94,7 @@ class ExampleMachine(BaseMachine):
88
94
  async def _write_identification(self) -> None:
89
95
  # These identification variables must be set for machines
90
96
  await self.identification.SerialNumber.write("1234-56789-abc")
91
- await self.identification.ProductInstanceUri.write(
92
- "urn:smartfactory.de-model:snr-1234-56789-abc"
93
- )
97
+ await self.identification.ProductInstanceUri.write("urn:smartfactory.de-model:snr-1234-56789-abc")
94
98
  await self.identification.Manufacturer.write(
95
99
  ua.LocalizedText("Technologie-Initiative SmartFactory-KL e. V.", "de-DE")
96
100
  )
@@ -116,7 +120,7 @@ if __name__ == "__main__":
116
120
  write parameters or call skill methods.
117
121
  4. Navigate to `ExampleMachine/SkillSet/ExampleSkill/SkillExecution`. This is where the skill's `ParameterSet`,
118
122
  `StateMachine`, and `FinalResultData` etc. live.
119
- 5. Under `ParameterSet`, write values for `x` and `y`.
123
+ 5. Under `ParameterSet`, write values for `X` and `Y`.
120
124
  6. Under `StateMachine`, call `Reset()`. Skills start in the `Halted` state and must be reset to `Ready` before
121
125
  they can run.
122
126
  7. Call `Start()`. The skill moves through `Starting` → `Running` → `Completing` → `Completed`.
@@ -128,7 +132,7 @@ Or simply use our [OpenSMI-Client](https://github.com/SmartFactory-KL/opensmi-cl
128
132
  **Explore the safety features:**
129
133
 
130
134
  - Try writing parameters or calling skill methods *without* holding the Lock — it will be rejected.
131
- - Try writing `x` or `y` outside their allowed range — it will be rejected.
135
+ - Try writing `X` or `Y` outside their allowed range — it will be rejected.
132
136
  - Try acquiring the Lock while authenticated as user `visitor` with password `visitor` — it will be rejected.
133
137
 
134
138
  See [here](examples) for more OpenSMI server examples.
@@ -0,0 +1,141 @@
1
+ # Migration
2
+
3
+ This guide helps you upgrade to the newest version of OpenSMI-Server. Sections are ordered newest first. If you skip
4
+ versions, apply every section between your version and the newest one, oldest first.
5
+
6
+ - [OpenSMI v0.2 -> v0.3 (unreleased)](#opensmi-v02---v03-unreleased)
7
+ - [OpenSMI v0.1 -> v0.2](#opensmi-v01---v02)
8
+
9
+ ## OpenSMI v0.2 -> v0.3 (unreleased)
10
+
11
+ ### Dependencies
12
+
13
+ - OpenSMI-Server requires `OpenSMI-Core>=0.7,<0.8`.
14
+ - Clients must handle the new server-wide users folder, the `ErrorCode` event field and the new `SourceNode` of
15
+ notification events, see [Users](#users-are-server-wide),
16
+ [Notifications](#notifications-error-code-no-longer-in-the-message) and
17
+ [`SourceNode`](#notifications-sourcenode-is-the-object-the-message-is-about). Released OpenSMI-Client versions up to
18
+ now do not show users and drop notifications.
19
+
20
+ ### Server configuration
21
+
22
+ - `Server(config_path=...)` is now `Server(config=...)`. `config` accepts a path to a TOML file or a
23
+ `ServerConfiguration` instance.
24
+ - `Server.load_config()` was removed. Pass the config to `__init__()` or assign `server.config` before the server is
25
+ initialized.
26
+ - `AccessControl(server=...)` is now `AccessControl(config=...)` with an `AccessControlConfiguration`. You only need
27
+ this if you construct `AccessControl` yourself, the server does it for you.
28
+
29
+ ### Node sets moved to OpenSMI-Core
30
+
31
+ `opensmi.server.nodesets` was removed. The NodeSet2 XMLs and the generated NodeId classes now live in
32
+ `opensmi.core.nodesets`:
33
+
34
+ ```python
35
+ # Previous version (v0.2)
36
+ from opensmi.server.nodesets import RSLNodeIds
37
+
38
+ # New version (v0.3)
39
+ from opensmi.core.nodesets import RSLNodeIds
40
+ ```
41
+
42
+ ### Paths and names
43
+
44
+ - Paths now include the OpenSMI folders, e.g. `/M1/Components/Gripper`, `/M1/SkillSet/Pick` and
45
+ `/M1/MethodSet/Pick`. Feasibility and precondition checks lie below their skill, e.g.
46
+ `/M1/SkillSet/Pick/FeasibilityCheck`, while their parent is still the machinery item. Use `server.resolve(path)` to
47
+ look up an object by path.
48
+ - `UaObject.path` is an `ObjectPath` from `opensmi.core.paths` (was `PurePosixPath`). It is never equal to a `str`,
49
+ so compare with `ObjectPath.parse("/M1/SkillSet/Pick")` or `str(obj.path)`.
50
+ - Every object is checked when it is registered. **These now raise `ValueError`:** an empty name, a name containing
51
+ `/`, and a path (or alias) that is already taken, e.g. two siblings with the same name.
52
+ - New naming rule for browse names: `^[A-Z][A-Za-z0-9]*$`, and not `True`, `False` or `None`. Names that break it only
53
+ log a warning for now, but **will be rejected from opensmi-server 1.0 on**. Usernames are exempt. Rename e.g.
54
+ `pick_place` to `PickPlace`.
55
+ - The parent of an object can't change after it was registered.
56
+ - A variable that is added to a further variable container (e.g. a component variable added to the machine's
57
+ `Monitoring`) is referenced from there with `Organizes` instead of `HasComponent` and gets an alias path. The
58
+ `HasComponent` reference stays with its owner.
59
+
60
+ ### Users are server-wide
61
+
62
+ - Users moved from `<Machine>/MachineryBuildingBlocks/Users` to the server-wide folder `Objects/Users`, created at
63
+ startup before any machine. Their paths are `/Users/<name>`. Machines no longer have a users folder.
64
+ - `server.users` is the users folder. `server.access_control.users` is typed `Mapping[str, User]`.
65
+ - `AccessControl.init_ua_users()` was removed.
66
+ - `Users` is a reserved machine name, `server.add_machine()` raises `ValueError` for it.
67
+ - Users belong to no machine, so no lock protects them: OPC UA writes to user nodes are always denied.
68
+
69
+ ### Notifications: error code no longer in the message
70
+
71
+ Error events no longer append `|||<code>` to `Message`. The code is only in the `ErrorCode` event field. Clients that
72
+ parsed the message must read `ErrorCode` instead.
73
+
74
+ ### Notifications: `SourceNode` is the object the message is about
75
+
76
+ Notification events now set `SourceNode` and `SourceName` to the object that logged the message (the `source`
77
+ argument of `ua_log_*()`, else the machinery item the `Notification` belongs to). Before, both were the `Notification`
78
+ object itself. The events are still emitted by the `Notification` object, so clients keep subscribing to it.
79
+
80
+ Clients that matched incoming events to their subscription by `SourceNode` no longer find a match and drop the events.
81
+ Match by the monitored item instead, e.g. by `event.server_handle` in asyncua. OpenSMI-Core v0.7.0 and older match by
82
+ `SourceNode`, so clients based on them (OpenSMI-Client up to now) need OpenSMI-Core v0.7.1 or newer.
83
+
84
+ Notification events are now also kept in the server's event history (up to 1000 per `Notification` object) and can be
85
+ read with `HistoryRead`.
86
+
87
+ ### Other API changes
88
+
89
+ - `server.get_enum()` was renamed to `server.ensure_enum()`. Its `option_set` parameter was removed.
90
+ - `UaVariable.write_check()` is now `async`. `write_check_callback` may be a sync or async function and may return
91
+ `False` instead of raising `OutOfRangeError` to reject a value.
92
+ - `UaFiniteStateMachine` is generic over its state type. Its unused internals were removed and `init()` no longer takes
93
+ `state_machine_type`.
94
+
95
+ ### Relative Spatial Location (RSL)
96
+
97
+ - `Position` and `Orientation` moved to `opensmi.core.rsl`, which also provides the new `Pose` (position and
98
+ orientation together).
99
+ - Frames take a `Pose` and keyword-only arguments. `CartesianFrame(name=..., position=..., orientation=..., base=...)`
100
+ is now `CartesianFrame(name=..., initial_pose=Pose(...), initial_base=...)`. `initial_base` may also be a raw
101
+ `ua.NodeId`. `PositionFrame` and `WorldFrame` likewise take `initial_pose` (and `initial_base`).
102
+ - New `write_pose()`, `read_pose()` and `update_pose()` methods. `write_position()`/`write_orientation()` and their
103
+ `read_*()` counterparts still exist.
104
+ - `SpatialObject.add_attach_point()` now takes an `initial_pose` (plus optional `name` and `initial_base`), creates
105
+ the frame and returns it, instead of taking an initialized `CartesianFrame`. New: `add_internal_frame()` and
106
+ `add_alternative_frame()`.
107
+ - `SpatialObject` and `SpatialObjectList` are no longer in `Monitoring`, but directly below their parent. The
108
+ `SpatialObject` browse name is always `SpatialObject`, its `name` is written to the `Identifier` property.
109
+ - `SpatialObjectListMixin` no longer creates the `SpatialObjectList` automatically. Call
110
+ `await self._init_spatial_object_list()` in `_init()` of your machine. It optionally takes the `WorldFrame` pose and
111
+ a `name` (default `MachineRoomList`).
112
+
113
+ See [examples/rsl/main.py](../examples/rsl/main.py) for the current usage.
114
+
115
+ ### `ParentMixin`: forward references are now resolved and checked
116
+
117
+ `ParentMixin[...]` now resolves and checks every type argument at runtime, see
118
+ [parent_mixin.py](../src/opensmi/server/mixins/parent_mixin.py). Before, it only checked plain classes and skipped
119
+ the check for everything else.
120
+
121
+ - **Forward references are checked.** A string type argument such as `ParentMixin["BaseMachineryItem"]` used to log
122
+ `Forward reference not supported!` and skip the runtime parent check. It is now resolved in the module of the class
123
+ and checked. **Assigning a parent of the wrong type now raises `TypeError` where it used to pass silently.** Run
124
+ your tests to find wrongly typed parents.
125
+ - **More type forms are supported:** unions (`ParentMixin[BaseMachine | MyComponent]`), parameterized generics (only
126
+ the origin is checked, e.g. `UaObjectContainer` for `UaObjectContainer[Resource]`), `Annotated[...]` (the
127
+ metadata is ignored) and TypeVars (their default, else their bound, else `UaObject`).
128
+ - **Unsupported forms fail early.** `Literal[...]`, a `None` member (e.g. `Optional[X]` or `X | None`) and other
129
+ forms that are not a class now raise `TypeError` when the class is defined. Before, they logged a warning and skipped
130
+ the check. The parent of an `UaObject` is never `None`, so remove `None` from the type argument.
131
+ - **`TYPE_CHECKING`-only names are matched by class name.** If a forward reference cannot be resolved, e.g. because
132
+ the class is only imported under `if TYPE_CHECKING:`, the parent passes if any class in its MRO has that name.
133
+ - **A class without a `ParentMixin[...]` argument silently uses `UaObject`.** Subclassing a bare `ParentMixin` used to
134
+ log `... does not specialize ParentMixin`. It now accepts any `UaObject` parent without logging a warning.
135
+
136
+ ## OpenSMI v0.1 -> v0.2
137
+
138
+ - `Server.ua_import_xml()` parameters are keyword-only: use `ua_import_xml(path=...)`. It also accepts
139
+ `xml_string=...` instead of a path.
140
+ - The deprecated `add_*_variable()` methods were re-added for backwards compatibility. Use `UaVariable` class
141
+ attributes in the variable containers (`ParameterSet`, `Monitoring`, etc.) instead.
@@ -0,0 +1,132 @@
1
+ # SPDX-FileCopyrightText: 2026 OpenSMI Contributors
2
+ #
3
+ # SPDX-License-Identifier: CC0-1.0
4
+
5
+ """Example demonstrating how a feasibility check can be used. Precondition checks work analogous."""
6
+
7
+ import asyncio
8
+ import random
9
+
10
+ from asyncua import ua
11
+ from opensmi.core.errors import OpenSmiRuntimeError
12
+ from typing_extensions import override
13
+
14
+ from opensmi.server import BaseMachine, BaseSkillFinalResultData, BaseSkillFinite, ParameterSet, Server, UaVariable
15
+ from opensmi.server.base_feasibility_check import BaseFeasibilityCheck
16
+ from opensmi.server.mixins import (
17
+ FinalResultDataMixin,
18
+ MonitoringMixin,
19
+ ParameterSetMixin,
20
+ SpatialObjectListMixin,
21
+ )
22
+
23
+ # this would probably be a database or similar for real applications
24
+ feasibility_check_map: dict[int, tuple[int, int]] = {}
25
+
26
+
27
+ class _FullSkillFeasibilityCheckParameterSet(ParameterSet):
28
+ X = UaVariable(0)
29
+ """First summand to check."""
30
+ Y = UaVariable(0)
31
+ """Second summand to check."""
32
+
33
+
34
+ class _FullSkillFeasibilityCheckFinalResultData(BaseSkillFinalResultData):
35
+ FeasibilityID = UaVariable(0)
36
+ """ID of the successful check, required to start ``FullSkill``."""
37
+
38
+
39
+ class FullSkillFeasibilityCheck(
40
+ ParameterSetMixin[_FullSkillFeasibilityCheckParameterSet],
41
+ FinalResultDataMixin[_FullSkillFeasibilityCheckFinalResultData],
42
+ BaseFeasibilityCheck,
43
+ ):
44
+ """Check whether ``X`` + ``Y`` is odd and return a ``FeasibilityID`` for `FullSkill`."""
45
+
46
+ @override
47
+ async def _handle_resetting(self) -> None:
48
+ await self.final_result_data.FeasibilityID.reset()
49
+
50
+ @override
51
+ async def _handle_running(self) -> None:
52
+ x = await self.parameter_set.X.read()
53
+ y = await self.parameter_set.Y.read()
54
+
55
+ await asyncio.sleep(1) # add your feasibility check here
56
+ if (x + y) % 2 == 0:
57
+ msg = f"{x=} + {y=} would result in an even number!"
58
+ raise OpenSmiRuntimeError(msg, error_code="E9435")
59
+
60
+ feasibility_id = random.randint(0, 42)
61
+
62
+ feasibility_check_map[feasibility_id] = (x, y)
63
+
64
+ await self.final_result_data.FeasibilityID.write(feasibility_id)
65
+
66
+
67
+ class _FullSkillParameterSet(ParameterSet):
68
+ FeasibilityID = UaVariable(0, write_check_callback=lambda x: x in feasibility_check_map)
69
+ """ID of a successful feasibility check, whose summands are added."""
70
+
71
+
72
+ class _FullSkillFinalResultData(BaseSkillFinalResultData):
73
+ ComputationResult = UaVariable(0)
74
+ """Sum of the summands of the feasibility check."""
75
+
76
+
77
+ class FullSkill(
78
+ ParameterSetMixin[_FullSkillParameterSet],
79
+ FinalResultDataMixin[_FullSkillFinalResultData],
80
+ BaseSkillFinite,
81
+ ):
82
+ """Add the summands of the feasibility check with the given ``FeasibilityID``."""
83
+
84
+ @override
85
+ async def _handle_resetting(self) -> None:
86
+ await self.final_result_data.ComputationResult.reset()
87
+
88
+ @override
89
+ async def _handle_running(self) -> None:
90
+ feasibility_id = await self.parameter_set.FeasibilityID.read()
91
+
92
+ # read our parameters from the previous feasibility check
93
+ x, y = feasibility_check_map[feasibility_id]
94
+
95
+ await asyncio.sleep(1)
96
+
97
+ await self.final_result_data.ComputationResult.write(x + y)
98
+
99
+
100
+ class ExampleMachine(
101
+ MonitoringMixin,
102
+ SpatialObjectListMixin,
103
+ BaseMachine,
104
+ ):
105
+ """Example machine with a skill using a feasibility check."""
106
+
107
+ @override
108
+ async def _write_identification(self) -> None:
109
+ # These identification variables must be set for machines
110
+ await self.identification.SerialNumber.write("1234-56789-abc")
111
+ await self.identification.ProductInstanceUri.write("urn:smartfactory.de-model:snr-1234-56789-abc")
112
+ await self.identification.Manufacturer.write(
113
+ ua.LocalizedText("Technologie-Initiative SmartFactory KL e. V.", "de-DE")
114
+ )
115
+
116
+ @override
117
+ async def _init(self) -> None:
118
+ await super()._init()
119
+
120
+ skill = FullSkill()
121
+ await self.add_skill(skill)
122
+ await skill.add_feasibility_check(FullSkillFeasibilityCheck())
123
+
124
+
125
+ async def main() -> None:
126
+ async with Server() as server: # will properly shut down the server
127
+ await server.add_machine(ExampleMachine()) # add machine(s)
128
+ await server.start(blocking=True) # start the server and block while it is running
129
+
130
+
131
+ if __name__ == "__main__":
132
+ asyncio.run(main())
@@ -0,0 +1,55 @@
1
+ # SPDX-FileCopyrightText: 2026 OpenSMI Contributors
2
+ #
3
+ # SPDX-License-Identifier: CC0-1.0
4
+
5
+ """Example to demonstrate the use of OPC UA dictionary entries to provide semantic information.
6
+
7
+ Dictionary entries can be added either via constructors or method ``add_dictionary_entry``.
8
+ """
9
+
10
+ import asyncio
11
+
12
+ from asyncua import ua
13
+
14
+ from opensmi.server import BaseMachine, ParameterSet, Server, UaVariable
15
+ from opensmi.server.mixins import ParameterSetMixin
16
+ from opensmi.server.ua_dictionary_entry import IrdiDictionaryEntry, UriDictionaryEntry
17
+
18
+
19
+ class _ParameterSet(ParameterSet):
20
+ FaxNumber = UaVariable(
21
+ initial_value="+49.631.12345-6789",
22
+ dictionary_entry=IrdiDictionaryEntry(
23
+ semantic_id="0112/2///61360_7#CBA202#001", # IRDI from IEC Common Data Dictionary (https://cdd.iec.ch/)
24
+ name="fax number", # should be IEC CDD preferred name
25
+ ),
26
+ )
27
+ """Most technologically advanced contact information, straight from the cutting edge of German bureaucracy."""
28
+
29
+
30
+ class ExampleMachine(ParameterSetMixin[_ParameterSet], BaseMachine):
31
+ """Semantically well-annotated machine whose main purpose is to receive faxes."""
32
+
33
+ async def _init(self) -> None:
34
+ await super()._init()
35
+ await self.add_dictionary_entry(
36
+ UriDictionaryEntry("https://smartfactory.de/dictionary/machine/example-machine")
37
+ )
38
+
39
+ async def _write_identification(self) -> None:
40
+ # These identification variables must be set for machines
41
+ await self.identification.SerialNumber.write("1234-56789-abc")
42
+ await self.identification.ProductInstanceUri.write("urn:smartfactory.de-model:snr-1234-56789-abc")
43
+ await self.identification.Manufacturer.write(
44
+ ua.LocalizedText("Technologie-Initiative SmartFactory KL e. V.", "de-DE")
45
+ )
46
+
47
+
48
+ async def main() -> None:
49
+ async with Server() as server: # will properly shut down the server
50
+ await server.add_machine(ExampleMachine()) # add machine(s)
51
+ await server.start(blocking=True) # start the server and block while it is running
52
+
53
+
54
+ if __name__ == "__main__":
55
+ asyncio.run(main())