PRO HEADER_CFAR_v2 , Cfar2dSettings, Cfar2dResults, Cfar2dParameters

;
C2D_N_RBIN_MAX = 2048L
MAX_MTI_ALARM_NUMBER = 128L
C2D_PFA_NUM             = 3
C2D_RSC_NUM             = 5
C2D_NC_3_LEN            = 6
C2D_R_LEN               = 10

Cfar2dScheme = $
{   $
    cfar2d_scheme_CA : 0L, $;    // 0 = Cell Average
    cfar2d_scheme_GO : 0L, $;    // 1 = Greatest Of
    cfar2d_scheme_SO : 0L, $;    // 2 = Smallest Of
    cfar2d_scheme_BC : 0L  $;    // 3 = Biparametric CFAR2D
}


;/* possible schemes for the sample support geometry */
Cfar2dGeometryId = $
{   $
    cfar2d_geom_id_4ba : 0L, $      ;// 1 = 4 basic areas
    cfar2d_geom_id_2ba_dop : 0L, $  ;// 2 = 2 basic areas along doppler
    cfar2d_geom_id_2ba_rng : 0L, $  ;// 3 = 2 basic areas along range
    cfar2d_geom_id_ring : 0L $      ;// 4 = ring
}

;/* possible pairings of the basic sample support areas */
Cfar2dGradient =  $
{   $
    gradient_no_pair : 0L, $   ;// 0 = no pairing
    gradient_along_rng : 0L, $ ;// 1 = pairing along range
    gradient_along_dop : 0L, $ ;// 2 = pairing along doppler
    gradient_cross_pair : 0L $ ;// 3 = cross pairing
}

;/* possible PFA values */
Cfar2dPfa = $
{   $
    pfa_aa_low : 0L, $   // 0 = AA low PFA  = C2D_AA_LOW_PFA
    pfa_low : 0L, $      // 1 = low PFA    = C2D_LOW_PFA
    pfa_medium: 0L, $    // 2 = medium PFA = C2D_MEDIUM_PFA
    pfa_high: 0L $       // 3 = high PFA   = C2D_HIGH_PFA
}

;/* CFAR2D collapsing structure */
Cfar2dCollapsing = $
{   $
    ;/* max number of detection to be collapsed in tha same alarm */
    max_coll_det : 0L ,$;
    ;/* max range extension of detections wich can be collapsed in the same alarm (range bins) */
    coll_max_rng : 0L ,$;
    ;/* max doppler extension of detections wich can be collapsed in the same alarm (filters) */
    coll_max_dop : 0L $;
};       //str_3w


Cfar2dSampleSupport = $
{   $
;    /* id of the available scheme for the sample support geometry */
	CFAR_Geometry_ID : 0L, $;                 //1w
;    /* odd value > 0; 1..C2D_RNG_DIM_MAX
;       range dimension of the basic CFAR2D sample support area */
    cfar_rng_dim : 0L, $                 //1w
;    /* -1 OR odd value > 0 (max = C2D_RNG_GUARD_MAX)
;       range guard between the BUT and the basic CFAR2D sample support area */
    cfar_rng_guard : 0L, $;               //1w
;    /* odd value > 0; 1..C2D_DOP_DIM_MAX
;       doppler dimension of the basic CFAR2D sample support area */
    cfar_dop_dim : 0L, $;                 //1w
;    /* -1 OR odd value > 0 (max = C2D_DOP_GUARD_MAX)
;       doppler guard between the BUT and the basic CFAR2D sample support area */
    cfar_dop_guard : 0L, $              //1w
;    /* id of the pairing of the basic sample support areas */
    Gradient : 0L, $;                //1w
;    /* flag enabling the ring area configuration for the CFAR2D sample support
;       0 = FALSE = ring disabled, separated areas;
;       1 = TRUE  = ring enabled, ring area */
    cfar_ring : 0L $;                    //1w
}


cfar_sensing = $
  {   $
  MIN_RBIN : 0L, $  
  MAX_RBIN : 0L, $
  MIN_FILT: 0L, $
  MAX_FILT: 0L $
}


