/****************************************************************************
*   File: libtracked.h
*                                                                           *
*       Copyright 1995 by Loral Advanced Distributed Simulation, Inc.       *
*                                                                           *
*               Loral Advanced Distributed Simulation, Inc.                 *
*               50 Moulton Street                                           *
*               Cambridge, MA 02138                                         *
*               617-441-2000                                                *
*                                                                           *
*       This software was developed by Loral under U. S. Government contracts *
*       and may be reproduced by or for the U. S. Government pursuant to    *
*       the copyright license under the clause at DFARS 252.227-7013        *
*       (OCT 1988).                                                         *
*                                                                           *
*       Contents: Public header file for libtracked
*       Created: Mon Jul 13 11:35:57 PDT 1992
*       Author: jesmith
*      $Revision$                                                     *
*       Remarks:                                                            *
*                                                                           *
****************************************************************************/

#ifndef _LIBTRACKED_H_INCLUDED
#define _LIBTRACKED_H_INCLUDED

#include <stdtypes.h> /*common/include/global*/
#include <libclass.h>
#include <libctdb.h>
#include <libdeployables.h>

/**
 ** tracked parametric data structure.
 **/

/* Data file entry should read:
 *
 * (tracked (soils (<integer soil type> (max_speeds <float forward KPH>
 *                                                  <float reverse KPH>)
 *                                      (max_accel <float mps2>)
 *                                      (max_decel <float mps2>)
 *                                      (max_turn  <float dps>)
 *                                      (max_climb <float degrees>)
 *                                      (dust_speeds <float smallKPH>
 *                                                   <float mediumKPH>
 *                                                   <float largeKPH>)
 *                                      (plow_speeds
 *                                          (<plow_type1> Ss Sd)
 *                                          (<plow_type2> Ss Sd)
 *                                          ...
 *                                          (<plow_typeN> Ss Sd)))
 *                 (<integer soil type> (max_speeds <float KPH>
 *                                                  <float reverse KPH>)
 *                                      (max_accel <float mps2>)
 *                                      (max_decel <float mps2>)
 *                                      (max_turn  <float dps>)
 *                                      (max_climb <float degrees>)
 *                                      (dust_speeds <float smallKPH>
 *                                                   <float mediumKPH>
 *                                                   <float largeKPH>)
 *                                      (plow_speeds
 *                                          (<plow_type1> Ss Sd)
 *                                          (<plow_type2> Ss Sd)
 *                                          ...
 *                                          (<plow_typeN> Ss Sd)))
 *
 *                  ...)
 *          (fuel_usage (<float speed> ...)
 *			(<float rate>  ...))
 *  )
 *
 *
 * such that:
 *   - there can be between 0 and DEPLOYABLES_PLOW_COUNT <plow_type>
 *     entries per soil type.
 *   - Ss is the speed (kmph) the vehicle can travel in this soil when it 
 *     has <plow_type> attached and it is stowed (not being used).
 *   - Sd is the speed (kmph) the vehicle can travel in this soil when it 
 *     has <plow_type> attached and it is deployed (in use).
 *
 */

#define TRK_MAX_FUEL_DIM 10

typedef struct tracked_parametric_data
{
    int32 fuel_table_length;
    float64 fuel_speeds[TRK_MAX_FUEL_DIM]; 
    float64 fuel_rates[TRK_MAX_FUEL_DIM];

    /* CCTT Mobility Model Parameters */
    int32       mobility_model;
    float64     throttle_forward_loop_gain;
    float64     throttle_accel_feedback_gain;
    float64     tau_throttle_inv;
    float64     heading_error_rate_tau;
    float64     reverse_drive_factor;
    int32       n_throttle_positions;
    int32       n_slopes;
    int32       n_soil_types;
    int32       n_speeds;
    int32       n_brake_positions;
    uint32      in_trouble_limit;         /* milliseconds */

    int32 n_soils;
    struct tracked_soils
    {
	uint32  soil_type;

#define TRACKED_MAX_FORWARD 0
#define TRACKED_MAX_REVERSE 1

	float64 max_speeds_mps[2];
	float64 max_dry_slope;
	float64 max_wet_slope;
	float64 max_accel_mps2;
	float64 max_decel_mps2;
	float64 max_turn_rps;
	float64 max_climb_sin;
	float64 dust_speeds_mps[3];
	
	uint32  n_plows;
	uint32  plow_type[DEPLOYABLES_PLOW_COUNT];
	float64 plow_data[DEPLOYABLES_PLOW_COUNT][2];

    } soils[1];	

} TRACKED_PARAMETRIC_DATA;

/** 
 ** Functions relating to global libtracked operation
 **
 **/


/* tracked_init:
 *
 * Initializes libtracked.  Call this before calling any other libtracked
 * functions.
 */
extern void tracked_init(
    int32 cant, 
    char *data_path, 
    int32 constant_env,
    int32 mobility_sw);

/* functions to support parser control of statistics gathering */
extern void tracked_statsOn(void);
extern void tracked_statsOff(void);
extern void tracked_statsReset(void);
extern void tracked_statsPrint(void);
extern void tracked_statsStatus(void);
extern void tracked_statsQuit(void);

/**
 ** Functions relating to per-vehicle tracked class information.
 **
 **/

#endif /*_LIBTRACKED_H_INCLUDED*/
