/****************************************************************************/
/* Copyright (c) 2007 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  :                                                               */
/* Filename : StatePacket.x                                                 */
/* Author   :                                                               */
/* Project  : Onboard Deliberative Autonomy                                 */
/* Version  : 1.0                                                           */
/* Created  : 02/07/2007                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/



/** Define battery state enumerations and data structure; these are similar
    but not necessarily identical to those generated by the MBARI QNX 
    "mini-IDL" compiler. The definitons here are used by the QNX flight
    code as well as whatever is receiving the data on another computer. This
    file should be compiled with rpcgen, which generates definitions and
    functions to convert between machine-local and XDR data formats.
*/

enum BatteryState {
  BattUnknown,
  BattShutdown,
  BattDischarging,
  BattCharging,
  BattBalancing
};

enum BatteryFaultCode {
  BattClear,
  BattOverVolt, 
  BattUnderVolt, 
  BattOverCurrent,
  BattMaxCellOverVolt, 
  BattMinCellUnderVolt,
  BattOverTemp, 
  BattWaterLeak, 
  BattHardwareProt,
  BattHardwareTransient, 
  BattWatchdogTimeout,
  BattUnknownFault
};

struct Battery {

/*   bool valid; */

  BatteryState state;
/*   BatteryFaultCode fault; */
/*   long  battSN; */
  float voltage;
/*   float current; */
/*   float temp; */
  float minvoltage;
/*   float maxvoltage; */
/*   long  waterleak; */
/*   float capacity; */
};  


struct Hydroscat {
  bool    valid;

  double  bb470;
  double  bb676;
  double  fl;
}; 


/** 
    Vehicle attitude and rates.  Copied from NavigationIF.idl and modified.
*/
struct Attitude {
  bool valid;

  double roll;
  double pitch;
  double yaw;
  double omega_B_x;
  double omega_B_y;
  double omega_B_z;
  long updateTimeSec;
  long updateTimeNanosec;
};

/** 
    Vehicle position and rates.  Copied from NavigationIF.idl and modified.
*/
struct Position {
  bool valid;

  double latitude;
  double longitude; 
  double x;
  double y;
  double z;
/*   double altitude; */
/*   double xRate; */
/*   double yRate; */
/*   double zRate; */
/*   double depthRate;    */
/*   double altitudeRate; */
/*   long updateTimeSec; */
/*   long updateTimeNanosec; */
};

/** Structure to hold tail-cone data. */ 
struct TailCone
{
  bool valid;

  double omega;
  double elevator; 
  double rudder;
  long updateTimeSec;
  long updateTimeNanosec;
};

/** Output of the cluster */
struct Cluster {
  bool valid;
  int id;
};

/** Output of the CTD server */
struct Ctd {
  bool valid;
  float c;    
  float t;
  float d;
  float salinity;
};

/** Output of the Isus server */
struct Isus {
  bool valid;
  double nitrate;
}; 

enum GulperState {
     g_Free =0,
     g_Allocated =1,
     g_Fired =2,
     g_Unknown =3
};

struct GulperInfo {
     GulperState state;
};


/** State information needed by TREX */
struct StatePacket {

  struct Position position;
/*   struct Attitude attitude; */
/*   struct TailCone tailCone; */
  struct Cluster  cluster;

/*  struct Battery batteryData; */

  struct Hydroscat hydroscat;

  struct Ctd ctd;
  struct Isus isus;

  struct GulperInfo gulper[10];
};