Cfar2dSettings = $
{   $
; 	/* 2..C2D_N_RBIN_MAX;
;       num of RGs in each PRI */
    n_rbin : 0L ,$;                                 //1w
;    /* 1..C2D_N_FFT_MAX;
;       lenght of the FFT filter */
	n_fft : 0L ,$;                                  //1w
;    /* 0..(C2D_N_FFT_MAX-1)
;       init filter of region in the range/doppler plane where the CFAR2D processing operates */
    cfar_start_filt : 0L ,$                      //1w
;    /* 0..(C2D_N_FFT_MAX-1)
;       final filter of region in the range/doppler plane where the CFAR2D processing operates */
    cfar_stop_filt : 0L , $                       //1w
;    /* 0..C2D_N_FFT_MAX-(cfar2d_stop_filt-cfar2d_start_filt+1)
;       num of filters excluded from the CFAR2D processing */
    doppler_notch : 0. ,$                          //1w
;    /* id of the adopted CFAR2D processing scheme */
    CFAR_Scheme : 0L ,$;                          //1w
;    /* odd values > 0; 1..C2D_MAX_RBIN_BLOCK_DIM
;       range block dimension */
    rbin_block_dim : 0L ,$                        //1w
;    // CFAR2D sample supprt data */
    cfar_sample_support : Cfar2dSampleSupport ,$ ;                        //str_7w
;    /* supported PFA values */
    pfa : 0L, $ ;                                    //1w
;    /* range-scale index */
    rs_index : 0L ,$;                               //1w
;    /* struct containing the range and doppler limits of the area
;       where the CFAR2D sensing shall be performed */
    cfar_sensing : cfar_sensing ,$ ; DS dai file non riesco a capire come � definito il cfar2d_sensing //str_4w
;    /* 0..C2D_N_RBIN_MAX
;       number of saturations in the current batch */
    num_sat : 0L ,$;                                //1w
;    /* for each range bin the vector contains a flag relevant to the saturation status:
;       TRUE  = range bin saturated
;       FALSE = range bin not saturated */
    SAT_VECTOR  : 0L ,$ ;LONARR(C2D_N_RBIN_MAX) ,$;                //2048w
;    /* identifier of the current batch */
    batch_id : 0L ,$;                               //1w
;    /* actual antenna pointing direction in NED frame (rad) */
	antenna_az_ned : 0. ,$;                         //1w
;    /* structure of collapsing data */
    COLLAPSING : Cfar2dCollapsing ,$;                                  //str_3w
;    /* Noise Level at the CFAR input (linear, >0) */
    noise_level : 0. ,$;                            //1w
;    /* flag selecting subfunctions for SUM or GUARD data processing:
;       FALSE = SUM data processing;
;       TRUE  = GUARD data processing */
    GUARD_SWITCH_FLAG : 0L ,$                       //1w
;	// AGGIUNTO VALE X PERMETTERE DI SOVRASCRIVERE IL VALORE DEL CFAR_GAIN
	cfar_2D_thr_ovr : 0. ,$;							//1w
;	//Luglio 2018 allineamento struttura per coerenzadati vettore generato da sistemista
;	//Aggiunto per il GRIFO va utilizzato il GAIN fisso letto dai settings quindi abbiamo 1 campo (4byte) in piu rispetto al Gabbiano
	cfar2d_grifo_gain : 0., $;
	grifo_gain_delta : 0. $
} ;//str_2077w

MtiAleData = $
{   $
    valid : 0L ,$;
    meas : 0L ,$;
    rrate : 0L $;
}

;AlarmJemSign =  $
;{   $
;    js_not_app : 0 ,$ ;// 0 = not applicable
;    js_body : 0 ,$    ;// 1 = body
;    js_jem : 0 $     ;// 2 = JEM
;}


AlarmJemSign =  $
{   $
    js_not_app : 0L $ ;// 0 = not applicable

}


