/***************************************************************************
                     FILE INFORMATION HEADER
                     -----------------------

    a.  PROJECT NAME:       GRIFO_S7  P2813
    b.  ITEM TYPE               header
    c.  ITEM NAME:              dbs_types2.h
    d.  ITEM REFERENCE:
    e.  CURRENT VERSION:        1.1
    f.  DATE:                   3/6/97
    g.  SOURCE FILE LOCATION:   /sparc-2/library/sr3b_end/dati/common/cmn_dt/s.dbs_types2.h
    h.  'C' RELEASE:            2.11
    i.  ITEM DESCRIPTION:
    j.  DOCUMENTATION REFERENCES: SDD Tracker Computer SR2
    k.  PROGRAMMER NAME(S):
    l.  COPYRIGHT:              FIAR
    m.  REVISION HISTORY:    07-11-01 - Baseline copied from 3B.86 R3K Metis radar version


 ***************************************************************************/

#ifndef dbs_types2_defined
//## attribute ::types_reverse::TopLevel.dbs_types2_defined
const RhpString dbs_types2_defined;

//## dependency base_types
#include "base_types.h"
//## dependency dsp_base_types
#include "dsp_base_types.h"
//## dependency fixed_point_types
#include "fixed_point_types.h"
//## dependency dbs_types1
#include "dbs_types1.h"
// ***********************  DBS Constants  *********************************
//## attribute ::types_reverse::TopLevel.MAX_FOCUS_RNG_CBP
const RhpString MAX_FOCUS_RNG_CBP(3);

//## attribute ::types_reverse::TopLevel.DBS1_FOCUS_RNG_CBP
const RhpString DBS1_FOCUS_RNG_CBP(3);

//## attribute ::types_reverse::TopLevel.DBS2_FOCUS_RNG_CBP
const RhpString DBS2_FOCUS_RNG_CBP(1);

//#[ type FOCUS_RNG_CBP
#define FOCUS_RNG_CBP( op_code ) \
  ( (op_code == dbs_1) ? DBS1_FOCUS_RNG_CBP : \
    (op_code == dbs_2) ? DBS2_FOCUS_RNG_CBP : 0 )
//#]

// * The number of phi-az arrays required by the DBS module.      *
// * NOTE: this is different from that produced by the algorithm. *
//## attribute ::types_reverse::TopLevel.MAX_DBS_PHI_AZ
const RhpString MAX_DBS_PHI_AZ(5);

//## attribute ::types_reverse::TopLevel.DBS1_PHI_AZ
const RhpString DBS1_PHI_AZ(5);

//## attribute ::types_reverse::TopLevel.DBS2_PHI_AZ
const RhpString DBS2_PHI_AZ(3);

//#[ type DBS_PHI_AZ
#define DBS_PHI_AZ( op_code ) \
  ( (op_code == dbs_1) ? DBS1_PHI_AZ : \
    (op_code == dbs_2) ? DBS2_PHI_AZ : 0 )
//#]

//## attribute ::types_reverse::TopLevel.MAX_NFFT
const RhpString MAX_NFFT(128);

//## attribute ::types_reverse::TopLevel.DBS1_NFFT
const RhpString DBS1_NFFT(24);

// #define DBS1_NFFT  22
//## attribute ::types_reverse::TopLevel.DBS2_NFFT
const RhpString DBS2_NFFT(128);

//#[ type DBS_NFFT
#define DBS_NFFT( op_code ) \
  ( (op_code == dbs_1) ? DBS1_NFFT : \
    (op_code == dbs_2) ? DBS2_NFFT : 0 )
//#]

//## attribute ::types_reverse::TopLevel.NFIL_POST_DBS1
const RhpString NFIL_POST_DBS1(32);

//## attribute ::types_reverse::TopLevel.NFIL_POST_DBS2
const RhpString NFIL_POST_DBS2(128);

//#[ type NFIL_POST
#define NFIL_POST( op_code ) \
   ( (op_code == dbs_1) ? NFIL_POST_DBS1 : \
     (op_code == dbs_2) ? NFIL_POST_DBS2 : 1 )
