historydatabase.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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 2018 (c) basysKom GmbH <opensource@basyskom.com> (Author: Peter Rustler)
  6. */
  7. #ifndef UA_PLUGIN_HISTORYDATABASE_H_
  8. #define UA_PLUGIN_HISTORYDATABASE_H_
  9. #include <open62541/server.h>
  10. _UA_BEGIN_DECLS
  11. typedef struct UA_HistoryDatabase UA_HistoryDatabase;
  12. struct UA_HistoryDatabase {
  13. void *context;
  14. void (*clear)(UA_HistoryDatabase *hdb);
  15. /* This function will be called when a nodes value is set.
  16. * Use this to insert data into your database(s) if polling is not suitable
  17. * and you need to get all data changes.
  18. * Set it to NULL if you do not need it.
  19. *
  20. * server is the server this node lives in.
  21. * hdbContext is the context of the UA_HistoryDatabase.
  22. * sessionId and sessionContext identify the session which set this value.
  23. * nodeId is the node id for which data was set.
  24. * historizing is the nodes boolean flag for historizing
  25. * value is the new value. */
  26. void
  27. (*setValue)(UA_Server *server,
  28. void *hdbContext,
  29. const UA_NodeId *sessionId,
  30. void *sessionContext,
  31. const UA_NodeId *nodeId,
  32. UA_Boolean historizing,
  33. const UA_DataValue *value);
  34. /* This function is called if a history read is requested with
  35. * isRawReadModified set to false. Setting it to NULL will result in a
  36. * response with statuscode UA_STATUSCODE_BADHISTORYOPERATIONUNSUPPORTED.
  37. *
  38. * server is the server this node lives in.
  39. * hdbContext is the context of the UA_HistoryDatabase.
  40. * sessionId and sessionContext identify the session which set this value.
  41. * requestHeader, historyReadDetails, timestampsToReturn, releaseContinuationPoints
  42. * nodesToReadSize and nodesToRead is the requested data from the client. It
  43. * is from the request object.
  44. * response the response to fill for the client. If the request is ok, there
  45. * is no need to use it. Use this to set status codes other than
  46. * "Good" or other data. You find an already allocated
  47. * UA_HistoryReadResult array with an UA_HistoryData object in the
  48. * extension object in the size of nodesToReadSize. If you are not
  49. * willing to return data, you have to delete the results array,
  50. * set it to NULL and set the resultsSize to 0. Do not access
  51. * historyData after that.
  52. * historyData is a proper typed pointer array pointing in the
  53. * UA_HistoryReadResult extension object. use this to provide
  54. * result data to the client. Index in the array is the same as
  55. * in nodesToRead and the UA_HistoryReadResult array. */
  56. void
  57. (*readRaw)(UA_Server *server,
  58. void *hdbContext,
  59. const UA_NodeId *sessionId,
  60. void *sessionContext,
  61. const UA_RequestHeader *requestHeader,
  62. const UA_ReadRawModifiedDetails *historyReadDetails,
  63. UA_TimestampsToReturn timestampsToReturn,
  64. UA_Boolean releaseContinuationPoints,
  65. size_t nodesToReadSize,
  66. const UA_HistoryReadValueId *nodesToRead,
  67. UA_HistoryReadResponse *response,
  68. UA_HistoryData * const * const historyData);
  69. /* No default implementation is provided by UA_HistoryDatabase_default
  70. * for the following function */
  71. void
  72. (*readModified)(UA_Server *server,
  73. void *hdbContext,
  74. const UA_NodeId *sessionId,
  75. void *sessionContext,
  76. const UA_RequestHeader *requestHeader,
  77. const UA_ReadRawModifiedDetails *historyReadDetails,
  78. UA_TimestampsToReturn timestampsToReturn,
  79. UA_Boolean releaseContinuationPoints,
  80. size_t nodesToReadSize,
  81. const UA_HistoryReadValueId *nodesToRead,
  82. UA_HistoryReadResponse *response,
  83. UA_HistoryModifiedData * const * const historyData);
  84. /* No default implementation is provided by UA_HistoryDatabase_default
  85. * for the following function */
  86. void
  87. (*readProcessed)(UA_Server *server,
  88. void *hdbContext,
  89. const UA_NodeId *sessionId,
  90. void *sessionContext,
  91. const UA_RequestHeader *requestHeader,
  92. const UA_ReadProcessedDetails *historyReadDetails,
  93. UA_TimestampsToReturn timestampsToReturn,
  94. UA_Boolean releaseContinuationPoints,
  95. size_t nodesToReadSize,
  96. const UA_HistoryReadValueId *nodesToRead,
  97. UA_HistoryReadResponse *response,
  98. UA_HistoryData * const * const historyData);
  99. /* No default implementation is provided by UA_HistoryDatabase_default
  100. * for the following function */
  101. void
  102. (*readAtTime)(UA_Server *server,
  103. void *hdbContext,
  104. const UA_NodeId *sessionId,
  105. void *sessionContext,
  106. const UA_RequestHeader *requestHeader,
  107. const UA_ReadAtTimeDetails *historyReadDetails,
  108. UA_TimestampsToReturn timestampsToReturn,
  109. UA_Boolean releaseContinuationPoints,
  110. size_t nodesToReadSize,
  111. const UA_HistoryReadValueId *nodesToRead,
  112. UA_HistoryReadResponse *response,
  113. UA_HistoryData * const * const historyData);
  114. void
  115. (*updateData)(UA_Server *server,
  116. void *hdbContext,
  117. const UA_NodeId *sessionId,
  118. void *sessionContext,
  119. const UA_RequestHeader *requestHeader,
  120. const UA_UpdateDataDetails *details,
  121. UA_HistoryUpdateResult *result);
  122. void
  123. (*deleteRawModified)(UA_Server *server,
  124. void *hdbContext,
  125. const UA_NodeId *sessionId,
  126. void *sessionContext,
  127. const UA_RequestHeader *requestHeader,
  128. const UA_DeleteRawModifiedDetails *details,
  129. UA_HistoryUpdateResult *result);
  130. /* Add more function pointer here.
  131. * For example for read_event, read_annotation, update_details */
  132. };
  133. _UA_END_DECLS
  134. #endif /* UA_PLUGIN_HISTORYDATABASE_H_ */