Commit f0f06d9
committed
feat(opcua): implement DataProvider + OperationProvider + FaultProvider; harden plugin
Address all critical and important findings from maintainer review:
Provider migration (#11 critical):
- Implement DataProvider (list_data, read_data, write_data) so standard
SOVD GET/PUT /{type}/{id}/data endpoints work for PLC entities
- Implement OperationProvider (list_operations, execute_operation) for
POST /{type}/{id}/operations/{name}
- Implement FaultProvider (list_faults, get_fault, clear_fault) for
GET/DELETE /{type}/{id}/faults
- Export get_data_provider, get_operation_provider, get_fault_provider
via extern "C" in opcua_plugin_exports.cpp
- Keep all vendor x-plc-* routes for backward compat + rich PLC data
- MCP tools (sovd_read_data etc.), Web UI, fleet gateway now work on
PLC entities through standard SOVD paths
Shutdown guard (#13 important):
- Add std::atomic<bool> shutdown_requested_ with exchange(true) pattern
- Destructor calls shutdown() (was = default)
- Callbacks (publish_values, on_alarm_change) check flag before work
- All 4 route handlers + 8 provider methods return 503 when shutdown
Null checks (#14 important):
- All route handlers and provider methods check ctx_ and poller_ at
entry, returning 503 ERR_SERVICE_UNAVAILABLE if uninitialized
Condition variable sleep (#15 important):
- Replace integer-division sleep loops in opcua_poller with
std::condition_variable::wait_for so stop() wakes the thread
immediately and sub-100ms intervals no longer cause CPU spin
- Replace assert(!running_) in set_poll_callback with std::logic_error
throw that survives Release builds
Small fixes (#21, #22, #25, #26):
- SecurityPolicy=None warning now includes endpoint URL
- FetchContent GIT_TAG pinned to full SHA (122ea4c8) instead of
mutable v0.16.0 tag
- package.xml: XML comment explaining open62541pp FetchContent + #366
- opcua-plugin.yml: add permissions: contents: read
Rename private fault helpers (avoid name collision with FaultProvider):
- report_fault -> send_report_fault
- clear_fault(fault_code) -> send_clear_fault(fault_code)1 parent 854e687 commit f0f06d9
8 files changed
Lines changed: 449 additions & 25 deletions
File tree
- .github/workflows
- src/ros2_medkit_plugins/ros2_medkit_opcua
- include/ros2_medkit_opcua
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
Lines changed: 50 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
| 27 | + | |
25 | 28 | | |
| 29 | + | |
26 | 30 | | |
27 | 31 | | |
28 | 32 | | |
| |||
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
39 | | - | |
40 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
41 | 48 | | |
42 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
43 | 60 | | |
44 | 61 | | |
45 | 62 | | |
46 | 63 | | |
47 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
48 | 69 | | |
49 | 70 | | |
50 | 71 | | |
| |||
61 | 82 | | |
62 | 83 | | |
63 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
64 | 105 | | |
65 | 106 | | |
66 | 107 | | |
| |||
72 | 113 | | |
73 | 114 | | |
74 | 115 | | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
79 | 120 | | |
80 | 121 | | |
81 | 122 | | |
82 | 123 | | |
83 | 124 | | |
84 | 125 | | |
85 | 126 | | |
| 127 | + | |
86 | 128 | | |
87 | 129 | | |
88 | 130 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
100 | 101 | | |
101 | 102 | | |
102 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
25 | 30 | | |
26 | 31 | | |
27 | 32 | | |
| |||
0 commit comments