open62541pp 0.16.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/common.hpp" // TimestampsToReturn, MonitoringMode
11#include "open62541pp/config.hpp"
12#include "open62541pp/detail/client_utils.hpp" // getHandle
19#include "open62541pp/span.hpp"
20#include "open62541pp/types.hpp"
22
23#ifdef UA_ENABLE_SUBSCRIPTIONS
24
25namespace opcua {
26class Client;
27} // namespace opcua
28
29namespace opcua::services {
30
31/**
32 * @defgroup MonitoredItem MonitoredItem service set
33 * Subscribe to data and events.
34 *
35 * Note the difference between Subscriptions and MonitoredItems. Subscriptions are used to report
36 * back notifications. Monitored items are used to generate notifications. Every monitored item is
37 * attached to exactly one subscription. And a subscription can contain many monitored items.
38 *
39 * Monitored items can also be registered locally (server-side). Notifications are then forwarded
40 * to a user-defined callback instead of a remote client.
41 *
42 * @see Subscription
43 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.12
44 * @ingroup Services
45 * @{
46 */
47
48/**
49 * Extended monitoring parameters with default values from open62541.
50 * This is an extended version of `UA_MonitoringParameters` with the `timestamps` parameter.
51 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/7.21
52 */
54 /// Timestamps to be transmitted.
56 /// Interval in milliseconds that defines the fastest rate at which the MonitoredItem should be
57 /// accessed and evaluated. The following values have special meaning:
58 /// - `0.0` to use the fastest practical rate
59 /// - `-1.0` to use the default sampling interval (publishing interval of the subscription)
60 double samplingInterval = 250.0;
61 /// Filter is used by the server to determine if the MonitoredItem should generate
62 /// notifications. The filter parameter type is an extensible parameter type and can be, for
63 /// example, of type DataChangeFilter, EventFilter or AggregateFilter.
64 /// @see https://reference.opcfoundation.org/Core/Part4/v105/docs/7.22
66 /// Size of the MonitoringItem queue.
67 /// The following values have special meaning:
68 /// - `0` to retrieve the server's default queue size
69 /// - `1` to retrieve the server's minimum queue size
70 /// In the case of a queue overflow, an Event of the type EventQueueOverflowEventType is
71 /// generated.
72 uint32_t queueSize = 1;
73 /// Discard policy when the queue is full.
74 /// - `true`: the oldest (first) notification in the queue is discarded
75 /// - `false`: the last notification added to the queue gets replaced with the new notification
76 bool discardOldest = true;
77};
78
79/**
80 * @defgroup CreateMonitoredItems CreateMonitoredItems service
81 * Create and add a monitored item to a subscription.
82 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.12.2
83 * @{
84 */
85
86/**
87 * MonitoredItem deletion callback.
88 * @param subId Subscription identifier
89 * @param monId MonitoredItem identifier
90 */
91using DeleteMonitoredItemCallback = std::function<void(uint32_t subId, uint32_t monId)>;
92
93/**
94 * Data change notification callback.
95 * @param subId Subscription identifier (`0U` for local (server-side) monitored item)
96 * @param monId MonitoredItem identifier
97 * @param value Changed value
98 */
100 std::function<void(uint32_t subId, uint32_t monId, const DataValue& value)>;
101
102/**
103 * Event notification callback.
104 * @param subId Subscription identifier (`0U` for local (server-side) monitored item)
105 * @param monId MonitoredItem identifier
106 * @param eventFields Event fields
107 */
109 std::function<void(uint32_t subId, uint32_t monId, Span<const Variant> eventFields)>;
110
111namespace detail {
112std::vector<std::unique_ptr<MonitoredItemContext>> createMonitoredItemContexts(
113 Client& connection,
114 const CreateMonitoredItemsRequest& request,
115 DataChangeNotificationCallback dataChangeCallback,
116 EventNotificationCallback eventCallback,
117 DeleteMonitoredItemCallback deleteCallback
118);
119
121 Span<const std::unique_ptr<MonitoredItemContext>> contexts,
122 Span<MonitoredItemContext*> contextsPtr,
123 Span<UA_Client_DataChangeNotificationCallback> dataChangeCallbacksNative,
126) noexcept;
127
129 Client& connection,
130 uint32_t subscriptionId,
131 const CreateMonitoredItemsResponse& response,
132 Span<std::unique_ptr<MonitoredItemContext>> contexts
133);
134} // namespace detail
135
136/**
137 * Create and add monitored items to a subscription for data change notifications.
138 * Don't use this function to monitor the `EventNotifier` attribute.
139 * Create monitored items with @ref createMonitoredItemsEvent instead.
140 *
141 * @param connection Instance of type Client
142 * @param request Create monitored items request
143 * @param dataChangeCallback Invoked when the monitored item is changed
144 * @param deleteCallback Invoked when the monitored item is deleted
145 */
147 Client& connection,
148 const CreateMonitoredItemsRequest& request,
149 DataChangeNotificationCallback dataChangeCallback,
150 DeleteMonitoredItemCallback deleteCallback
151);
152
153#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
154/**
155 * @copydoc createMonitoredItemsDataChange(Client&, const CreateMonitoredItemsRequest&,
156 * DataChangeNotificationCallback, DeleteMonitoredItemCallback)
157 * @param token @completiontoken{void(CreateMonitoredItemsResponse&)}
158 * @return @asyncresult{CreateMonitoredItemsResponse}
159 */
160template <typename CompletionToken>
162 Client& connection,
163 const CreateMonitoredItemsRequest& request,
164 DataChangeNotificationCallback dataChangeCallback,
165 DeleteMonitoredItemCallback deleteCallback,
166 CompletionToken&& token
167) {
169 connection, request, std::move(dataChangeCallback), {}, std::move(deleteCallback)
170 );
171 std::vector<detail::MonitoredItemContext*> contextsPtr(contexts.size());
172 std::vector<UA_Client_DataChangeNotificationCallback> dataChangeCallbacks(contexts.size());
173 std::vector<UA_Client_DeleteMonitoredItemCallback> deleteCallbacks(contexts.size());
175 contexts, contextsPtr, dataChangeCallbacks, {}, deleteCallbacks
176 );
178 connection,
179 [&](UA_ClientAsyncServiceCallback callback, void* userdata) {
181 opcua::detail::getHandle(connection),
182 asNative(request),
183 reinterpret_cast<void**>(contextsPtr.data()), // NOLINT
184 dataChangeCallbacks.data(),
185 deleteCallbacks.data(),
186 callback,
187 userdata,
188 nullptr
189 ));
190 },
192 [&connection,
193 subscriptionId = request.getSubscriptionId(),
194 contexts = std::move(contexts)](const auto& response) mutable {
195 detail::storeMonitoredItemContexts(connection, subscriptionId, response, contexts);
196 },
197 std::forward<CompletionToken>(token)
198 )
199 );
200}
201#endif
202
203/**
204 * Create and add a monitored item to a subscription for data change notifications.
205 * Don't use this function to monitor the `EventNotifier` attribute.
206 * Create a monitored item with @ref createMonitoredItemEvent instead.
207 *
208 * @param connection Instance of type Server or Client
209 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription.
210 * Use `0U` for a local server-side monitored item.
211 * @param itemToMonitor Item to monitor
212 * @param monitoringMode Monitoring mode
213 * @param parameters Monitoring parameters
214 * @param dataChangeCallback Invoked when the monitored item is changed
215 * @param deleteCallback Invoked when the monitored item is deleted
216 */
217template <typename T>
219 T& connection,
220 uint32_t subscriptionId,
221 const ReadValueId& itemToMonitor,
222 MonitoringMode monitoringMode,
223 const MonitoringParametersEx& parameters,
224 DataChangeNotificationCallback dataChangeCallback,
225 DeleteMonitoredItemCallback deleteCallback
226);
227
228#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
229/**
230 * @copydoc createMonitoredItemDataChange(Client&, uint32_t, const ReadValueId&, MonitoringMode,
231 * const MonitoringParametersEx&, DataChangeNotificationCallback,
232 * DeleteMonitoredItemCallback)
233 * @param token @completiontoken{void(MonitoredItemCreateResult&)}
234 * @return @asyncresult{MonitoredItemCreateResult}
235 */
236template <typename CompletionToken>
238 Client& connection,
239 uint32_t subscriptionId,
240 const ReadValueId& itemToMonitor,
241 MonitoringMode monitoringMode,
242 const MonitoringParametersEx& parameters,
243 DataChangeNotificationCallback dataChangeCallback,
244 DeleteMonitoredItemCallback deleteCallback,
245 CompletionToken&& token
246) {
247 auto item = detail::createMonitoredItemCreateRequest(itemToMonitor, monitoringMode, parameters);
249 subscriptionId, parameters.timestamps, {&item, 1}
250 );
252 connection,
254 std::move(dataChangeCallback),
255 std::move(deleteCallback),
260 std::forward<CompletionToken>(token)
261 )
262 );
263}
264#endif
265
266/**
267 * Create and add monitored items to a subscription for event notifications.
268 * The `attributeId` of ReadValueId must be set to AttributeId::EventNotifier.
269 *
270 * @param connection Instance of type Client
271 * @param request Create monitored items request
272 * @param eventCallback Invoked when an event is published
273 * @param deleteCallback Invoked when the monitored item is deleted
274 */
276 Client& connection,
277 const CreateMonitoredItemsRequest& request,
278 EventNotificationCallback eventCallback,
279 DeleteMonitoredItemCallback deleteCallback
280);
281
282#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
283/**
284 * @copydoc createMonitoredItemsEvent(Client&, const CreateMonitoredItemsRequest&,
285 * EventNotificationCallback, DeleteMonitoredItemCallback)
286 * @param token @completiontoken{void(CreateMonitoredItemsResponse&)}
287 * @return @asyncresult{CreateMonitoredItemsResponse}
288 */
289template <typename CompletionToken>
291 Client& connection,
292 const CreateMonitoredItemsRequest& request,
293 EventNotificationCallback eventCallback,
294 DeleteMonitoredItemCallback deleteCallback,
295 CompletionToken&& token
296) {
298 connection, request, {}, std::move(eventCallback), std::move(deleteCallback)
299 );
300 std::vector<detail::MonitoredItemContext*> contextsPtr(contexts.size());
301 std::vector<UA_Client_EventNotificationCallback> eventCallbacks(contexts.size());
302 std::vector<UA_Client_DeleteMonitoredItemCallback> deleteCallbacks(contexts.size());
304 contexts, contextsPtr, {}, eventCallbacks, deleteCallbacks
305 );
307 connection,
308 [&](UA_ClientAsyncServiceCallback callback, void* userdata) {
310 opcua::detail::getHandle(connection),
311 asNative(request),
312 reinterpret_cast<void**>(contextsPtr.data()), // NOLINT
313 eventCallbacks.data(),
314 deleteCallbacks.data(),
315 callback,
316 userdata,
317 nullptr
318 ));
319 },
321 [&connection,
322 subscriptionId = request.getSubscriptionId(),
323 contexts = std::move(contexts)](const auto& response) mutable {
324 detail::storeMonitoredItemContexts(connection, subscriptionId, response, contexts);
325 },
326 std::forward<CompletionToken>(token)
327 )
328 );
329}
330#endif
331
332/**
333 * Create and add a monitored item to a subscription for event notifications.
334 * The `attributeId` of ReadValueId must be set to AttributeId::EventNotifier.
335 *
336 * @param connection Instance of type Client
337 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription
338 * @param itemToMonitor Item to monitor
339 * @param monitoringMode Monitoring mode
340 * @param parameters Monitoring parameters
341 * @param eventCallback Invoked when an event is published
342 * @param deleteCallback Invoked when the monitored item is deleted
343 */
345 Client& connection,
346 uint32_t subscriptionId,
347 const ReadValueId& itemToMonitor,
348 MonitoringMode monitoringMode,
349 const MonitoringParametersEx& parameters,
350 EventNotificationCallback eventCallback,
351 DeleteMonitoredItemCallback deleteCallback = {}
352);
353
354#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
355/**
356 * @copydoc createMonitoredItemEvent(Client&, uint32_t, const ReadValueId&, MonitoringMode,
357 * const MonitoringParametersEx&, EventNotificationCallback, DeleteMonitoredItemCallback)
358 * @param token @completiontoken{void(MonitoredItemCreateResult&)}
359 * @return @asyncresult{MonitoredItemCreateResult}
360 */
361template <typename CompletionToken>
363 Client& connection,
364 uint32_t subscriptionId,
365 const ReadValueId& itemToMonitor,
366 MonitoringMode monitoringMode,
367 const MonitoringParametersEx& parameters,
368 EventNotificationCallback eventCallback,
369 DeleteMonitoredItemCallback deleteCallback,
370 CompletionToken&& token
371) {
372 auto item = detail::createMonitoredItemCreateRequest(itemToMonitor, monitoringMode, parameters);
374 subscriptionId, parameters.timestamps, {&item, 1}
375 );
377 connection,
379 std::move(eventCallback),
380 std::move(deleteCallback),
385 std::forward<CompletionToken>(token)
386 )
387 );
388}
389#endif
390
391/**
392 * @}
393 * @defgroup ModifyMonitoredItems ModifyMonitoredItems service
394 * Modify a monitored items of a subscription.
395 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.12.3
396 * @{
397 */
398
399/**
400 * Modify monitored items of a subscription.
401 *
402 * @param connection Instance of type Client
403 * @param request Modify monitored items request
404 */
406 Client& connection, const ModifyMonitoredItemsRequest& request
407) noexcept;
408
409#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
410/**
411 * @copydoc modifyMonitoredItems(Client&, const ModifyMonitoredItemsRequest&)
412 * @param token @completiontoken{void(ModifyMonitoredItemsResponse&)}
413 * @return @asyncresult{ModifyMonitoredItemsResponse}
414 */
415template <typename CompletionToken>
417 Client& connection, const ModifyMonitoredItemsRequest& request, CompletionToken&& token
418) {
420 connection,
421 [&](UA_ClientAsyncServiceCallback callback, void* userdata) {
422 throwIfBad(UA_Client_MonitoredItems_modify_async(
423 opcua::detail::getHandle(connection), asNative(request), callback, userdata, nullptr
424 ));
425 },
426 std::forward<CompletionToken>(token)
427 );
428}
429#endif
430
431/**
432 * Modify a monitored item of a subscription.
433 *
434 * @param connection Instance of type Client
435 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription
436 * @param monitoredItemId Identifier of the monitored item
437 * @param parameters Monitoring parameters
438 */
440 Client& connection,
441 uint32_t subscriptionId,
442 uint32_t monitoredItemId,
443 const MonitoringParametersEx& parameters
444) noexcept {
445 auto item = detail::createMonitoredItemModifyRequest(monitoredItemId, parameters);
446 auto request = detail::createModifyMonitoredItemsRequest(subscriptionId, parameters, item);
447 auto response = modifyMonitoredItems(
448 connection, asWrapper<ModifyMonitoredItemsRequest>(request)
449 );
451}
452
453#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
454/**
455 * @copydoc modifyMonitoredItems(Client&, uint32_t, uint32_t, const MonitoringParametersEx&)
456 * @param token @completiontoken{void(MonitoredItemModifyResult&)}
457 * @return @asyncresult{MonitoredItemModifyResult}
458 */
459template <typename CompletionToken>
461 Client& connection,
462 uint32_t subscriptionId,
463 uint32_t monitoredItemId,
464 const MonitoringParametersEx& parameters,
465 CompletionToken&& token
466) {
467 auto item = detail::createMonitoredItemModifyRequest(monitoredItemId, parameters);
468 auto request = detail::createModifyMonitoredItemsRequest(subscriptionId, parameters, item);
470 connection,
476 std::forward<CompletionToken>(token)
477 )
478 );
479}
480#endif
481
482/**
483 * @}
484 * @defgroup SetMonitoringMode SetMonitoringMode service
485 * Set the monitoring mode of a monitored items.
486 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.12.4
487 * @{
488 */
489
490/**
491 * Set the monitoring mode of monitored items.
492 *
493 * @param connection Instance of type Client
494 * @param request Set monitoring mode request
495 */
497 Client& connection, const SetMonitoringModeRequest& request
498) noexcept;
499
500/**
501 * @copydoc setMonitoringMode(Client&, const SetMonitoringModeRequest&)
502 * @param token @completiontoken{void(SetMonitoringModeResponse&)}
503 * @return @asyncresult{SetMonitoringModeResponse}
504 */
505template <typename CompletionToken>
507 Client& connection, const SetMonitoringModeRequest& request, CompletionToken&& token
508) {
510 connection, request, std::forward<CompletionToken>(token)
511 );
512}
513
514/**
515 * Set the monitoring mode of a monitored item.
516 *
517 * @param connection Instance of type Client
518 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription
519 * @param monitoredItemId Identifier of the monitored item
520 * @param monitoringMode Monitoring mode
521 */
523 Client& connection,
524 uint32_t subscriptionId,
525 uint32_t monitoredItemId,
526 MonitoringMode monitoringMode
527) noexcept {
528 const auto request = detail::createSetMonitoringModeRequest(
529 subscriptionId, {&monitoredItemId, 1}, monitoringMode
530 );
533 );
534}
535
536/**
537 * @copydoc setMonitoringMode(Client&, uint32_t, uint32_t, MonitoringMode)
538 * @param token @completiontoken{void(StatusCode)}
539 * @return @asyncresult{StatusCode}
540 */
541template <typename CompletionToken>
543 Client& connection,
544 uint32_t subscriptionId,
545 uint32_t monitoredItemId,
546 MonitoringMode monitoringMode,
547 CompletionToken&& token
548) {
549 const auto request = detail::createSetMonitoringModeRequest(
550 subscriptionId, {&monitoredItemId, 1}, monitoringMode
551 );
553 connection,
556 detail::getSingleStatus<SetMonitoringModeResponse>, std::forward<CompletionToken>(token)
557 )
558 );
559}
560
561/**
562 * @}
563 * @defgroup SetTriggering SetTriggering service
564 * Create and delete triggering links for a triggering item.
565 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.12.1.6
566 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.12.5
567 * @{
568 */
569
570/**
571 * Add and delete triggering links of monitored items.
572 * The triggering item and the items to report shall belong to the same subscription.
573 * @note Supported since open62541 v1.2
574 *
575 * @param connection Instance of type Client
576 * @param request Set triggering request
577 */
579 Client& connection, const SetTriggeringRequest& request
580) noexcept;
581
582/**
583 * @copydoc setTriggering
584 * @param token @completiontoken{void(SetTriggeringResponse&)}
585 * @return @asyncresult{SetTriggeringResponse}
586 */
587template <typename CompletionToken>
589 Client& connection, const SetTriggeringRequest& request, CompletionToken&& token
590) {
592 connection, request, std::forward<CompletionToken>(token)
593 );
594}
595
596/**
597 * @}
598 * @defgroup DeleteMonitoredItems DeleteMonitoredItems service
599 * Delete a monitored items from subscriptions.
600 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.12.6
601 * @{
602 */
603
604/**
605 * Delete monitored items from a subscription.
606 *
607 * @param connection Instance of type Client
608 * @param request Delete monitored items request
609 */
611 Client& connection, const DeleteMonitoredItemsRequest& request
612) noexcept;
613
614#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
615/**
616 * @copydoc deleteMonitoredItems
617 * @param token @completiontoken{void(DeleteMonitoredItemsResponse&)}
618 * @return @asyncresult{DeleteMonitoredItemsResponse}
619 */
620template <typename CompletionToken>
622 Client& connection, const DeleteMonitoredItemsRequest& request, CompletionToken&& token
623) {
625 connection,
626 [&](UA_ClientAsyncServiceCallback callback, void* userdata) {
628 opcua::detail::getHandle(connection), asNative(request), callback, userdata, nullptr
629 ));
630 },
631 std::forward<CompletionToken>(token)
632 );
633}
634#endif
635
636/**
637 * Delete a monitored item from a subscription.
638 *
639 * @param connection Instance of type Server or Client
640 * @param subscriptionId Identifier of the subscription returned by @ref createSubscription.
641 * Use `0U` for a local server-side monitored item.
642 * @param monitoredItemId Identifier of the monitored item
643 */
644template <typename T>
645StatusCode deleteMonitoredItem(T& connection, uint32_t subscriptionId, uint32_t monitoredItemId);
646
647#if UAPP_HAS_ASYNC_SUBSCRIPTIONS
648/**
649 * @copydoc deleteMonitoredItem
650 * @param token @completiontoken{void(StatusCode)}
651 * @return @asyncresult{StatusCode}
652 */
653template <typename CompletionToken>
655 Client& connection, uint32_t subscriptionId, uint32_t monitoredItemId, CompletionToken&& token
656) {
658 subscriptionId, {&monitoredItemId, 1}
659 );
661 connection,
665 std::forward<CompletionToken>(token)
666 )
667 );
668}
669#endif
670
671/**
672 * @}
673 * @}
674 */
675
676} // namespace opcua::services
677
678#endif
High-level client class.
Definition client.hpp:121
UA_CreateMonitoredItemsRequest wrapper class.
uint32_t getSubscriptionId() const noexcept
UA_CreateMonitoredItemsResponse wrapper class.
UA_DataValue wrapper class.
Definition types.hpp:1478
UA_DeleteMonitoredItemsRequest wrapper class.
UA_DeleteMonitoredItemsResponse wrapper class.
UA_ExtensionObject wrapper class.
Definition types.hpp:1664
UA_ModifyMonitoredItemsRequest wrapper class.
UA_CreateMonitoredItemsResponse wrapper class.
UA_MonitoredItemCreateResult wrapper class.
UA_MonitoredItemModifyResult wrapper class.
UA_ReadValueId wrapper class.
UA_SetMonitoringModeRequest wrapper class.
UA_SetMonitoringModeResponse wrapper class.
UA_SetTriggeringRequest wrapper class.
UA_SetTriggeringResponse wrapper class.
View to a contiguous sequence of objects, similar to std::span in C++20.
Definition span.hpp:26
UA_StatusCode wrapper class.
Definition types.hpp:44
void(* UA_ClientAsyncServiceCallback)(UA_Client *client, void *userdata, UA_UInt32 requestId, void *response)
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)
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.
auto createMonitoredItemsEventAsync(Client &connection, const CreateMonitoredItemsRequest &request, EventNotificationCallback eventCallback, DeleteMonitoredItemCallback deleteCallback, CompletionToken &&token)
Create and add monitored items to a subscription for event notifications.
MonitoredItemCreateResult createMonitoredItemDataChange(T &connection, uint32_t 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.
std::function< void(uint32_t subId, uint32_t monId)> DeleteMonitoredItemCallback
MonitoredItem deletion callback.
auto createMonitoredItemEventAsync(Client &connection, uint32_t 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(uint32_t subId, uint32_t monId, const DataValue &value)> DataChangeNotificationCallback
Data change notification callback.
auto createMonitoredItemDataChangeAsync(Client &connection, uint32_t subscriptionId, const ReadValueId &itemToMonitor, MonitoringMode monitoringMode, const MonitoringParametersEx &parameters, DataChangeNotificationCallback dataChangeCallback, DeleteMonitoredItemCallback deleteCallback, CompletionToken &&token)
CreateMonitoredItemsResponse createMonitoredItemsEvent(Client &connection, const CreateMonitoredItemsRequest &request, EventNotificationCallback eventCallback, DeleteMonitoredItemCallback deleteCallback)
Create and add monitored items to a subscription for event notifications.
MonitoredItemCreateResult createMonitoredItemEvent(Client &connection, uint32_t 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 createMonitoredItemsDataChangeAsync(Client &connection, const CreateMonitoredItemsRequest &request, DataChangeNotificationCallback dataChangeCallback, DeleteMonitoredItemCallback deleteCallback, CompletionToken &&token)
Create and add monitored items to a subscription for data change notifications.
std::function< void(uint32_t subId, uint32_t monId, Span< const Variant > eventFields)> EventNotificationCallback
Event notification callback.
StatusCode deleteMonitoredItem(T &connection, uint32_t subscriptionId, uint32_t monitoredItemId)
Delete a monitored item from a subscription.
auto deleteMonitoredItemAsync(Client &connection, uint32_t subscriptionId, uint32_t 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.
auto modifyMonitoredItemAsync(Client &connection, uint32_t subscriptionId, uint32_t monitoredItemId, const MonitoringParametersEx &parameters, CompletionToken &&token)
auto modifyMonitoredItemsAsync(Client &connection, const ModifyMonitoredItemsRequest &request, CompletionToken &&token)
Modify monitored items of a subscription.
MonitoredItemModifyResult modifyMonitoredItem(Client &connection, uint32_t subscriptionId, uint32_t monitoredItemId, const MonitoringParametersEx &parameters) noexcept
Modify a monitored item of a subscription.
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 NativeType * asNative(WrapperType *wrapper) noexcept
Cast Wrapper object pointers to native object pointers.
Definition wrapper.hpp:191
UA_Client * getHandle(Client &client) noexcept
UA_MonitoredItemModifyRequest createMonitoredItemModifyRequest(uint32_t monitoredItemId, MonitoringParameters &parameters) noexcept
std::vector< std::unique_ptr< MonitoredItemContext > > createMonitoredItemContexts(Client &connection, const CreateMonitoredItemsRequest &request, DataChangeNotificationCallback dataChangeCallback, EventNotificationCallback eventCallback, DeleteMonitoredItemCallback deleteCallback)
UA_CreateMonitoredItemsRequest createCreateMonitoredItemsRequest(uint32_t subscriptionId, TimestampsToReturn timestampsToReturn, Span< const UA_MonitoredItemCreateRequest > itemsToCreate) noexcept
UA_MonitoredItemCreateRequest createMonitoredItemCreateRequest(const ReadValueId &itemToMonitor, MonitoringMode monitoringMode, MonitoringParameters &parameters) noexcept
HookToken(HookFunction &&, CompletionToken &&) -> HookToken< HookFunction, CompletionToken >
void convertMonitoredItemContexts(Span< const std::unique_ptr< MonitoredItemContext > > contexts, Span< MonitoredItemContext * > contextsPtr, Span< UA_Client_DataChangeNotificationCallback > dataChangeCallbacksNative, Span< UA_Client_EventNotificationCallback > eventCallbacksNative, Span< UA_Client_DeleteMonitoredItemCallback > deleteCallbacksNative) noexcept
WrapperType wrapSingleResultWithStatus(Response &response) noexcept
StatusCode getSingleStatus(const Response &response) noexcept
UA_SetMonitoringModeRequest createSetMonitoringModeRequest(uint32_t subscriptionId, Span< const uint32_t > monitoredItemIds, MonitoringMode monitoringMode) noexcept
UA_DeleteMonitoredItemsRequest createDeleteMonitoredItemsRequest(uint32_t subscriptionId, Span< const uint32_t > monitoredItemIds) noexcept
auto sendRequestAsync(Client &client, const Request &request, CompletionToken &&token)
Async client service requests.
UA_ModifyMonitoredItemsRequest createModifyMonitoredItemsRequest(uint32_t subscriptionId, MonitoringParameters &parameters, UA_MonitoredItemModifyRequest &item) noexcept
void storeMonitoredItemContexts(Client &connection, uint32_t subscriptionId, const CreateMonitoredItemsResponse &response, Span< std::unique_ptr< MonitoredItemContext > > contexts)
OPC UA services as free functions.
Definition attribute.hpp:22
constexpr void throwIfBad(UA_StatusCode code)
Check the status code and throw a BadStatus exception if the status code is bad.
Definition exception.hpp:87
TimestampsToReturn
Timestamps to return.
Definition common.hpp:287
Client * asWrapper(UA_Client *client) noexcept
Convert native UA_Client pointer to its wrapper instance.
MonitoringMode
Monitoring mode.
Definition common.hpp:302
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.
static auto initiate(Client &client, Initiation &&initiation, CompletionToken &&token)
Initiate open62541 async client operation with user-defined completion token.
Special token to transform async results within the completion handler.