#ifndef  _SOFT_TERRAIN_H_
#define  _SOFT_TERRAIN_H_
#include "stdint.h"
#include "stdbool.h"
#include "common.h"
//莫之比仿地
void can_recv_mocib_terrain(uint8_t *data);
typedef struct {
    short powerful;
    short near;
    short far;
}UAVH30;
extern UAVH30 uavh30_dist;

extern bool terrain_is_link;
extern uint16_t terrain_height;
extern bool F4d_send_flag;

void can_recv_enzhao_terrain(uint32_t CanID, uint8_t data[], uint8_t len);

void can_recv_muniu_terrain(uint8_t *data);

//仿地
#pragma pack(1)
typedef struct 
{
  //获取心跳属性
  Connect_check Link;

  //获取雷达高度数据
  short height;
  uint8_t crc;
  
  //获取灵敏度
  char send_fcu_sensi_count;
  char get_radar_sensi_count;
  bool get_radar_sensi_flag; //标志位
  bool fcu_set_sensi_flag;
  short fcu_set_sensi;      //灵敏度
  short get_radar_sensi;
  char set_radar_sensi_count;
  bool set_radar_sensi_ack;

  //获取版本信息
  bool get_radar_ver_flag;
  bool get_radar_sn_flag;
  char version[11];
  int soft_verison;
  int hard_version;

  bool get_radar_blind_flag;
  bool get_radar_power_flag;
  bool get_radar_rawSwitch_flag;

  //SN号
  char sn[20];
}uavr_terrain;
#pragma pack()
extern uavr_terrain uavr56_info;
extern uavr_terrain mimo_ter_info; 
extern uavr_terrain DM_ter_info; 
extern int16_t F_4DRadar[3][3];

// //木牛仿地
// #pragma pack(1)
// typedef struct 
// {
//     uint16_t muniu_hight;
//     uint16_t muniu_SNR;
    
//     Connect_check Link;
// }muniu;
// extern muniu muniu_ter_info;
// #pragma pack()


#pragma pack(1)
struct dm_byte1
{
  uint8_t tail:1;
  uint8_t head:1;
  uint8_t i:6;
};
#pragma pack()

union dm_byte
{
  uint8_t frame_flag;
  struct dm_byte1 flag;
};

#pragma pack(1)
typedef struct 
{
  uint8_t target_num;
  uint16_t power_level;
  uint16_t crc;
  uint16_t warn;
  union dm_byte byte7;


  uint8_t buf[150];
}DM_RADAR;
#pragma pack()

typedef struct 
{
  uint8_t pack_num;
  uint8_t target_num;

  uint8_t buf[150 * 5];
}DM_4DRADAR;
extern DM_4DRADAR FMU_4D_info; 

#pragma pack(1)
typedef struct 
{
  uint8_t target_num;
  uint16_t time_delay;
  uint16_t crc;
  uint16_t warn;
  union dm_byte byte7;

  uint8_t RawData[256 * 5];
}DM_4dFRADAR;
#pragma pack()
extern DM_4dFRADAR DM_F4d;


extern Connect_check DM_status;
extern Connect_check DM_4dstatus;
extern DM_RADAR DM_T_info,FMU_DM_info;
extern uint8_t DM_recv_flag;
extern uint8_t DM4d_recv_flag;
extern uint8_t DM4d_to_fmu_flag;
void DM_terrain_recieved_hookfuction(uint32_t cellCanID,uint8_t data[], uint8_t len);
void DM_Fobs_recieved_hookfuction(uint32_t cellCanID,uint8_t data[], uint8_t len);
#endif 
