#ifndef _BICAM_H_
#define _BICAM_H_

/** \file Bicam.h 
    Defines classes implementing the Benthic Imaging AUV
    Camera interfaces.
*/
/****************************************************************************/
/* Copyright (c) 2008 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : Bicam.h                                                       */
/* Author   : K Headley                                                     */
/* Project  : Benthic Imaging AUV                                           */
/* Created  : 04/01/2008                                                    */
/****************************************************************************/
/* Modification History:                                                    */
/*  $Id: Bicam.h,v 1.4.4.1 2016/05/19 18:28:57 headley Exp $   */
/*  $Name: gnc $ */
/****************************************************************************/

#include <signal.h>
#include <errno.h>
#include <sys/time.h>
#include "XPort.h"
#include "NMEA.h"
#include "Utils.h"
#include "qnx_port.h"
#include "BicamConsts.h"
/* 
   Function Declarations
*/

/** @deprecated BicamTrigger: Use BicamGPIO instead.
    Triggers an image capture via the Lantronix XPort.
    Camera trigger is connected to XPort GPIO pins. BicamTrigger uses
    an XPort object to activate and deactivate the GPIO pins.

    BicamGPS synthesizes NMEA GPS strings and uses the XPort serial port 
    to send the GPS strings to the camera's GPS input port.

    @see XPort
    @see XPortGPIO
    @see BicamGPS
    @see NMEA
    
*/
class BicamTrigger;

/** BicamGPS synthesizes NMEA GPS strings and uses the XPort serial port 
    to send the GPS strings to the camera's GPS input port.

    BicamTrigger triggers an image capture via the Lantronix XPort.
    Camera trigger is connected to XPort GPIO pins. BicamTrigger uses
    an XPort object to activate and deactivate the GPIO pins.

    @see XPort
    @see BicamTrigger
    @see NMEA
    
*/
class BicamGPS{
 private:
 protected:
  /** Lantronix XPort single port terminal server w/ GPIO */
  XPort *xport; 
  /** GPGGA NMEA message. 
      @see GPGGA
   */
  GPGGA gpgga;
  /** GPRMC NMEA message. 
      @see GPRMC
   */
  GPRMC gprmc;
  /** current latitude (decimal degrees) */
  double latitude;
  /** current longitude (decimal degrees) */
  double longitude;
  /** current alttitude (m) */
  double altitude;
  /** Indicates whether the NMEA messages are initialized*/
  boolean initialized;
  int initNMEA();
  int degrees(double value);
  double decimalMinutes(double value);
 public:
  BicamGPS();
  BicamGPS(XPort *pXPort);
  BicamGPS(char *host, int serialIPPort);
  ~BicamGPS();
  int configure(XPort *pXPort);
  GPGGA *getGPGGA();
  GPRMC *getGPRMC();
  XPort *getXPort();
  void setXPort(XPort *xp);
  XPort *connect(char *host, int serialIPPort);
  int initialize();
  int writeNMEA();
  int updatePosition(double lat, double lon, double alt);
  int updateTime(time_t timeVal);
  int updateTime(struct timeval timeVal);
  int update(time_t timeVal,double lat, double lon, double alt);
  int update(struct timeval timeVal,double lat, double lon, double alt);
  double getLat();
  double getLon();
  double getAlt();
};

#endif /*_BICAM_H_*/
