open62541pp 0.21.2
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()),
192 innerDataChangeCallbacks.data()
193 ),
194 const_cast<UA_Client_DeleteMonitoredItemCallback*>(innerDeleteCallbacks.data()),
195 // NOLINTEND
196 callback,
197 userdata,
198 nullptr
199 ));
200 },
201 detail::HookToken(
202 [&connection,
203 subscriptionId = request.subscriptionId(),
204 contexts = std::move(contexts)](const auto& response) mutable {
205 detail::storeMonitoredItemContexts(connection, subscriptionId, response, contexts);
206 },
207 std::forward<CompletionToken>(token)
208 ),
209 request,
210 std::move(contextsPtr),
211 std::move(dataChangeCallbacks),
212 std::move(deleteCallbacks)
213 );
214}
215#endif
216
217/**
218 * Create and add a monitored item to a subscription for data change notifications.
219 * Don't use this function to monitor the `EventNotifier` attribute.
220 * Create a monitored item with @ref createMonitoredItemEvent instead.
221 *
222 * @param connection Instance of type Server or Client
223 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription.
224 * Use `0U` for a local server-side monitored item.
225 * @param itemToMonitor Item to monitor
226 * @param monitoringMode Monitoring mode
227 * @param parameters Monitoring parameters
228 * @param dataChangeCallback Invoked when the monitored item is changed
229 * @param deleteCallback Invoked when the monitored item is deleted
230 */
231template <typename T>
233 T& connection,
234 IntegerId subscriptionId,
235 const ReadValueId& itemToMonitor,
236 MonitoringMode monitoringMode,
237 const MonitoringParametersEx& parameters,
238 DataChangeNotificationCallback dataChangeCallback,
239 DeleteMonitoredItemCallback deleteCallback
240);
241
242#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
243/**
244 * @copydoc createMonitoredItemDataChange(Client&, IntegerId, const ReadValueId&, MonitoringMode,
245 * const MonitoringParametersEx&, DataChangeNotificationCallback,
246 * DeleteMonitoredItemCallback)
247 * @param token @completiontoken{void(MonitoredItemCreateResult&)}
248 * @return @asyncresult{MonitoredItemCreateResult}
249 */
250template <typename CompletionToken>
252 Client& connection,
253 IntegerId subscriptionId,
254 const ReadValueId& itemToMonitor,
255 MonitoringMode monitoringMode,
256 const MonitoringParametersEx& parameters,
257 DataChangeNotificationCallback dataChangeCallback,
258 DeleteMonitoredItemCallback deleteCallback,
259 CompletionToken&& token
260) {
261 auto item = detail::makeMonitoredItemCreateRequest(itemToMonitor, monitoringMode, parameters);
262 const auto request = detail::makeCreateMonitoredItemsRequest(
263 subscriptionId, parameters.timestamps, {&item, 1}
264 );
266 connection,
267 asWrapper<CreateMonitoredItemsRequest>(request),
268 std::move(dataChangeCallback),
269 std::move(deleteCallback),
270 detail::TransformToken(
271 detail::wrapSingleResultWithStatus<
274 std::forward<CompletionToken>(token)
275 )
276 );
277}
278#endif
279
280/**
281 * Create and add monitored items to a subscription for event notifications.
282 * The `attributeId` of ReadValueId must be set to AttributeId::EventNotifier.
283 *
284 * @param connection Instance of type Client
285 * @param request Create monitored items request
286 * @param eventCallback Invoked when an event is published
287 * @param deleteCallback Invoked when the monitored item is deleted
288 */
290 Client& connection,
291 const CreateMonitoredItemsRequest& request,
292 EventNotificationCallback eventCallback,
293 DeleteMonitoredItemCallback deleteCallback
294);
295
296#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
297/**
298 * @copydoc createMonitoredItemsEvent(Client&, const CreateMonitoredItemsRequest&,
299 * EventNotificationCallback, DeleteMonitoredItemCallback)
300 * @param token @completiontoken{void(CreateMonitoredItemsResponse&)}
301 * @return @asyncresult{CreateMonitoredItemsResponse}
302 */
303template <typename CompletionToken>
305 Client& connection,
306 const CreateMonitoredItemsRequest& request,
307 EventNotificationCallback eventCallback,
308 DeleteMonitoredItemCallback deleteCallback,
309 CompletionToken&& token
310) {
311 auto contexts = detail::makeMonitoredItemContexts(
312 connection, request, {}, std::move(eventCallback), std::move(deleteCallback)
313 );
314 std::vector<void*> contextsPtr{contexts.size()};
315 std::vector<UA_Client_EventNotificationCallback> eventCallbacks{contexts.size()};
316 std::vector<UA_Client_DeleteMonitoredItemCallback> deleteCallbacks{contexts.size()};
317 detail::convertMonitoredItemContexts(
318 contexts, contextsPtr, {}, eventCallbacks, deleteCallbacks
319 );
320 return detail::AsyncServiceAdapter<CreateMonitoredItemsResponse>::initiate(
321 connection,
322 [&connection](
324 void* userdata,
325 const CreateMonitoredItemsRequest& innerRequest,
326 Span<void* const> innerContextsPtr,
329 ) {
331 opcua::detail::getHandle(connection),
332 asNative(innerRequest),
333 // NOLINGBEGIN
334 const_cast<void**>(innerContextsPtr.data()),
335 const_cast<UA_Client_EventNotificationCallback*>(innerEventCallbacks.data()),
336 const_cast<UA_Client_DeleteMonitoredItemCallback*>(innerDeleteCallbacks.data()),
337 // NOLINTEND
338 callback,
339 userdata,
340 nullptr
341 ));
342 },
343 detail::HookToken(
344 [&connection,
345 subscriptionId = request.subscriptionId(),
346 contexts = std::move(contexts)](const auto& response) mutable {
347 detail::storeMonitoredItemContexts(connection, subscriptionId, response, contexts);
348 },
349 std::forward<CompletionToken>(token)
350 ),
351 request,
352 std::move(contextsPtr),
353 std::move(eventCallbacks),
354 std::move(deleteCallbacks)
355 );
356}
357#endif
358
359/**
360 * Create and add a monitored item to a subscription for event notifications.
361 * The `attributeId` of ReadValueId must be set to AttributeId::EventNotifier.
362 *
363 * @param connection Instance of type Client
364 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription
365 * @param itemToMonitor Item to monitor
366 * @param monitoringMode Monitoring mode
367 * @param parameters Monitoring parameters
368 * @param eventCallback Invoked when an event is published
369 * @param deleteCallback Invoked when the monitored item is deleted
370 */
372 Client& connection,
373 IntegerId subscriptionId,
374 const ReadValueId& itemToMonitor,
375 MonitoringMode monitoringMode,
376 const MonitoringParametersEx& parameters,
377 EventNotificationCallback eventCallback,
378 DeleteMonitoredItemCallback deleteCallback = {}
379);
380
381#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
382/**
383 * @copydoc createMonitoredItemEvent(Client&, IntegerId, const ReadValueId&, MonitoringMode,
384 * const MonitoringParametersEx&, EventNotificationCallback, DeleteMonitoredItemCallback)
385 * @param token @completiontoken{void(MonitoredItemCreateResult&)}
386 * @return @asyncresult{MonitoredItemCreateResult}
387 */
388template <typename CompletionToken>
390 Client& connection,
391 IntegerId subscriptionId,
392 const ReadValueId& itemToMonitor,
393 MonitoringMode monitoringMode,
394 const MonitoringParametersEx& parameters,
395 EventNotificationCallback eventCallback,
396 DeleteMonitoredItemCallback deleteCallback,
397 CompletionToken&& token
398) {
399 auto item = detail::makeMonitoredItemCreateRequest(itemToMonitor, monitoringMode, parameters);
400 const auto request = detail::makeCreateMonitoredItemsRequest(
401 subscriptionId, parameters.timestamps, {&item, 1}
402 );
404 connection,
405 asWrapper<CreateMonitoredItemsRequest>(request),
406 std::move(eventCallback),
407 std::move(deleteCallback),
408 detail::TransformToken(
409 detail::wrapSingleResultWithStatus<
412 std::forward<CompletionToken>(token)
413 )
414 );
415}
416#endif
417
418/**
419 * @}
420 * @defgroup ModifyMonitoredItems ModifyMonitoredItems service
421 * Modify a monitored items of a subscription.
422 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.13.3
423 * @{
424 */
425
426/**
427 * Modify monitored items of a subscription.
428 *
429 * @param connection Instance of type Client
430 * @param request Modify monitored items request
431 */
433 Client& connection, const ModifyMonitoredItemsRequest& request
434) noexcept;
435
436#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
437/**
438 * @copydoc modifyMonitoredItems(Client&, const ModifyMonitoredItemsRequest&)
439 * @param token @completiontoken{void(ModifyMonitoredItemsResponse&)}
440 * @return @asyncresult{ModifyMonitoredItemsResponse}
441 */
442template <typename CompletionToken>
444 Client& connection, const ModifyMonitoredItemsRequest& request, CompletionToken&& token
445) {
446 return detail::AsyncServiceAdapter<ModifyMonitoredItemsResponse>::initiate(
447 connection,
448 [&connection](
450 void* userdata,
451 const ModifyMonitoredItemsRequest& innerRequest
452 ) {
454 opcua::detail::getHandle(connection),
455 asNative(innerRequest),
456 callback,
457 userdata,
458 nullptr
459 ));
460 },
461 std::forward<CompletionToken>(token),
462 request
463 );
464}
465#endif
466
467/**
468 * Modify a monitored item of a subscription.
469 *
470 * @param connection Instance of type Client
471 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription
472 * @param monitoredItemId Identifier of the monitored item
473 * @param parameters Monitoring parameters
474 */
476 Client& connection,
477 IntegerId subscriptionId,
478 IntegerId monitoredItemId,
479 const MonitoringParametersEx& parameters
480) noexcept {
481 auto item = detail::makeMonitoredItemModifyRequest(monitoredItemId, parameters);
482 auto request = detail::makeModifyMonitoredItemsRequest(subscriptionId, parameters, item);
483 auto response = modifyMonitoredItems(
484 connection, asWrapper<ModifyMonitoredItemsRequest>(request)
485 );
486 return detail::wrapSingleResultWithStatus<MonitoredItemModifyResult>(response);
487}
488
489#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
490/**
491 * @copydoc modifyMonitoredItems(Client&, IntegerId, IntegerId, const MonitoringParametersEx&)
492 * @param token @completiontoken{void(MonitoredItemModifyResult&)}
493 * @return @asyncresult{MonitoredItemModifyResult}
494 */
495template <typename CompletionToken>
497 Client& connection,
498 IntegerId subscriptionId,
499 IntegerId monitoredItemId,
500 const MonitoringParametersEx& parameters,
501 CompletionToken&& token
502) {
503 auto item = detail::makeMonitoredItemModifyRequest(monitoredItemId, parameters);
504 auto request = detail::makeModifyMonitoredItemsRequest(subscriptionId, parameters, item);
506 connection,
507 asWrapper<ModifyMonitoredItemsRequest>(request),
508 detail::TransformToken(
509 detail::wrapSingleResultWithStatus<
512 std::forward<CompletionToken>(token)
513 )
514 );
515}
516#endif
517
518/**
519 * @}
520 * @defgroup SetMonitoringMode SetMonitoringMode service
521 * Set the monitoring mode of a monitored items.
522 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.13.4
523 * @{
524 */
525
526/**
527 * Set the monitoring mode of monitored items.
528 *
529 * @param connection Instance of type Client
530 * @param request Set monitoring mode request
531 */
533 Client& connection, const SetMonitoringModeRequest& request
534) noexcept;
535
536/**
537 * @copydoc setMonitoringMode(Client&, const SetMonitoringModeRequest&)
538 * @param token @completiontoken{void(SetMonitoringModeResponse&)}
539 * @return @asyncresult{SetMonitoringModeResponse}
540 */
541template <typename CompletionToken>
543 Client& connection, const SetMonitoringModeRequest& request, CompletionToken&& token
544) {
545 return detail::sendRequestAsync<SetMonitoringModeRequest, SetMonitoringModeResponse>(
546 connection, request, std::forward<CompletionToken>(token)
547 );
548}
549
550/**
551 * Set the monitoring mode of a monitored item.
552 *
553 * @param connection Instance of type Client
554 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription
555 * @param monitoredItemId Identifier of the monitored item
556 * @param monitoringMode Monitoring mode
557 */
559 Client& connection,
560 IntegerId subscriptionId,
561 IntegerId monitoredItemId,
562 MonitoringMode monitoringMode
563) noexcept {
564 const auto request = detail::makeSetMonitoringModeRequest(
565 subscriptionId, {&monitoredItemId, 1}, monitoringMode
566 );
567 return detail::getSingleStatus(
568 setMonitoringMode(connection, asWrapper<SetMonitoringModeRequest>(request))
569 );
570}
571
572/**
573 * @copydoc setMonitoringMode(Client&, IntegerId, IntegerId, MonitoringMode)
574 * @param token @completiontoken{void(StatusCode)}
575 * @return @asyncresult{StatusCode}
576 */
577template <typename CompletionToken>
579 Client& connection,
580 IntegerId subscriptionId,
581 IntegerId monitoredItemId,
582 MonitoringMode monitoringMode,
583 CompletionToken&& token
584) {
585 const auto request = detail::makeSetMonitoringModeRequest(
586 subscriptionId, {&monitoredItemId, 1}, monitoringMode
587 );
589 connection,
590 asWrapper<SetMonitoringModeRequest>(request),
591 detail::TransformToken(
592 detail::getSingleStatus<SetMonitoringModeResponse>, std::forward<CompletionToken>(token)
593 )
594 );
595}
596
597/**
598 * @}
599 * @defgroup SetTriggering SetTriggering service
600 * Create and delete triggering links for a triggering item.
601 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.13.1.6
602 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.13.5
603 * @{
604 */
605
606/**
607 * Add and delete triggering links of monitored items.
608 * The triggering item and the items to report shall belong to the same subscription.
609 * @note Supported since open62541 v1.2
610 *
611 * @param connection Instance of type Client
612 * @param request Set triggering request
613 */
615 Client& connection, const SetTriggeringRequest& request
616) noexcept;
617
618/**
619 * @copydoc setTriggering
620 * @param token @completiontoken{void(SetTriggeringResponse&)}
621 * @return @asyncresult{SetTriggeringResponse}
622 */
623template <typename CompletionToken>
625 Client& connection, const SetTriggeringRequest& request, CompletionToken&& token
626) {
627 return detail::sendRequestAsync<SetTriggeringRequest, SetTriggeringResponse>(
628 connection, request, std::forward<CompletionToken>(token)
629 );
630}
631
632/**
633 * @}
634 * @defgroup DeleteMonitoredItems DeleteMonitoredItems service
635 * Delete a monitored items from subscriptions.
636 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.13.6
637 * @{
638 */
639
640/**
641 * Delete monitored items from a subscription.
642 *
643 * @param connection Instance of type Client
644 * @param request Delete monitored items request
645 */
647 Client& connection, const DeleteMonitoredItemsRequest& request
648) noexcept;
649
650#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
651/**
652 * @copydoc deleteMonitoredItems
653 * @param token @completiontoken{void(DeleteMonitoredItemsResponse&)}
654 * @return @asyncresult{DeleteMonitoredItemsResponse}
655 */
656template <typename CompletionToken>
658 Client& connection, const DeleteMonitoredItemsRequest& request, CompletionToken&& token
659) {
660 return detail::AsyncServiceAdapter<DeleteMonitoredItemsResponse>::initiate(
661 connection,
662 [&connection](
664 void* userdata,
665 const DeleteMonitoredItemsRequest& innerRequest
666 ) {
668 opcua::detail::getHandle(connection),
669 asNative(innerRequest),
670 callback,
671 userdata,
672 nullptr
673 ));
674 },
675 std::forward<CompletionToken>(token),
676 request
677 );
678}
679#endif
680
681/**
682 * Delete a monitored item from a subscription.
683 *
684 * @param connection Instance of type Server or Client
685 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription.
686 * Use `0U` for a local server-side monitored item.
687 * @param monitoredItemId Identifier of the monitored item
688 */
689template <typename T>
690StatusCode deleteMonitoredItem(T& connection, IntegerId subscriptionId, IntegerId monitoredItemId);
691
692#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
693/**
694 * @copydoc deleteMonitoredItem
695 * @param token @completiontoken{void(StatusCode)}
696 * @return @asyncresult{StatusCode}
697 */
698template <typename CompletionToken>
700 Client& connection, IntegerId subscriptionId, IntegerId monitoredItemId, CompletionToken&& token
701) {
702 const auto request = detail::makeDeleteMonitoredItemsRequest(
703 subscriptionId, {&monitoredItemId, 1}
704 );
706 connection,
707 asWrapper<DeleteMonitoredItemsRequest>(request),
708 detail::TransformToken(
709 detail::getSingleStatus<DeleteMonitoredItemsResponse>,
710 std::forward<CompletionToken>(token)
711 )
712 );
713}
714#endif
715
716/**
717 * @}
718 * @}
719 */
720
721} // namespace opcua::services
722
723#endif
High-level client class.
Definition client.hpp:130
UA_DataValue wrapper class.
Definition types.hpp:1576
UA_ExtensionObject wrapper class.
Definition types.hpp:1750
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:41
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.