ua_pubsub.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. *
  5. * Copyright (c) 2017-2018 Fraunhofer IOSB (Author: Andreas Ebner)
  6. */
  7. #ifndef UA_PUBSUB_H_
  8. #define UA_PUBSUB_H_
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #include <queue.h>
  13. #include "ua_plugin_pubsub.h"
  14. #include "ua_pubsub_networkmessage.h"
  15. #include "ua_server.h"
  16. #include "ua_server_pubsub.h"
  17. //forward declarations
  18. struct UA_WriterGroup;
  19. typedef struct UA_WriterGroup UA_WriterGroup;
  20. /* The configuration structs (public part of PubSub entities) are defined in include/ua_plugin_pubsub.h */
  21. /**********************************************/
  22. /* PublishedDataSet */
  23. /**********************************************/
  24. typedef struct{
  25. UA_PublishedDataSetConfig config;
  26. UA_DataSetMetaDataType dataSetMetaData;
  27. LIST_HEAD(UA_ListOfDataSetField, UA_DataSetField) fields;
  28. UA_NodeId identifier;
  29. UA_UInt16 fieldSize;
  30. UA_UInt16 promotedFieldsCount;
  31. } UA_PublishedDataSet;
  32. UA_StatusCode
  33. UA_PublishedDataSetConfig_copy(const UA_PublishedDataSetConfig *src, UA_PublishedDataSetConfig *dst);
  34. UA_PublishedDataSet *
  35. UA_PublishedDataSet_findPDSbyId(UA_Server *server, UA_NodeId identifier);
  36. void
  37. UA_PublishedDataSet_deleteMembers(UA_Server *server, UA_PublishedDataSet *publishedDataSet);
  38. /**********************************************/
  39. /* Connection */
  40. /**********************************************/
  41. //the connection config (public part of connection) object is defined in include/ua_plugin_pubsub.h
  42. typedef struct{
  43. UA_PubSubConnectionConfig *config;
  44. //internal fields
  45. UA_PubSubChannel *channel;
  46. UA_NodeId identifier;
  47. LIST_HEAD(UA_ListOfWriterGroup, UA_WriterGroup) writerGroups;
  48. } UA_PubSubConnection;
  49. UA_StatusCode
  50. UA_PubSubConnectionConfig_copy(const UA_PubSubConnectionConfig *src, UA_PubSubConnectionConfig *dst);
  51. UA_PubSubConnection *
  52. UA_PubSubConnection_findConnectionbyId(UA_Server *server, UA_NodeId connectionIdentifier);
  53. void
  54. UA_PubSubConnectionConfig_deleteMembers(UA_PubSubConnectionConfig *connectionConfig);
  55. void
  56. UA_PubSubConnection_deleteMembers(UA_Server *server, UA_PubSubConnection *connection);
  57. /**********************************************/
  58. /* DataSetWriter */
  59. /**********************************************/
  60. typedef struct UA_DataSetWriterSample{
  61. UA_Boolean valeChanged;
  62. UA_DataValue *value;
  63. } UA_DataSetWriterSample;
  64. typedef struct UA_DataSetWriter{
  65. UA_DataSetWriterConfig config;
  66. //internal fields
  67. LIST_ENTRY(UA_DataSetWriter) listEntry;
  68. UA_NodeId identifier;
  69. UA_NodeId linkedWriterGroup;
  70. UA_NodeId connectedDataSet;
  71. UA_ConfigurationVersionDataType connectedDataSetVersion;
  72. UA_UInt16 deltaFrameCounter; //actual count of sent deltaFrames
  73. size_t lastSamplesCount;
  74. UA_DataSetWriterSample *lastSamples;
  75. UA_UInt16 actualDataSetMessageSequenceCount;
  76. } UA_DataSetWriter;
  77. UA_StatusCode
  78. UA_DataSetWriterConfig_copy(const UA_DataSetWriterConfig *src, UA_DataSetWriterConfig *dst);
  79. UA_DataSetWriter *
  80. UA_DataSetWriter_findDSWbyId(UA_Server *server, UA_NodeId identifier);
  81. void
  82. UA_DataSetWriter_deleteMembers(UA_Server *server, UA_DataSetWriter *dataSetWriter);
  83. /**********************************************/
  84. /* WriterGroup */
  85. /**********************************************/
  86. struct UA_WriterGroup{
  87. UA_WriterGroupConfig config;
  88. //internal fields
  89. LIST_ENTRY(UA_WriterGroup) listEntry;
  90. UA_NodeId identifier;
  91. UA_NodeId linkedConnection;
  92. LIST_HEAD(UA_ListOfDataSetWriter, UA_DataSetWriter) writers;
  93. UA_UInt32 writersCount;
  94. UA_UInt64 publishCallbackId;
  95. UA_Boolean publishCallbackIsRegistered;
  96. };
  97. UA_StatusCode
  98. UA_WriterGroupConfig_copy(const UA_WriterGroupConfig *src, UA_WriterGroupConfig *dst);
  99. UA_WriterGroup *
  100. UA_WriterGroup_findWGbyId(UA_Server *server, UA_NodeId identifier);
  101. void
  102. UA_WriterGroup_deleteMembers(UA_Server *server, UA_WriterGroup *writerGroup);
  103. /**********************************************/
  104. /* DataSetField */
  105. /**********************************************/
  106. typedef struct UA_DataSetField{
  107. UA_DataSetFieldConfig config;
  108. //internal fields
  109. LIST_ENTRY(UA_DataSetField) listEntry;
  110. UA_NodeId identifier;
  111. UA_NodeId publishedDataSet; //ref to parent pds
  112. UA_FieldMetaData fieldMetaData;
  113. UA_UInt64 sampleCallbackId;
  114. UA_Boolean sampleCallbackIsRegistered;
  115. UA_DataValue lastValue;
  116. } UA_DataSetField;
  117. UA_StatusCode
  118. UA_DataSetFieldConfig_copy(const UA_DataSetFieldConfig *src, UA_DataSetFieldConfig *dst);
  119. UA_DataSetField *
  120. UA_DataSetField_findDSFbyId(UA_Server *server, UA_NodeId identifier);
  121. void
  122. UA_DataSetField_deleteMembers(UA_DataSetField *field);
  123. /*********************************************************/
  124. /* PublishValues handling */
  125. /*********************************************************/
  126. UA_StatusCode
  127. UA_WriterGroup_addPublishCallback(UA_Server *server, UA_WriterGroup *writerGroup);
  128. void
  129. UA_WriterGroup_publishCallback(UA_Server *server, UA_WriterGroup *writerGroup);
  130. #ifdef __cplusplus
  131. } // extern "C"
  132. #endif
  133. #endif /* UA_PUBSUB_H_ */