goose_publisher.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. /*
  2. * goose_publisher.h
  3. *
  4. * Copyright 2013-2022 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 "r_session.h"
  27. #include "linked_list.h"
  28. #include "mms_value.h"
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. #ifndef GOOSE_SV_COMM_PARAMETERS
  33. #define GOOSE_SV_COMM_PARAMETERS
  34. typedef struct sCommParameters {
  35. uint8_t vlanPriority;
  36. uint16_t vlanId;
  37. uint16_t appId;
  38. uint8_t dstAddress[6];
  39. } CommParameters;
  40. #endif
  41. typedef struct sGoosePublisher* GoosePublisher;
  42. /**
  43. * \brief Create a new GoosePublisher instance
  44. *
  45. * NOTE: The created GoosePublisher instance uses VLAN tags
  46. *
  47. * \param parameters GOOSE communication parameters
  48. * \param interfaceId name of the Ethernet interface to use (e.g. "eth0")
  49. *
  50. * \return the new GoosePublisher instance
  51. */
  52. LIB61850_API GoosePublisher
  53. GoosePublisher_create(CommParameters* parameters, const char* interfaceID);
  54. /**
  55. * \brief Create a new GoosePublisher instance for Ethernet GOOSE
  56. *
  57. * \param parameters GOOSE communication parameters
  58. * \param interfaceId name of the Ethernet interface to use (e.g. "eth0")
  59. * \param useVlanTag enable or disable the usage of VLAN tags in GOOSE messages
  60. *
  61. * \return the new GoosePublisher instance
  62. */
  63. LIB61850_API GoosePublisher
  64. GoosePublisher_createEx(CommParameters* parameters, const char* interfaceID, bool useVlanTag);
  65. /**
  66. * \brief Create a new GoosePublisher instance for R-GOOSE
  67. *
  68. * \param session R-session protocol instance to use
  69. * \param appId the appID value to use
  70. *
  71. * \return the new GoosePublisher instance
  72. */
  73. LIB61850_API GoosePublisher
  74. GoosePublisher_createRemote(RSession session, uint16_t appId);
  75. /**
  76. * \brief Release all resources of the GoosePublisher instance
  77. *
  78. * \param self GoosePublisher instance
  79. */
  80. LIB61850_API void
  81. GoosePublisher_destroy(GoosePublisher self);
  82. /**
  83. * \brief Publish a GOOSE message
  84. *
  85. * NOTE: This function also increased the sequence number of the GOOSE publisher
  86. *
  87. * \param self GoosePublisher instance
  88. * \param dataSet the GOOSE data set to send
  89. */
  90. LIB61850_API int
  91. GoosePublisher_publish(GoosePublisher self, LinkedList dataSet);
  92. /**
  93. * \brief Publish a GOOSE message and store the sent message in the provided buffer
  94. *
  95. * \param self GoosePublisher instance
  96. * \param dataSet the GOOSE data set to send
  97. * \param msgBuf to store the sent message
  98. * \param[out] msgLen the length of the sent message
  99. * \param bufSize the size of the buffer to store the sent message
  100. */
  101. LIB61850_API int
  102. GoosePublisher_publishAndDump(GoosePublisher self, LinkedList dataSet, char* msgBuf, int32_t* msgLen, int32_t bufSize);
  103. /**
  104. * \brief Sets the GoID used by the GoosePublisher instance
  105. *
  106. * \param self GoosePublisher instance
  107. * \param goID the GoId string
  108. */
  109. LIB61850_API void
  110. GoosePublisher_setGoID(GoosePublisher self, char* goID);
  111. /**
  112. * \brief Sets the GoCB reference used by the GoosePublisher instance
  113. *
  114. * \param self GoosePublisher instance
  115. * \param goCbRef the GoCB reference string
  116. */
  117. LIB61850_API void
  118. GoosePublisher_setGoCbRef(GoosePublisher self, char* goCbRef);
  119. /**
  120. * \brief Sets the time allowed to live value of the GOOSE messages
  121. *
  122. * \param self GoosePublisher instance
  123. * \param timeAllowedToLive the time allowed to live value in milliseconds
  124. */
  125. LIB61850_API void
  126. GoosePublisher_setTimeAllowedToLive(GoosePublisher self, uint32_t timeAllowedToLive);
  127. /**
  128. * \brief Sets the data set reference used by the GoosePublisher instance
  129. *
  130. * \param self GoosePublisher instance
  131. * \param dataSetRef the data set reference string
  132. */
  133. LIB61850_API void
  134. GoosePublisher_setDataSetRef(GoosePublisher self, char* dataSetRef);
  135. /**
  136. * \brief Sets the configuration revision used by the GoosePublisher instance
  137. *
  138. * \param self GoosePublisher instance
  139. * \param confRev the configuration revision value
  140. */
  141. LIB61850_API void
  142. GoosePublisher_setConfRev(GoosePublisher self, uint32_t confRev);
  143. /**
  144. * \brief Sets simulation flag in sent GOOSE messages
  145. *
  146. * \param self GoosePublisher instance
  147. * \param simulation the value of the simulation flag
  148. */
  149. LIB61850_API void
  150. GoosePublisher_setSimulation(GoosePublisher self, bool simulation);
  151. /**
  152. * \brief Manually sets the state number (stNum) of the GoosePublisher instance
  153. *
  154. * NOTE: Only for testing! Use \ref GoosePublisher_increaseStNum instead whenever
  155. * a data set member changes.
  156. *
  157. * \param self GoosePublisher instance
  158. * \param stNum the state number of the next GOOSE message to send
  159. */
  160. LIB61850_API void
  161. GoosePublisher_setStNum(GoosePublisher self, uint32_t stNum);
  162. /**
  163. * \brief Manually sets the sequence number (sqNum) of the GoosePublisher instance
  164. *
  165. * NOTE: Only for testing! The sequence number is increase manually whenever \ref GoosePublisher_publish is called.
  166. *
  167. * \param self GoosePublisher instance
  168. * \param sqNum the sequence number of the next GOOSE message to send
  169. */
  170. LIB61850_API void
  171. GoosePublisher_setSqNum(GoosePublisher self, uint32_t sqNum);
  172. /**
  173. * \brief Sets the needs commission flag in sent GOOSE messages
  174. *
  175. * \param self GoosePublisher instance
  176. * \param ndsCom the value of the needs commission flag
  177. */
  178. LIB61850_API void
  179. GoosePublisher_setNeedsCommission(GoosePublisher self, bool ndsCom);
  180. /**
  181. * \brief Increase the state number (stNum) of the GoosePublisher instance
  182. *
  183. * The state number should be increased whenever a member of the GOOSE data set changed
  184. *
  185. * NOTE: This function also resets the sequence number (sqNum)
  186. *
  187. * \param self GoosePublisher instance
  188. */
  189. LIB61850_API uint64_t
  190. GoosePublisher_increaseStNum(GoosePublisher self);
  191. /**
  192. * \brief Reset state and sequence number of the GoosePublisher instance
  193. *
  194. * This function will set the state number (stNum) to 1 and the sequence number (sqNum) to 0.
  195. *
  196. * \param self GoosePublisher instance
  197. */
  198. LIB61850_API void
  199. GoosePublisher_reset(GoosePublisher self);
  200. #ifdef __cplusplus
  201. }
  202. #endif
  203. #endif /* GOOSE_PUBLISHER_H_ */