#include "soft_version.h"
#include "soft_obstacle.h"
#include "soft_terrain.h"
#include "string.h"
#include "main_task.h"
#include "usart_data_handle.h"
#include "soft_flow.h"
#include "soft_device.h"
#include "soft_can.h"
#include "soft_seed_weight.h"
#include "soft_water.h"
#include "config.h"


dev_version_content dev_pmu;
dev_version_content dev_ter;
dev_version_content dev_obsf;
dev_version_content dev_obsb;
dev_version_content dev_bms1;
dev_version_content dev_bms2;
dev_version_content dev_spreader;
dev_version_content dev_weight;
dev_version_content dev_flowmeter;
dev_version_content dev_pump;
dev_version_content dev_arm;
dev_version_content dev_lack;
dev_version_content dev_centri;
dev_version_content dev_current;
dev_version_content dev_pump1,dev_pump2;
dev_version_content dev_nozzle1,dev_nozzle2,dev_nozzle3,dev_nozzle4;

dev_version_content dev_null;

// void *dev_ptr[10] = {&temp,
                    
//                     &dev_pmu,
//                    &dev_ter,
//                    &dev_obsf,
//                    &dev_obsb,
//                    &dev_bms1,
//                    &dev_bms2,
//                    &dev_spreader,
//                    &dev_weight,
//                    &dev_flowmeter,
//                    &dev_arm,
//                   };
void *dev_ptr[] = {&dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_pmu,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_ter,
                   &dev_obsf,
                   &dev_obsb,
                   &dev_bms1,
                   &dev_bms2,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_null,
                   &dev_spreader,
                   &dev_weight,
                   &dev_pump,
                   &dev_centri,
                   &dev_flowmeter,
                   &dev_arm,
                   &dev_lack,
                   &dev_null,
                   &dev_current,
                   &dev_null,
                   &dev_pump1,
                   &dev_pump2,
                   &dev_null,
                   &dev_null,
                   &dev_nozzle1,
                   &dev_nozzle2,
                   &dev_nozzle3,
                   &dev_nozzle4,
                  };
