/*
 * dsp_ris_internals_.h
 *
 */

#ifndef DSP_RIS_INTERNALS__H_
#define DSP_RIS_INTERNALS__H_


#include "idd_dsp_types.h"
#include "idd_avionic_types.h"

#include "DspLrpHeader.h"
#include "DspScanConvert.h"

extern void DspRisInstall();

extern void DspRisProcessEnvironment(unsigned int timetag, const iddtypes::inu_data_t* inu);	/*Process environment, that is mainly the navigation data, independent on the Radar mode and DSP batch*/


struct dsp_ris_tgt_t
{
	int enabled;

	unsigned int unique_id;

	int not_traceable;

	float az;
	float ground_range;
	float speed;
	float heading;
	float altitude;
	float amplitude;
	float sdr;

	float vx;
	float vy;
	float vz;

	float x;
	float y;

	float el;
	float range_rate;
	float range_delta;
	float slant_range;

	float rad_vel;

	float turn;
	float turn_duration;

	unsigned int hits;
	int tot;
	int max_tot;
	int already_seen;

	//Start value
	int restarted;

	float az_start;
	float el_start;
	float rng_start_meters;
	float heading_start;
	float speed_start;
	float altitude_start;
	bool altitude_invalid;
};

#define DSP_RIS_MAX_TGT	32


struct dsp_ris_agr_t
{
	int enable;
	unsigned int rb_start;
	unsigned int rb_len;
	float level;
};

struct dsp_ris_tgt_db_t
{
	unsigned int no_override;
	unsigned int contentions;
	int space_invaders;
	dsp_ris_tgt_t t[DSP_RIS_MAX_TGT];

	dsp_ris_agr_t agr;

	float rbm_range;
	float rbm_sim;

	float vxyz;
	float vxy;

	iddtypes::inu_data_t inu;
};


extern dsp_ris_tgt_db_t& dsp_ris_tgt_db;

void DspRisTgtUpdate(const iddtypes::inu_data_t& inu, float delta_time);

const iddtypes::inu_data_t& DspRisTgtInuData();

void DspRisTargetsLookup(const DspLrpHeaderOutput::Header* hdr, idddsp::dsp_detections_t& dspdet, idddsp::dsp_stt_data_t* stt, bool scan_mode);

bool DspRigTgtMutexAcquire(bool please_wait);
void DspRigTgtMutexRelease();

float DspRisRanceScale2Meters(iddtypes::range_scale_t);


bool DspRisPostprocessSignal(const DspLrpHeaderOutput::Header* hdrptr, DspRawSweepData* sc);

void DspRisSfpUpdateHeader(const DspLrpHeaderOutput::Header* hdrptr);


#endif /* DSP_RIS_INTERNALS__H_ */
