#ifndef JUNDEG_H
#define JUNDEG_H
#include "usart.h"
#include "queue.h"
#include "main.h"
#include "string.h"
#define BSP_USART3_DMA_RX_BUF_LEN 256
/** 
  * @brief  frame header structure definition
  */

typedef __packed struct
{
  uint8_t  sof;
  uint16_t data_length;
  uint8_t  seq;
  uint8_t  crc8;
} Frame_Header_t;

/** 
  * @brief  frame header structure definition
  */

typedef __packed struct
{
 uint8_t game_type : 4;
 uint8_t game_progress : 4;
 uint16_t stage_remain_time;
} ext_game_state_t;
/** 
  * @brief  frame header structure definition
  */

typedef __packed struct
{
 uint8_t winner;
} ext_game_result_t;
/** 
  * @brief  frame header structure definition
  */

typedef __packed struct
{
 uint16_t robot_legion;
} ext_game_robot_survivors_t;
/** 
  * @brief  frame header structure definition
  */

typedef __packed struct
{
 uint32_t event_type;
} ext_event_data_t;
/** 
  * @brief  frame header structure definition
  */

typedef __packed struct
{
 uint8_t supply_projectile_id;
 uint8_t supply_robot_id;
 uint8_t supply_projectile_step;
uint8_t supply_projectile_num;
} ext_supply_projectile_action_t;

/** 
  * @brief  frame header structure definition
  */
typedef __packed struct
{
uint8_t robot_id;
uint8_t robot_level;
uint16_t remain_HP;
uint16_t max_HP;
uint16_t shooter_id1_17mm_cooling_rate;
uint16_t shooter_id1_17mm_cooling_limit;
uint16_t shooter_id1_17mm_speed_limit;
uint16_t shooter_id2_17mm_cooling_rate;
uint16_t shooter_id2_17mm_cooling_limit;
uint16_t shooter_id2_17mm_speed_limit;
uint16_t shooter_id1_42mm_cooling_rate;
uint16_t shooter_id1_42mm_cooling_limit;
uint16_t shooter_id1_42mm_speed_limit;
uint16_t chassis_power_limit;
uint8_t mains_power_gimbal_output : 1;
uint8_t mains_power_chassis_output : 1;
uint8_t mains_power_shooter_output : 1;
} ext_game_robot_status_t;
/**
  * @brief  frame header structure definition
  */
typedef __packed struct
{
uint16_t chassis_volt;
uint16_t chassis_current;
float chassis_power;
uint16_t chassis_power_buffer;
uint16_t shooter_id1_17mm_cooling_heat;
uint16_t shooter_id2_17mm_cooling_heat;
uint16_t shooter_id1_42mm_cooling_heat;
} ext_power_heat_data_t;
/** 
  * @brief  frame header structure definition
  */
typedef __packed struct{
 float x;
 float y;
 float z;
 float yaw;
} ext_game_robot_pos_t;
/** 
  * @brief  frame header structure definition
  */
typedef __packed struct
{
 uint8_t power_rune_buff;
}ext_buff_musk_t;
/** 
  * @brief  frame header structure definition
  */
typedef __packed struct
{
 uint8_t energy_point;
 uint8_t attack_time;
} aerial_robot_energy_t;
/** 
  * @brief  frame header structure definition
  */
typedef __packed struct
{
 uint8_t armor_id : 4;
 uint8_t hurt_type : 4;
} ext_robot_hurt_t;
/** 
  * @brief  frame header structure definition
  */
typedef __packed struct
{
 uint8_t bullet_type;
 uint8_t bullet_freq;
 float bullet_speed;
} ext_shoot_data_t;
/** 
  * @brief  frame header structure definition
  */
typedef __packed struct
{
	uint16_t data_cmd_id;
	uint16_t sender_ID;
	uint16_t receiver_ID;
}ext_student_interactive_header_data_t;
/** 
  * @brief  frame header structure definition
  */
typedef __packed struct
{
	uint8_t graphic_name[3];
	uint32_t operate_tpye:3;
	uint32_t graphic_tpye:3;
	uint32_t layer:4;
	uint32_t color:4;
	uint32_t start_angle:9;
	uint32_t end_angle:9;
	uint32_t width:10;
	uint32_t start_x:11;
	uint32_t start_y:11;
	uint32_t radius:10;
	uint32_t end_x:11;
	uint32_t end_y:11;
}graphic_data_struct_t;



typedef __packed struct
{
	Frame_Header_t txFrame_Header;
	uint16_t CMD_ID;
	ext_student_interactive_header_data_t Client_Custom_ID;
	graphic_data_struct_t Graphic_Data[7];
	uint16_t CRC16;
}ext_draw_crosshair_t;//UI_图形

typedef __packed struct
{
	Frame_Header_t txFrame_Header;
	uint16_t CMD_ID;
	ext_student_interactive_header_data_t Client_Custom_ID;
	graphic_data_struct_t grapic_data_struct;
	uint8_t data[30];
	uint16_t CRC16;
}ex_draw_char;//UI_字符


typedef union
{
	uint8_t save[3];/* data */
	ext_game_state_t date;
}Jundge_Game_State;
typedef union
{
	uint8_t save[16];/* data */
	ext_power_heat_data_t date;
}Jundge_Power_Heat_Data_t;

typedef union
{
	uint8_t save[29];/* data */
	ext_game_robot_status_t	date;
}Jundge_Gawme_Robot_Status_t;

typedef union
{
	uint8_t save[6];/* data */
	ext_shoot_data_t date;
}jundge_shoot_data_t;

/*cmd_id*/
#define	game_State  	0x0001						/*比赛状态数据*/
#define	game_result  	0x002						/*比赛结果数据*/
#define	event_data  	0x101						/*场地事件数据*/
	
#define	supply_projectile_action 	0x0102			/*补给动作标识*/
#define	game_robot_status 			0x0201			/*机器人状态*/
#define	power_heat_data 			0x0202			/*实际功率热量数据*/
	
#define	game_robot_pos 		0x0203					/*机器人位置*/
#define	buff_musk 			0x0204					/*机器人增益*/
	
#define	aerial_robot_energy  0x0205				/*空中机器人能量状态*/
#define	robot_hurt 			 0x0206				/*伤害状态数据*/
#define	shoot_data  		 0x0207				/*实时射击数据*/	

#define game_UI_data 0x0301

extern ex_draw_char Draw_Char;
extern ext_draw_crosshair_t Draw_CH;

extern ext_game_robot_status_t Judge_extGameRobotStatus;
extern QUEUE8_t Queue_Date;
extern uint8_t My_Queue[256];

//extern ext_client_custom_character_t Dram_character; /*字符串*/
extern Jundge_Power_Heat_Data_t jundge_power_heat_data_t ;
extern Jundge_Gawme_Robot_Status_t jundge_game_robot_status_t;
void Jundge_Analysis(void);
void Draw_CrossHair_1(ext_draw_crosshair_t *draw,uint16_t cmd_id,uint16_t data_id,uint16_t tx_id,uint16_t rx_id);
void Draw_Dynamicr_Char(ex_draw_char *draw,uint16_t cmd_id,uint16_t data_id,uint16_t tx_id,uint16_t rx_id);
void Draw_Static_Char(ex_draw_char *draw,uint16_t cmd_id,uint16_t data_id,uint16_t tx_id,uint16_t rx_id);
#endif



