#ifndef _MIDWATERSAMPLER_H
#define _MIDWATERSAMPLER_H
#include "MidWaterApp.h"
#include "MicroSampler.h"

// Digital Bits to Degrees Transfer Function - 10 Degs of offset
#define BITS_TO_DEGS(bits) ((bits / 193) - 10)

#define MWSLED_IBC_DM_PERIOD    500000 //Mwsled Dcon Data Period 2 hz.
#define HUMIDITY_DM_PERIOD     2000000 //HUMIDITY Period .5 hz
#define ATOD_PERIOD             100000 //A to D channel Period 10 hz.

/*
CLASS
MidWaterSampler

DESCRIPTION
Periodic sample and process application specific data from micro

AUTHOR
Douglas Au
*/
class MidWaterSampler : public MicroSampler
{
  public:
  ///////////////////////////////////////////////////////////////////
  // Constructor
  // [input] name: application name
  // [input] MICRO: Parent MicroApp
  MidWaterSampler(const char *name, MicroApp *micro);
  ~MidWaterSampler();

  ///////////////////////////////////////////////////////////////////
  // Saves the last state of Suction Sampler Index
  MBool lastSSIndexSense;
  ///////////////////////////////////////////////////////////////////
  // Updates A to D input Values from A to D board.
  STATUS updateAtoDValues( sio32Chan *serialChan, MwsledDconDmItems *dmItems);
  ///////////////////////////////////////////////////////////////////
  // Updates Digital input Values from Isolated I/O Board
  STATUS updateInputValue( sio32Chan *serialChan, MwsledDconDmItems *dmItems);
  ///////////////////////////////////////////////////////////////////
  // Initializes Index Sense Value on startup
  MBool initIndexSense( sio32Chan *serialChan, MwsledDconDmItems *dmItems);

  protected:
  ///////////////////////////////////////////////////////////////////
  // Call Back Fuction used to read Ibc Card Telemetry at call back period.
  void callback();
  ///////////////////////////////////////////////////////////////////
  // Call Back Fuction used to read Humidity at call back period.
  void humidityCallback();
  ///////////////////////////////////////////////////////////////////
  // Call Back Fuction used to read A to D channels at call back period.
  void atodCallback();
  ///////////////////////////////////////////////////////////////////
  // Call Back Fuction used to read Digital inputs at call back period.
  void digitalInputCallback();
  ///////////////////////////////////////////////////////////////////
  // Pointer to the main app
  MidWaterApp *_midwaterApp;

};


#endif













