ua_plugin_pubsub.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 (c) 2017-2018 Fraunhofer IOSB (Author: Andreas Ebner)
  6. */
  7. #ifndef UA_PLUGIN_PUBSUB_H_
  8. #define UA_PLUGIN_PUBSUB_H_
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #include "ua_server_pubsub.h"
  13. /**
  14. * .. _pubsub_connection:
  15. *
  16. * PubSub Connection Plugin API
  17. * ============================
  18. *
  19. * The PubSub Connection API is the interface between concrete network implementations and the internal pubsub
  20. * code.
  21. *
  22. * The PubSub specification enables the creation of new connections on runtime. Wording:
  23. * 'Connection' -> OPC UA standard 'highlevel' perspective,
  24. * 'Channel' -> open62541 implementation 'lowlevel' perspective. A channel can be assigned with different
  25. * network implementations like UDP, MQTT, AMQP. The channel provides basis services
  26. * like send, regist, unregist, receive, close.
  27. */
  28. typedef enum {
  29. UA_PUBSUB_CHANNEL_RDY,
  30. UA_PUBSUB_CHANNEL_PUB,
  31. UA_PUBSUB_CHANNEL_SUB,
  32. UA_PUBSUB_CHANNEL_PUB_SUB,
  33. UA_PUBSUB_CHANNEL_ERROR,
  34. UA_PUBSUB_CHANNEL_CLOSED
  35. } UA_PubSubChannelState;
  36. struct UA_PubSubChannel;
  37. typedef struct UA_PubSubChannel UA_PubSubChannel;
  38. //interface structure between network plugin and internal implementation
  39. struct UA_PubSubChannel{
  40. UA_UInt32 publisherId; // unique identifier
  41. UA_PubSubChannelState state;
  42. UA_PubSubConnectionConfig *connectionConfig; //link to parent connection config
  43. UA_Int32 sockfd;
  44. void *handle; //implementation specific data
  45. /*@info for handle: each network implementation should provide an structure
  46. * UA_PubSubChannelData[ImplementationName] This structure can be used by the
  47. * network implementation to store network implementation specific data.*/
  48. /* Sending out the content of the buf parameter */
  49. UA_StatusCode (*send)(UA_PubSubChannel *channel, UA_ExtensionObject *transportSettings,
  50. const UA_ByteString *buf);
  51. /* Register to an specified message source, e.g. multicast group or topic */
  52. UA_StatusCode (*regist)(UA_PubSubChannel * channel, UA_ExtensionObject *transportSettings);
  53. /* Remove subscription to an specified message source, e.g. multicast group or topic */
  54. UA_StatusCode (*unregist)(UA_PubSubChannel * channel, UA_ExtensionObject *transportSettings);
  55. /* Receive messages. A regist to the message source is needed before. */
  56. UA_StatusCode (*receive)(UA_PubSubChannel * channel, UA_ByteString *,
  57. UA_ExtensionObject *transportSettings, UA_UInt32 timeout);
  58. /* Closing the connection and implicit free of the channel structures. */
  59. UA_StatusCode (*close)(UA_PubSubChannel *channel);
  60. };
  61. /**
  62. *
  63. * The UA_PubSubTransportLayer is used for the creation of new connections. Whenever on runtime a new
  64. * connection is request, the internal PubSub implementation call * the 'createPubSubChannel' function.
  65. * The 'transportProfileUri' contains the standard defined transport profile information
  66. * and is used to identify the type of connections which can be created by the
  67. * TransportLayer. The server config contains a list of UA_PubSubTransportLayer.
  68. * Take a look in the tutorial_pubsub_connection to get informations about the TransportLayer handling.
  69. */
  70. typedef struct UA_PubSubTransportLayer{
  71. UA_String transportProfileUri;
  72. UA_PubSubChannel * (*createPubSubChannel)(UA_PubSubConnectionConfig *connectionConfig);
  73. } UA_PubSubTransportLayer;
  74. #ifdef __cplusplus
  75. } // extern "C"
  76. #endif
  77. #endif /* UA_PLUGIN_PUBSUB_H_ */