Tezzeret  1
Tezzeret
GmMFAMDataSource.hpp
1 #ifndef GM_TIVA_MFAM_DATA_SOURCE_HPP_
2 #define GM_TIVA_MFAM_DATA_SOURCE_HPP_
3 
4 #include "GmBufferedSensor.hpp"
5 
6 #ifndef GMMFAMDATA_HPP_
7 #include <GmMfamData.hpp>
8 #endif
9 
10 #include <GmRingBuffer.hpp>
11 #include <GmManagedRingBuffer.hpp>
12 #include <GmChildRingBuffer.hpp>
13 
14 // TODO RHC document the meanings of all these.
15 
16 #define OUT_MSG_LEN 32
17 // todo rhc should this be 24?
18 
19 // Error codes.
20 // As with all sensors, the base success code is
21 // GM_SENSOR_OK, defined in the base CSensor header.
22 #define MFAM_FAILED_INIT 1
23 #define MFAM_FAILED 2
24 #define MFAM_BLOCK_COUNT 100
25 
26 
27 
28 namespace Geometrics
29 {
36  {
37  public:
38  GmMfamDataSource (UInt8 iSubjectId,
40  int Start ();
41  virtual int CheckCalibrate (Bool bForceCalibrate);
42  int SetSimpleSubsampleRate (int iNewRate);
43  int ResetBuffers (Bool bForceCalibrate);
44  virtual UInt16 SystemStatus () { return m_static_iSystemStatus; };
45  virtual int WriteToStorage (UInt32 ui32Topic,
46  char *pData,
47  UInt32 iSize,
48  GmStorage *psStorage,
49  UInt32 ui32FormatId);
50  virtual void Halt () = 0;
51  Bool IsSuperMag ();
52  Bool MagOneDataValid ();
53  Bool MagTwoDataValid ();
54  Bool PpsLocked ();
55  Bool PpsAvailable ();
56  static int DecodeMagStartupStatus (UInt16 iMagStatus,
57  char *strBuffer,
58  int iBufferLength);
59  static int DecodeMagOperatingStatus (UInt16 iMagStatus,
60  char *strBuffer,
61  int iBufferLength);
62  int MagOneStartupStatusString (char *strBuffer,
63  int iBufferLength);
64  int MagTwoStartupStatusString (char *strBuffer,
65  int iBufferLength);
66  int MagOneOperatingStatusString (char *strBuffer,
67  int iBufferLength);
68  int MagTwoOperatingStatusString (char *strBuffer,
69  int iBufferLength);
70  int LastMagOneDataValue (float *pfDataValue);
71  int LastMagTwoDataValue (float *pfDataValue);
72  UInt16 MagMainMode ();
73  UInt16 CompassStatus ();
74  bool IsInStartup ();
75  Bool SystemHasStartedUp ();
76  Bool SystemFailed ();
77  #if GEO_MFAM_FULL_FILTER == GEO_TRUE
78  void SaveMonitorPacket (IndexedMfamFilteredPacketWithHeader *pMonitorPacket, Bool bFilter);
79  #else
80  void SaveMonitorPacket (MfamSpiPacket *pMonitorPacket, Bool bFilter);
81  #endif
82  static UInt16 m_static_iSystemStatus;
83  uint32_t mQueueFillTopThreshold,
84  mQueueFillRestartThreshold;
85  protected:
86 
87  int RecordStatus (MfamSpiPacket *pmspRecord);
88 
89  /*****************************************************/
90  /* Keep one packet with which to keep status */
91  /* information about the MFAM system. */
92  /*****************************************************/
93  #if GEO_MFAM_FULL_FILTER == GEO_TRUE
94  IndexedMfamFilteredPacketWithHeader m_mspStatusPacket;
95  #else
96  MfamSpiPacket m_mspStatusPacket;
97  #endif
98 
99  static bool m_static_boolInitialized;
100  int m_iSimpleSubsampleRate;
101  static int m_static_iSubsampleCount;
102 
103  /**********************************************************************************/
104  /* Keep an array of spi packets to track current status of the system. Each */
105  /* packet tracks one aspect of the status. This avoids mixing */
106  /* the information, and because MFAM cycles through different uses for the */
107  /* system and mag status fields. */
108  /* These records are for updating the UI about system status, not for real-time */
109  /* response to events. */
110  /**********************************************************************************/
111  #define MAG_SPI_LAST_DATA 0
112  #define MAG_SPI_SYS_STAT 0
113  #define MAG_SPI_ONE_STAT 0
114  #define MAG_SPI_TWO_STAT 0
115  #define MAG_SPI_AUX_SERIAL 0
116  #define MAG_SPI_AUX_ACCEL 1
117  #define MAG_SPI_AUX_GYRO 2
118  #define MAG_SPI_AUX_COMPASS 3
119  #define MAG_SPI_TOTAL_RECORDS 4
120  #if GEO_MFAM_FULL_FILTER == GEO_TRUE
121  IndexedMfamFilteredPacketWithHeader m_amspStatusRecords [MAG_SPI_TOTAL_RECORDS];
122  #else
123  MfamSpiPacket m_amspStatusRecords [MAG_SPI_TOTAL_RECORDS];
124  #endif
125 
126  };
127 
128 } // End of namespace
129 
130 #endif
The class from which event sources and sensors that post events to the application's main event queue...
Definition: GmBufferedSensor.hpp:18
Abstract class - the interface - to the MFAM sensor. This abstract layer was created in order to acco...
Definition: GmMFAMDataSource.hpp:36
virtual int WriteToStorage(UInt32 ui32Topic, char *pData, UInt32 iSize, GmStorage *psStorage, UInt32 ui32FormatId)
Definition: GmMFAMDataSource.cpp:402
Definition: GmStorage.hpp:81
GmApp/GmLoggingApp.hpp>
Definition: Analogs.hpp:47