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

#ifndef __BluefinBatteryIF_H
#define __BluefinBatteryIF_H

#include "TaskInterface.h"


#define BluefinBatteryIFServerName "BluefinBatteryIFServer"

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

DESCRIPTION
TaskInterface to Simulator

AUTHORS
Tom O'Reilly
Rob McEwen
*/
/****************************************************************************/
/* Copyright (c) 2007 MBARI                                                 */
/* MBARI Proprietary Information. All rights reserved.                      */
/****************************************************************************/
/* Summary  : Interface to Bluefin Battery controller                       */
/* Filename : BluefinBatteryIF.idl                                          */
/* Author   : Henthorn                                                      */
/* Project  : Autonomy                                                      */
/* Version  : 1.0                                                           */
/* Created  : 10/04/2007                                                    */
/* Modified :                                                               */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/****************************************************************************/
/*
CLASS 
BluefinBatteryIF

DESCRIPTION
TaskInterface to Bluefin Battery device driver

AUTHOR
Henthorn

*/
class BluefinBatteryIF : public TaskInterface {

  friend class BluefinBatteryIF_SK;

  public:

  // Forward declarations of public structures
  struct BfBattData;
  
  //: BatteryIF { 
  enum BatteryState {
    Unknown,
    Shutdown,
    Discharging,
    Charging,
    Balancing
  };

  enum FaultCode {
    Clear,
    OverVolt,
    UnderVolt,
    OverCurrent,
    MaxCellOverVolt,
    MinCellUnderVolt,
    OverTemp,
    WaterLeak,
    HardwareProt,
    HardwareTransient,
    WatchdogTimeout
  };

  
  
  ////////////////////////////////////////////////////////////
  // Bluefin Battery Data structure
  struct BfBattData {
    //timespec sampleTime;
    BluefinBatteryIF::BatteryState state;
    BluefinBatteryIF::FaultCode fault;
    long battSN;
    float voltage;
    float current;
    float temp;
    float minvoltage;
    float maxvoltage;
    long waterleak;
    float capacity;
  };
  BluefinBatteryIF(const char *name, int timeout = 10);

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

  ~BluefinBatteryIF();

  ///////////////////////////////////////////////////////////////////
  // Return data for given battery 
  void getBatteryData(short batteryNum, BluefinBatteryIF::BfBattData *data);

  ///////////////////////////////////////////////////////////////////
  // Get the number of batteries
  short getBatteryQuantity();

  
  protected:

  // Message codes for each method
  enum BluefinBatteryIFMsgCode {
    GetBatteryDataMsgCode,
    GetBatteryQuantityMsgCode
  };

  // Define message structure for each method
  struct GetBatteryDataMsg : Request, Reply {
    short batteryNum;
    BluefinBatteryIF::BfBattData data;
  
  } _getBatteryDataMsg;

  struct GetBatteryQuantityMsg : Request, Reply {
    short returnVal;
  
  } _getBatteryQuantityMsg;

};

#endif

