ua_subscription.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef UA_SUBSCRIPTION_H_
  2. #define UA_SUBSCRIPTION_H_
  3. #include "ua_util.h"
  4. #include "ua_types.h"
  5. #include "ua_types_generated.h"
  6. #include "ua_nodes.h"
  7. #define INITPOINTER(src) (src) = NULL;
  8. #define ISNOTZERO(value) ((value == 0) ? 0 : 1)
  9. /*****************/
  10. /* MonitoredItem */
  11. /*****************/
  12. typedef struct {
  13. UA_Int32 currentValue;
  14. UA_Int32 minValue;
  15. UA_Int32 maxValue;
  16. } UA_Int32_BoundedValue;
  17. typedef struct {
  18. UA_UInt32 currentValue;
  19. UA_UInt32 minValue;
  20. UA_UInt32 maxValue;
  21. } UA_UInt32_BoundedValue;
  22. typedef enum {
  23. MONITOREDITEM_TYPE_CHANGENOTIFY = 1,
  24. MONITOREDITEM_TYPE_STATUSNOTIFY = 2,
  25. MONITOREDITEM_TYPE_EVENTNOTIFY = 4
  26. } UA_MONITOREDITEM_TYPE;
  27. typedef struct MonitoredItem_queuedValue {
  28. UA_Variant value;
  29. TAILQ_ENTRY(MonitoredItem_queuedValue) listEntry;
  30. } MonitoredItem_queuedValue;
  31. typedef struct UA_MonitoredItem {
  32. LIST_ENTRY(UA_MonitoredItem) listEntry;
  33. UA_UInt32 itemId;
  34. UA_MONITOREDITEM_TYPE monitoredItemType;
  35. UA_UInt32 timestampsToReturn;
  36. UA_UInt32 monitoringMode;
  37. UA_NodeId monitoredNodeId;
  38. UA_UInt32 attributeID;
  39. UA_UInt32 clientHandle;
  40. UA_UInt32 samplingInterval;
  41. UA_UInt32_BoundedValue queueSize;
  42. UA_Boolean discardOldest;
  43. UA_DateTime lastSampled;
  44. UA_ByteString lastSampledValue;
  45. // FIXME: indexRange is ignored; array values default to element 0
  46. // FIXME: dataEncoding is hardcoded to UA binary
  47. TAILQ_HEAD(QueueOfQueueDataValues, MonitoredItem_queuedValue) queue;
  48. } UA_MonitoredItem;
  49. UA_MonitoredItem *UA_MonitoredItem_new(void);
  50. void MonitoredItem_delete(UA_MonitoredItem *monitoredItem);
  51. void MonitoredItem_QueuePushDataValue(UA_Server *server, UA_MonitoredItem *monitoredItem);
  52. void MonitoredItem_ClearQueue(UA_MonitoredItem *monitoredItem);
  53. UA_Boolean MonitoredItem_CopyMonitoredValueToVariant(UA_UInt32 attributeID, const UA_Node *src,
  54. UA_Variant *dst);
  55. int MonitoredItem_QueueToDataChangeNotifications(UA_MonitoredItemNotification *dst,
  56. UA_MonitoredItem *monitoredItem);
  57. /****************/
  58. /* Subscription */
  59. /****************/
  60. typedef struct UA_unpublishedNotification {
  61. LIST_ENTRY(UA_unpublishedNotification) listEntry;
  62. UA_NotificationMessage *notification;
  63. } UA_unpublishedNotification;
  64. typedef struct UA_Subscription {
  65. LIST_ENTRY(UA_Subscription) listEntry;
  66. UA_UInt32_BoundedValue lifeTime;
  67. UA_Int32_BoundedValue keepAliveCount;
  68. UA_DateTime publishingInterval;
  69. UA_DateTime lastPublished;
  70. UA_Int32 subscriptionID;
  71. UA_Int32 notificationsPerPublish;
  72. UA_Boolean publishingMode;
  73. UA_UInt32 priority;
  74. UA_UInt32 sequenceNumber;
  75. UA_Guid timedUpdateJobGuid;
  76. UA_Job *timedUpdateJob;
  77. UA_Boolean timedUpdateIsRegistered;
  78. LIST_HEAD(UA_ListOfUnpublishedNotifications, UA_unpublishedNotification) unpublishedNotifications;
  79. LIST_HEAD(UA_ListOfUAMonitoredItems, UA_MonitoredItem) MonitoredItems;
  80. } UA_Subscription;
  81. UA_Subscription *UA_Subscription_new(UA_Int32 subscriptionID);
  82. void UA_Subscription_deleteMembers(UA_Subscription *subscription, UA_Server *server);
  83. void Subscription_updateNotifications(UA_Subscription *subscription);
  84. UA_UInt32 Subscription_queuedNotifications(UA_Subscription *subscription);
  85. UA_UInt32 *Subscription_getAvailableSequenceNumbers(UA_Subscription *sub);
  86. void Subscription_copyTopNotificationMessage(UA_NotificationMessage *dst, UA_Subscription *sub);
  87. UA_UInt32 Subscription_deleteUnpublishedNotification(UA_UInt32 seqNo, UA_Subscription *sub);
  88. void Subscription_generateKeepAlive(UA_Subscription *subscription);
  89. UA_StatusCode Subscription_createdUpdateJob(UA_Server *server, UA_Guid jobId, UA_Subscription *sub);
  90. UA_StatusCode Subscription_registerUpdateJob(UA_Server *server, UA_Subscription *sub);
  91. UA_StatusCode Subscription_unregisterUpdateJob(UA_Server *server, UA_Subscription *sub);
  92. static void Subscription_timedUpdateNotificationsJob(UA_Server *server, void *data);
  93. #endif /* UA_SUBSCRIPTION_H_ */