//#]

//## attribute ::types_reverse::TopLevel.DBS_MAX_RNG_COEFFS
const RhpString DBS_MAX_RNG_COEFFS(494);

//## attribute ::types_reverse::TopLevel.DBS1_MAX_RNG_COEFFS
const RhpString DBS1_MAX_RNG_COEFFS(494);

//## attribute ::types_reverse::TopLevel.DBS2_MAX_RNG_COEFFS
const RhpString DBS2_MAX_RNG_COEFFS(62);

//#[ type MAX_RNG_COEFFS
#define MAX_RNG_COEFFS( op_code ) \
  ( (op_code == dbs_1) ? DBS1_MAX_RNG_COEFFS : \
    (op_code == dbs_2) ? DBS2_MAX_RNG_COEFFS : 0 )
//#]

//#[ type MAX_NRBIN
#define MAX_NRBIN( op_code ) \
  ( (op_code == dbs_1) ? DBS1_MAX_RNG_COEFFS : \
    (op_code == dbs_2) ? DBS2_MAX_RNG_COEFFS : 0 )
//#]

/**************************  DBS Datatypes  *********************************/

namespace legacy
{
    // **************************************************************************
    // **** INPUT: dbs_event                                                 ****
    // ****        This is always present.                                   ****
    //#[ type dbs_event_t
    typedef enum {
      no_dbs_event,
      new_config,
      dbs_map_init,
      start_dbs_bar,
      dbs_bar_valid,
      end_dbs_bar,
      end_dbs_frame
    }  dbs_event_t;
    //#]
}

/****************************************************************************/

namespace legacy
{
    // **************************************************************************
    // **** INPUT: dbs_map_init_data                                         ****
    // ****        This is only present when the dbs_event is new_config.    ****
    //#[ type dbs_config_data_t
    typedef struct {
      dbs_op_code_t                op_code;
      num_dbs_bars_t               num_bars;
      metres_t                     lambda;
      int                          code_len;
    } dbs_config_data_t;
    //#]
}

/****************************************************************************/

namespace legacy
{
    // **************************************************************************
    // **** INPUT: dbs_map_init_data                                         ****
    // ****        This is only present when the dbs_event is dbs_map_init.  ****
    // ****                                                                  ****
    // ****        NOTE:                                                     ****
    // ****          ac_map_hd_angle1, ac_dbs_start_az1 are for the first    ****
    // ****          bar, whereas ac_map_hd_angle2, ac_dbs_start_az2 is for  ****
    // ****          the second bar and is valid only when num_bars is 2.    ****
    //#[ type dbs_map_init_data_t
    typedef struct {
      radians_t                    ac_map_hd_angle1;
      radians_t                    ac_map_hd_angle2;
      radians_t                    ac_dbs_start_az1;
      radians_t                    ac_dbs_start_az2;
      float                        ac_dbs_const;
      timetag_t                    map_ref_time;
      metres_t                     map_ref_alt;
      metres_t                     map_sl_rng;
      short_range_bin_t            rb_start_init;
      short_range_bin_t            rb_len_init;
      short_range_bin_t            rb_start_ref;
      short_range_bin_t            rb_stop_ref;
      short_range_bin_t            rb_init;
      short_range_bin_t            rb_fin;
      int                          num_focus;
      int                          middle_focus_id;
      short_range_bin_t            rng_focus_array[MAX_FOCUS_RNG_CBP];
      radians_t                    elev_focus_array[MAX_FOCUS_RNG_CBP];
      short_range_bin_t            ppm_fil_ref;
    } dbs_map_init_data_t;
    //#]
}

/****************************************************************************/

namespace legacy
{
    // **************************************************************************
    // **** INPUT: dbs_event_data                                            ****
    // ****        This is data associated with the event.                   ****
    //#[ type dbs_event_data_t
    typedef union {
      dbs_config_data_t    new_config;
      dbs_map_init_data_t  dbs_map_init;
    } dbs_event_data_t;
    //#]
}