MtiAlarm = $
{   $
    alm_id : 0L ,$;
    num_det : 0L ,$;
    rbin_ctr_mass : 0. ,$;
    filt_ctr_mass : 0. ,$;
    min_det_rbin : 0 ,$;
    max_det_rbin : 0 ,$;
    min_det_filt : 0 ,$;
    max_det_filt : 0 ,$;
    alm_amp  : 0. ,$;
    alm_thr_excess : 0. ,$;
    alm_mean : 0. ,$;
    alm_doa : 0. ,$;
    alm_snr : 0. ,$;
    alm_peak_rbin : 0. ,$;
    alm_peak_filt : 0. ,$;
    alm_peak_val : 0. ,$;
    dop_split : 0 ,$;
    jem_sign : 0 ,$;
    sat_mark : 0 ,$;
    guard_amplitude  : 0. ,$;
    delta_mag : 0. ,$;
    theta_tgt : 0. ,$;
    ale_flag : 0 ,$;
    blabla : 0 $;
}


MtiAlarmList = $
{   $
    batch_id : 0 ,$;
    num_alm : 0 ,$;
    ale : MtiAleData ,$ ;
    alm_rep :  REPLICATE(MtiAlarm ,MAX_MTI_ALARM_NUMBER) $;
}


;/*______ CFAR2D Results ______*/

Cfar2dResults = $
{   $
    ;/* number of CFAR2D minimum threshold selections */
    cnt_min_thr : 0 ,$;                    //1w
    ;/* noise level estimation for CFAR2D sensing */
    noise_level_dB : 0. ,$;                 //1w
    ;/* CFAR2D gain: from LAA matrix to THR matrix */
    cfar2d_gain : 0. ,$;                    //1w
    ;/* CFAR2D generated alarm list */
    alm_list : MtiAlarmList $;                       //str_3077w

};      //str_3080w



;/*______ CFAR2D Parameters ______*/

;/* possible schemes for the sample support geometry */
;typedef enum _Cfar2dGeometryId_t
;{
;    cfar2d_geom_id_4ba = 1,   // 1 = 4 basic areas
;    cfar2d_geom_id_2ba_dop,   // 2 = 2 basic areas along doppler
;    cfar2d_geom_id_2ba_rng,   // 3 = 2 basic areas along range
;    cfar2d_geom_id_ring       // 4 = ring
;} Cfar2dGeometryId_t;
;
;/* possible pairings of the basic sample support areas */
;typedef enum _Cfar2dGradient_t
;{
;    gradient_no_pair = 0,   // 0 = no pairing
;    gradient_along_rng,     // 1 = pairing along range
;    gradient_along_dop,     // 2 = pairing along doppler
;    gradient_cross_pair     // 3 = cross pairing
;} Cfar2dGradient_t;

Cfar2d_Gain_Data_Store = $
{   $
    ca_gain : LONARR(C2D_PFA_NUM * C2D_RSC_NUM * C2D_NC_3_LEN) ,$
    go_gain : LONARR(C2D_PFA_NUM * C2D_RSC_NUM * C2D_NC_3_LEN) ,$
    so_gain : LONARR(C2D_PFA_NUM * C2D_RSC_NUM * C2D_NC_3_LEN) ,$
    bipar_gain : LONARR(C2D_PFA_NUM * (C2D_R_LEN + 1)) $
}

Cfar2dParameters = $
{   $
;    /* enable/disable the overwriting of the CFAR2D gain with a pre-defined
;       value stored in the gain table:
;       1 = TRUE  = enable overwriting;
;       0 = FALSE = disable overwriting */
    MANUAL_CFAR_GAIN_FLAG : 0 ,$;       //1w
;    /* table containing pre-defined CFAR2D gain values */
    Cfar_Gain_Data_Store : Cfar2d_Gain_Data_Store ,$;                 //str_303w
;    /* minimum CFAR2D threshold */
    MIN_CFAR_THR : 0.1  ,$          ;//1w
;    /* maximum CFAR2D threshold */
    MAX_CFAR_THR : 1000 ,$;             //1w
;    /* flag selecting the algorithm for alarm center of mass evaluation:
;       FALSE = no amp-weighted center mass;
;       TRUE  = amplitude weighted center mass */
    WEIGHT_CTR_MASS_FLAG : 0, $;            //1w
    MAX_NUM_ALM           : 128 $
}  ;//str_307w

END