/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : Fan.h                                                         */
/* Author   : rsm                                                           */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 03/21/2004                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#ifndef _Fan_H
#define _Fan_H
#include "PeriodicTask.h"
//#include "FanIF.h"
#include "FanLog.h"
#include "FanOutput.h"

const unsigned FanPollPeriod = 10000;  //millisec; Poll every ten seconds.
const int FanEnvIOBase=0x360;         //Location of fan card on 104 bus
//
// Average atmospheric pressure at sea level 
//(From http://ww2010.atmos.uiuc.edu/(Gh)/guides/mtr/fw/prs/def.rxml)
// 29.92" Hg = 1.0 atm = 101.325 kPa = 1013.25 mb = 14.7 psi 
// 
// Data:  counts  kPa
//         123    ambient - 10
//         121            - 12
//         119            - 14
//         117            - 16
//         114            - 18
//         112            - 20
//
// Least squares gives .8974 kPa/count, with ambient = 120.6 kPa. 
// (This seems high.)  Data taken on 18 Mar 2004.
// 
const double pCnts2kPa = .8974;
//
// The offset was measured on 9 Apr.  The MBA weather station was showing
// 101.6 kPa, and the card was reading 122.0 in my office, so
// 122.0-101.6=20.4.
//
const double pOffset   =  20.4;   

class Fan : public PeriodicTask {

      friend class FanLog;

   public:
      Fan();
      ~Fan();
      //
      ////////////////////////////////////////////////////////////////////
      // Read device data
      //
      virtual void periodicComputation();


   protected:
      FanLog *_log;
      FanOutput *_fanOutput;

   private:
      double Temp1620[2], Temp1620Hi[2], Temp1620Lo[2];
      int Temp1620Status[2];
      double Pressure;
      double Humidity;
      double TempSHT1x;
};

#endif
