OpenSMI-Server 0.3.1__tar.gz → 0.4__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.3.1 → opensmi_server-0.4}/PKG-INFO +4 -2
- {opensmi_server-0.3.1 → opensmi_server-0.4}/README.md +2 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/docs/development.md +0 -2
- opensmi_server-0.4/docs/events.md +73 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/docs/faq.md +0 -2
- {opensmi_server-0.3.1 → opensmi_server-0.4}/docs/migration.md +69 -4
- {opensmi_server-0.3.1 → opensmi_server-0.4}/docs/skills.md +56 -39
- opensmi_server-0.4/docs/variables.md +162 -0
- opensmi_server-0.4/examples/structures/README.md +44 -0
- opensmi_server-0.4/examples/structures/client.py +62 -0
- opensmi_server-0.4/examples/structures/server.py +104 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/pyproject.toml +1 -1
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/OpenSMI_Server.egg-info/PKG-INFO +4 -2
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/OpenSMI_Server.egg-info/SOURCES.txt +8 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/OpenSMI_Server.egg-info/requires.txt +1 -1
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/OpenSMI_Server.egg-info/scm_file_list.json +14 -0
- opensmi_server-0.4/src/OpenSMI_Server.egg-info/scm_version.json +8 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/__init__.py +2 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/_history.py +34 -2
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/_server.py +78 -26
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/access_control.py +20 -9
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/base_skill.py +119 -13
- opensmi_server-0.4/src/opensmi/server/data_types.py +171 -0
- opensmi_server-0.4/src/opensmi/server/errors.py +11 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/interfaces.py +6 -8
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/mixins/skill_logic_mixins.py +71 -65
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/notification.py +30 -3
- opensmi_server-0.4/src/opensmi/server/structures.py +390 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/ua_variable.py +243 -44
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/ua_variable_containers.py +167 -7
- opensmi_server-0.3.1/src/OpenSMI_Server.egg-info/scm_version.json +0 -8
- {opensmi_server-0.3.1 → opensmi_server-0.4}/.github/workflows/api-docs.yml +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/.github/workflows/checks.yml +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/.github/workflows/python-publish.yml +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/.gitignore +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/.pre-commit +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/.pre-commit-config.yaml +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/LICENSE +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/LICENSES/CC0-1.0.txt +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/LICENSES/MIT.txt +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/MANIFEST.in +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/docs/machinery_item.md +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/docs/methods.md +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/check/main.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dictionary_entries/main.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/__init__.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/composite_skill.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/config.toml +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/continuous_skill.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/continuous_skill_self_halting.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/dummy_component.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/dummy_machine.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/dummy_method.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/dummy_skill.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/dummy_skill_resources.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/dummy_skill_simple.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/main.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/resources.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/startup_skill.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/dummy/suspendable_dummy_skill.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/quick_start/main.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/examples/rsl/main.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/setup.cfg +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/OpenSMI_Server.egg-info/dependency_links.txt +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/OpenSMI_Server.egg-info/top_level.txt +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/base_callable.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/base_feasibility_check.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/base_machine.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/base_machinery_item.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/base_method.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/base_precondition_check.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/base_startup_skill.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/common.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/config.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/lock.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/mixins/__init__.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/mixins/description_mixin.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/mixins/lockable_mixin.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/mixins/notification_mixins.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/mixins/parent_mixin.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/mixins/requirements_mixin.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/mixins/spatial_object_mixin.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/mixins/ua_object_container_mixins.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/mixins/ua_variable_container_mixins.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/protocols.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/resource.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/spatial_object.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/ua_dictionary_entry.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/ua_fsm.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/ua_object.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/ua_object_containers.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/src/opensmi/server/user.py +0 -0
- {opensmi_server-0.3.1 → opensmi_server-0.4}/tools/create_password.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: OpenSMI-Server
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4
|
|
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
|
|
@@ -26,7 +26,7 @@ Classifier: Typing :: Typed
|
|
|
26
26
|
Requires-Python: >=3.11
|
|
27
27
|
Description-Content-Type: text/markdown
|
|
28
28
|
License-File: LICENSES/MIT.txt
|
|
29
|
-
Requires-Dist: OpenSMI-Core<0.
|
|
29
|
+
Requires-Dist: OpenSMI-Core<0.9,>=0.8.1
|
|
30
30
|
Requires-Dist: asyncua<3,>=2.0.1
|
|
31
31
|
Requires-Dist: transitions<1,>=0.9
|
|
32
32
|
Requires-Dist: structlog>=26
|
|
@@ -186,6 +186,8 @@ See [here](examples) for more OpenSMI server examples.
|
|
|
186
186
|
| [**Machines**](docs/machinery_item.md#machines) | The top-level unit a client addresses as "the machine," e.g. a robot + storage + transport port. A single server can expose several machines. |
|
|
187
187
|
| [**Skills**](docs/skills.md) | Asynchronous, stateful capabilities — finite (run once, complete) or continuous (run indefinitely), atomic or composite. |
|
|
188
188
|
| [**Methods**](docs/methods.md) | Synchronous, quick operations — no state machine, just `call()` in, result out. |
|
|
189
|
+
| [**Variables**](docs/variables.md) | Values that belong together: structures as dataclasses, their fields as child variables, and groups of variables. |
|
|
190
|
+
| [**Events**](docs/events.md) | Messages as OPC UA events: info, warning and error notifications and their history. |
|
|
189
191
|
|
|
190
192
|
## Project Status
|
|
191
193
|
|
|
@@ -146,6 +146,8 @@ See [here](examples) for more OpenSMI server examples.
|
|
|
146
146
|
| [**Machines**](docs/machinery_item.md#machines) | The top-level unit a client addresses as "the machine," e.g. a robot + storage + transport port. A single server can expose several machines. |
|
|
147
147
|
| [**Skills**](docs/skills.md) | Asynchronous, stateful capabilities — finite (run once, complete) or continuous (run indefinitely), atomic or composite. |
|
|
148
148
|
| [**Methods**](docs/methods.md) | Synchronous, quick operations — no state machine, just `call()` in, result out. |
|
|
149
|
+
| [**Variables**](docs/variables.md) | Values that belong together: structures as dataclasses, their fields as child variables, and groups of variables. |
|
|
150
|
+
| [**Events**](docs/events.md) | Messages as OPC UA events: info, warning and error notifications and their history. |
|
|
149
151
|
|
|
150
152
|
## Project Status
|
|
151
153
|
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Events
|
|
2
|
+
|
|
3
|
+
Machines, and components that have their own `Notification`, report messages as OPC UA events. Clients receive them by
|
|
4
|
+
subscribing to the events of the `Notification` object, and can read past events from its event history.
|
|
5
|
+
|
|
6
|
+
## Notifications
|
|
7
|
+
|
|
8
|
+
A `Notification` is a child object of a machinery item. Machines always have one (via `NotificationMixin`); components
|
|
9
|
+
either have their own (via `NotificationMixin`) or forward their messages to their parent (via
|
|
10
|
+
`NotificationForwarderMixin`), as do skills and methods.
|
|
11
|
+
|
|
12
|
+
Log a message with one of these methods of the machinery item, skill or method:
|
|
13
|
+
|
|
14
|
+
| Method | Event type | Default `Severity` |
|
|
15
|
+
|--------------------|-----------------|--------------------|
|
|
16
|
+
| `ua_log_info()` | `BaseEventType` | 0 |
|
|
17
|
+
| `ua_log_warning()` | `BaseEventType` | 555 |
|
|
18
|
+
| `ua_log_error()` | `AlertType` | 999 |
|
|
19
|
+
|
|
20
|
+
`ua_log_error()` also takes a `code`, sent in the `ErrorCode` field of the event.
|
|
21
|
+
|
|
22
|
+
Every event is emitted by the `Notification` object. `SourceNode` and `SourceName` name the object the message is
|
|
23
|
+
about: the `source` argument if given, else the machinery item the `Notification` belongs to.
|
|
24
|
+
|
|
25
|
+
## Event history
|
|
26
|
+
|
|
27
|
+
The server keeps the events of every `Notification` in its event history, which clients read with `HistoryRead`
|
|
28
|
+
(e.g. `node.read_event_history()` in asyncua). How many events it keeps depends on the history storage, set by
|
|
29
|
+
`history_db` in the `[ua_server]` section of the server configuration:
|
|
30
|
+
|
|
31
|
+
| `history_db` | Kept events |
|
|
32
|
+
|----------------------|----------------------------------------------------------------------------------------------|
|
|
33
|
+
| `"memory"` (default) | The last 1000 events, none older than 7 days. Lost when the server stops. |
|
|
34
|
+
| `"sqlite"` | All events of the last 7 days, in `data/opcua_history.sql` below the working directory. |
|
|
35
|
+
|
|
36
|
+
The storages differ because asyncua implements them differently: its in-memory storage applies both the count and the
|
|
37
|
+
period, its SQLite storage only the period. The limits are `Notification.HISTORY_EVENT_COUNT` and
|
|
38
|
+
`Notification.HISTORY_EVENT_PERIOD`.
|
|
39
|
+
|
|
40
|
+
## Advanced: own event types
|
|
41
|
+
|
|
42
|
+
Most machines only need `ua_log_info()`, `ua_log_warning()` and `ua_log_error()`. This section is for integrations that
|
|
43
|
+
define their own event types in a NodeSet and emit them from a `Notification`.
|
|
44
|
+
|
|
45
|
+
Create the generator for such an event type with `Notification.add_event_generator()`, not with
|
|
46
|
+
`ua_server.get_event_generator()`:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from collections.abc import AsyncGenerator
|
|
50
|
+
|
|
51
|
+
from asyncua.server.event_generator import EventGenerator
|
|
52
|
+
from opensmi.core.lifecycle_mixin import lifecycle
|
|
53
|
+
|
|
54
|
+
from opensmi.server import BaseMachine
|
|
55
|
+
from opensmi.server.mixins import NotificationMixin
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class MyMachine(BaseMachine):
|
|
59
|
+
_my_events: EventGenerator
|
|
60
|
+
|
|
61
|
+
@lifecycle(after=NotificationMixin.lifecycle_notification)
|
|
62
|
+
async def lifecycle_my_events(self) -> AsyncGenerator[None]:
|
|
63
|
+
self._my_events = await self.notification.add_event_generator(self.server.ua_get_node_id(MY_EVENT_TYPE))
|
|
64
|
+
yield
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
The event history only stores the fields of the event types the `Notification` generates when its history is set up.
|
|
68
|
+
`add_event_generator()` sets it up again, so the fields of the new event type are stored as well. A generator created
|
|
69
|
+
with `ua_server.get_event_generator()` emits its events, but their fields specific to the new type are missing from
|
|
70
|
+
the history.
|
|
71
|
+
|
|
72
|
+
Add event types during setup, before the machine emits events: events emitted shortly before or while
|
|
73
|
+
`add_event_generator()` runs can be missing from the history.
|
|
@@ -3,10 +3,75 @@
|
|
|
3
3
|
This guide helps you upgrade to the newest version of OpenSMI-Server. Sections are ordered newest first. If you skip
|
|
4
4
|
versions, apply every section between your version and the newest one, oldest first.
|
|
5
5
|
|
|
6
|
-
- [OpenSMI v0.
|
|
6
|
+
- [OpenSMI v0.3 -> v0.4](#opensmi-v03---v04)
|
|
7
|
+
- [OpenSMI v0.2 -> v0.3](#opensmi-v02---v03)
|
|
7
8
|
- [OpenSMI v0.1 -> v0.2](#opensmi-v01---v02)
|
|
8
9
|
|
|
9
|
-
## OpenSMI v0.
|
|
10
|
+
## OpenSMI v0.3 -> v0.4
|
|
11
|
+
|
|
12
|
+
### Dependencies
|
|
13
|
+
|
|
14
|
+
- OpenSMI-Server requires `OpenSMI-Core>=0.8.1,<0.9`.
|
|
15
|
+
|
|
16
|
+
### Skills: transitions follow the nodeset
|
|
17
|
+
|
|
18
|
+
The skill state machine is now built from `SkillStateMachineType` (via `opensmi.core.skill_state_machine`) instead of
|
|
19
|
+
a hand-written table, see [Skills](skills.md#the-state-machine-in-the-address-space). Changes in behavior:
|
|
20
|
+
|
|
21
|
+
- `reset()` works only from `Halted` and `Completed`, no longer from `Starting` or `Suspended`. Halt a starting or
|
|
22
|
+
suspended skill first.
|
|
23
|
+
- `halt()` also works from `Completing`.
|
|
24
|
+
- A finite skill whose `_handle_running()` returns while it is `Suspending` no longer halts: it finishes suspending
|
|
25
|
+
and completes once it is started again.
|
|
26
|
+
- Work paused at `_suspend_point()` continues only once the skill is `Running` again, not already while `Starting`
|
|
27
|
+
(where finishing work halted the skill).
|
|
28
|
+
- A skill created with `suspendable=False` has no suspend transitions; `suspend()` on it raises
|
|
29
|
+
`UaStatusCodeError(BadNotImplemented)` right away.
|
|
30
|
+
|
|
31
|
+
Only if you subclass skills beyond the `_handle_*` hooks and `_condition_*_allowed` conditions:
|
|
32
|
+
|
|
33
|
+
- `_condition_is_suspendable()` was removed; overriding it has no effect. Pass `suspendable` to the constructor.
|
|
34
|
+
- `AbstractSkill` has a new abstract property `is_suspendable`. `BaseSkill` implements it.
|
|
35
|
+
- The internal triggers are `<state>_done` (`resetting_done`, `halting_done`, `starting_done`, `running_done`,
|
|
36
|
+
`completing_done`, `suspending_done`); `done_internal` is gone.
|
|
37
|
+
|
|
38
|
+
### Skills: new nodes for clients
|
|
39
|
+
|
|
40
|
+
Every skill's state machine now has `CurrentState/Number` and `LastTransition` with its `Id`, and fills
|
|
41
|
+
`CurrentState/Id`, `AvailableStates` and `AvailableTransitions`. Nothing to do; clients may use them.
|
|
42
|
+
|
|
43
|
+
### Enum types
|
|
44
|
+
|
|
45
|
+
- Two different `IntEnum` classes of one name are refused: `server.ensure_enum()` raises `TypeConflictError`
|
|
46
|
+
(`opensmi.server.errors`, also exported from `opensmi.server`) for the second instead of creating a second DataType
|
|
47
|
+
with the same BrowseName. The same holds for an enum and a structure of one name. Rename one of them.
|
|
48
|
+
- `server.register_enum()` is now `async`: `await server.register_enum(...)`. It compares the members of the enum with
|
|
49
|
+
what the DataType publishes and raises `TypeConflictError` if they differ. Binding the same enum to the same DataType
|
|
50
|
+
again no longer raises; binding it to another DataType still needs `overwrite=True`.
|
|
51
|
+
- An enum DataType the server creates has the NodeId `ns=1;s=<EnumName>` instead of a numeric one that depended on the
|
|
52
|
+
order enums were created in (like `ns=1;i=3012`). Clients that find enum types by BrowseName, as OpenSMI-Client does,
|
|
53
|
+
are not affected; update code or NodeSet exports that stored the numeric NodeIds. A machine of the same name as an
|
|
54
|
+
enum now clashes with it, as with structures: adding the machine after the enum fails with an unrelated looking
|
|
55
|
+
`UaStatusCodeError`, creating the enum after the machine with `BadNodeIdExists`. Rename one of them.
|
|
56
|
+
|
|
57
|
+
### Variables: bad status
|
|
58
|
+
|
|
59
|
+
- A write with a bad status is no longer checked, since it has no value: every variable accepts it, also one that is
|
|
60
|
+
not `optional_ok`, and its `write_check_callback` is not called. A client still needs the access level and the
|
|
61
|
+
lock to write it. Replace dummy
|
|
62
|
+
values that were only written to get a bad status through the check by the new `UaVariable.write_status()`:
|
|
63
|
+
`await variable.write_status(ua.StatusCodes.BadNoCommunication)`.
|
|
64
|
+
|
|
65
|
+
### Notifications: own event types
|
|
66
|
+
|
|
67
|
+
- Only if you create generators for your own event types on a `Notification` with `ua_server.get_event_generator()`:
|
|
68
|
+
switch to the new `Notification.add_event_generator()`, see
|
|
69
|
+
[Advanced: own event types](events.md#advanced-own-event-types). Until then the event history stores these events
|
|
70
|
+
without the fields specific to their type.
|
|
71
|
+
- The SQLite history storage adds missing event field columns to an existing table, so a database written by an
|
|
72
|
+
earlier version also stores them from now on.
|
|
73
|
+
|
|
74
|
+
## OpenSMI v0.2 -> v0.3
|
|
10
75
|
|
|
11
76
|
### Dependencies
|
|
12
77
|
|
|
@@ -81,8 +146,8 @@ Clients that matched incoming events to their subscription by `SourceNode` no lo
|
|
|
81
146
|
Match by the monitored item instead, e.g. by `event.server_handle` in asyncua. OpenSMI-Core v0.7.0 and older match by
|
|
82
147
|
`SourceNode`, so clients based on them (OpenSMI-Client up to now) need OpenSMI-Core v0.7.1 or newer.
|
|
83
148
|
|
|
84
|
-
Notification events are now also kept in the server's event history
|
|
85
|
-
|
|
149
|
+
Notification events are now also kept in the server's event history and can be read with `HistoryRead`. How many
|
|
150
|
+
are kept depends on the history storage, see [Event history](events.md#event-history).
|
|
86
151
|
|
|
87
152
|
### Other API changes
|
|
88
153
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
# Skills
|
|
2
2
|
|
|
3
|
-
[[_TOC_]]
|
|
4
|
-
|
|
5
3
|
## Basics
|
|
6
4
|
|
|
7
5
|
Each skill is a self-contained capability exposed over OPC-UA with `start()`/`suspend()`/`reset()`/`halt()` methods and
|
|
@@ -27,26 +25,22 @@ final position and result data until reset for the next move.
|
|
|
27
25
|
```mermaid
|
|
28
26
|
stateDiagram-v2
|
|
29
27
|
[*] --> Halted
|
|
30
|
-
Halted -->
|
|
31
|
-
|
|
32
|
-
Suspended --> Resetting: reset()
|
|
33
|
-
Completed --> Resetting: reset()
|
|
34
|
-
Resetting --> Ready: _internal_
|
|
35
|
-
Ready --> Halting: halt()
|
|
36
|
-
Running --> Halting: halt()
|
|
37
|
-
Suspended --> Halting: halt()
|
|
38
|
-
Starting --> Halting: halt()
|
|
39
|
-
Resetting --> Halting: halt()
|
|
40
|
-
Suspending --> Halting: halt()
|
|
41
|
-
Completed --> Halting: halt()
|
|
28
|
+
Halted --> Operational: reset()
|
|
29
|
+
Operational --> Halting: halt()
|
|
42
30
|
Halting --> Halted: _internal_
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
|
|
32
|
+
state Operational {
|
|
33
|
+
[*] --> Resetting
|
|
34
|
+
Resetting --> Ready: _internal_
|
|
35
|
+
Ready --> Starting: start()
|
|
36
|
+
Starting --> Running: _internal_
|
|
37
|
+
Running --> Suspending: suspend()
|
|
38
|
+
Suspending --> Suspended: _internal_
|
|
39
|
+
Suspended --> Starting: start()
|
|
40
|
+
Running --> Completing: _internal_
|
|
41
|
+
Completing --> Completed: _internal_
|
|
42
|
+
Completed --> Resetting: reset()
|
|
43
|
+
}
|
|
50
44
|
```
|
|
51
45
|
|
|
52
46
|
- `Halted`: A halted skill is in a failed/safe-ish state. E.g. a motor should apply fail-safe brakes, cut power etc. and
|
|
@@ -69,6 +63,8 @@ stateDiagram-v2
|
|
|
69
63
|
- `Suspended`: A suspended skill has paused at a safe point and is holding its state, ready to resume from exactly
|
|
70
64
|
where it left off. Unlike `Halted`, this isn't a failure/safe-mode — actuators may still be powered and holding
|
|
71
65
|
position. E.g. a robot arm is stationary between cycles, gripper still closed on a part, waiting to continue.
|
|
66
|
+
`start()` resumes it through `Starting`, so `_handle_starting()` runs again before the paused work continues in
|
|
67
|
+
`Running`.
|
|
72
68
|
- `Completing` *(finite skills only)*: A completing skill has finished its primary work and is performing final
|
|
73
69
|
cleanup or result reporting before being marked done. E.g. a gripper releases the part it just placed, or final
|
|
74
70
|
measurement data is written to the result record.
|
|
@@ -76,10 +72,14 @@ stateDiagram-v2
|
|
|
76
72
|
final results until it is reset for the next run. E.g. a part has been placed and the skill is reporting success
|
|
77
73
|
while awaiting a `reset()` before it can `start()` again.
|
|
78
74
|
|
|
75
|
+
`Operational` is only a box in the diagram, not a state: `halt()` works from every state in it, and `reset()` from
|
|
76
|
+
`Halted` enters it at `Resetting`. A finite skill completes only from `Running`. If `_handle_running()` returns while
|
|
77
|
+
the skill is `Suspending`, the skill finishes suspending and completes once it is started again.
|
|
78
|
+
|
|
79
79
|
> [!note]
|
|
80
80
|
> The \*ing states (`Halting`, `Resetting`, `Starting`, `Suspending`, `Completing`) all share the same shape: they're
|
|
81
|
-
the "in transition, doing async work" counterparts to their target steady state, and each is driven by a _handle_
|
|
82
|
-
that skill authors override.
|
|
81
|
+
> the "in transition, doing async work" counterparts to their target steady state, and each is driven by a `_handle_*`
|
|
82
|
+
> hook that skill authors override.
|
|
83
83
|
|
|
84
84
|
### Continuous Skills
|
|
85
85
|
|
|
@@ -94,25 +94,42 @@ skill would consider itself "done."
|
|
|
94
94
|
```mermaid
|
|
95
95
|
stateDiagram-v2
|
|
96
96
|
[*] --> Halted
|
|
97
|
-
Halted -->
|
|
98
|
-
|
|
99
|
-
Suspended --> Resetting: reset()
|
|
100
|
-
Resetting --> Ready: _internal_
|
|
101
|
-
Ready --> Halting: halt()
|
|
102
|
-
Running --> Halting: halt()
|
|
103
|
-
Suspended --> Halting: halt()
|
|
104
|
-
Starting --> Halting: halt()
|
|
105
|
-
Resetting --> Halting: halt()
|
|
106
|
-
Suspending --> Halting: halt()
|
|
97
|
+
Halted --> Operational: reset()
|
|
98
|
+
Operational --> Halting: halt()
|
|
107
99
|
Halting --> Halted: _internal_
|
|
108
|
-
Ready --> Starting: start()
|
|
109
|
-
Suspended --> Starting: start()
|
|
110
|
-
Starting --> Running: _internal_
|
|
111
|
-
Running --> Suspending: suspend()
|
|
112
|
-
Suspending --> Suspended: _internal_
|
|
113
100
|
|
|
101
|
+
state Operational {
|
|
102
|
+
[*] --> Resetting
|
|
103
|
+
Resetting --> Ready: _internal_
|
|
104
|
+
Ready --> Starting: start()
|
|
105
|
+
Starting --> Running: _internal_
|
|
106
|
+
Running --> Suspending: suspend()
|
|
107
|
+
Suspending --> Suspended: _internal_
|
|
108
|
+
Suspended --> Starting: start()
|
|
109
|
+
}
|
|
114
110
|
```
|
|
115
111
|
|
|
112
|
+
As for finite skills, `halt()` works from every state in the `Operational` box.
|
|
113
|
+
|
|
114
|
+
### The state machine in the address space
|
|
115
|
+
|
|
116
|
+
The transitions are those of `SkillStateMachineType` in the MachineSet nodeset; OpenSMI-Core provides them as
|
|
117
|
+
`opensmi.core.skill_state_machine`, which the server builds its state machine from and clients use to know which
|
|
118
|
+
commands a state allows (`allowed_commands()`). A skill created with `suspendable=False` has no `Suspend` method in
|
|
119
|
+
the address space and never reaches `Suspending` or `Suspended`; calling its Python `suspend()` raises
|
|
120
|
+
`BadNotImplemented`.
|
|
121
|
+
|
|
122
|
+
Besides the text of `CurrentState`, every skill's state machine publishes:
|
|
123
|
+
|
|
124
|
+
- `CurrentState/Id` and `CurrentState/Number`: NodeId and number of the state in `SkillStateMachineType`.
|
|
125
|
+
- `LastTransition` and `LastTransition/Id`: name and NodeId of the transition that led to the current state, empty
|
|
126
|
+
until the first transition after startup. The `SourceTimestamp` is the time of the transition. `LastTransition` has
|
|
127
|
+
no `Number`, as the nodeset defines none.
|
|
128
|
+
- `AvailableStates` and `AvailableTransitions`: the NodeIds of the states and transitions this skill can reach,
|
|
129
|
+
depending on whether it is finite and suspendable.
|
|
130
|
+
|
|
131
|
+
`CurrentState` and `LastTransition` change together, with the same timestamp.
|
|
132
|
+
|
|
116
133
|
## Advanced
|
|
117
134
|
|
|
118
135
|
### Composite Skills
|
|
@@ -128,7 +145,7 @@ and "Open"/"Close" skills.
|
|
|
128
145
|
|
|
129
146
|
> [!Note]
|
|
130
147
|
> The composite/atomic distinction is purely about what a skill's handlers do, not a different code path in the OpenSMI
|
|
131
|
-
framework.
|
|
148
|
+
> framework.
|
|
132
149
|
|
|
133
150
|
### Feasibility Check
|
|
134
151
|
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# Variables
|
|
2
|
+
|
|
3
|
+
Machinery items, skills and methods hold their values in `UaVariable`s inside the variable containers `ParameterSet`,
|
|
4
|
+
`Monitoring` and `FinalResultData` (see [Machinery Items](machinery_item.md)). This page covers values without a valid
|
|
5
|
+
value, and values that belong together: structures, and groups of variables.
|
|
6
|
+
|
|
7
|
+
## Bad status
|
|
8
|
+
|
|
9
|
+
When a variable has no valid value, e.g. because the connection to its data source is lost, mark it with a bad
|
|
10
|
+
status instead of leaving the last value. Clients then see the status and no value:
|
|
11
|
+
|
|
12
|
+
```python
|
|
13
|
+
from asyncua import ua
|
|
14
|
+
|
|
15
|
+
await self.monitoring.Temperature.write_status(ua.StatusCodes.BadNoCommunication)
|
|
16
|
+
...
|
|
17
|
+
await self.monitoring.Temperature.write(21.5) # valid again: the status is Good
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
`write_status()` accepts bad statuses only; a good or uncertain status comes with a value, so use `write()`. A bad
|
|
21
|
+
status is not checked: every variable accepts it, also one that is not `optional_ok`, and its `write_check_callback`
|
|
22
|
+
is not called.
|
|
23
|
+
|
|
24
|
+
## Structures
|
|
25
|
+
|
|
26
|
+
A variable whose `initial_value` is a dataclass instance holds a structure. The server creates the OPC UA DataType
|
|
27
|
+
from the dataclass when the variable is created, and the variable reads and writes instances of it:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from dataclasses import dataclass, field
|
|
31
|
+
|
|
32
|
+
from opensmi.server import ParameterSet, UaVariable
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@dataclass
|
|
36
|
+
class Dimensions:
|
|
37
|
+
length: float = 0.0
|
|
38
|
+
width: float = 0.0
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class Workpiece:
|
|
43
|
+
id: str = ""
|
|
44
|
+
dimensions: Dimensions = field(default_factory=Dimensions)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class Parameters(ParameterSet):
|
|
48
|
+
CurrentWorkpiece = UaVariable(initial_value=Workpiece("W-001", Dimensions(120.0, 80.0)))
|
|
49
|
+
"""The workpiece in the machine."""
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Fields are `float`, `int`, `str`, `bool`, `bytes`, another dataclass, or a `list` of one of these. A list of dataclass
|
|
53
|
+
instances is a variable too; if it starts empty, name the class with `variable_type`. Every write is checked: the
|
|
54
|
+
variable accepts only an instance of its class (or a list of them) and refuses anything else with `BadTypeMismatch`.
|
|
55
|
+
|
|
56
|
+
A client needs no class of its own. asyncua's `Client.load_data_type_definitions()` builds one from the
|
|
57
|
+
`DataTypeDefinition` the server publishes. The module docstring of `opensmi.server.structures` has the details, e.g.
|
|
58
|
+
how to pick other OPC UA number types for a field.
|
|
59
|
+
|
|
60
|
+
## Complex variables
|
|
61
|
+
|
|
62
|
+
A variable that holds one structure (not a list) is a complex variable: below the variable is one child variable per
|
|
63
|
+
field, and below a nested structure its fields again. The browse name of a child is its field name in PascalCase:
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
ParameterSet
|
|
67
|
+
CurrentWorkpiece Workpiece (the whole structure)
|
|
68
|
+
Id String
|
|
69
|
+
Dimensions Dimensions (complex again)
|
|
70
|
+
Length Double
|
|
71
|
+
Width Double
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
A list, also of dataclass instances, is one child of its own, without children for its elements.
|
|
75
|
+
|
|
76
|
+
Clients can read, subscribe to and write each child like any other variable, so a client without the structure's
|
|
77
|
+
class can still show and change `CurrentWorkpiece/Dimensions/Length`. In Python, `variable.children` maps the names to
|
|
78
|
+
the child variables, and `variable["Dimensions"]["Length"]` is one of them:
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
length = self.parameter_set.CurrentWorkpiece["Dimensions"]["Length"]
|
|
82
|
+
await length.write(95.0)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
To change one field from server code, write the child rather than reading, changing and writing the whole structure.
|
|
86
|
+
A write to a child is merged into the current structure while other writes to the variable wait, so a concurrent
|
|
87
|
+
write to another field, e.g. by a client, is kept. Between your `read()` and `write()` of the whole structure,
|
|
88
|
+
another write can land, and yours would undo it.
|
|
89
|
+
|
|
90
|
+
The variable and its children always agree:
|
|
91
|
+
|
|
92
|
+
- A write to the variable also writes all its children, and a write to a child also writes the variable and the
|
|
93
|
+
structures on the way up. All of them get one `SourceTimestamp` and the status of the write.
|
|
94
|
+
- A bad status (e.g. `BadNoCommunication`, see [Bad status](#bad-status)) has no value and is not checked. Written to
|
|
95
|
+
the variable or to any child, it reaches the variable and all its children, and none of them has a value.
|
|
96
|
+
- Every write is checked once, by the variable that holds the whole structure, on the whole new structure. Its
|
|
97
|
+
`write_check_callback` therefore also sees writes to a child and can check rules across fields. A refused write
|
|
98
|
+
changes nothing. A `write_check_callback` only checks: it must not write any variable.
|
|
99
|
+
- The children share the access of the variable: `writable`, `bypass_lock` and `minimum_access_level`, also after
|
|
100
|
+
`set_writable()`. They have no `write_check_callback` of their own.
|
|
101
|
+
- While the variable has a bad status, a write to a child is refused with that status, since there is no structure to
|
|
102
|
+
change. Write the whole structure first.
|
|
103
|
+
|
|
104
|
+
## Groups
|
|
105
|
+
|
|
106
|
+
A `VariableGroup` is an Object in a variable container that holds variables and further groups, for variables that
|
|
107
|
+
belong together but are not one structure. Declare it like a variable:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from opensmi.server import ParameterSet, UaVariable, VariableGroup
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class FollowPath(VariableGroup):
|
|
114
|
+
MaxVelX = UaVariable(initial_value=0.5)
|
|
115
|
+
"""Maximum forward velocity in m/s."""
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class Controller(VariableGroup):
|
|
119
|
+
UseSimTime = UaVariable(initial_value=False)
|
|
120
|
+
"""Whether the controller uses the simulation time."""
|
|
121
|
+
|
|
122
|
+
FollowPath = FollowPath()
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class Parameters(ParameterSet):
|
|
126
|
+
Controller = Controller()
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Clients browse it as `ParameterSet/Controller/FollowPath/MaxVelX`. A group takes the writability and the
|
|
130
|
+
`minimum_access_level` of its container, so the variables declared in it are writable in a `ParameterSet` and
|
|
131
|
+
read-only in `Monitoring`, as if they were declared in the container itself.
|
|
132
|
+
|
|
133
|
+
Add and remove groups while the server runs with `add_group()` and `remove_group()`. Removing a group removes
|
|
134
|
+
everything below it:
|
|
135
|
+
|
|
136
|
+
```python
|
|
137
|
+
sensors = await self.monitoring.add_group("Sensors")
|
|
138
|
+
await sensors.add(UaVariable(initial_value=0.0, name="Level"))
|
|
139
|
+
...
|
|
140
|
+
await self.monitoring.remove_group("Sensors")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
In Python, a declared group is an attribute of its container (`parameters.Controller.FollowPath.MaxVelX`), and
|
|
144
|
+
`container.groups` maps the names of all groups to them, declared or added. The rest of the container interface covers
|
|
145
|
+
its variables only: `container["MaxVelX"]`, `"MaxVelX" in container`, `len(container)` and `for variable in
|
|
146
|
+
container` do not see groups. `read_all()`, `write_all()` and `reset_all()` include the groups, as nested mappings:
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
await parameters.read_all()
|
|
150
|
+
# {"Controller": {"UseSimTime": False, "FollowPath": {"MaxVelX": 0.5}}}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Structure or group?
|
|
154
|
+
|
|
155
|
+
A complex variable is one value: it is valid as a whole or not at all. A bad status on any of its nodes reaches all
|
|
156
|
+
of them, and a client can read it atomically. A group is only a namespace: each variable in it has its own value and
|
|
157
|
+
status, and the group itself has none.
|
|
158
|
+
|
|
159
|
+
- Use a **structure** for values that arrive and are valid together, from one source, e.g. a workpiece record or a
|
|
160
|
+
pose read from the controller in one go.
|
|
161
|
+
- Use a **group** for values that come from independent sources and can fail separately, e.g. the readings of two
|
|
162
|
+
sensors. Then one lost sensor marks only its own variables bad, and the others stay readable.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Structures
|
|
2
|
+
|
|
3
|
+
Shows structured values defined as dataclasses. The machine has two parameters: `CurrentWorkpiece`, a `Workpiece`
|
|
4
|
+
(id, material and nested `Dimensions`), and `Measurements`, a list of `Measurement` (name, value, in tolerance). They
|
|
5
|
+
are declared like any other variable, with a dataclass instance as `initial_value`. The structure types are created on
|
|
6
|
+
the server when the variables are created, and the server reads and writes the dataclass objects directly. Every
|
|
7
|
+
write is checked: `CurrentWorkpiece` accepts only a `Workpiece` and `Measurements` only a list of `Measurement` (a
|
|
8
|
+
list that starts empty names its class with `variable_type`). The server changes the workpiece once after it starts.
|
|
9
|
+
|
|
10
|
+
A dataclass value is a complex variable: the variable holds the whole structure, and below it is one child variable per
|
|
11
|
+
field (`CurrentWorkpiece/Dimensions/Length`), recursively. The browse name of a child is the field name in PascalCase,
|
|
12
|
+
its display name is the field name. A client can read, write or subscribe to a single field, and the structure always
|
|
13
|
+
agrees with its fields. A write is checked once, at the parent, so a `write_check_callback` always sees the whole
|
|
14
|
+
structure. In Python, `variable["Dimensions"]["Length"]` is the child variable.
|
|
15
|
+
|
|
16
|
+
The parameters also hold a declared group, `Gripper` (a `VariableGroup`, an Object that holds variables), and the
|
|
17
|
+
server adds a group named `station 1: left` to the monitoring at runtime. A name that comes from runtime data is added
|
|
18
|
+
with `runtime_keyed=True`, which only requires a valid path segment (not empty, no `/`) instead of the naming rule.
|
|
19
|
+
|
|
20
|
+
`client.py` is plain asyncua and knows none of the classes. It calls `load_data_type_definitions`, which builds them
|
|
21
|
+
from the `DataTypeDefinition` the server published, reads the workpiece, reads and writes its length through the child
|
|
22
|
+
variable, reads the workpiece again, browses the two groups, adds a measurement and tries to write a `Workpiece` into
|
|
23
|
+
`Measurements`.
|
|
24
|
+
|
|
25
|
+
Run the server in one terminal and the client in another, from the repository root:
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
python examples/structures/server.py
|
|
29
|
+
python examples/structures/client.py
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The server logs its startup and ends with the line `Serving on opc.tcp://0.0.0.0:4841/server`.
|
|
33
|
+
The client prints:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
Workpiece: W-002 (aluminium), 90.0 x 60.0 x 5.0 mm
|
|
37
|
+
Length: 90.0 mm
|
|
38
|
+
Workpiece now: 95.0 mm long
|
|
39
|
+
Gripper: ['Force']
|
|
40
|
+
Monitoring group 'station 1: left': ['Temperature']
|
|
41
|
+
Measurements: ['length']
|
|
42
|
+
Measurements now: ['length', 'width']
|
|
43
|
+
Writing a workpiece to Measurements was refused: BadTypeMismatch
|
|
44
|
+
```
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 OpenSMI Contributors
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: CC0-1.0
|
|
4
|
+
|
|
5
|
+
"""Client for ``server.py``: reads and writes the structures with plain asyncua and tries a write of the wrong type.
|
|
6
|
+
|
|
7
|
+
The client knows none of the classes. ``load_data_type_definitions`` builds them from the ``DataTypeDefinition``
|
|
8
|
+
that the server published.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import asyncio
|
|
12
|
+
import logging
|
|
13
|
+
|
|
14
|
+
from asyncua import Client, ua
|
|
15
|
+
|
|
16
|
+
URL = "opc.tcp://operator:operator@localhost:4841/server"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
async def main() -> None:
|
|
20
|
+
"""Read both variables, add a measurement and try a write of the wrong type."""
|
|
21
|
+
async with Client(URL) as client:
|
|
22
|
+
await client.load_data_type_definitions()
|
|
23
|
+
|
|
24
|
+
workpiece_node = client.get_node("ns=1;s=ExampleMachine.ParameterSet.CurrentWorkpiece")
|
|
25
|
+
workpiece = await workpiece_node.read_value()
|
|
26
|
+
size = workpiece.dimensions
|
|
27
|
+
print(f"Workpiece: {workpiece.id} ({workpiece.material}), {size.length} x {size.width} x {size.height} mm") # noqa: T201
|
|
28
|
+
|
|
29
|
+
# The workpiece has a child variable per field: read one leaf, write it, and read the whole workpiece again
|
|
30
|
+
length_node = await workpiece_node.get_child(["1:Dimensions", "1:Length"])
|
|
31
|
+
print(f"Length: {await length_node.read_value()} mm") # noqa: T201
|
|
32
|
+
await length_node.write_value(ua.Variant(95.0, ua.VariantType.Double))
|
|
33
|
+
print(f"Workpiece now: {(await workpiece_node.read_value()).dimensions.length} mm long") # noqa: T201
|
|
34
|
+
|
|
35
|
+
# Groups are objects: browse the declared one in the ParameterSet and the one added at runtime
|
|
36
|
+
parameter_set = client.get_node("ns=1;s=ExampleMachine.ParameterSet")
|
|
37
|
+
gripper = await parameter_set.get_child("1:Gripper")
|
|
38
|
+
print(f"Gripper: {[(await each.read_browse_name()).Name for each in await gripper.get_children()]}") # noqa: T201
|
|
39
|
+
monitoring = client.get_node("ns=1;s=ExampleMachine.Monitoring")
|
|
40
|
+
for group in await monitoring.get_children(nodeclassmask=ua.NodeClass.Object):
|
|
41
|
+
names = [(await each.read_browse_name()).Name for each in await group.get_children()]
|
|
42
|
+
print(f"Monitoring group {(await group.read_browse_name()).Name!r}: {names}") # noqa: T201
|
|
43
|
+
|
|
44
|
+
measurements_node = client.get_node("ns=1;s=ExampleMachine.ParameterSet.Measurements")
|
|
45
|
+
measurements = await measurements_node.read_value()
|
|
46
|
+
print(f"Measurements: {[each.name for each in measurements]}") # noqa: T201
|
|
47
|
+
|
|
48
|
+
# Add a measurement, built from a copy of the first one
|
|
49
|
+
width = type(measurements[0])(name="width", value=size.width, in_tolerance=False)
|
|
50
|
+
await measurements_node.write_value(ua.Variant([*measurements, width], ua.VariantType.ExtensionObject))
|
|
51
|
+
print(f"Measurements now: {[each.name for each in await measurements_node.read_value()]}") # noqa: T201
|
|
52
|
+
|
|
53
|
+
# A workpiece where a list of measurements belongs: the server refuses it
|
|
54
|
+
try:
|
|
55
|
+
await measurements_node.write_value(ua.Variant([workpiece], ua.VariantType.ExtensionObject))
|
|
56
|
+
except ua.UaStatusCodeError as err:
|
|
57
|
+
print(f"Writing a workpiece to Measurements was refused: {ua.StatusCode(err.code).name}") # noqa: T201
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if __name__ == "__main__":
|
|
61
|
+
logging.getLogger("asyncua").setLevel(logging.ERROR)
|
|
62
|
+
asyncio.run(main())
|