PowerRecordingExample.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. 2014
  6. All rights reserved.
  7. */
  8. #ifndef _EXAMPLE_H_
  9. #define _EXAMPLE_H_
  10. #include "types.h"
  11. #include "dsi_framer_ant.hpp"
  12. #include "dsi_thread.h"
  13. #include "dsi_serial_generic.hpp"
  14. #define CHANNEL_TYPE_MASTER (0)
  15. #define CHANNEL_TYPE_SLAVE (1)
  16. #define CHANNEL_TYPE_INVALID (2)
  17. class Example {
  18. public:
  19. Example();
  20. virtual ~Example();
  21. BOOL Init(UCHAR ucDeviceNumber_, UCHAR ucChannelType_, USHORT usAntDeviceNumber_, DOUBLE dRecordInterval_, DOUBLE dTimeBase_, UCHAR ucPowerMeterType_, DOUBLE dReSyncInterval_);
  22. void Start();
  23. void Close();
  24. private:
  25. BOOL InitANT();
  26. //Starts the Message thread.
  27. static DSI_THREAD_RETURN RunMessageThread(void *pvParameter_);
  28. //Listens for a response from the module
  29. void MessageThread();
  30. //Decodes the received message
  31. void ProcessMessage(ANT_MESSAGE stMessage, USHORT usSize_);
  32. //Receiver for the power records from the power decoder
  33. static void RecordReceiver(double dLastRecordTime_, double dTotalRotation_, double dTotalEnergy_, float fAverageCadence_, float fAveragePower_);
  34. //Receiver for Torque Effectiveness/Pedal Smoothness data
  35. void Example::TePsReceiver(double dRxTime_, float fLeftTorqEff_, float fRightTorqEff_, float fLeftOrCPedSmth_, float fRightPedSmth_);
  36. //Receiver for Power Balance data
  37. void Example::PowerBalanceReceiver(double dRxTime_, float fPowerBalance_, bool bPowerBalanceRightPedalIndicator_);
  38. // print user menu
  39. void PrintMenu();
  40. BOOL bBursting; //holds whether the bursting phase of the test has started
  41. BOOL bBroadcasting;
  42. BOOL bMyDone;
  43. BOOL bDone;
  44. BOOL bPowerDecoderInitialized;
  45. UCHAR ucChannelType;
  46. USHORT usAntDeviceNumber;
  47. DOUBLE dRecordInterval;
  48. DOUBLE dTimeBase;
  49. DOUBLE dReSyncInterval;
  50. DSISerialGeneric* pclSerialObject;
  51. DSIFramerANT* pclMessageObject;
  52. DSI_THREAD_ID uiDSIThread;
  53. DSI_CONDITION_VAR condTestDone;
  54. DSI_MUTEX mutexTestDone;
  55. time_t previousRxTime;
  56. UCHAR ucPowerOnlyUpdateEventCount;
  57. DOUBLE dRxTimeTePs;
  58. BOOL bDisplay;
  59. UCHAR aucTransmitBuffer[ANT_STANDARD_DATA_PAYLOAD_SIZE];
  60. unsigned long ulNewEventTime;
  61. unsigned short usPreviousEventTime;
  62. };
  63. #endif