/****************************************************************************/
/* Copyright (c) 2000 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : Parosci.h                                                     */
/* Author   :                                                               */
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2000                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
/*
CLASS 
PSA916

DESCRIPTION
Paroscientific depth sensor driver

AUTHOR
John Rieffel

*/

#ifndef _PAROSCI_H
#define _PAROSCI_H

#include <unistd.h>
#include <termios.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/uio.h>
#include <fcntl.h>
#include <errno.h>
#include <iostream.h>
#include <math.h>

#include "MissionClock.h"
#include "ParosciOutput.h"
#include "ParosciLog.h"

#include "SharedData.h"
#include "PeriodicTask.h"
#include "SerialDevice.h"
#include "time.h"
#include "WorkSiteIF.h"

#define BAUD 9600
#define PARITY "NONE"
#define STOP_BITS 1
#define DATA_BITS 8
#define READ_TIMEOUT 5000

#define PARO_TIMEOUT 5000
#define INT_TIME 20 
#define  UNITS_VAL 1

#define MAX_PRESSURE 1000
#define MIN_PRESSURE -1

#define REPLY_LEN 32

class Parosci : public PeriodicTask {

  friend class ParosciLog;

public:
     
     Parosci(SerialDevice *interface);
     virtual ~Parosci();
     
protected:

     ParosciLog *_log;
     
     double pressure, depth;
     double pres_period, temp_period;

     int serialNo;
     timespec readtime;
     double init_pres, init_temp;
     double site_latitude;

     static const char *coeffNameList[];
     int coeffNameListLen;
//     double pc[sizeof(iniseq)/sizeof(char*)];
// I wish this didn't need to be hard coded
     double pc[16];

     char reply[REPLY_LEN];
     
     ParosciOutput *_output;
     MissionClock *clock;
     SerialDevice *_device;
     
     int init();

     static const double kPsiToBar;
     inline double psiToBar( double psi )
       { return kPsiToBar * psi; };

     void periodicParosciCallback( void );

     double comp_temp(double);
     double comp_press_bar(double, double);
     double corrected_depth(double);
     
     int getParosci(void);

};


#endif