short dev_num = sizeof( dev_ptr )/sizeof( void * );
/**
  * @file    can_recv_mocib_version_info
  * @brief   获取莫之比SN和版本号
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
void can_recv_mocib_version_info(uint32_t cellCanID, uint8_t data[], uint8_t len)
{
    static uint8_t frame_fi = 0,frame_bi = 0,frame_ti = 0;
    switch (cellCanID)
    {
    //SN号
    case CAN_OBSTARCLE11_SN:

        if(frame_fi == 0)
        {
            memcpy(&uavr11_info.sn[0],&data[2],6);//要后六个字节
            frame_fi += 6;
        }
        else if(frame_fi == 6)
        {
            memcpy(&uavr11_info.sn[frame_fi],&data[1],7);//要后7个字节
            frame_fi += 7;
        }
        else if(frame_fi >= 13)
        {
            memcpy(&uavr11_info.sn[frame_fi],&data[1],3);
            frame_fi = 0;
            
            regist_dev_info(&dev_obsf,DEVICE_OBSF,false,uavr11_info.sn,20,NULL,0,NULL,0,"mocib",6);
            uavr11_info.get_radar_sn_flag = true;
        }
        
        break;
    case CAN_OBSTARCLE12_SN:
        if(frame_bi == 0)
        {
            memcpy(&uavr12_info.sn[0],&data[2],6);//要后六个字节
            frame_bi += 6;
        }
        else if(frame_bi == 6)
        {
            memcpy(&uavr12_info.sn[frame_bi],&data[1],7);//要后7个字节
            frame_bi += 7;
        }
        else if(frame_bi >= 13)
        {
            memcpy(&uavr12_info.sn[frame_bi],&data[1],3);
            frame_bi = 0;

            regist_dev_info(&dev_obsb,DEVICE_OBSB,false,uavr12_info.sn,20,NULL,0,NULL,0,"mocib",6);
            uavr12_info.get_radar_sn_flag = true;
        }
        break;
    case CAN_OBSTARCLE56_SN:
        if(frame_ti == 0)
        {
            memcpy(&uavr56_info.sn[0],&data[2],6);//要后六个字节
            frame_ti += 6;
        }
        else if(frame_ti == 6)
        {
            memcpy(&uavr56_info.sn[frame_ti],&data[1],7);//要后7个字节
            frame_ti += 7;
        }
        else if(frame_ti >= 13)
        {
            memcpy(&uavr56_info.sn[frame_ti],&data[1],3);
            frame_ti = 0;

            regist_dev_info(&dev_ter,DEVICE_TERRA,false,uavr56_info.sn,20,NULL,0,NULL,0,"mocib",6);
            uavr56_info.get_radar_sn_flag = true;
        }
        break;
    case CAN_OBSTARCLE57_SN:
        if(frame_ti == 0)
        {
            memcpy(&Mocib_radar_part.sn[0],&data[2],6);//要后六个字节
            frame_ti += 6;
        }
        else if(frame_ti == 6)
        {
            memcpy(&Mocib_radar_part.sn[frame_ti],&data[1],7);//要后7个字节
            frame_ti += 7;
        }
        else if(frame_ti >= 13)
        {
            memcpy(&Mocib_radar_part.sn[frame_ti],&data[1],3);
            frame_ti = 0;

            regist_dev_info(&dev_ter,DEVICE_TERRA,false,Mocib_radar_part.sn,20,NULL,0,NULL,0,"mocib",6);
            Mocib_radar_part.get_radar_sn_flag = true;
        }
        break;
    //版本信息
    case 0x00eeff11:
        uavr11_info.version[0] = 'M';
        uavr11_info.version[1] = '1';
        uavr11_info.version[2] = (data[1] + data[2]) + '0';
        uavr11_info.version[3] = (data[3] + data[4]) + '0';
        char_to_hex_string(&data[5], 3, &uavr11_info.version[4], 6, "00");
        uavr11_info.soft_verison = ((data[5] & 0xff) << 16) + ((data[6] & 0xff) << 8) + (data[7] & 0xff);
        uavr11_info.get_radar_ver_flag = true;

        regist_dev_info(&dev_obsf,DEVICE_OBSF,false,NULL,0,uavr11_info.version,10,NULL,0,"mocib",6);
        break;
    case 0x00eeff12:
        uavr12_info.version[0] = 'M';
        uavr12_info.version[1] = '2';
        uavr12_info.version[2] = (data[1] + data[2]) + '0';
        uavr12_info.version[3] = (data[3] + data[4]) + '0';
        char_to_hex_string(&data[5], 3, &uavr12_info.version[4], 6, "00");
        uavr12_info.soft_verison = ((data[5] & 0xff) << 16) + ((data[6] & 0xff) << 8) + (data[7] & 0xff);
        uavr12_info.get_radar_ver_flag = true;

        regist_dev_info(&dev_obsb,DEVICE_OBSB,false,NULL,0,uavr12_info.version,10,NULL,0,"mocib",6);
        break;
    case 0x00eeff0b:
        uavr56_info.version[0] = 'M';
        uavr56_info.version[1] = 'B';
        uavr56_info.version[2] = (data[1] + data[2]) + '0';
        uavr56_info.version[3] = (data[3] + data[4]) + '0';
        char_to_hex_string(&data[5], 3, &uavr56_info.version[4], 6, "00");
        uavr56_info.soft_verison = ((data[5] & 0xff) << 16) + ((data[6] & 0xff) << 8) + (data[7] & 0xff);
        uavr56_info.get_radar_ver_flag = true;

        regist_dev_info(&dev_ter,DEVICE_TERRA,false,NULL,0,uavr56_info.version,10,NULL,0,"mocib",6);
        break;
    case  0x00EEFF0C:
        Mocib_radar_part.version[0] = 'M';
        Mocib_radar_part.version[1] = '5';
        Mocib_radar_part.version[2] = (data[1] + data[2]) + '0';
        Mocib_radar_part.version[3] = (data[3] + data[4]) + '0';
        char_to_hex_string(&data[5], 3, &Mocib_radar_part.version[4], 6, "00");
        Mocib_radar_part.soft_verison = ((data[5] & 0xff) << 16) + ((data[6] & 0xff) << 8) + (data[7] & 0xff);
        Mocib_radar_part.get_radar_ver_flag = true;

        regist_dev_info(&dev_ter,DEVICE_TERRA,false,NULL,0,Mocib_radar_part.version,10,NULL,0,"mocib",6);
        break;
    default:
        break;
    }
}


/**
  * @file    can_recv_mimo_dev_version
  * @brief   获取恩曌流量计雷达版本信息
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
void can_recv_mimo_dev_version(uint32_t cellCanID, uint8_t data[], uint8_t len)
{
    static uint8_t mimo_version[28] = {0};
    static uint8_t frame_num = 0;
    static bool frame_head = false;
    uint8_t i = 0;
    uint32_t checksum = 0;
    uint32_t soft_ver = 0;
    switch (cellCanID)
    {
    case 0XFB:
        if(data[0] == 0XAA && data[1] == 0X55)
        {
            if(data[2] == 0X03 && data[3] == 0X61 && data[4] == 0X03 && data[5] == 0X01 && data[6] == 0X65)
            {
                pmu_set_ack(_MSGID_SET,MSGID_SET_RADAR_FB,0x11,0);
            }
            else if(data[2] == 0X03 && data[3] == 0X61 && data[4] == 0X03 && data[5] == 0X02 && data[6] == 0X66)
            {
                pmu_set_ack(_MSGID_SET,MSGID_SET_RADAR_FB,0x12,0);
            }
            else if(data[2] == 0X03 && data[3] == 0X61 && data[4] == 0X00 && data[5] == 0X03 && data[6] == 0X64)
            {
                pmu_set_ack(_MSGID_SET,MSGID_SET_RADAR_FB,0x100,0);
            }
            else
            {
                frame_num = 0;
                memcpy(&mimo_version[frame_num],&data[4],4);
                frame_num += 4;
                frame_head = true;
            }
            
        }
        //读取分区
        else if(data[0] == 0xBB && data[1] == 0x24 && data[2] == 0x03  )
        {
            if(data[3] == 0x02 && data[4] == 0x07 )
            {
                if((data[5] + (data[6] << 8)) != 12)
                {
                    mimo360_status.set_TotalSect_flag = true;
                }
                mimo360_status.get_TotalSect_flag = false;
            }
            if(data[3] == 0x82 && data[4] == 0x07 && (data[5] + (data[6] << 8)) == 0 )
            {
                mimo360_status.set_TotalSect_flag = false;
            }
        }
        //断料记
        else if(data[0] == 0xFB && data[1] == 0x03 && data[2] == 0)
        {   
            //设置距离最大值反馈
            if(data[3] == 0xB2 && data[4] == 0xE1)
            {
                pmu_set_ack(_MSGID_SET,MSGID_SET_LACKLOSS_CAL,mimo_lackloss.cal_distance,mimo_lackloss.strength);
            }
        }
        //流量计
        else if(data[0] == 0xFB && data[1] == 0x10) //雷达版本和流量计协议有冲突
        {
            switch (data[2])
            {
            case 0:
                if(data[4] == 0XD1) //流速K
                {
                    flow_mimo1.flow_k = data[5] * 256 + data[6];
                    flow_mimo1.get_k = true; 
                }
                else if(data[4] == 0XC1)//设置流速K ack
                {
                    if(data[6] == 0)
                    {
                        flow_mimo1.flow_k = flow_mimo1.flow_calk;
                        if(Dev.Flow_Link1.connect_status == COMP_NORMAL && Dev.Flow_Link2.connect_status != COMP_NORMAL)
                        {
                            pmu_set_ack(_MSGID_SET,MSGID_SET_MIMO_FLOW,flow_mimo1.flow_k,0);
                            flow_mimo1.set_k = false;
                        }
                    }
                }
                else if(data[4] == 0xE2)
                {
                    if(data[6] == 0 && Dev.Flow_Link1.connect_status == COMP_NORMAL && Dev.Flow_Link2.connect_status != COMP_NORMAL)
                    {
                        pmu_set_ack(_MSGID_SET,MSGID_SET_FLOW_BACKGROUND,0,0);
                    }
                    flow_inf.ch1.clear_background = false;
                }
                else if (data[4] == 0XEB)//sn 两包 协议冲突 协议有问题
                {
                    for( i= 0;i<2;i++)  //内容第一自字节0X0F？先舍弃一字节，
                    {
                        flow_mimo1.sn[2*i] = ((data[6 + i] >> 4) & 0xf) + '0';
                        flow_mimo1.sn[2*i+1] = (data[6 + i] & 0xf )+ '0';
                    }
                    frame_num = 21;//流量序列号的标记
                }
                else if(data[4] == 0XEC)//软件号
                {
                    flow_mimo1.soft_version[0] = data[5] + '0';
                    flow_mimo1.soft_version[1] = data[6] + '0';

                }
                break;
            case 1:
                if(data[4] == 0XD1)
                {
                    flow_mimo2.flow_k = data[5] * 256 + data[6];
                    flow_mimo2.get_k = true;
                }
                else if(data[4] == 0XC1)
                {
                    if(data[6] == 0)
                    {
                        flow_mimo2.flow_k = flow_mimo2.flow_calk;
                        if(Dev.Flow_Link1.connect_status == COMP_NORMAL && Dev.Flow_Link2.connect_status == COMP_NORMAL)
                        {
                            pmu_set_ack(_MSGID_SET,MSGID_SET_MIMO_FLOW,flow_mimo1.flow_k,flow_mimo2.flow_k);
                            flow_mimo1.set_k = false;
                            flow_mimo2.set_k = false;
                        }
                        else if(Dev.Flow_Link1.connect_status != COMP_NORMAL && Dev.Flow_Link2.connect_status == COMP_NORMAL)
                        {
                            pmu_set_ack(_MSGID_SET,MSGID_SET_MIMO_FLOW,0,flow_mimo2.flow_k);
                            flow_mimo2.set_k = false;
                        }
                    }
                }
                else if(data[4] == 0xE2)
                {
                    if(data[6] == 0 && Dev.Flow_Link1.connect_status == COMP_NORMAL && Dev.Flow_Link2.connect_status == COMP_NORMAL)
                    {
                        pmu_set_ack(_MSGID_SET,MSGID_SET_FLOW_BACKGROUND,0,0);
                    }
                    flow_inf.ch1.clear_background = false;
                }
                break;
            default:
                break;
            }
        }
        else
        {   
            if(frame_num == 21)
            {
                for( i=0;i<5;i++)
                {
                    flow_mimo1.sn[4+2*i] = ((data[i] >> 4) & 0xf) + '0';
                    flow_mimo1.sn[4+2*i+1] = (data[i] & 0xf )+ '0';
                }
                //flow_mimo1.sn[1] = 'F';
                frame_num = 0;
            }
            if(frame_num <= 20)
            {
                if(frame_head == true)
                {
                    memcpy(&mimo_version[frame_num],&data[0],8);
                    frame_num += 8;
                }
                if(frame_num == 0x1c) //恩曌SN取中间日期12位，其他有问题
                {
                    checksum = 0x01;
                    for(uint8_t i = 0; i < 27; i++)
                    {
                        checksum += mimo_version[i];
                    }
                    if((checksum & 0xFF) == mimo_version[27])
                    {
                        memcpy(&soft_ver,&mimo_version[23],4);

                        switch (mimo_version[18])
                        {
                        case 0x00:
                            mimo_ter_info.version[0] = 'E';
                            mimo_ter_info.version[1] = 'B';
                            mimo_ter_info.version[2] = '0';
                            mimo_ter_info.version[3] = '0';
                            Int2String(soft_ver,&mimo_ter_info.version[4],6);
                            memcpy(&mimo_ter_info.hard_version,&mimo_version[19],4);
                            if(mimo_ter_info.hard_version == 210221)
                            {
                                mimo_ter_info.version[3] = 'J';
                            }
                            for( i= 0;i<9;i++)
                            {
                                mimo_ter_info.sn[2*i] = ((mimo_version[7 + i] >> 4) & 0xf) + '0';
                                mimo_ter_info.sn[2*i+1] = (mimo_version[7 + i] & 0xf )+ '0';
                            }
                            //memcpy(&mimo_ter_info.sn[0],&mimo_version[4],12);

                            regist_dev_info(&dev_ter,DEVICE_TERRA,false,mimo_ter_info.sn,18,mimo_ter_info.version,10,mimo_ter_info.version,10,"mimo",5);

                            mimo_ter_info.get_radar_ver_flag = true;
                            mimo_ter_info.Link.boot_flag = false;
                            break;
                        case 0x03:
                            mimo_f_info.version[0] = 'E';
                            mimo_f_info.version[1] = '1';
                            mimo_f_info.version[2] = '0';
                            mimo_f_info.version[3] = '0';
                            Int2String(soft_ver,&mimo_f_info.version[4],6);
                            memcpy(&mimo_f_info.hard_version,&mimo_version[19],4);
                            if(mimo_f_info.hard_version == 190302) //恩曌协议定义
                            {
                                mimo_f_info.version[2] = '1'; //极翼
                                mimo_f_info.version[3] = 'J';
                            }
                            else
                            {
                                mimo_f_info.version[2] = '0'; //vk
                                mimo_f_info.version[3] = 'V';
                            }
                            for( i= 0;i<9;i++)
                            {
                                mimo_f_info.sn[2*i] = ((mimo_version[7 + i] >> 4) & 0xf) + '0';
                                mimo_f_info.sn[2*i+1] = (mimo_version[7 + i] & 0xf )+ '0';
                            }

                            regist_dev_info(&dev_obsf,DEVICE_OBSF,false,mimo_f_info.sn,18,mimo_f_info.version,10,mimo_f_info.version,10,"mimo",5);
                            mimo_f_info.get_radar_ver_flag = true;
                            mimo_f_info.Link.boot_flag = false;
                            break;
                        case 0x04:
                            mimo_b_info.version[0] = 'E';
                            mimo_b_info.version[1] = '2';
                            mimo_b_info.version[2] = '0';
                            mimo_b_info.version[3] = '0';
                            Int2String(soft_ver,&mimo_b_info.version[4],6);
                            memcpy(&mimo_b_info.hard_version,&mimo_version[19],4);
                            if(mimo_b_info.hard_version == 190302) //恩曌协议定义
                            {
                                mimo_b_info.version[2] = '1'; //极翼
                                mimo_b_info.version[3] = 'J';
                            }
                            else
                            {
                                mimo_b_info.version[2] = '0'; //vk
                                mimo_b_info.version[3] = 'V';
                            }
                            for( i= 0;i<9;i++)
                            {
                                mimo_b_info.sn[2*i] = ((mimo_version[7 + i] >> 4) & 0xf) + '0';
                                mimo_b_info.sn[2*i+1] = (mimo_version[7 + i] & 0xf )+ '0';
                            }
                            regist_dev_info(&dev_obsb,DEVICE_OBSB,false,mimo_b_info.sn,18,mimo_b_info.version,10,mimo_b_info.version,10,"mimo",5);
                            mimo_b_info.get_radar_ver_flag = true;
                            mimo_b_info.Link.boot_flag = false;
                            break;
                        default:
                            break;
                        }
                        frame_num = 0;
                        frame_head = false;
                        pmu_send = PMU_SEND_VERSION;
                    } 
                }
            }
            else
            {   
            }

        }

        // char_to_hex_string(&data[5], 3, &mimo_ter_info.version[4], 6, "00");
        // mimo_ter_info.soft_verison = ((data[5] & 0xff) << 16) + ((data[6] & 0xff) << 8) + (data[7] & 0xff);        
        break;
    
    default:
        break;
    }
}


/**
  * @file    get_radar_version_and_sn
  * @brief   获取雷达版本和SN号
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
void get_radar_version_and_sn(void)
{
    uint8_t radar_can_buf[8] = {0};

    //版本信息识别 mocib    mimo
    //新加同时获取SN号
    if(uavr11_info.Link.connect_status == COMP_NORMAL && uavr11_info.get_radar_ver_flag == false)
    {
        radar_can_buf[0] = 0x11; 
        Can_Send_Msg_Func(CANID1, radar_can_buf, 1, 0x00eeff11, CAN_ID_EXT);
    }
    else if(uavr11_info.Link.connect_status == COMP_NORMAL && uavr11_info.get_radar_sn_flag == false)
    {
        radar_can_buf[0] = 0x85;    
        Can_Send_Msg_Func(CANID1, radar_can_buf, 1, 0x210, CAN_ID_EXT);
    }
    if(uavr12_info.Link.connect_status == COMP_NORMAL && uavr12_info.get_radar_ver_flag == false)
    { 
        radar_can_buf[0] = 0x12;
        Can_Send_Msg_Func(CANID1, radar_can_buf, 1, 0x00eeff12, CAN_ID_EXT);        
    }
    else if(uavr12_info.Link.connect_status == COMP_NORMAL && uavr12_info.get_radar_sn_flag == false)
    {
        radar_can_buf[0] = 0x85;    
        Can_Send_Msg_Func(CANID1, radar_can_buf, 1, 0x220, CAN_ID_EXT); 
    }
    if(uavr56_info.Link.connect_status == COMP_NORMAL && uavr56_info.get_radar_ver_flag == false)
    {
        radar_can_buf[0] = 0x0b;
        Can_Send_Msg_Func(CANID1, radar_can_buf, 1, 0x00eeff0b, CAN_ID_EXT); 
    }
    else if(uavr56_info.Link.connect_status == COMP_NORMAL && uavr56_info.get_radar_sn_flag == false)
    {
        radar_can_buf[0] = 0x85;    
        Can_Send_Msg_Func(CANID1, radar_can_buf, 1, 0x230, CAN_ID_EXT); 
    }
    if((Dev.Part_Tradar_Link.connect_status == COMP_NORMAL && Dev.Part_radarT.facid == FAC_MOCIB_RT) && Mocib_radar_part.get_radar_sn_flag == false)
    {
        radar_can_buf[0] = 0x85;    
        Can_Send_Msg_Func(CANID1, radar_can_buf, 1, 0x240, CAN_ID_EXT); 
    }
    else if((Dev.Part_Tradar_Link.connect_status == COMP_NORMAL && Dev.Part_radarT.facid == FAC_MOCIB_RT) && Mocib_radar_part.get_radar_ver_flag == false)
    {
        radar_can_buf[0] = 0x0C;
        Can_Send_Msg_Func(CANID1, radar_can_buf, 1, 0x00eeff0C, CAN_ID_EXT); 
    }
    if((mimo_ter_info.Link.connect_status == COMP_NORMAL || (Dev.Part_Tradar_Link.connect_status == COMP_NORMAL && Dev.Part_radarT.facid == FAC_MIMO_RB)) &&
         mimo_ter_info.get_radar_ver_flag == false)
    {
        radar_can_buf[0] = 0x55;
        radar_can_buf[1] = 0xAA;
        radar_can_buf[2] = 0x03;
        radar_can_buf[3] = 0x70;
        radar_can_buf[4] = 0x00;
        radar_can_buf[5] = 0x01;
        radar_can_buf[6] = 0x71;
        Can_Send_Msg_Func(CANID1, radar_can_buf, 7, 0xFA, CAN_ID_STD);
    }
    else if((mimo_f_info.Link.connect_status == COMP_NORMAL || Dev.Part_Fradar_Link.connect_status == COMP_NORMAL) && 
        mimo_f_info.get_radar_ver_flag == false)
    {
        radar_can_buf[0] = 0x55;
        radar_can_buf[1] = 0xAA;
        radar_can_buf[2] = 0x03;
        radar_can_buf[3] = 0x70;
        radar_can_buf[4] = 0x03;
        radar_can_buf[5] = 0x01;
        radar_can_buf[6] = 0x74;
        Can_Send_Msg_Func(CANID1, radar_can_buf, 7, 0xFA, CAN_ID_STD);

    }
    else if((mimo_b_info.Link.connect_status == COMP_NORMAL || Dev.Part_Bradar_Link.connect_status == COMP_NORMAL ) && 
        mimo_b_info.get_radar_ver_flag == false)
    {
        radar_can_buf[0] = 0x55;
        radar_can_buf[1] = 0xAA;
        radar_can_buf[2] = 0x03;
        radar_can_buf[3] = 0x70;
        radar_can_buf[4] = 0x04;
        radar_can_buf[5] = 0x01;
        radar_can_buf[6] = 0x75;
        Can_Send_Msg_Func(CANID1, radar_can_buf, 7, 0xFA, CAN_ID_STD);
    }
    if(DM_ter_info.Link.connect_status == COMP_NORMAL && DM_ter_info.get_radar_ver_flag == false)
    {
        radar_can_buf[0] = 1;
        radar_can_buf[7] = 7;
        Can_Send_Msg_Func(CANID1, radar_can_buf, 8, 0x981300, CAN_ID_EXT);
    }
    else if((DM_f_info.Link.connect_status == COMP_NORMAL || Dev.DM_Part_Fradar_Link.connect_status ==  COMP_NORMAL) && DM_f_info.get_radar_ver_flag == false)
    {
        radar_can_buf[0] = 1;
        radar_can_buf[7] = 7;
        Can_Send_Msg_Func(CANID1, radar_can_buf, 8, 0xA81300, CAN_ID_EXT);
        //can_send_msg_normal(radar_can_buf, 8, 0XA81300);
    }
    else if( Dev.DM_Part_Bradar_Link.connect_status == COMP_NORMAL &&  DM_4DB_info.get_radar_ver_flag == false)
    {
        radar_can_buf[0] = 1;
        radar_can_buf[7] = 7;
        Can_Send_Msg_Func(CANID1, radar_can_buf, 8, 0XB81300, CAN_ID_EXT);
        //can_send_msg_normal(radar_can_buf, 8, 0XB81300);
    }
}


/**
  * @file    get_flowmeter_version_and_sn
  * @brief   获取流量计版本、SN号、K值
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
void get_flowmeter_version_and_sn(void)
{

    if((Dev.Flow_Link1.connect_status == COMP_NORMAL || Dev.Flow_Link2.connect_status == COMP_NORMAL) && 
    (Dev.Flow.facid == FAC_MIMO_SIG || Dev.Flow.facid == FAC_MIMO_DOU))
    {
        uint8_t can_buf[8] = {0};

        //读取K值 和序列号
        if(flow_mimo1.get_k == false && Dev.Flow_Link1.connect_status == COMP_NORMAL )
        {   
            //K值
            can_buf[0] = 0xfa;
            can_buf[1] = 0x10;
            can_buf[2] = 0x00;
            can_buf[3] = 0xB1;
            can_buf[4] = 0xD1;
            can_buf[5] = 0x00;
            can_buf[6] = 0x00;

            for(uint8_t i = 1; i < 7; i++)
            {
                can_buf[7] += can_buf[i];
            }
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0xFA, CAN_ID_STD);
            can_buf[7] = 0;
            
            HAL_Delay(50);
            //序列号
            can_buf[0] = 0xfa;
            can_buf[1] = 0x10;
            can_buf[2] = 0x00;
            can_buf[3] = 0xB2;
            can_buf[4] = 0xEB;
            can_buf[5] = 0x00;
            can_buf[6] = 0x00;

            for(uint8_t i = 1; i < 7; i++)
            {
                can_buf[7] += can_buf[i];
            }
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0xFA, CAN_ID_STD); 
            can_buf[7] = 0;

            HAL_Delay(50);
            //软件版本
            can_buf[0] = 0xfa;
            can_buf[1] = 0x10;
            can_buf[2] = 0x00;
            can_buf[3] = 0xB2;
            can_buf[4] = 0xEC;
            can_buf[5] = 0x00;
            can_buf[6] = 0x00;

            for(uint8_t i = 1; i < 7; i++)
            {
                can_buf[7] += can_buf[i];
            }
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0xFA, CAN_ID_STD); 
            can_buf[7] = 0;            
        }
        else if(flow_mimo2.get_k == false && Dev.Flow_Link2.connect_status == COMP_NORMAL)
        {   
            can_buf[0] = 0xfa;
            can_buf[1] = 0x10;
            can_buf[2] = 0x01;
            can_buf[3] = 0xB1;
            can_buf[4] = 0xD1;
            can_buf[5] = 0x00;
            can_buf[6] = 0x00;
            
            for(uint8_t i = 1; i < 7; i++)
            {
                can_buf[7] += can_buf[i];
            }
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0xFA, CAN_ID_STD); 
            can_buf[7] = 0;

            //序列号
            can_buf[0] = 0xfa;
            can_buf[1] = 0x10;
            can_buf[2] = 0x00;
            can_buf[3] = 0xB2;
            can_buf[4] = 0xEB;
            can_buf[5] = 0x00;
            can_buf[6] = 0x00;

            for(uint8_t i = 1; i < 7; i++)
            {
                can_buf[7] += can_buf[i];
            }
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0xFA, CAN_ID_STD); 
            can_buf[7] = 0;

            //软件版本
            can_buf[0] = 0xfa;
            can_buf[1] = 0x10;
            can_buf[2] = 0x00;
            can_buf[3] = 0xB2;
            can_buf[4] = 0xEC;
            can_buf[5] = 0x00;
            can_buf[6] = 0x00;

            for(uint8_t i = 1; i < 7; i++)
            {
                can_buf[7] += can_buf[i];
            }
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0xFA, CAN_ID_STD); 
            can_buf[7] = 0;  
        }
        
        //设置流量计K
        if(flow_mimo1.set_k == true && Dev.Flow_Link1.connect_status == COMP_NORMAL )
        {
            can_buf[0] = 0xfa;
            can_buf[1] = 0x10;
            can_buf[2] = 0x00;
            can_buf[3] = 0xB1;
            can_buf[4] = 0xC1;
            can_buf[5] = flow_mimo1.flow_calk >> 8;
            can_buf[6] = flow_mimo1.flow_calk;
            can_buf[7] = 0;
            for(uint8_t i = 1; i < 7; i++)
            {
                can_buf[7] += can_buf[i];
            }

            Can_Send_Msg_Func(CANID1, can_buf, 8, 0xFA, CAN_ID_STD); 
            HAL_Delay(50);
        }
        if(flow_mimo2.set_k == true && Dev.Flow_Link2.connect_status == COMP_NORMAL)
        {            
            can_buf[0] = 0xfa;
            can_buf[1] = 0x10;
            can_buf[2] = 0x01;
            can_buf[3] = 0xB1;
            can_buf[4] = 0xC1;
            can_buf[5] = flow_mimo2.flow_calk >> 8;
            can_buf[6] = flow_mimo2.flow_calk;
            can_buf[7] = 0;
            for(uint8_t i = 1; i < 7; i++)
            {
                can_buf[7] += can_buf[i];
            }
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0xFA, CAN_ID_STD);
        }

        if(flow_inf.ch1.clear_background == true)
        {
            can_buf[0] = 0xfa;
            can_buf[1] = 0x10;
            can_buf[2] = 0x00;
            can_buf[3] = 0xB2;
            can_buf[4] = 0xE2;
            can_buf[5] = 0;
            can_buf[6] = 0;
            can_buf[7] = 0;
            for(uint8_t i = 1; i < 7; i++)
            {
                can_buf[7] += can_buf[i];
            }
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0xFA, CAN_ID_STD);
        }
        else if(flow_inf.ch2.clear_background == true)
        {
            can_buf[0] = 0xfa;
            can_buf[1] = 0x10;
            can_buf[2] = 0x01;
            can_buf[3] = 0xB2;
            can_buf[4] = 0xE2;
            can_buf[5] = 0;
            can_buf[6] = 0;
            can_buf[7] = 0;
            for(uint8_t i = 1; i < 7; i++)
            {
                can_buf[7] += can_buf[i];
            }
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0xFA, CAN_ID_STD);
        }
        
    }
}

/**
  * @file    get_eftdev_version_and_sn
  * @brief   版本号
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
bool p1_runing_time = false,p2_runing_time = false,n1_runing_time = false,n2_runing_time = false,
      n3_runing_time = false,n4_runing_time = false,weight_runing_time = false,spreader_runing_time = false;
/**
 * @brief   get the version and SN of all EFT devices
 * @details get the version and SN of all EFT devices, and send the messages to the 
 *          corresponding devices
 * @author  Zhang Sir 
 **/
