ua_plugin_history_data_backend.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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_HISTORY_DATA_BACKEND_H_
  8. #define UA_PLUGIN_HISTORY_DATA_BACKEND_H_
  9. #include "ua_types.h"
  10. #include "ua_server.h"
  11. _UA_BEGIN_DECLS
  12. typedef enum {
  13. MATCH_EQUAL,
  14. MATCH_AFTER,
  15. MATCH_EQUAL_OR_AFTER,
  16. MATCH_BEFORE,
  17. MATCH_EQUAL_OR_BEFORE
  18. } MatchStrategy;
  19. typedef struct UA_HistoryDataBackend UA_HistoryDataBackend;
  20. struct UA_HistoryDataBackend {
  21. void *context;
  22. void
  23. (*deleteMembers)(UA_HistoryDataBackend *backend);
  24. /* This function sets a DataValue for a node in the historical data storage.
  25. *
  26. * server is the server the node lives in.
  27. * hdbContext is the context of the UA_HistoryDataBackend.
  28. * sessionId and sessionContext identify the session that wants to read historical data.
  29. * nodeId is the node for which the value shall be stored.
  30. * value is the value which shall be stored.
  31. * historizing is the historizing flag of the node identified by nodeId.
  32. * If sessionId is NULL, the historizing flag is invalid and must not be used. */
  33. UA_StatusCode
  34. (*serverSetHistoryData)(UA_Server *server,
  35. void *hdbContext,
  36. const UA_NodeId *sessionId,
  37. void *sessionContext,
  38. const UA_NodeId *nodeId,
  39. UA_Boolean historizing,
  40. const UA_DataValue *value);
  41. /* This function is the high level interface for the ReadRaw operation. Set
  42. * it to NULL if you use the low level API for your plugin. It should be
  43. * used if the low level interface does not suite your database. It is more
  44. * complex to implement the high level interface but it also provide more
  45. * freedom. If you implement this, then set all low level api function
  46. * pointer to NULL.
  47. *
  48. * server is the server the node lives in.
  49. * hdbContext is the context of the UA_HistoryDataBackend.
  50. * sessionId and sessionContext identify the session that wants to read historical data.
  51. * backend is the HistoryDataBackend whose storage is to be queried.
  52. * start is the start time of the HistoryRead request.
  53. * end is the end time of the HistoryRead request.
  54. * nodeId is the node id of the node for which historical data is requested.
  55. * maxSizePerResponse is the maximum number of items per response the server can provide.
  56. * numValuesPerNode is the maximum number of items per response the client wants to receive.
  57. * returnBounds determines if the client wants to receive bounding values.
  58. * timestampsToReturn contains the time stamps the client is interested in.
  59. * range is the numeric range the client wants to read.
  60. * releaseContinuationPoints determines if the continuation points shall be released.
  61. * continuationPoint is the continuation point the client wants to release or start from.
  62. * outContinuationPoint is the continuation point that gets passed to the
  63. * client by the HistoryRead service.
  64. * result contains the result histoy data that gets passed to the client. */
  65. UA_StatusCode
  66. (*getHistoryData)(UA_Server *server,
  67. const UA_NodeId *sessionId,
  68. void *sessionContext,
  69. const UA_HistoryDataBackend *backend,
  70. const UA_DateTime start,
  71. const UA_DateTime end,
  72. const UA_NodeId *nodeId,
  73. size_t maxSizePerResponse,
  74. UA_UInt32 numValuesPerNode,
  75. UA_Boolean returnBounds,
  76. UA_TimestampsToReturn timestampsToReturn,
  77. UA_NumericRange range,
  78. UA_Boolean releaseContinuationPoints,
  79. const UA_ByteString *continuationPoint,
  80. UA_ByteString *outContinuationPoint,
  81. UA_HistoryData *result);
  82. /* This function is part of the low level HistoryRead API. It returns the
  83. * index of a value in the database which matches certain criteria.
  84. *
  85. * server is the server the node lives in.
  86. * hdbContext is the context of the UA_HistoryDataBackend.
  87. * sessionId and sessionContext identify the session that wants to read historical data.
  88. * nodeId is the node id of the node for which the matching value shall be found.
  89. * timestamp is the timestamp of the requested index.
  90. * strategy is the matching strategy which shall be applied in finding the index. */
  91. size_t
  92. (*getDateTimeMatch)(UA_Server *server,
  93. void *hdbContext,
  94. const UA_NodeId *sessionId,
  95. void *sessionContext,
  96. const UA_NodeId *nodeId,
  97. const UA_DateTime timestamp,
  98. const MatchStrategy strategy);
  99. /* This function is part of the low level HistoryRead API. It returns the
  100. * index of the element after the last valid entry in the database for a
  101. * node.
  102. *
  103. * server is the server the node lives in.
  104. * hdbContext is the context of the UA_HistoryDataBackend.
  105. * sessionId and sessionContext identify the session that wants to read historical data.
  106. * nodeId is the node id of the node for which the end of storage shall be returned. */
  107. size_t
  108. (*getEnd)(UA_Server *server,
  109. void *hdbContext,
  110. const UA_NodeId *sessionId,
  111. void *sessionContext,
  112. const UA_NodeId *nodeId);
  113. /* This function is part of the low level HistoryRead API. It returns the
  114. * index of the last element in the database for a node.
  115. *
  116. * server is the server the node lives in.
  117. * hdbContext is the context of the UA_HistoryDataBackend.
  118. * sessionId and sessionContext identify the session that wants to read historical data.
  119. * nodeId is the node id of the node for which the index of the last element
  120. * shall be returned. */
  121. size_t
  122. (*lastIndex)(UA_Server *server,
  123. void *hdbContext,
  124. const UA_NodeId *sessionId,
  125. void *sessionContext,
  126. const UA_NodeId *nodeId);
  127. /* This function is part of the low level HistoryRead API. It returns the
  128. * index of the first element in the database for a node.
  129. *
  130. * server is the server the node lives in.
  131. * hdbContext is the context of the UA_HistoryDataBackend.
  132. * sessionId and sessionContext identify the session that wants to read historical data.
  133. * nodeId is the node id of the node for which the index of the first
  134. * element shall be returned. */
  135. size_t
  136. (*firstIndex)(UA_Server *server,
  137. void *hdbContext,
  138. const UA_NodeId *sessionId,
  139. void *sessionContext,
  140. const UA_NodeId *nodeId);
  141. /* This function is part of the low level HistoryRead API. It returns the
  142. * number of elements between startIndex and endIndex including both.
  143. *
  144. * server is the server the node lives in.
  145. * hdbContext is the context of the UA_HistoryDataBackend.
  146. * sessionId and sessionContext identify the session that wants to read historical data.
  147. * nodeId is the node id of the node for which the number of elements shall be returned.
  148. * startIndex is the index of the first element in the range.
  149. * endIndex is the index of the last element in the range. */
  150. size_t
  151. (*resultSize)(UA_Server *server,
  152. void *hdbContext,
  153. const UA_NodeId *sessionId,
  154. void *sessionContext,
  155. const UA_NodeId *nodeId,
  156. size_t startIndex,
  157. size_t endIndex);
  158. /* This function is part of the low level HistoryRead API. It copies data
  159. * values inside a certain range into a buffer.
  160. *
  161. * server is the server the node lives in.
  162. * hdbContext is the context of the UA_HistoryDataBackend.
  163. * sessionId and sessionContext identify the session that wants to read historical data.
  164. * nodeId is the node id of the node for which the data values shall be copied.
  165. * startIndex is the index of the first value in the range.
  166. * endIndex is the index of the last value in the range.
  167. * reverse determines if the values shall be copied in reverse order.
  168. * valueSize is the maximal number of data values to copy.
  169. * range is the numeric range which shall be copied for every data value.
  170. * releaseContinuationPoints determines if the continuation points shall be released.
  171. * continuationPoint is a continuation point the client wants to release or start from.
  172. * outContinuationPoint is a continuation point which will be passed to the client.
  173. * providedValues contains the number of values that were copied.
  174. * values contains the values that have been copied from the database. */
  175. UA_StatusCode
  176. (*copyDataValues)(UA_Server *server,
  177. void *hdbContext,
  178. const UA_NodeId *sessionId,
  179. void *sessionContext,
  180. const UA_NodeId *nodeId,
  181. size_t startIndex,
  182. size_t endIndex,
  183. UA_Boolean reverse,
  184. size_t valueSize,
  185. UA_NumericRange range,
  186. UA_Boolean releaseContinuationPoints,
  187. const UA_ByteString *continuationPoint,
  188. UA_ByteString *outContinuationPoint,
  189. size_t *providedValues,
  190. UA_DataValue *values);
  191. /* This function is part of the low level HistoryRead API. It returns the
  192. * data value stored at a certain index in the database.
  193. *
  194. * server is the server the node lives in.
  195. * hdbContext is the context of the UA_HistoryDataBackend.
  196. * sessionId and sessionContext identify the session that wants to read historical data.
  197. * nodeId is the node id of the node for which the data value shall be returned.
  198. * index is the index in the database for which the data value is requested. */
  199. const UA_DataValue*
  200. (*getDataValue)(UA_Server *server,
  201. void *hdbContext,
  202. const UA_NodeId *sessionId,
  203. void *sessionContext,
  204. const UA_NodeId *nodeId,
  205. size_t index);
  206. /* This function returns UA_TRUE if the backend supports returning bounding
  207. * values for a node. This function is mandatory.
  208. *
  209. * server is the server the node lives in.
  210. * hdbContext is the context of the UA_HistoryDataBackend.
  211. * sessionId and sessionContext identify the session that wants to read
  212. * historical data.
  213. * nodeId is the node id of the node for which the capability to return
  214. * bounds shall be queried. */
  215. UA_Boolean
  216. (*boundSupported)(UA_Server *server,
  217. void *hdbContext,
  218. const UA_NodeId *sessionId,
  219. void *sessionContext,
  220. const UA_NodeId *nodeId);
  221. /* This function returns UA_TRUE if the backend supports returning the
  222. * requested timestamps for a node. This function is mandatory.
  223. *
  224. * server is the server the node lives in.
  225. * hdbContext is the context of the UA_HistoryDataBackend.
  226. * sessionId and sessionContext identify the session that wants to read historical data.
  227. * nodeId is the node id of the node for which the capability to return
  228. * certain timestamps shall be queried. */
  229. UA_Boolean
  230. (*timestampsToReturnSupported)(UA_Server *server,
  231. void *hdbContext,
  232. const UA_NodeId *sessionId,
  233. void *sessionContext,
  234. const UA_NodeId *nodeId,
  235. const UA_TimestampsToReturn timestampsToReturn);
  236. };
  237. _UA_END_DECLS
  238. #endif /* UA_PLUGIN_HISTORY_DATA_BACKEND_H_ */