/*******************************************************************************

$Id: mvc_fcc_api.h,v 1.2 2001/04/02 21:15:07 jrieffel Exp $

$Log: mvc_fcc_api.h,v $
Revision 1.2  2001/04/02 21:15:07  jrieffel
new fuel cell driver
now with logging (TM)!

Revision 1.3  2001/01/24 20:22:27  ted
Added 3 values to the FCC_DATA structure.
Total size of structure remains unchanged.

Revision 1.2  2000/05/09 12:48:56  root
Changed FC_remaining_kwh and RB_remaining_wh to data type short.

Revision 1.1  2000/05/09 12:39:59  root
Initial revision



*******************************************************************************/

// NOTE: this file is a special version of fcc_api.h for exclusive use by the MVC

#ifndef __MVC_FCC_API_H__
#define __MVC_FCC_API_H__
#ifdef __cplusplus
extern "C" {
#endif

#define BOOLEAN unsigned char
#define TRUE    1
#define FALSE   0

// FCC_STATUS.health defines               
#define FCC_HEALTHY                         0x00
#define FCC_ERR_FC_VOLTAGE_YELLOW           0x01
#define FCC_ERR_FC_VOLTAGE_RED              0x02
#define FCC_ERR_ANOLYTE_TEMP_YELLOW         0x04
#define FCC_ERR_ANOLYTE_TEMP_RED            0x08
#define FCC_ERR_CATHOLYTE_TEMP_YELLOW       0x10
#define FCC_ERR_CATHOLYTE_TEMP_RED          0x20
#define FCC_ERR_PEROXIDE_TEMP_YELLOW        0X40
#define FCC_ERR_PEROXIDE_TEMP_RED           0x80
#define FCC_ERR_ANOLYTE_A_CURRENT_YELLOW    0x0100
#define FCC_ERR_ANOLYTE_A_CURRENT_RED       0x0200      
#define FCC_ERR_ANOLYTE_B_CURRENT_YELLOW    0x0400
#define FCC_ERR_ANOLYTE_B_CURRENT_RED       0x0800      
#define FCC_ERR_CATHOLYTE_CURRENT_YELLOW    0x1000
#define FCC_ERR_CATHOLYTE_CURRENT_RED       0x2000      
#define FCC_ERR_PEROXIDE_CURRENT_YELLOW     0x4000
#define FCC_ERR_PEROXIDE_CURRENT_RED        0x8000      
#define FCC_ERR_RB_VOLTAGE_YELLOW           0x10000
#define FCC_ERR_RB_VOLTAGE_RED              0x20000
        
// Built-in self-test results and status defines
#define FCC_BIT_IN_PROGRESS                 0x01
#define FCC_BIT_COMPLETE                    0x02
#define FCC_BIT_OK                          0x00


// Commands sent to FCC Central Command process
typedef enum
{ 
    FCC_CMD_NONE = 0,
    FCC_CMD_START,
    FCC_CMD_STOP,
    FCC_CMD_OFFLINE,
    FCC_CMD_RESUME
}FCC_COMMAND;

// fc_control states
typedef enum 
{   
    FC_STATE_IDLE = 1,
    FC_STATE_OFFLINE,
    FC_STATE_RAMPING,
    FC_STATE_ONLINE
}FC_CONTROL_STATE;

// Fuel Cell Controller discharge data returned to the MVC on request and
// sent back via satellite
typedef struct
{                                   // UNIT         DOMAIN          RESOLUTION (LSB)
    unsigned int  elapsed_time;     // seconds      0-1000*60*3600  1
    short anolyte_pump_a_current;   // amps         0-500           0.01
    short anolyte_pump_b_current;   // amps         0-500           0.01
    short catholyte_pump_current;   // amps         0-500           0.01
    short peroxide_pump_current;    // amps         0-500           0.01
    short anolyte_temp;             // degrees C    -100 - +1000    0.1
    short catholyte_temp;           // degrees C    -100 - +1000    0.1
    short fwd_peroxide_temp;        // degrees C    -100 - +1000    0.1
    short aft_peroxide_temp;        // degrees C    -100 - +1000    0.1
    short stack_voltage;            // volts        0-4000          0.01
    short stack_current;            // amps         0-2000          0.01
    short battery_voltage;          // volts        0-4000          0.01
    short battery_current;          // amps         0-2000          0.01
    short peroxide_used;            // grams        0-10000         1
    short v_setpoint;               // volts        0-5000          0.01
    short makeup_injection_count;   // ea.          0-10000         1
    short base_injection_duration;  // seconds      0-1000          0.01
    short spare[1];                 // future expansion

} FCC_DATA;

// Fuel Cell Controller status information returned to the MVC on request
typedef struct
{                                       // DOMAIN   
    FC_CONTROL_STATE fc_control_state;  // see enum above 
    unsigned int  health;               // see #defines above 
    short FC_remaining_kwh;             // 0 - 100  Remaining Fuel Cell KWH     
    short RB_remaining_wh;              // 0 - 1000  Remaining Recovery Battery watt hours      
    unsigned char BIT_status;           // FCC_BIT_IN_PROGRESS, FCC_BIT_COMPLETE ( not currently used )
    unsigned char BIT_result;           // see #defines above ( not currently used )
    short spare[4];                     // future expansion
} FCC_STATUS;
               

/*
************************************************************
**      FCC CENTRAL COMMAND SPECIAL REPLY CODES
************************************************************
*/

typedef enum
{   
    FCC_ERR_OK = 1,
    FCC_ERR_INVALID_PARAM,
    FCC_ERR_NO_CLIENT,
    FCC_ERR_TOO_MANY_CLIENTS,
    FCC_ERR_COMM,
}FCC_CMD_REPLY;

/*
********************************************************************************
**  FUNCTION PROTOTYPES 
********************************************************************************
*/

// public interface
int get_FCC_data( FCC_DATA *);
int get_FCC_status ( FCC_STATUS *);
int send_FCC_command ( FCC_COMMAND cmd);

#ifdef __cplusplus
};
#endif
#endif

// End of File */
