dsi_ant_message_processor.hpp 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. This software is subject to the license described in the License.txt file
  3. included with this software distribution. You may not use this file except
  4. in compliance with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2016
  6. All rights reserved.
  7. */
  8. #if !defined(DSI_ANT_MESSAGE_PROCESSOR_HPP)
  9. #define DSI_ANT_MESSAGE_PROCESSOR_HPP
  10. #include "types.h"
  11. #include "dsi_framer_ant.hpp"
  12. //////////////////////////////////////////////////////////////////////////////////
  13. // Public Definitions
  14. //////////////////////////////////////////////////////////////////////////////////
  15. typedef enum
  16. {
  17. ANT_DEVICE_NOTIFICATION_RESET = 1,
  18. ANT_DEVICE_NOTIFICATION_SHUTDOWN = 2
  19. } ANT_DEVICE_NOTIFICATION;
  20. //////////////////////////////////////////////////////////////////////////////////
  21. // Public Class Prototypes
  22. //////////////////////////////////////////////////////////////////////////////////
  23. /////////////////////////////////////////////////////////////////
  24. // Inherit from this class to create new classes that can be
  25. // registered to a DSIANTDevice or .NET ANT_Device to
  26. // process ANT messages for a specific channel based on application
  27. // level logic.
  28. /////////////////////////////////////////////////////////////////
  29. class DSIANTMessageProcessor
  30. {
  31. protected:
  32. UCHAR ucChannelNumber;
  33. public:
  34. virtual ~DSIANTMessageProcessor(){}
  35. virtual BOOL Init(DSIFramerANT* pclANT_, UCHAR ucChannelNumber_) = 0;
  36. /////////////////////////////////////////////////////////////////
  37. // Begins to initialize the DSIANTMessageProcessor object
  38. // Returns TRUE if successful. Otherwise, it returns FALSE.
  39. // Parameters:
  40. // *pclANT_: Pointer to a DSIFramerANT object.
  41. // ucChannel_: Channel number to use for the ANT-FS host
  42. // Operation:
  43. // This function is used from a class managing the connection
  44. // to ANT (e.g. DSIANTDevice or .NET ANT_Device), to
  45. // initialize the DSIANTMessageProcessor object, assign a channel
  46. // number and enable it to send ANT messages.
  47. // IT IS NOT NECESSARY TO CALL THIS FUNCTION DIRECTLY FROM USER APPLICATIONS.
  48. /////////////////////////////////////////////////////////////////
  49. virtual void Close(void) = 0;
  50. /////////////////////////////////////////////////////////////////
  51. // Stops any pending actions and clean up resources
  52. // Operation:
  53. // This function is used from a class managing the connection
  54. // to ANT (e.g. DSIANTDevice or .NET ANT_Device), to
  55. // clean up any resources.
  56. // IT IS NOT NECESSARY TO CALL THIS FUNCTION DIRECTLY FROM USER APPLICATIONS.
  57. /////////////////////////////////////////////////////////////////
  58. virtual void ProcessMessage(ANT_MESSAGE* pstMessage_, USHORT usMesgSize_) = 0;
  59. /////////////////////////////////////////////////////////////////
  60. // Processes incoming ANT messages
  61. // Parameters:
  62. // pstMessage_: Pointer to an ANT message structure
  63. // usMesgSize_: ANT message size
  64. // Operation:
  65. // This function is used from a class managing the connection
  66. // to ANT (e.g. DSIANTDevice or .NET ANT_Device), and allows
  67. // classes derived from DSIANTMessageProcessor to do custom processing of
  68. // ANT messages
  69. // IT IS NOT NECESSARY TO CALL THIS FUNCTION DIRECTLY FROM USER APPLICATIONS.
  70. /////////////////////////////////////////////////////////////////
  71. virtual void ProcessDeviceNotification(ANT_DEVICE_NOTIFICATION eCode_, void* pvParameter_) = 0;
  72. /////////////////////////////////////////////////////////////////
  73. // Processes device level notifications regarding events that
  74. // may impact the operation of the associated channel
  75. // Parameters:
  76. // eCode_: Device notification event code
  77. // pvParameter_: Pointer to struct defining specific parameters related
  78. // to the event code
  79. // Operation:
  80. // This function is used from a class managing the connection to
  81. // ANT (e.g. DSIANTDevice or .NET ANT_Device), and allows
  82. // classes derived from DSIANTMessageProcessor to handle device level
  83. // notifications, such as a reset or shutting down the device
  84. /////////////////////////////////////////////////////////////////
  85. virtual UCHAR GetChannelNumber(void) { return ucChannelNumber; }
  86. /////////////////////////////////////////////////////////////////
  87. // Returns the ANT channel number
  88. /////////////////////////////////////////////////////////////////
  89. virtual BOOL GetEnabled() = 0;
  90. /////////////////////////////////////////////////////////////////
  91. // Returns the current status of ANT message processing
  92. // Returns TRUE if this class will process ANT messages, and FALSE
  93. // otherwise.
  94. // Operation:
  95. // This function is used from a class managing the connection
  96. // to ANT (e.g. DSIANTDevice or .NET ANT_Device).
  97. // IT IS NOT NECESSARY TO CALL THIS FUNCTION DIRECTLY FROM USER APPLICATIONS.
  98. /////////////////////////////////////////////////////////////////
  99. };
  100. #endif // DSI_ANT_MESSAGE_PROCESSOR_HPP