/****************************************************************************/

namespace legacy
{
    // **************************************************************************
    // **** OUTPUT: common types                                             ****
    //## type m_pointer_t
    typedef unsigned short m_pointer_t;
}

//## attribute ::types_reverse::TopLevel.M_POINTER_T_MIN
const RhpString M_POINTER_T_MIN(1);

//## attribute ::types_reverse::TopLevel.M_POINTER_T_MAX
const RhpString M_POINTER_T_MAX(8);

namespace legacy
{
    //## type dbs_batch_count_t
    typedef unsigned short dbs_batch_count_t;
}

//## attribute ::types_reverse::TopLevel.DBS_BATCH_COUNT_T_MIN
const RhpString DBS_BATCH_COUNT_T_MIN(0);

//## attribute ::types_reverse::TopLevel.DBS_BATCH_COUNT_T_MAX
const RhpString DBS_BATCH_COUNT_T_MAX(256);

namespace legacy
{
    //#[ type rm_data_rec_t
    typedef struct {
      m_pointer_t        mat;
      short_range_bin_t  start;
    } rm_data_rec_t;
    //#]
    
    // **************************************************************************
    // **** OUTPUT: dbs_prf_data                                             ****
    // ****         These are the PRF results for either DBS1 or DBS2        ****
    //#[ type dbs_prf_data_t
    typedef struct {
      short_range_bin_t  prt;
      int                prt_tx_no;
      short_range_bin_t  rb_start;
      short_range_bin_t  rb_len;
      short_range_bin_t  n_rbin;
      radians_t          vplat_az;
    } dbs_prf_data_t;
    //#]
}

/** SIZE = 16 bytes **/

/****************************************************************************/

namespace legacy
{
    // **************************************************************************
    // **** OUTPUT: dbs_results                                              ****
    // ****         These are the dbs results for either DBS1 or DBS2.       ****
    // ****         The boolean dbs_batch indicates that the data relative   ****
    // ****         to the DBS Module is to be sent.                         ****
    // ****                                                                  ****
    //#[ type dbs_results_t
    typedef struct {
      dbs_op_code_t      op_code;
      boolean            reset_sp;
      boolean            reset_agc;
      boolean            reset_pp_batch_count;
      int                num_bars;
      boolean            pvu_request;
      dbs_prf_data_t     prf_data;
      boolean            dbs_batch;
      boolean            rmc_init_flag;
      dbs_batch_count_t  batch_count;
      short_range_bin_t  rm_len;
      radians_t          batch_az_angle;
      timetag_t          batch_duration;
      short_range_bin_t  prt_avg;
      hertz_t            v_los_ref_freq;
      short_range_bin_t  nrb;
      union {
        struct {
          rm_data_rec_t      rm[DBS1_NFFT];
          short_range_bin_t  im[DBS1_FOCUS_RNG_CBP];
          ushort_radians_t   phi_az[DBS1_FOCUS_RNG_CBP][DBS1_NFFT];
          ushort_radians_t   phi_rng[DBS1_MAX_RNG_COEFFS];
        } dbs1;
        struct {
          rm_data_rec_t      rm[DBS2_NFFT];
          short_range_bin_t  im[DBS2_FOCUS_RNG_CBP];
          ushort_radians_t   phi_az[DBS2_FOCUS_RNG_CBP][DBS2_NFFT];
          ushort_radians_t   phi_rng[DBS2_MAX_RNG_COEFFS];
        } dbs2;
      } specific;
    } dbs_results_t;
    //#]
}

/****************************************************************************/

namespace legacy
{
    // **************************************************************************
    // **** OUTPUT: dbs_settings                                             ****
    //#[ type total_dbs_settings_t
    typedef struct {
      dbs_dsp_settings_t  dbs_dsp_settings;
      dbs_results_t       dbs_settings;
      } total_dbs_settings_t;
    //#]
}

/****************************************************************************/

#endif