void get_eftZ70_version_and_sn(void)
{
    // uint8_t can_buf[8] = {0};

    // if(drone_type == Drone_Z70)
    // {
    //     if((dev_pump1.regist.sn == false && Dev.Eft_CanDev_Link[0].connect_status == COMP_NORMAL) ||
    //        (dev_pump2.regist.sn == false && Dev.Eft_CanDev_Link[1].connect_status == COMP_NORMAL) ||
    //        (dev_nozzle1.regist.sn == false && Dev.Eft_CanDev_Link[2].connect_status == COMP_NORMAL) ||
    //        (dev_nozzle2.regist.sn == false && Dev.Eft_CanDev_Link[3].connect_status == COMP_NORMAL) ||
    //        (dev_nozzle3.regist.sn == false && Dev.Eft_CanDev_Link[4].connect_status == COMP_NORMAL) ||
    //        (dev_nozzle4.regist.sn == false && Dev.Eft_CanDev_Link[5].connect_status == COMP_NORMAL) )
    //     {
    //         put_date_to_can(can_buf,0xF3,0,0,0,0,0xF1,0xF3,0 );
    //         Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
    //     }
    //     else if((dev_pump1.regist.soft == false && Dev.Eft_CanDev_Link[0].connect_status == COMP_NORMAL) ||
    //             (dev_pump2.regist.soft == false && Dev.Eft_CanDev_Link[1].connect_status == COMP_NORMAL) ||
    //             (dev_nozzle1.regist.soft == false && Dev.Eft_CanDev_Link[2].connect_status == COMP_NORMAL) ||
    //             (dev_nozzle2.regist.soft == false && Dev.Eft_CanDev_Link[3].connect_status == COMP_NORMAL) ||
    //             (dev_nozzle3.regist.soft == false && Dev.Eft_CanDev_Link[4].connect_status == COMP_NORMAL) ||
    //             (dev_nozzle4.regist.soft == false && Dev.Eft_CanDev_Link[5].connect_status == COMP_NORMAL) )
    //     {
    //         put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
    //         Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
    //     }
    //     else if((p1_runing_time == false && Dev.Eft_CanDev_Link[0].connect_status == COMP_NORMAL) ||
    //             (p2_runing_time == false && Dev.Eft_CanDev_Link[1].connect_status == COMP_NORMAL) ||
    //             (n1_runing_time == false && Dev.Eft_CanDev_Link[2].connect_status == COMP_NORMAL) ||
    //             (n2_runing_time == false && Dev.Eft_CanDev_Link[3].connect_status == COMP_NORMAL) ||
    //             (n3_runing_time == false && Dev.Eft_CanDev_Link[4].connect_status == COMP_NORMAL) ||
    //             (n4_runing_time == false && Dev.Eft_CanDev_Link[5].connect_status == COMP_NORMAL))
    //     {
    //         put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
    //         Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
    //     }
    //     //称重单独处理
    //     else if( dev_weight.regist.sn == false &&Dev.Weight_Link.connect_status == COMP_NORMAL)
    //     {
    //         put_date_to_can(can_buf,0xF3,0,0,0,0,0xF1,0xF3,0 );
    //         if(Z70_LiftingWeight_exist == false)
    //             Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
    //         else
    //             Can_Send_Msg_Func(CANID2, can_buf, 8, 0X88BB, CAN_ID_EXT);
    //     }
    //     else if(dev_weight.regist.soft == false && Dev.Weight_Link.connect_status == COMP_NORMAL)
    //     {
    //         put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
    //         if(Z70_LiftingWeight_exist == false)
    //             Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
    //         else
    //             Can_Send_Msg_Func(CANID2, can_buf, 8, 0X88BB, CAN_ID_EXT);
    //     }
    //     else if(weight_runing_time == false && Dev.Weight_Link.connect_status == COMP_NORMAL)
    //     {
    //         put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
    //         if(Z70_LiftingWeight_exist == false)
    //             Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
    //         else
    //             Can_Send_Msg_Func(CANID2, can_buf, 8, 0X88BB, CAN_ID_EXT);
    //     }
    // }
}
void get_eftdev_version_and_sn(void)
{
    uint8_t can_buf[8] = {0};
    //水泵1
    if(Dev.Eft_CanDev_Link[0].connect_status == COMP_NORMAL)
    {
        if(dev_pump1.regist.sn == false)
        {
            put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8811, CAN_ID_EXT);
        }
        else if(dev_pump1.regist.soft == false)
        {
            put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8811, CAN_ID_EXT);
        }
        else if(p1_runing_time == false)
        {
            put_date_to_can(can_buf,0xF6,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8811, CAN_ID_EXT);
        }
    }

    //水泵2
    if(Dev.Eft_CanDev_Link[1].connect_status == COMP_NORMAL)
    {
        if(dev_pump2.regist.sn == false)
        {
            put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8822, CAN_ID_EXT);
        }
        else if(dev_pump2.regist.soft == false)
        {
            put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8822, CAN_ID_EXT);
        }
        else if(p2_runing_time == false)
        {
            put_date_to_can(can_buf,0xF6,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8822, CAN_ID_EXT);
        }
    }

    //离心1
    if(Dev.Eft_CanDev_Link[2].connect_status == COMP_NORMAL)
    {
        if(dev_nozzle1.regist.sn == false)
        {
            put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8833, CAN_ID_EXT);
        }
        else if(dev_nozzle1.regist.soft == false)
        {
            put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8833, CAN_ID_EXT);
        }
        else if(n1_runing_time == false)
        {
            put_date_to_can(can_buf,0xF6,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8833, CAN_ID_EXT);
        }
    }
    //离心2
    if(Dev.Eft_CanDev_Link[3].connect_status == COMP_NORMAL)
    {
        if(dev_nozzle2.regist.sn == false)
        {
            put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8844, CAN_ID_EXT);
        }
        else if(dev_nozzle2.regist.soft == false)
        {
            put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8844, CAN_ID_EXT);
        }
        else if(n2_runing_time == false)
        {
            put_date_to_can(can_buf,0xF6,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8844, CAN_ID_EXT);
        }
    }
    //离心3
    if(Dev.Eft_CanDev_Link[4].connect_status == COMP_NORMAL)
    {
        if(dev_nozzle3.regist.sn == false)
        {
            put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8855, CAN_ID_EXT);
        }
        else if(dev_nozzle3.regist.soft == false)
        {
            put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8855, CAN_ID_EXT);
        }
        else if(n3_runing_time == false)
        {
            put_date_to_can(can_buf,0xF6,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8855, CAN_ID_EXT);
        }
    }
    //离心4
    if(Dev.Eft_CanDev_Link[5].connect_status == COMP_NORMAL)
    {
        if(dev_nozzle4.regist.sn == false)
        {
            put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8866, CAN_ID_EXT);
        }
        else if(dev_nozzle4.regist.soft == false)
        {
            put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8866, CAN_ID_EXT);
        }
        else if(n4_runing_time == false)
        {
            put_date_to_can(can_buf,0xF6,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8866, CAN_ID_EXT);
        }
    }

    //称重
    if(Dev.Weight_Link.connect_status == COMP_NORMAL && Dev.Weight.facid == FAC_EFT)
    {
        if(dev_weight.regist.sn == false)
        {
            put_date_to_can(can_buf,0xE3,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0x8877, CAN_ID_EXT);
        }
        else if(dev_weight.regist.soft == false)
        {
            put_date_to_can(can_buf,0xE2,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0x8877, CAN_ID_EXT);
        }
        else if(weight_runing_time == false)
        {
            put_date_to_can(can_buf,0xE4,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0x8877, CAN_ID_EXT);
        }
    }
    //播撒器
    if(Dev.Seed_Link.connect_status == COMP_NORMAL && Dev.Seed.facid == FAC_EFT)
    {
        if(dev_spreader.regist.sn == false)
        {
            put_date_to_can(can_buf,0xF8,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x88F2, CAN_ID_EXT);
        }
        else if(dev_spreader.regist.soft == false)
        {
            put_date_to_can(can_buf,0xf9,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x88F2, CAN_ID_EXT);
        }
        else if(spreader_runing_time == false)
        {
            put_date_to_can(can_buf,0xFB,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x88F2, CAN_ID_EXT);
        }
    }


}



