open62541pp 0.22.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
monitoreditem.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <functional>
5#include <memory>
6#include <utility> // forward
7#include <vector>
8
10#include "open62541pp/config.hpp"
11#include "open62541pp/detail/client_utils.hpp" // getHandle
18#include "open62541pp/span.hpp"
19#include "open62541pp/types.hpp"
21
22#ifdef UA_ENABLE_SUBSCRIPTIONS
23
24namespace opcua {
25class Client;
26} // namespace opcua
27
28namespace opcua::services {
29
30/**
31 * @defgroup MonitoredItem MonitoredItem service set
32 * Subscribe to data and events.
33 *
34 * Note the difference between Subscriptions and MonitoredItems. Subscriptions are used to report
35 * back notifications. Monitored items are used to generate notifications. Every monitored item is
36 * attached to exactly one subscription. And a subscription can contain many monitored items.
37 *
38 * Monitored items can also be registered locally (server-side). Notifications are then forwarded
39 * to a user-defined callback instead of a remote client.
40 *
41 * @see Subscription
42 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.13
43 * @ingroup Services
44 * @{
45 */
46
47/**
48 * Extended monitoring parameters with default values from open62541.
49 * This is an extended version of `UA_MonitoringParameters` with the `timestamps` parameter.
50 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/7.21
51 */
53 /// Timestamps to be transmitted.
54 TimestampsToReturn timestamps = TimestampsToReturn::Both;
55 /// Interval in milliseconds that defines the fastest rate at which the MonitoredItem should be
56 /// accessed and evaluated. The following values have special meaning:
57 /// - `0.0` to use the fastest practical rate
58 /// - `-1.0` to use the default sampling interval (publishing interval of the subscription)
59 double samplingInterval = 250.0;
60 /// Filter is used by the server to determine if the MonitoredItem should generate
61 /// notifications. The filter parameter type is an extensible parameter type and can be, for
62 /// example, of type DataChangeFilter, EventFilter or AggregateFilter.
63 /// @see https://reference.opcfoundation.org/Core/Part4/v105/docs/7.22
65 /// Size of the MonitoringItem queue.
66 /// The following values have special meaning:
67 /// - `0` to retrieve the server's default queue size
68 /// - `1` to retrieve the server's minimum queue size
69 /// In the case of a queue overflow, an Event of the type EventQueueOverflowEventType is
70 /// generated.
71 uint32_t queueSize = 1;
72 /// Discard policy when the queue is full.
73 /// - `true`: the oldest (first) notification in the queue is discarded
74 /// - `false`: the last notification added to the queue gets replaced with the new notification
75 bool discardOldest = true;
76};
77
78/**
79 * @defgroup CreateMonitoredItems CreateMonitoredItems service
80 * Create and add a monitored item to a subscription.
81 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.13.2
82 * @{
83 */
84
85/**
86 * MonitoredItem deletion callback.
87 * @param subId Subscription identifier
88 * @param monId MonitoredItem identifier
89 */
90using DeleteMonitoredItemCallback = std::function<void(IntegerId subId, IntegerId monId)>;
91
92/**
93 * Data change notification callback.
94 * @param subId Subscription identifier (`0U` for local (server-side) monitored item)
95 * @param monId MonitoredItem identifier
96 * @param value Changed value
97 */
99 std::function<void(IntegerId subId, IntegerId monId, const DataValue& value)>;
100
101/**
102 * Event notification callback.
103 * @param subId Subscription identifier (`0U` for local (server-side) monitored item)
104 * @param monId MonitoredItem identifier
105 * @param eventFields Event fields
106 */
108 std::function<void(IntegerId subId, IntegerId monId, Span<const Variant> eventFields)>;
109
110namespace detail {
111std::vector<std::unique_ptr<MonitoredItemContext>> makeMonitoredItemContexts(
112 Client& connection,
113 const CreateMonitoredItemsRequest& request,
114 DataChangeNotificationCallback dataChangeCallback,
115 EventNotificationCallback eventCallback,
116 DeleteMonitoredItemCallback deleteCallback
117);
118
119void convertMonitoredItemContexts(
120 Span<const std::unique_ptr<MonitoredItemContext>> contexts,
121 Span<void*> contextsPtr,
122 Span<UA_Client_DataChangeNotificationCallback> dataChangeCallbacksNative,
125) noexcept;
126
127void storeMonitoredItemContexts(
128 Client& connection,
129 IntegerId subscriptionId,
130 const CreateMonitoredItemsResponse& response,
131 Span<std::unique_ptr<MonitoredItemContext>> contexts
132);
133} // namespace detail
134
135/**
136 * Create and add monitored items to a subscription for data change notifications.
137 * Don't use this function to monitor the `EventNotifier` attribute.
138 * Create monitored items with @ref createMonitoredItemsEvent instead.
139 *
140 * @param connection Instance of type Client
141 * @param request Create monitored items request
142 * @param dataChangeCallback Invoked when the monitored item is changed
143 * @param deleteCallback Invoked when the monitored item is deleted
144 */
146 Client& connection,
147 const CreateMonitoredItemsRequest& request,
148 DataChangeNotificationCallback dataChangeCallback,
149 DeleteMonitoredItemCallback deleteCallback
150);
151
152#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
153/**
154 * @copydoc createMonitoredItemsDataChange(Client&, const CreateMonitoredItemsRequest&,
155 * DataChangeNotificationCallback, DeleteMonitoredItemCallback)
156 * @param token @completiontoken{void(CreateMonitoredItemsResponse&)}
157 * @return @asyncresult{CreateMonitoredItemsResponse}
158 */
159template <typename CompletionToken>
161 Client& connection,
162 const CreateMonitoredItemsRequest& request,
163 DataChangeNotificationCallback dataChangeCallback,
164 DeleteMonitoredItemCallback deleteCallback,
165 CompletionToken&& token
166) {
167 auto contexts = detail::makeMonitoredItemContexts(
168 connection, request, std::move(dataChangeCallback), {}, std::move(deleteCallback)
169 );
170 std::vector<void*> contextsPtr{contexts.size()};
171 std::vector<UA_Client_DataChangeNotificationCallback> dataChangeCallbacks{contexts.size()};
172 std::vector<UA_Client_DeleteMonitoredItemCallback> deleteCallbacks{contexts.size()};
173 detail::convertMonitoredItemContexts(
174 contexts, contextsPtr, dataChangeCallbacks, {}, deleteCallbacks
175 );
176 return detail::AsyncServiceAdapter<CreateMonitoredItemsResponse>::initiate(
177 connection,
178 [&connection](
180 void* userdata,
181 const CreateMonitoredItemsRequest& innerRequest,
182 Span<void* const> innerContextsPtr,
185 ) {
187 opcua::detail::getHandle(connection),
188 asNative(innerRequest),
189 // NOLINTBEGIN
190 const_cast<void**>(innerContextsPtr.data()),
191 const_cast<UA_Client_DataChangeNotificationCallback*>(innerDataChangeCallbacks.data(
192 )),
193 const_cast<UA_Client_DeleteMonitoredItemCallback*>(innerDeleteCallbacks.data()),
194 // NOLINTEND
195 callback,
196 userdata,
197 nullptr
198 ));
199 },
200 detail::HookToken(
201 [&connection,
202 subscriptionId = request.subscriptionId(),
203 contexts = std::move(contexts)](const auto& response) mutable {
204 detail::storeMonitoredItemContexts(connection, subscriptionId, response, contexts);
205 },
206 std::forward<CompletionToken>(token)
207 ),
208 request,
209 std::move(contextsPtr),
210 std::move(dataChangeCallbacks),
211 std::move(deleteCallbacks)
212 );
213}
214#endif
215
216/**
217 * Create and add a monitored item to a subscription for data change notifications.
218 * Don't use this function to monitor the `EventNotifier` attribute.
219 * Create a monitored item with @ref createMonitoredItemEvent instead.
220 *
221 * @param connection Instance of type Server or Client
222 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription.
223 * Use `0U` for a local server-side monitored item.
224 * @param itemToMonitor Item to monitor
225 * @param monitoringMode Monitoring mode
226 * @param parameters Monitoring parameters
227 * @param dataChangeCallback Invoked when the monitored item is changed
228 * @param deleteCallback Invoked when the monitored item is deleted
229 */
230template <typename T>
232 T& connection,
233 IntegerId subscriptionId,
234 const ReadValueId& itemToMonitor,
235 MonitoringMode monitoringMode,
236 const MonitoringParametersEx& parameters,
237 DataChangeNotificationCallback dataChangeCallback,
238 DeleteMonitoredItemCallback deleteCallback
239);
240
241#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
242/**
243 * @copydoc createMonitoredItemDataChange(Client&, IntegerId, const ReadValueId&, MonitoringMode,
244 * const MonitoringParametersEx&, DataChangeNotificationCallback,
245 * DeleteMonitoredItemCallback)
246 * @param token @completiontoken{void(MonitoredItemCreateResult&)}
247 * @return @asyncresult{MonitoredItemCreateResult}
248 */
249template <typename CompletionToken>
251 Client& connection,
252 IntegerId subscriptionId,
253 const ReadValueId& itemToMonitor,
254 MonitoringMode monitoringMode,
255 const MonitoringParametersEx& parameters,
256 DataChangeNotificationCallback dataChangeCallback,
257 DeleteMonitoredItemCallback deleteCallback,
258 CompletionToken&& token
259) {
260 auto item = detail::makeMonitoredItemCreateRequest(itemToMonitor, monitoringMode, parameters);
261 const auto request = detail::makeCreateMonitoredItemsRequest(
262 subscriptionId, parameters.timestamps, {&item, 1}
263 );
265 connection,
266 asWrapper<CreateMonitoredItemsRequest>(request),
267 std::move(dataChangeCallback),
268 std::move(deleteCallback),
269 detail::TransformToken(
270 detail::wrapSingleResultWithStatus<
273 std::forward<CompletionToken>(token)
274 )
275 );
276}
277#endif
278
279/**
280 * Create and add monitored items to a subscription for event notifications.
281 * The `attributeId` of ReadValueId must be set to AttributeId::EventNotifier.
282 *
283 * @param connection Instance of type Client
284 * @param request Create monitored items request
285 * @param eventCallback Invoked when an event is published
286 * @param deleteCallback Invoked when the monitored item is deleted
287 */
289 Client& connection,
290 const CreateMonitoredItemsRequest& request,
291 EventNotificationCallback eventCallback,
292 DeleteMonitoredItemCallback deleteCallback
293);
294
295#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
296/**
297 * @copydoc createMonitoredItemsEvent(Client&, const CreateMonitoredItemsRequest&,
298 * EventNotificationCallback, DeleteMonitoredItemCallback)
299 * @param token @completiontoken{void(CreateMonitoredItemsResponse&)}
300 * @return @asyncresult{CreateMonitoredItemsResponse}
301 */
302template <typename CompletionToken>
304 Client& connection,
305 const CreateMonitoredItemsRequest& request,
306 EventNotificationCallback eventCallback,
307 DeleteMonitoredItemCallback deleteCallback,
308 CompletionToken&& token
309) {
310 auto contexts = detail::makeMonitoredItemContexts(
311 connection, request, {}, std::move(eventCallback), std::move(deleteCallback)
312 );
313 std::vector<void*> contextsPtr{contexts.size()};
314 std::vector<UA_Client_EventNotificationCallback> eventCallbacks{contexts.size()};
315 std::vector<UA_Client_DeleteMonitoredItemCallback> deleteCallbacks{contexts.size()};
316 detail::convertMonitoredItemContexts(
317 contexts, contextsPtr, {}, eventCallbacks, deleteCallbacks
318 );
319 return detail::AsyncServiceAdapter<CreateMonitoredItemsResponse>::initiate(
320 connection,
321 [&connection](
323 void* userdata,
324 const CreateMonitoredItemsRequest& innerRequest,
325 Span<void* const> innerContextsPtr,
328 ) {
330 opcua::detail::getHandle(connection),
331 asNative(innerRequest),
332 // NOLINGBEGIN
333 const_cast<void**>(innerContextsPtr.data()),
334 const_cast<UA_Client_EventNotificationCallback*>(innerEventCallbacks.data()),
335 const_cast<UA_Client_DeleteMonitoredItemCallback*>(innerDeleteCallbacks.data()),
336 // NOLINTEND
337 callback,
338 userdata,
339 nullptr
340 ));
341 },
342 detail::HookToken(
343 [&connection,
344 subscriptionId = request.subscriptionId(),
345 contexts = std::move(contexts)](const auto& response) mutable {
346 detail::storeMonitoredItemContexts(connection, subscriptionId, response, contexts);
347 },
348 std::forward<CompletionToken>(token)
349 ),
350 request,
351 std::move(contextsPtr),
352 std::move(eventCallbacks),
353 std::move(deleteCallbacks)
354 );
355}
356#endif
357
358/**
359 * Create and add a monitored item to a subscription for event notifications.
360 * The `attributeId` of ReadValueId must be set to AttributeId::EventNotifier.
361 *
362 * @param connection Instance of type Client
363 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription
364 * @param itemToMonitor Item to monitor
365 * @param monitoringMode Monitoring mode
366 * @param parameters Monitoring parameters
367 * @param eventCallback Invoked when an event is published
368 * @param deleteCallback Invoked when the monitored item is deleted
369 */
371 Client& connection,
372 IntegerId subscriptionId,
373 const ReadValueId& itemToMonitor,
374 MonitoringMode monitoringMode,
375 const MonitoringParametersEx& parameters,
376 EventNotificationCallback eventCallback,
377 DeleteMonitoredItemCallback deleteCallback = {}
378);
379
380#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
381/**
382 * @copydoc createMonitoredItemEvent(Client&, IntegerId, const ReadValueId&, MonitoringMode,
383 * const MonitoringParametersEx&, EventNotificationCallback, DeleteMonitoredItemCallback)
384 * @param token @completiontoken{void(MonitoredItemCreateResult&)}
385 * @return @asyncresult{MonitoredItemCreateResult}
386 */
387template <typename CompletionToken>
389 Client& connection,
390 IntegerId subscriptionId,
391 const ReadValueId& itemToMonitor,
392 MonitoringMode monitoringMode,
393 const MonitoringParametersEx& parameters,
394 EventNotificationCallback eventCallback,
395 DeleteMonitoredItemCallback deleteCallback,
396 CompletionToken&& token
397) {
398 auto item = detail::makeMonitoredItemCreateRequest(itemToMonitor, monitoringMode, parameters);
399 const auto request = detail::makeCreateMonitoredItemsRequest(
400 subscriptionId, parameters.timestamps, {&item, 1}
401 );
403 connection,
404 asWrapper<CreateMonitoredItemsRequest>(request),
405 std::move(eventCallback),
406 std::move(deleteCallback),
407 detail::TransformToken(
408 detail::wrapSingleResultWithStatus<
411 std::forward<CompletionToken>(token)
412 )
413 );
414}
415#endif
416
417/**
418 * @}
419 * @defgroup ModifyMonitoredItems ModifyMonitoredItems service
420 * Modify a monitored items of a subscription.
421 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.13.3
422 * @{
423 */
424
425/**
426 * Modify monitored items of a subscription.
427 *
428 * @param connection Instance of type Client
429 * @param request Modify monitored items request
430 */
432 Client& connection, const ModifyMonitoredItemsRequest& request
433) noexcept;
434
435#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
436/**
437 * @copydoc modifyMonitoredItems(Client&, const ModifyMonitoredItemsRequest&)
438 * @param token @completiontoken{void(ModifyMonitoredItemsResponse&)}
439 * @return @asyncresult{ModifyMonitoredItemsResponse}
440 */
441template <typename CompletionToken>
443 Client& connection, const ModifyMonitoredItemsRequest& request, CompletionToken&& token
444) {
445 return detail::AsyncServiceAdapter<ModifyMonitoredItemsResponse>::initiate(
446 connection,
447 [&connection](
449 void* userdata,
450 const ModifyMonitoredItemsRequest& innerRequest
451 ) {
453 opcua::detail::getHandle(connection),
454 asNative(innerRequest),
455 callback,
456 userdata,
457 nullptr
458 ));
459 },
460 std::forward<CompletionToken>(token),
461 request
462 );
463}
464#endif
465
466/**
467 * Modify a monitored item of a subscription.
468 *
469 * @param connection Instance of type Client
470 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription
471 * @param monitoredItemId Identifier of the monitored item
472 * @param parameters Monitoring parameters
473 */
475 Client& connection,
476 IntegerId subscriptionId,
477 IntegerId monitoredItemId,
478 const MonitoringParametersEx& parameters
479) noexcept {
480 auto item = detail::makeMonitoredItemModifyRequest(monitoredItemId, parameters);
481 auto request = detail::makeModifyMonitoredItemsRequest(subscriptionId, parameters, item);
482 auto response = modifyMonitoredItems(
483 connection, asWrapper<ModifyMonitoredItemsRequest>(request)
484 );
485 return detail::wrapSingleResultWithStatus<MonitoredItemModifyResult>(response);
486}
487
488#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
489/**
490 * @copydoc modifyMonitoredItems(Client&, IntegerId, IntegerId, const MonitoringParametersEx&)
491 * @param token @completiontoken{void(MonitoredItemModifyResult&)}
492 * @return @asyncresult{MonitoredItemModifyResult}
493 */
494template <typename CompletionToken>
496 Client& connection,
497 IntegerId subscriptionId,
498 IntegerId monitoredItemId,
499 const MonitoringParametersEx& parameters,
500 CompletionToken&& token
501) {
502 auto item = detail::makeMonitoredItemModifyRequest(monitoredItemId, parameters);
503 auto request = detail::makeModifyMonitoredItemsRequest(subscriptionId, parameters, item);
505 connection,
506 asWrapper<ModifyMonitoredItemsRequest>(request),
507 detail::TransformToken(
508 detail::wrapSingleResultWithStatus<
511 std::forward<CompletionToken>(token)
512 )
513 );
514}
515#endif
516
517/**
518 * @}
519 * @defgroup SetMonitoringMode SetMonitoringMode service
520 * Set the monitoring mode of a monitored items.
521 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.13.4
522 * @{
523 */
524
525/**
526 * Set the monitoring mode of monitored items.
527 *
528 * @param connection Instance of type Client
529 * @param request Set monitoring mode request
530 */
532 Client& connection, const SetMonitoringModeRequest& request
533) noexcept;
534
535/**
536 * @copydoc setMonitoringMode(Client&, const SetMonitoringModeRequest&)
537 * @param token @completiontoken{void(SetMonitoringModeResponse&)}
538 * @return @asyncresult{SetMonitoringModeResponse}
539 */
540template <typename CompletionToken>
542 Client& connection, const SetMonitoringModeRequest& request, CompletionToken&& token
543) {
544 return detail::sendRequestAsync<SetMonitoringModeRequest, SetMonitoringModeResponse>(
545 connection, request, std::forward<CompletionToken>(token)
546 );
547}
548
549/**
550 * Set the monitoring mode of a monitored item.
551 *
552 * @param connection Instance of type Client
553 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription
554 * @param monitoredItemId Identifier of the monitored item
555 * @param monitoringMode Monitoring mode
556 */
558 Client& connection,
559 IntegerId subscriptionId,
560 IntegerId monitoredItemId,
561 MonitoringMode monitoringMode
562) noexcept {
563 const auto request = detail::makeSetMonitoringModeRequest(
564 subscriptionId, {&monitoredItemId, 1}, monitoringMode
565 );
566 return detail::getSingleStatus(
567 setMonitoringMode(connection, asWrapper<SetMonitoringModeRequest>(request))
568 );
569}
570
571/**
572 * @copydoc setMonitoringMode(Client&, IntegerId, IntegerId, MonitoringMode)
573 * @param token @completiontoken{void(StatusCode)}
574 * @return @asyncresult{StatusCode}
575 */
576template <typename CompletionToken>
578 Client& connection,
579 IntegerId subscriptionId,
580 IntegerId monitoredItemId,
581 MonitoringMode monitoringMode,
582 CompletionToken&& token
583) {
584 const auto request = detail::makeSetMonitoringModeRequest(
585 subscriptionId, {&monitoredItemId, 1}, monitoringMode
586 );
588 connection,
589 asWrapper<SetMonitoringModeRequest>(request),
590 detail::TransformToken(
591 detail::getSingleStatus<SetMonitoringModeResponse>, std::forward<CompletionToken>(token)
592 )
593 );
594}
595
596/**
597 * @}
598 * @defgroup SetTriggering SetTriggering service
599 * Create and delete triggering links for a triggering item.
600 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.13.1.6
601 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.13.5
602 * @{
603 */
604
605/**
606 * Add and delete triggering links of monitored items.
607 * The triggering item and the items to report shall belong to the same subscription.
608 * @note Supported since open62541 v1.2
609 *
610 * @param connection Instance of type Client
611 * @param request Set triggering request
612 */
614 Client& connection, const SetTriggeringRequest& request
615) noexcept;
616
617/**
618 * @copydoc setTriggering
619 * @param token @completiontoken{void(SetTriggeringResponse&)}
620 * @return @asyncresult{SetTriggeringResponse}
621 */
622template <typename CompletionToken>
624 Client& connection, const SetTriggeringRequest& request, CompletionToken&& token
625) {
626 return detail::sendRequestAsync<SetTriggeringRequest, SetTriggeringResponse>(
627 connection, request, std::forward<CompletionToken>(token)
628 );
629}
630
631/**
632 * @}
633 * @defgroup DeleteMonitoredItems DeleteMonitoredItems service
634 * Delete a monitored items from subscriptions.
635 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.13.6
636 * @{
637 */
638
639/**
640 * Delete monitored items from a subscription.
641 *
642 * @param connection Instance of type Client
643 * @param request Delete monitored items request
644 */
646 Client& connection, const DeleteMonitoredItemsRequest& request
647) noexcept;
648
649#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
650/**
651 * @copydoc deleteMonitoredItems
652 * @param token @completiontoken{void(DeleteMonitoredItemsResponse&)}
653 * @return @asyncresult{DeleteMonitoredItemsResponse}
654 */
655template <typename CompletionToken>
657 Client& connection, const DeleteMonitoredItemsRequest& request, CompletionToken&& token
658) {
659 return detail::AsyncServiceAdapter<DeleteMonitoredItemsResponse>::initiate(
660 connection,
661 [&connection](
663 void* userdata,
664 const DeleteMonitoredItemsRequest& innerRequest
665 ) {
667 opcua::detail::getHandle(connection),
668 asNative(innerRequest),
669 callback,
670 userdata,
671 nullptr
672 ));
673 },
674 std::forward<CompletionToken>(token),
675 request
676 );
677}
678#endif
679
680/**
681 * Delete a monitored item from a subscription.
682 *
683 * @param connection Instance of type Server or Client
684 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription.
685 * Use `0U` for a local server-side monitored item.
686 * @param monitoredItemId Identifier of the monitored item
687 */
688template <typename T>
689StatusCode deleteMonitoredItem(T& connection, IntegerId subscriptionId, IntegerId monitoredItemId);
690
691#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
692/**
693 * @copydoc deleteMonitoredItem
694 * @param token @completiontoken{void(StatusCode)}
695 * @return @asyncresult{StatusCode}
696 */
697template <typename CompletionToken>
699 Client& connection, IntegerId subscriptionId, IntegerId monitoredItemId, CompletionToken&& token
700) {
701 const auto request = detail::makeDeleteMonitoredItemsRequest(
702 subscriptionId, {&monitoredItemId, 1}
703 );
705 connection,
706 asWrapper<DeleteMonitoredItemsRequest>(request),
707 detail::TransformToken(
708 detail::getSingleStatus<DeleteMonitoredItemsResponse>,
709 std::forward<CompletionToken>(token)
710 )
711 );
712}
713#endif
714
715/**
716 * @}
717 * @}
718 */
719
720} // namespace opcua::services
721
722#endif
High-level client class.
Definition client.hpp:150
UA_DataValue wrapper class.
Definition types.hpp:1577
UA_ExtensionObject wrapper class.
Definition types.hpp:1751
View to a contiguous sequence of objects, similar to std::span in C++20.
Definition span.hpp:29
constexpr pointer data() const noexcept
Definition span.hpp:102
UA_StatusCode wrapper class.
Definition types.hpp:42
UA_CreateMonitoredItemsRequest wrapper class.
Definition types.hpp:2009
IntegerId subscriptionId() const noexcept
Definition types.hpp:2027
UA_CreateMonitoredItemsResponse wrapper class.
Definition types.hpp:2037
UA_DeleteMonitoredItemsRequest wrapper class.
Definition types.hpp:2218
UA_DeleteMonitoredItemsResponse wrapper class.
Definition types.hpp:2243
UA_ModifyMonitoredItemsRequest wrapper class.
Definition types.hpp:2086
UA_CreateMonitoredItemsResponse wrapper class.
Definition types.hpp:2114
UA_MonitoredItemCreateResult wrapper class.
Definition types.hpp:1993
UA_MonitoredItemModifyResult wrapper class.
Definition types.hpp:2071
UA_ReadValueId wrapper class.
Definition types.hpp:1363
UA_SetMonitoringModeRequest wrapper class.
Definition types.hpp:2128
UA_SetMonitoringModeResponse wrapper class.
Definition types.hpp:2156
UA_SetTriggeringRequest wrapper class.
Definition types.hpp:2170
UA_SetTriggeringResponse wrapper class.
Definition types.hpp:2202
void(* UA_ClientAsyncServiceCallback)(UA_Client *client, void *userdata, UA_UInt32 requestId, void *response)
UA_StatusCode UA_Client_MonitoredItems_modify_async(UA_Client *client, const UA_ModifyMonitoredItemsRequest request, UA_ClientAsyncServiceCallback callback, void *userdata, UA_UInt32 *requestId)
void(* UA_Client_EventNotificationCallback)(UA_Client *client, UA_UInt32 subId, void *subContext, UA_UInt32 monId, void *monContext, size_t nEventFields, UA_Variant *eventFields)
void(* UA_Client_DeleteMonitoredItemCallback)(UA_Client *client, UA_UInt32 subId, void *subContext, UA_UInt32 monId, void *monContext)
UA_StatusCode UA_Client_MonitoredItems_createEvents_async(UA_Client *client, const UA_CreateMonitoredItemsRequest request, void **contexts, UA_Client_EventNotificationCallback *callbacks, UA_Client_DeleteMonitoredItemCallback *deleteCallbacks, UA_ClientAsyncServiceCallback createCallback, void *userdata, UA_UInt32 *requestId)
void(* UA_Client_DataChangeNotificationCallback)(UA_Client *client, UA_UInt32 subId, void *subContext, UA_UInt32 monId, void *monContext, UA_DataValue *value)
UA_StatusCode UA_Client_MonitoredItems_delete_async(UA_Client *client, const UA_DeleteMonitoredItemsRequest request, UA_ClientAsyncServiceCallback callback, void *userdata, UA_UInt32 *requestId)
UA_StatusCode UA_Client_MonitoredItems_createDataChanges_async(UA_Client *client, const UA_CreateMonitoredItemsRequest request, void **contexts, UA_Client_DataChangeNotificationCallback *callbacks, UA_Client_DeleteMonitoredItemCallback *deleteCallbacks, UA_ClientAsyncServiceCallback createCallback, void *userdata, UA_UInt32 *requestId)
CreateMonitoredItemsResponse createMonitoredItemsDataChange(Client &connection, const CreateMonitoredItemsRequest &request, DataChangeNotificationCallback dataChangeCallback, DeleteMonitoredItemCallback deleteCallback)
Create and add monitored items to a subscription for data change notifications.
MonitoredItemCreateResult createMonitoredItemEvent(Client &connection, IntegerId subscriptionId, const ReadValueId &itemToMonitor, MonitoringMode monitoringMode, const MonitoringParametersEx &parameters, EventNotificationCallback eventCallback, DeleteMonitoredItemCallback deleteCallback={})
Create and add a monitored item to a subscription for event notifications.
auto createMonitoredItemsEventAsync(Client &connection, const CreateMonitoredItemsRequest &request, EventNotificationCallback eventCallback, DeleteMonitoredItemCallback deleteCallback, CompletionToken &&token)
Create and add monitored items to a subscription for event notifications.
auto createMonitoredItemEventAsync(Client &connection, IntegerId subscriptionId, const ReadValueId &itemToMonitor, MonitoringMode monitoringMode, const MonitoringParametersEx &parameters, EventNotificationCallback eventCallback, DeleteMonitoredItemCallback deleteCallback, CompletionToken &&token)
Create and add a monitored item to a subscription for event notifications.
std::function< void(IntegerId subId, IntegerId monId)> DeleteMonitoredItemCallback
MonitoredItem deletion callback.
MonitoredItemCreateResult createMonitoredItemDataChange(T &connection, IntegerId subscriptionId, const ReadValueId &itemToMonitor, MonitoringMode monitoringMode, const MonitoringParametersEx &parameters, DataChangeNotificationCallback dataChangeCallback, DeleteMonitoredItemCallback deleteCallback)
Create and add a monitored item to a subscription for data change notifications.
auto createMonitoredItemDataChangeAsync(Client &connection, IntegerId subscriptionId, const ReadValueId &itemToMonitor, MonitoringMode monitoringMode, const MonitoringParametersEx &parameters, DataChangeNotificationCallback dataChangeCallback, DeleteMonitoredItemCallback deleteCallback, CompletionToken &&token)
std::function< void(IntegerId subId, IntegerId monId, Span< const Variant > eventFields)> EventNotificationCallback
Event notification callback.
CreateMonitoredItemsResponse createMonitoredItemsEvent(Client &connection, const CreateMonitoredItemsRequest &request, EventNotificationCallback eventCallback, DeleteMonitoredItemCallback deleteCallback)
Create and add monitored items to a subscription for event notifications.
std::function< void(IntegerId subId, IntegerId monId, const DataValue &value)> DataChangeNotificationCallback
Data change notification callback.
auto createMonitoredItemsDataChangeAsync(Client &connection, const CreateMonitoredItemsRequest &request, DataChangeNotificationCallback dataChangeCallback, DeleteMonitoredItemCallback deleteCallback, CompletionToken &&token)
Create and add monitored items to a subscription for data change notifications.
StatusCode deleteMonitoredItem(T &connection, IntegerId subscriptionId, IntegerId monitoredItemId)
Delete a monitored item from a subscription.
auto deleteMonitoredItemAsync(Client &connection, IntegerId subscriptionId, IntegerId monitoredItemId, CompletionToken &&token)
Delete a monitored item from a subscription.
DeleteMonitoredItemsResponse deleteMonitoredItems(Client &connection, const DeleteMonitoredItemsRequest &request) noexcept
Delete monitored items from a subscription.
auto deleteMonitoredItemsAsync(Client &connection, const DeleteMonitoredItemsRequest &request, CompletionToken &&token)
Delete monitored items from a subscription.
ModifyMonitoredItemsResponse modifyMonitoredItems(Client &connection, const ModifyMonitoredItemsRequest &request) noexcept
Modify monitored items of a subscription.
MonitoredItemModifyResult modifyMonitoredItem(Client &connection, IntegerId subscriptionId, IntegerId monitoredItemId, const MonitoringParametersEx &parameters) noexcept
Modify a monitored item of a subscription.
auto modifyMonitoredItemsAsync(Client &connection, const ModifyMonitoredItemsRequest &request, CompletionToken &&token)
Modify monitored items of a subscription.
auto modifyMonitoredItemAsync(Client &connection, IntegerId subscriptionId, IntegerId monitoredItemId, const MonitoringParametersEx &parameters, CompletionToken &&token)
auto setMonitoringModeAsync(Client &connection, const SetMonitoringModeRequest &request, CompletionToken &&token)
Set the monitoring mode of monitored items.
SetMonitoringModeResponse setMonitoringMode(Client &connection, const SetMonitoringModeRequest &request) noexcept
Set the monitoring mode of monitored items.
SetTriggeringResponse setTriggering(Client &connection, const SetTriggeringRequest &request) noexcept
Add and delete triggering links of monitored items.
auto setTriggeringAsync(Client &connection, const SetTriggeringRequest &request, CompletionToken &&token)
Add and delete triggering links of monitored items.
constexpr T::NativeType * asNative(T *wrapper) noexcept
Cast Wrapper object pointers to native object pointers.
Definition wrapper.hpp:342
MonitoringMode
Monitoring mode.
Definition types.hpp:1623
TimestampsToReturn
Timestamps to return.
Definition types.hpp:1349
OPC UA services as free functions.
Definition attribute.hpp:21
uint32_t IntegerId
IntegerId.
Definition types.hpp:84
constexpr void throwIfBad(UA_StatusCode code)
Check the status code and throw a BadStatus exception if the status code is bad.
Definition exception.hpp:85
Extended monitoring parameters with default values from open62541.
uint32_t queueSize
Size of the MonitoringItem queue.
TimestampsToReturn timestamps
Timestamps to be transmitted.
ExtensionObject filter
Filter is used by the server to determine if the MonitoredItem should generate notifications.
double samplingInterval
Interval in milliseconds that defines the fastest rate at which the MonitoredItem should be accessed ...
bool discardOldest
Discard policy when the queue is full.