ua_subscription_manager.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #ifndef ENABLESUBSCRIPTIONS
  2. #define ENABLESUBSCRIPTIONS
  3. #endif
  4. #ifdef ENABLESUBSCRIPTIONS
  5. #ifndef UA_SUBSCRIPTION_MANAGER_H_
  6. #define UA_SUBSCRIPTION_MANAGER_H_
  7. #include "ua_server.h"
  8. #include "ua_types.h"
  9. #include "queue.h"
  10. #include "ua_nodestore.h"
  11. #define LIST_INITENTRY(item,entry) { \
  12. (item)->entry.le_next = NULL; \
  13. (item)->entry.le_prev = NULL; \
  14. };
  15. #define INITPOINTER(src) { \
  16. (src)=NULL; \
  17. }
  18. #define ISNOTZERO(value) ((value == 0) ? 0 : 1)
  19. typedef struct {
  20. UA_Int32 currentValue;
  21. UA_Int32 minValue;
  22. UA_Int32 maxValue;
  23. } UA_Int32_BoundedValue;
  24. typedef struct {
  25. UA_UInt32 currentValue;
  26. UA_UInt32 minValue;
  27. UA_UInt32 maxValue;
  28. } UA_UInt32_BoundedValue;
  29. typedef enum MONITOREITEM_TYPE_ENUM {MONITOREDITEM_CHANGENOTIFY_T=1, MONITOREDITEM_STATUSNOTIFY_T=2, MONITOREDITEM_EVENTNOTIFY_T=4 } MONITOREITEM_TYPE;
  30. typedef struct MonitoredItem_queuedValue_s {
  31. UA_Variant value;
  32. LIST_ENTRY(MonitoredItem_queuedValue_s) listEntry;
  33. } MonitoredItem_queuedValue;
  34. typedef LIST_HEAD(UA_ListOfQueuedDataValues_s, MonitoredItem_queuedValue_s) UA_ListOfQueuedDataValues;
  35. typedef struct UA_MonitoredItem_s {
  36. UA_UInt32 ItemId;
  37. MONITOREITEM_TYPE MonitoredItemType;
  38. UA_UInt32 TimestampsToReturn;
  39. UA_UInt32 MonitoringMode;
  40. const void *monitoredNode; // Pointer to a node of any type
  41. UA_UInt32 AttributeID;
  42. UA_UInt32 ClientHandle;
  43. UA_UInt32 SamplingInterval;
  44. UA_DateTime LastSampled;
  45. UA_UInt32_BoundedValue QueueSize;
  46. UA_Boolean DiscardOldest;
  47. // FIXME: indexRange is ignored; array values default to element 0
  48. // FIXME: dataEncoding is hardcoded to UA binary
  49. LIST_ENTRY(UA_MonitoredItem_s) listEntry;
  50. UA_ListOfQueuedDataValues *queue;
  51. } UA_MonitoredItem;
  52. typedef struct UA_unpublishedNotification_s {
  53. UA_NotificationMessage *notification;
  54. LIST_ENTRY(UA_unpublishedNotification_s) listEntry;
  55. } UA_unpublishedNotification;
  56. typedef LIST_HEAD(UA_ListOfUAMonitoredItems_s, UA_MonitoredItem_s) UA_ListOfUAMonitoredItems;
  57. typedef LIST_HEAD(UA_ListOfUnpublishedNotifications_s, UA_unpublishedNotification_s) UA_ListOfUnpublishedNotifications;
  58. typedef struct UA_Subscription_s {
  59. UA_UInt32_BoundedValue LifeTime;
  60. UA_Int32_BoundedValue KeepAliveCount;
  61. UA_DateTime PublishingInterval;
  62. UA_DateTime LastPublished;
  63. UA_Int32 SubscriptionID;
  64. UA_Int32 NotificationsPerPublish;
  65. UA_Boolean PublishingMode;
  66. UA_UInt32 Priority;
  67. UA_UInt32 SequenceNumber;
  68. LIST_ENTRY(UA_Subscription_s) listEntry;
  69. UA_ListOfUnpublishedNotifications *unpublishedNotifications;
  70. UA_ListOfUAMonitoredItems *MonitoredItems;
  71. } UA_Subscription;
  72. typedef LIST_HEAD(UA_ListOfUASubscriptions_s, UA_Subscription_s) UA_ListOfUASubscriptions;
  73. typedef struct UA_SubscriptionManager_s {
  74. UA_Int32_BoundedValue GlobalPublishingInterval;
  75. UA_UInt32_BoundedValue GlobalLifeTimeCount;
  76. UA_UInt32_BoundedValue GlobalKeepAliveCount;
  77. UA_Int32_BoundedValue GlobalNotificationsPerPublish;
  78. UA_UInt32_BoundedValue GlobalSamplingInterval;
  79. UA_UInt32_BoundedValue GlobalQueueSize;
  80. UA_Int32 LastSessionID;
  81. UA_ListOfUASubscriptions *ServerSubscriptions;
  82. } UA_SubscriptionManager;
  83. void SubscriptionManager_init(UA_Session *session);
  84. void SubscriptionManager_addSubscription(UA_SubscriptionManager *manager, UA_Subscription *subscription);
  85. UA_Subscription *SubscriptionManager_getSubscriptionByID(UA_SubscriptionManager *manager, UA_Int32 SubscriptionID);
  86. UA_Int32 SubscriptionManager_deleteSubscription(UA_SubscriptionManager *manager, UA_Int32 SubscriptionID);
  87. UA_Int32 SubscriptionManager_deleteMonitoredItem(UA_SubscriptionManager *manager, UA_Int32 SubscriptionID, UA_UInt32 MonitoredItemID);
  88. UA_Subscription *UA_Subscription_new(UA_Int32 SubscriptionID);
  89. void Subscription_updateNotifications(UA_Subscription *subscription);
  90. UA_UInt32 Subscription_queuedNotifications(UA_Subscription *subscription);
  91. UA_UInt32 *Subscription_getAvailableSequenceNumbers(UA_Subscription *sub);
  92. void Subscription_copyTopNotificationMessage(UA_NotificationMessage *dst, UA_Subscription *sub);
  93. void Subscription_deleteUnpublishedNotification(UA_UInt32 seqNo, UA_Subscription *sub);
  94. UA_MonitoredItem *UA_MonitoredItem_new(void);
  95. void MonitoredItem_delete(UA_MonitoredItem *monitoredItem);
  96. void MonitoredItem_QueuePushDataValue(UA_MonitoredItem *monitoredItem);
  97. void MonitoredItem_ClearQueue(UA_MonitoredItem *monitoredItem);
  98. int MonitoredItem_QueueToDataChangeNotifications(UA_MonitoredItemNotification *dst, UA_MonitoredItem *monitoredItem);
  99. #endif // ifndef... define UA_SUBSCRIPTION_MANAGER_H_
  100. #endif // ifdef EnableSubscriptions ...