/**
  * @file    get_spread_version_and_sn
  * @brief   获取播撒版本号
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
void get_spread_version_and_sn( void )
{
    uint8_t can_buf[8] = {0};

    if(HAL_GetTick() < 3000)  //有同样的设备同时存在情况
        return;

    switch (spread_type)
    {
    case SPREAD_NORMAL:
        if(dev_spreader.regist.sn == false)
        {
            put_date_to_can(can_buf,0xF8,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x88F2, CAN_ID_EXT);
        }
        else if(dev_spreader.regist.soft == false)
        {
            put_date_to_can(can_buf,0xf9,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x88F2, CAN_ID_EXT);
        }
        else if(spreader_runing_time == false)
        {
            put_date_to_can(can_buf,0xFB,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x88F2, CAN_ID_EXT);
        }
        break;
    case SPREAD_JIAOLONG:
        break;
    
    default:
        break;
    }
}

/**
  * @file    get_spary_version_and_sn
  * @brief   获取喷洒版本号
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
void get_spary_version_and_sn( void )
{
    uint8_t can_buf[8] = {0};

    if(HAL_GetTick() < 3000)  //有同样的设备同时存在情况
        return;

    switch (spary_type)
    {
    case SPARY_GEMO:
        break;
    case SPARY_ROUXING:
        //水泵1
        if(Dev.Eft_CanDev_Link[0].connect_status == COMP_NORMAL)
        {
            if(dev_pump1.regist.sn == false)
            {
                put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8811, CAN_ID_EXT);
            }
            else if(dev_pump1.regist.soft == false)
            {
                put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8811, CAN_ID_EXT);
            }
            else if(p1_runing_time == false)
            {
                put_date_to_can(can_buf,0xF6,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8811, CAN_ID_EXT);
            }
        }
        //水泵2
        if(Dev.Eft_CanDev_Link[1].connect_status == COMP_NORMAL)
        {
            if(dev_pump2.regist.sn == false)
            {
                put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8822, CAN_ID_EXT);
            }
            else if(dev_pump2.regist.soft == false)
            {
                put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8822, CAN_ID_EXT);
            }
            else if(p2_runing_time == false)
            {
                put_date_to_can(can_buf,0xF6,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8822, CAN_ID_EXT);
            }
        }
        break;
    case SPARY_TRANSFER:
        //水泵1
        if(Dev.Eft_CanDev_Link[0].connect_status == COMP_NORMAL)
        {
            if(dev_pump1.regist.sn == false)
            {
                put_date_to_can(can_buf,0xF3,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            else if(dev_pump1.regist.soft == false)
            {
                put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            else if(p1_runing_time == false)
            {
                put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            
        }
        //水泵2
        if(Dev.Eft_CanDev_Link[1].connect_status == COMP_NORMAL)
        {
            if(dev_pump2.regist.sn == false)
            {
                put_date_to_can(can_buf,0xF3,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            else if(dev_pump2.regist.soft == false)
            {
                put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            else if(p2_runing_time == false)
            {
                put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
        }
        break;
    
    default:
        break;
    }
}

/**
  * @file    get_nozzle_version_and_sn
  * @brief   获取离心喷头版本号
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
void get_nozzle_version_and_sn( void )
{
    uint8_t can_buf[8] = {0};

    if(HAL_GetTick() < 3000)  //有同样的设备同时存在情况
        return;

    switch (nozzle_type)
    {
    case NOZZLE_NORMAL:
        //离心1
        if(Dev.Eft_CanDev_Link[2].connect_status == COMP_NORMAL)
        {
            if(dev_nozzle1.regist.sn == false)
            {
                put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8833, CAN_ID_EXT);
            }
            else if(dev_nozzle1.regist.soft == false)
            {
                put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8833, CAN_ID_EXT);
            }
            else if(n1_runing_time == false)
            {
                put_date_to_can(can_buf,0xF6,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8833, CAN_ID_EXT);
            }
        }
        //离心2
        if(Dev.Eft_CanDev_Link[3].connect_status == COMP_NORMAL)
        {
            if(dev_nozzle2.regist.sn == false)
            {
                put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8844, CAN_ID_EXT);
            }
            else if(dev_nozzle2.regist.soft == false)
            {
                put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8844, CAN_ID_EXT);
            }
            else if(n2_runing_time == false)
            {
                put_date_to_can(can_buf,0xF6,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8844, CAN_ID_EXT);
            }
        }
        //离心3
        if(Dev.Eft_CanDev_Link[4].connect_status == COMP_NORMAL)
        {
            if(dev_nozzle3.regist.sn == false)
            {
                put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8855, CAN_ID_EXT);
            }
            else if(dev_nozzle3.regist.soft == false)
            {
                put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8855, CAN_ID_EXT);
            }
            else if(n3_runing_time == false)
            {
                put_date_to_can(can_buf,0xF6,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8855, CAN_ID_EXT);
            }
        }
        //离心4
        if(Dev.Eft_CanDev_Link[5].connect_status == COMP_NORMAL)
        {
            if(dev_nozzle4.regist.sn == false)
            {
                put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8866, CAN_ID_EXT);
            }
            else if(dev_nozzle4.regist.soft == false)
            {
                put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8866, CAN_ID_EXT);
            }
            else if(n4_runing_time == false)
            {
                put_date_to_can(can_buf,0xF6,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x8866, CAN_ID_EXT);
            }
        }
        break;
    case NOZZLE_TRANSFER:
        //离心1
        if(Dev.Eft_CanDev_Link[2].connect_status == COMP_NORMAL)
        {
            if(dev_nozzle1.regist.sn == false)
            {
                put_date_to_can(can_buf,0xF3,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            else if(dev_nozzle1.regist.soft == false)
            {
                put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            else if(n1_runing_time == false)
            {
                put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
        }
        //离心2
        if(Dev.Eft_CanDev_Link[3].connect_status == COMP_NORMAL)
        {
            if(dev_nozzle2.regist.sn == false)
            {
                put_date_to_can(can_buf,0xF3,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            else if(dev_nozzle2.regist.soft == false)
            {
                put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            else if(n2_runing_time == false)
            {
                put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
        }
        //离心3
        if(Dev.Eft_CanDev_Link[4].connect_status == COMP_NORMAL)
        {
            if(dev_nozzle3.regist.sn == false)
            {
                put_date_to_can(can_buf,0xF3,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            else if(dev_nozzle3.regist.soft == false)
            {
                put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            else if(n3_runing_time == false)
            {
                put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
        }
        //离心4
        if(Dev.Eft_CanDev_Link[5].connect_status == COMP_NORMAL)
        {
            if(dev_nozzle4.regist.sn == false)
            {
                put_date_to_can(can_buf,0xF3,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            else if(dev_nozzle4.regist.soft == false)
            {
                put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
            else if(n4_runing_time == false)
            {
                put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
                Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
            }
        }
        break;
    default:
        break;
    }
}


/**
  * @file    get_weight_version_and_sn
  * @brief   获取称重版本号
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
void get_weight_version_and_sn( void )
{
    uint8_t can_buf[8] = {0};

    if(HAL_GetTick() < 3000)  //有同样的设备同时存在情况
        return;

    switch (weight_type)
    {
    case WEIGHT_NORMAL:
        break;
    case WEIGHT_LIFT:
        if(dev_weight.regist.sn == false)
        {
            put_date_to_can(can_buf,0xF3,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0X88BB, CAN_ID_EXT);
        }
        else if(dev_weight.regist.soft == false)
        {
            put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0X88BB, CAN_ID_EXT);
        }
        else if(weight_runing_time == false)
        {
           put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0X88BB, CAN_ID_EXT);
        }
        break;
    case WEIGHT_FPLATE:
        if(dev_weight.regist.sn == false)
        {
            put_date_to_can(can_buf,0xE3,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0x8877, CAN_ID_EXT);
        }
        else if(dev_weight.regist.soft == false)
        {
            put_date_to_can(can_buf,0xE2,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0x8877, CAN_ID_EXT);
        }
        else if(weight_runing_time == false)
        {
            put_date_to_can(can_buf,0xE4,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID1, can_buf, 8, 0x8877, CAN_ID_EXT);
        }
        break;
    case WEIGHT_TRANFER:
        if(dev_weight.regist.sn == false)
        {
            put_date_to_can(can_buf,0xF3,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
        }
        else if(dev_weight.regist.soft == false)
        {
            put_date_to_can(can_buf,0xF4,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
        }
        else if(weight_runing_time == false)
        {
            put_date_to_can(can_buf,0xF5,0,0,0,0,0xF1,0xF3,0 );
            Can_Send_Msg_Func(CANID2, can_buf, 8, 0x7011, CAN_ID_EXT);
        }
        break;
    default:
        break;
    }       
}

/**
  * @file    regist_dev_info
  * @brief   注册设备信息
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
void regist_dev_info(dev_version_content *dev,uint8_t num,bool verify_flag,char *sn,uint8_t size1,
                        char *soft_serial,uint8_t size2,char *hard_serial,uint8_t size3,char *manu,uint8_t size4)
{   
    dev->num = num;
    dev->verify = verify_flag;

    if(dev->regist.dev == false)
    {
        dev->regist.dev = true;
        dev->send_times++;
    }
    
    if(sn != NULL && size1 <= 32 && dev->regist.sn == false)
    {
        memcpy(dev->sn,sn,size1);
        dev->regist.sn = true;
        dev->send_times++;

    }
    if(soft_serial != NULL && size2 <= 16 && dev->regist.soft == false)
    {
        memcpy(dev->soft_serial,soft_serial,size2);
        dev->regist.soft = true;
        dev->send_times++;
    }
    if(hard_serial != NULL && size3 <= 16 && dev->regist.hard == false)
    {
        memcpy(dev->hard_serial,hard_serial,size3);
        dev->regist.hard = true;
        dev->send_times++;
    }
    if(manu != NULL && size4 <= 16 && dev->regist.manu == false)
    {
        memcpy(dev->manu,manu,size4);
        dev->regist.manu = true;
        dev->send_times++;
    }
};

/**
  * @file    get_device_version_and_sn
  * @brief   版本号
  * @param   none
  * @details 
  * @author  Zhang Sir 
 **/
void get_device_version_and_sn(void)
{
    static uint32_t circu_time = 0;

    if(Check_Timer_Ready(&circu_time,_1_HZ_))
    {
        //获取雷达版本和SN号
        get_radar_version_and_sn();

        //获取流量计版本和SN号
        get_flowmeter_version_and_sn();

        get_spread_version_and_sn();
        get_spary_version_and_sn();
        get_nozzle_version_and_sn();
        get_weight_version_and_sn();
        // //获取EFT设备版本信息
        // if(drone_type == Drone_Z70)
        //     get_eftZ70_version_and_sn();
        // else if(drone_type == Drone_Z20)
        //     get_eftdev_version_and_sn();
    }
}