ANTClass.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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 in compliance
  4. with this license.
  5. Copyright (c) Dynastream Innovations Inc. 2012
  6. All rights reserved.
  7. */
  8. #pragma once
  9. #include "StdAfx.h"
  10. #include <stdio.h>
  11. #include "ant_dll.h"
  12. #include "types.h"
  13. #include "config.h"
  14. #define USB_ARCT_PID ((USHORT) 0x1007)
  15. #define RESPONSE_TIME ((ULONG) 500)
  16. //Port Types: these defines are used to decide what type of connection to connect over
  17. #define PORT_TYPE_USB 0
  18. //Framer Types: These are used to define which framing type to use
  19. #define FRAMER_TYPE_BASIC 0
  20. typedef void(*ANT_RESPONSE_FUNC)(UCHAR ucChannel_, UCHAR ucMessageCode_, UCHAR* pucBuffer_);
  21. typedef void(*ANT_EVENT_RESPONSE_FUNC)(UCHAR ucChannel_, UCHAR ucEvent_, char* pcBuffer_);
  22. public delegate void ChannelDelegate(UCHAR ucChannel_);
  23. public ref class TimeoutStruct : System::Timers::Timer
  24. {
  25. public:
  26. TimeoutStruct(ChannelDelegate^ pclChannelDelegate_);
  27. UCHAR ucChannel;
  28. UCHAR ucMessageID;
  29. UCHAR ucResponseID;
  30. BOOL bWaitingForResponse;
  31. ChannelDelegate^ ChannelCallback;
  32. void ProcessTimerEvent(
  33. System::Object^ sender,
  34. System::Timers::ElapsedEventArgs^ e);
  35. void
  36. WaitForResponse(
  37. UCHAR ucChannel_,
  38. UCHAR ucResponseID_,
  39. UCHAR ucMessageID_);
  40. void
  41. ClearWait();
  42. } ;
  43. public ref class ANTClass
  44. {
  45. public:
  46. ANTClass(){};
  47. ~ANTClass(){};
  48. static BOOL
  49. LibInit(
  50. ANT_EVENT_RESPONSE_FUNC pEventResponseFunc_);
  51. static BOOL
  52. AssignChannelEventFunctions(
  53. int iChannels_,
  54. ANT_RESPONSE_FUNC pResponseFunc_);
  55. static void
  56. Disconnect();
  57. static const UCHAR*
  58. GetLibVersion();
  59. static BOOL
  60. Init(
  61. UCHAR ucUSBPort_,
  62. ULONG ulBaud_,
  63. UCHAR ucPortType_,
  64. UCHAR ucSerialFrameType_);
  65. static BOOL
  66. GetDeviceUSBInfo(
  67. UCHAR ucUSBPort_,
  68. UCHAR* pucPID_,
  69. UCHAR* pucSerial_);
  70. static BOOL
  71. GetDeviceUSBPID(
  72. USHORT* pusPID_);
  73. static void
  74. Close();
  75. static void
  76. UnAssignChannel(
  77. UCHAR ucChannel_);
  78. static void
  79. AssignChannel(
  80. UCHAR ucChannel_,
  81. UCHAR ucType_,
  82. UCHAR ucNetworkNum_);
  83. static void
  84. SetChannelId(
  85. UCHAR ucChannel_,
  86. USHORT usDeviceNumber_,
  87. UCHAR ucDeviceType_,
  88. UCHAR ucTransmissionType_);
  89. static void
  90. SetChannelPeriod(
  91. UCHAR ucChannel_,
  92. USHORT usPeriod_);
  93. static void
  94. SetChannelSearchTimeout(
  95. UCHAR ucChannel_,
  96. UCHAR ucTimeout_);
  97. static void
  98. SetChannelRFFreq(
  99. UCHAR ucChannel_,
  100. UCHAR ucRFFreq_);
  101. static void
  102. SetNetworkKey(
  103. UCHAR ucNetNum_,
  104. UCHAR* pucKey_);
  105. static void
  106. SetTransmitPower(
  107. UCHAR ucPower_);
  108. static void
  109. SetChannelTxPower(
  110. UCHAR ucChannel_,
  111. UCHAR ucPower_);
  112. static void
  113. ResetSystem();
  114. static void
  115. OpenChannel(
  116. UCHAR ucChannel_);
  117. static void
  118. CloseChannel(
  119. UCHAR ucChannel_);
  120. static void
  121. RequestMessage(
  122. UCHAR ucChannel_,
  123. UCHAR ucMsgID_);
  124. static void
  125. WriteMessage(
  126. UCHAR ucMessageID,
  127. UCHAR* aucData,
  128. USHORT usMessageSize);
  129. static void
  130. SendBroadcastData(
  131. UCHAR ucChannel_,
  132. UCHAR* pucData_);
  133. static void
  134. SendAcknowledgedData(
  135. UCHAR ucChannel_,
  136. UCHAR* pucData_);
  137. static void
  138. SendAcknowledgedData(
  139. UCHAR ucChannel_,
  140. UCHAR* pucData_,
  141. USHORT usTimeout_);
  142. static void
  143. SendBurstTransfer(
  144. UCHAR ucChannel_,
  145. UCHAR* pucData_,
  146. USHORT);
  147. static void
  148. TimerEvent(
  149. UCHAR ucChannel_);
  150. static void
  151. AckTimerEvent(UCHAR ucChannel_);
  152. static TimeoutStruct^ pclMyCommandTimeout;
  153. static array<TimeoutStruct^>^ paclMyAckTimeout;
  154. };