goose_publisher.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. /*
  2. * goose_publisher.h
  3. *
  4. * Copyright 2013-2020 Michael Zillgith
  5. *
  6. * This file is part of libIEC61850.
  7. *
  8. * libIEC61850 is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * libIEC61850 is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with libIEC61850. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. * See COPYING file for the complete license text.
  22. */
  23. #ifndef GOOSE_PUBLISHER_H_
  24. #define GOOSE_PUBLISHER_H_
  25. #include "iec61850_common.h"
  26. #include "linked_list.h"
  27. #include "mms_value.h"
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. #ifndef GOOSE_SV_COMM_PARAMETERS
  32. #define GOOSE_SV_COMM_PARAMETERS
  33. typedef struct sCommParameters {
  34. uint8_t vlanPriority;
  35. uint16_t vlanId;
  36. uint16_t appId;
  37. uint8_t dstAddress[6];
  38. } CommParameters;
  39. #endif
  40. typedef struct sGoosePublisher* GoosePublisher;
  41. /**
  42. * \brief Create a new GoosePublisher instance
  43. *
  44. * NOTE: The created GoosePublisher instance uses VLAN tags
  45. *
  46. * \param parameters GOOSE communication parameters
  47. * \param interfaceId name of the Ethernet interface to use (e.g. "eth0")
  48. */
  49. LIB61850_API GoosePublisher
  50. GoosePublisher_create(CommParameters* parameters, const char* interfaceID);
  51. /**
  52. * \brief Create a new GoosePublisher instance
  53. *
  54. * \param parameters GOOSE communication parameters
  55. * \param interfaceId name of the Ethernet interface to use (e.g. "eth0")
  56. * \param useVlanTag enable or disable the usage of VLAN tags in GOOSE messages
  57. */
  58. LIB61850_API GoosePublisher
  59. GoosePublisher_createEx(CommParameters* parameters, const char* interfaceID, bool useVlanTag);
  60. /**
  61. * \brief Release all resources of the GoosePublisher instance
  62. *
  63. * \param self GoosePublisher instance
  64. */
  65. LIB61850_API void
  66. GoosePublisher_destroy(GoosePublisher self);
  67. /**
  68. * \brief Publish a GOOSE message
  69. *
  70. * NOTE: This function also increased the sequence number of the GOOSE publisher
  71. *
  72. * \param self GoosePublisher instance
  73. * \param dataSet the GOOSE data set to send
  74. */
  75. LIB61850_API int
  76. GoosePublisher_publish(GoosePublisher self, LinkedList dataSet);
  77. /**
  78. * \brief Publish a GOOSE message and store the sent message in the provided buffer
  79. *
  80. * \param self GoosePublisher instance
  81. * \param dataSet the GOOSE data set to send
  82. * \param msgBuf to store the sent message
  83. * \param[out] msgLen the length of the sent message
  84. * \param bufSize the size of the buffer to store the sent message
  85. */
  86. LIB61850_API int
  87. GoosePublisher_publishAndDump(GoosePublisher self, LinkedList dataSet, char* msgBuf, int32_t* msgLen, int32_t bufSize);
  88. /**
  89. * \brief Sets the GoID used by the GoosePublisher instance
  90. *
  91. * \param self GoosePublisher instance
  92. * \param goID the GoId string
  93. */
  94. LIB61850_API void
  95. GoosePublisher_setGoID(GoosePublisher self, char* goID);
  96. /**
  97. * \brief Sets the GoCB reference used by the GoosePublisher instance
  98. *
  99. * \param self GoosePublisher instance
  100. * \param goCbRef the GoCB reference string
  101. */
  102. LIB61850_API void
  103. GoosePublisher_setGoCbRef(GoosePublisher self, char* goCbRef);
  104. /**
  105. * \brief Sets the time allowed to live value of the GOOSE messages
  106. *
  107. * \param self GoosePublisher instance
  108. * \param timeAllowedToLive the time allowed to live value in milliseconds
  109. */
  110. LIB61850_API void
  111. GoosePublisher_setTimeAllowedToLive(GoosePublisher self, uint32_t timeAllowedToLive);
  112. /**
  113. * \brief Sets the data set reference used by the GoosePublisher instance
  114. *
  115. * \param self GoosePublisher instance
  116. * \param dataSetRef the data set reference string
  117. */
  118. LIB61850_API void
  119. GoosePublisher_setDataSetRef(GoosePublisher self, char* dataSetRef);
  120. /**
  121. * \brief Sets the configuration revision used by the GoosePublisher instance
  122. *
  123. * \param self GoosePublisher instance
  124. * \param confRev the configuration revision value
  125. */
  126. LIB61850_API void
  127. GoosePublisher_setConfRev(GoosePublisher self, uint32_t confRev);
  128. /**
  129. * \brief Sets simulation flag in sent GOOSE messages
  130. *
  131. * \param self GoosePublisher instance
  132. * \param simulation the value of the simulation flag
  133. */
  134. LIB61850_API void
  135. GoosePublisher_setSimulation(GoosePublisher self, bool simulation);
  136. /**
  137. * \brief Manually sets the state number (stNum) of the GoosePublisher instance
  138. *
  139. * NOTE: Only for testing! Use \ref GoosePublisher_increaseStNum instead whenever
  140. * a data set member changes.
  141. *
  142. * \param self GoosePublisher instance
  143. * \param stNum the state number of the next GOOSE message to send
  144. */
  145. LIB61850_API void
  146. GoosePublisher_setStNum(GoosePublisher self, uint32_t stNum);
  147. /**
  148. * \brief Manually sets the sequence number (sqNum) of the GoosePublisher instance
  149. *
  150. * NOTE: Only for testing! The sequence number is increase manually whenever \ref GoosePublisher_publish is called.
  151. *
  152. * \param self GoosePublisher instance
  153. * \param stNum the state number of the next GOOSE message to send
  154. */
  155. LIB61850_API void
  156. GoosePublisher_setSqNum(GoosePublisher self, uint32_t sqNum);
  157. /**
  158. * \brief Sets the needs commission flag in sent GOOSE messages
  159. *
  160. * \param self GoosePublisher instance
  161. * \param ndsCom the value of the needs commission flag
  162. */
  163. LIB61850_API void
  164. GoosePublisher_setNeedsCommission(GoosePublisher self, bool ndsCom);
  165. /**
  166. * \brief Increase the state number (stNum) of the GoosePublisher instance
  167. *
  168. * The state number should be increased whenever a member of the GOOSE data set changed
  169. *
  170. * NOTE: This function also resets the sequence number (sqNum)
  171. *
  172. * \param self GoosePublisher instance
  173. */
  174. LIB61850_API uint64_t
  175. GoosePublisher_increaseStNum(GoosePublisher self);
  176. /**
  177. * \brief Reset state and sequence number of the GoosePublisher instance
  178. *
  179. * This function will set the state number (stNum) to 1 and the sequence number (sqNum) to 0.
  180. *
  181. * \param self GoosePublisher instance
  182. */
  183. LIB61850_API void
  184. GoosePublisher_reset(GoosePublisher self);
  185. #ifdef __cplusplus
  186. }
  187. #endif
  188. #endif /* GOOSE_PUBLISHER_H_ */