/*
********************************************************
Copyright 2000 MBARI.
MBARI Proprietary Information. All rights reserved.
NOTE: This file is automatically generated.
DO NOT MODIFY.
********************************************************
*/

#ifndef __GpsIF_H
#define __GpsIF_H

#include "TaskInterface.h"

#include "InstrumentIF.h"
#include "TimeIF.h"

#define GpsIFServerName "GpsIFServer"

class GpsIF : public InstrumentIF {

  friend class GpsIF_SK;

  public:

  // Forward declarations of public structures
  struct GgaTime;
  struct Fix;
  struct GsaStruct;
  struct VgtStruct;
  
  /////////////////////////////////////////////////////////
  // "Quality" as defined by NMEA standard.
  enum Quality {
    Invalid,
    NonDifferential,
    Differential
  };

  enum Hemisphere {
    Northern,
    Southern,
    Eastern,
    Western
  };

  
  
  //
  // Save Gps time in the following structure:
  //
  struct GgaTime {
    short hours;
    short minutes;
    short seconds;
    short centiSeconds;
  };
  /////////////////////////////////////////////////////////
  // Data structure contains items specified by the
  // NMEA GPS data standard.
  struct Fix {
    TimeIF::TimeSpec sampleTime;
    GpsIF::GgaTime ggatime;
    /////////////////////////////////////////////////////////
    // Latitude (radians)
    double latitude;
    GpsIF::Hemisphere nsHemisphere;
    /////////////////////////////////////////////////////////
    // Longitude (radians)
    double longitude;
    GpsIF::Hemisphere ewHemisphere;
    /////////////////////////////////////////////////////////
    // Data quality (see above)
    GpsIF::Quality quality;
    /////////////////////////////////////////////////////////
    // Number of satellites used in fix
    short nSatellites;
    /////////////////////////////////////////////////////////
    // Horizontal dilution of precision
    double hdop;
    /////////////////////////////////////////////////////////
    // Altitude above mean sealevel in meters
    double altitude;
    /////////////////////////////////////////////////////////
    // Geoid height above mean sealevel in meters
    double geoidHeight;
    /////////////////////////////////////////////////////////
    // DGPS fix age in seconds
    short dgpsDataAge;
    /////////////////////////////////////////////////////////
    // DGPS reference station id
    short dgpsStationId;
  };
  /////////////////////////////////////////////////////////////////
  // Data structure contains items specified by the NMEA GSA string.
  struct GsaStruct {
    //
    // Manual or Auto mode:
    short mode;
    //
    // Fix mode; 1 = No fix; 2 = 2D Fix; 3 = 3D Fix:
    short fixMode;
    //
    // Satellite ID's:
    short satID1;
    short satID2;
    short satID3;
    short satID4;
    short satID5;
    short satID6;
    short satID7;
    short satID8;
    short satID9;
    short satID10;
    short satID11;
    short satID12;
    short satID13;
    short satID14;
    //
    // Pdop:
    float pdop;
    //
    // Expected horizontal DOP:
    float horizDop;
    //
    // Expected vertical DOP:
    float vertiDop;
  };
  /////////////////////////////////////////////////////////////////
  // Data structure contains items specified by the NMEA VGT string.
  struct VgtStruct {
    //
    // True course:
    double trueCourse;
    //
    // True course units:
    char trueCourseIndicator;
    //
    // Magnetic course:
    double magCourse;
    //
    // Magnetic course units:
    char magCourseIndicator;
    //
    // Speed in knots:
    double speedKnots;
    //
    // Speed in knots units: (]
    char speedKnotsUnits;
    //
    // Speed in km/hr:
    double speedKmHr;
    //
    // Speed in km/hr units: (]
    char speedKmHrUnits;
    //
    // Positioning Mode
    char positionMode;
  };
  GpsIF(const char *name, int timeout = 10);

  GpsIF(const char *name, const char *serverName, int timeout = 10);

  ~GpsIF();

  /////////////////////////////////////////////////////////
  // Get data from instrument
  // [output] Data: Gps data
  DeviceIF::Status getFix(GpsIF::Fix *fix);

  /////////////////////////////////////////////////////////
  // Get data from instrument
  DeviceIF::Status getGSA(GpsIF::GsaStruct *gsa);

  /////////////////////////////////////////////////////////
  // Get data from instrument
  DeviceIF::Status getVGT(GpsIF::VgtStruct *vgt);

  
  protected:

  // Message codes for each method
  enum GpsIFMsgCode {
    GetFixMsgCode = 8,
    GetGSAMsgCode,
    GetVGTMsgCode
  };

  // Define message structure for each method
  struct GetFixMsg : Request, Reply {
    DeviceIF::Status returnVal;
    GpsIF::Fix fix;
  
  } _getFixMsg;

  struct GetGSAMsg : Request, Reply {
    DeviceIF::Status returnVal;
    GpsIF::GsaStruct gsa;
  
  } _getGSAMsg;

  struct GetVGTMsg : Request, Reply {
    DeviceIF::Status returnVal;
    GpsIF::VgtStruct vgt;
  
  } _getVGTMsg;

};

#endif

