/****************************************************************************/
/* Copyright (c) 2005 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : DockDriver.h                                           */
/* Author   : rsm
/* Project  :                                                               */
/* Version  : 1.0                                                           */
/* Created  : 9/5/2006                                                      */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
#ifndef _DOCKDRIVER_H
#define _DOCKDRIVER_H
#include "PeriodicTask.h"
#include "Attributes.h"
#include "SerialDeviceExt.h"
#include "UsblIF.h"
#include "DockOutput.h"
#include "DockCommand.h"
//#include "DockLog.h"

const int MAX_LW = 5;
const double DEFAULT_ESV = 1485.;
const unsigned DockPollPeriod = 1000;  //millisec.


class DockDriver : public PeriodicTask {

// friend class DockLog;

   public:
      DockDriver(SerialDeviceExt *serialDevice, 
		 char* configfile = "dock.cfg");
      ~DockDriver();


   ////////////////////////////////////////////////////////////////////
   // Read device data
   //
   virtual void callback();


   protected:
      SerialDeviceExt *_device;
//    DockLog     *_log;
      DockOutput  *_output;
      DockCommand *_command;
      char *_config;
      char  _response[512];
      unsigned _timeout;
      long  _period;
      char *_beacon;
      char  _interrogation[32];
      char  _cmd[128];
      Boolean _continuousQuery;
      Boolean _network;
      
      //
      // Output
      //

      //
      // Config attributes
      //
      
      Attributes _attributes;
      
      void init();
      void loadConfigFile(const char* file);
      void reportCfgAttributes();
      void createCfgAttributes();
      int  getrs();
      int  query( char *cmd );
      int  moveProbe( char *cmd );
      int  PicCom( char *cmd, int nlines = 1, int nTries = 4, 
		   char *cmd2 = NULL, int nlines2 = 0 );
      int  PicWriteRead2( char *cmd, int nlines, 
			  char *cmd2, int nlines2 );

	  short _pingTimeOut;
	  int   _pingCtr;
      
   private:
};

#endif
