ua_plugin_history_data_gathering.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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_GATHERING_H_
  8. #define UA_PLUGIN_HISTORY_DATA_GATHERING_H_
  9. #include "ua_types.h"
  10. #include "ua_server.h"
  11. #include "ua_plugin_history_data_backend.h"
  12. _UA_BEGIN_DECLS
  13. typedef enum {
  14. UA_HISTORIZINGUPDATESTRATEGY_USER = 0x00, /* The user of the api stores the values to the database himself.
  15. The api will not store any value to the database. */
  16. UA_HISTORIZINGUPDATESTRATEGY_VALUESET = 0x01, /* Values will be stored when a node's value is set.
  17. The values will be stored when a node is updated via write service.*/
  18. UA_HISTORIZINGUPDATESTRATEGY_POLL = 0x02 /* The value of the node will be read periodically.
  19. This is mainly relevant for datasource nodes which do
  20. not use the write service.
  21. Values will not be stored if the value is
  22. equal to the old value. */
  23. } UA_HistorizingUpdateStrategy;
  24. typedef struct {
  25. UA_HistoryDataBackend historizingBackend; /* The database backend used for this node. */
  26. size_t maxHistoryDataResponseSize; /* The maximum number of values returned by the server in one response.
  27. If the result has more values, continuation points will be used. */
  28. UA_HistorizingUpdateStrategy historizingUpdateStrategy; /* Defines how the values in the database will be updated.
  29. See UA_HistorizingUpdateStrategy for details. */
  30. size_t pollingInterval; /* The polling interval for UA_HISTORIZINGUPDATESTRATEGY_POLL. */
  31. void *userContext; /* A pointer to store your own settings. */
  32. } UA_HistorizingNodeIdSettings;
  33. typedef struct UA_HistoryDataGathering UA_HistoryDataGathering;
  34. struct UA_HistoryDataGathering {
  35. void *context;
  36. void
  37. (*deleteMembers)(UA_HistoryDataGathering *gathering);
  38. /* This function registers a node for the gathering of historical data.
  39. *
  40. * server is the server the node lives in.
  41. * hdgContext is the context of the UA_HistoryDataGathering.
  42. * nodeId is the node id of the node to register.
  43. * setting contains the gatering settings for the node to register. */
  44. UA_StatusCode
  45. (*registerNodeId)(UA_Server *server,
  46. void *hdgContext,
  47. const UA_NodeId *nodeId,
  48. const UA_HistorizingNodeIdSettings setting);
  49. /* This function stops polling a node for value changes.
  50. *
  51. * server is the server the node lives in.
  52. * hdgContext is the context of the UA_HistoryDataGathering.
  53. * nodeId is id of the node for which polling shall be stopped.
  54. * setting contains the gatering settings for the node. */
  55. UA_StatusCode
  56. (*stopPoll)(UA_Server *server,
  57. void *hdgContext,
  58. const UA_NodeId *nodeId);
  59. /* This function starts polling a node for value changes.
  60. *
  61. * server is the server the node lives in.
  62. * hdgContext is the context of the UA_HistoryDataGathering.
  63. * nodeId is the id of the node for which polling shall be started. */
  64. UA_StatusCode
  65. (*startPoll)(UA_Server *server,
  66. void *hdgContext,
  67. const UA_NodeId *nodeId);
  68. /* This function modifies the gathering settings for a node.
  69. *
  70. * server is the server the node lives in.
  71. * hdgContext is the context of the UA_HistoryDataGathering.
  72. * nodeId is the node id of the node for which gathering shall be modified.
  73. * setting contains the new gatering settings for the node. */
  74. UA_Boolean
  75. (*updateNodeIdSetting)(UA_Server *server,
  76. void *hdgContext,
  77. const UA_NodeId *nodeId,
  78. const UA_HistorizingNodeIdSettings setting);
  79. /* Returns the gathering settings for a node.
  80. *
  81. * server is the server the node lives in.
  82. * hdgContext is the context of the UA_HistoryDataGathering.
  83. * nodeId is the node id of the node for which the gathering settings shall
  84. * be retrieved. */
  85. const UA_HistorizingNodeIdSettings*
  86. (*getHistorizingSetting)(UA_Server *server,
  87. void *hdgContext,
  88. const UA_NodeId *nodeId);
  89. /* Sets a DataValue for a node in the historical data storage.
  90. *
  91. * server is the server the node lives in.
  92. * hdgContext is the context of the UA_HistoryDataGathering.
  93. * sessionId and sessionContext identify the session which wants to set this value.
  94. * nodeId is the node id of the node for which a value shall be set.
  95. * historizing is the historizing flag of the node identified by nodeId.
  96. * value is the value to set in the history data storage. */
  97. void
  98. (*setValue)(UA_Server *server,
  99. void *hdgContext,
  100. const UA_NodeId *sessionId,
  101. void *sessionContext,
  102. const UA_NodeId *nodeId,
  103. UA_Boolean historizing,
  104. const UA_DataValue *value);
  105. };
  106. _UA_END_DECLS
  107. #endif /* UA_PLUGIN_HISTORY_DATA_GATHERING_H_ */