#define  GLOBALS_APP_TEST
#include "../App_Headers/includes.h"
#include "../Library/TimeCtrl.h"

#define STEP_MAX        34//????

void All_Lamp_TurnOn(void);

void APP_Test_Init(void){
    Key.StepAuto = null;
    Key.CAN_Step = null;
    Key.CAN_Step = null;

   // CurValueStr[ENUM_BatteryCurrent].val = 0;
    //CurValueStr[CoolTemp].val = 0;
    //CurValueStr[VehSpeed].val = 0;
    //CurValueStr[AD_Blue].val = 0;

   // CurValueStr[ENUM_BatteryCurrent].fval = Value_Plus;
    //CurValueStr[CoolTemp].fval = Value_Plus;
    //CurValueStr[VehSpeed].fval = Value_Plus;
    //CurValueStr[AD_Blue].fval = Value_Plus;

    //CanMessageID18F00029.Msg[1] = 0x7D;

    //LDW Open
    //CanMessageID18FE5BE8.Msg[0] |= 0x40;
    //FCW Open
   // CanMessageID0CF02FA0.Msg[0] |= 0x03;
    //AutoLwBm Open
  //  CanMessageID18FF0B21.Msg[5] |= 0x10;

    EOLMode = 1;
    EOLStep = 0;
    EOLError = 0;
}
unsigned int Self_propelled_flag = 0;//自走
unsigned int Key_Dodging_flag = 1;//按键打点
unsigned int speed_value = 0;
void APP_Button_Proc(void){
;
}




#define  TirePressure(value)  CurValueStr[ENUM_TirePressure_LF].val = value; CurValueStr[ENUM_TirePressure_RF].val = value; CurValueStr[ENUM_TirePressure_LR].val = value; CurValueStr[ENUM_TirePressure_RR].val = value;  

#define  TireTemp(value)      CurValueStr[ENUM_TireTemp_LF    ].val = value; CurValueStr[ENUM_TireTemp_RF    ].val = value; CurValueStr[ENUM_TireTemp_LR    ].val = value; CurValueStr[ENUM_TireTemp_RR    ].val = value;

unsigned int lost_flag = 0;
unsigned int CAN_init_flag = 0;
unsigned int CAN_lost_flag = 0;
unsigned int water_value = 0;

unsigned int  electricityclose = 0;         //????????????????
void APP_ICM_Proc(void)  /*zh321*/  /*FS04*/
{

    //if(Self_propelled_flag==1)
    {
        {
        // CurValueStr[Vspeed                     ].val = 0;
        // CurValueStr[hour                       ].val = 0;
        // CurValueStr[minute                     ].val = 0;
        // CurValueStr[electricity                ].val = 0;
        // CurValueStr[fault                      ].val = 0;
        // CurValueStr[Ready                      ].val = 0;
        // CurValueStr[Energy_recovery            ].val = 0;
        // CurValueStr[Energy_recovery_level      ].val = 0;
        // CurValueStr[Side_brackets              ].val = 0;
        // CurValueStr[TCS_close                  ].val = 1;
        // CurValueStr[TCS_crotrul                ].val = 1;
        // CurValueStr[TCS_mode                   ].val = 1;
        // CurValueStr[TCS_light                  ].val = 1;
        // CurValueStr[GPS                        ].val = 0;
        // CurValueStr[signal_4G                  ].val = 0;
        // CurValueStr[Battery_over               ].val = 0;
        // CurValueStr[Motor_overheating          ].val = 0;
        // CurValueStr[Cruise_control             ].val = 0;
        // CurValueStr[Gear                       ].val = 0;
        // CurValueStr[Bluetooth_phone            ].val = 0;
        // CurValueStr[Vvspeed_L                       ].val = 0;
        // CurValueStr[Power                     ].val = 0;
        // CurValueStr[Electricity_H                       ].val = 0;
        // CurValueStr[Electricity_L                       ].val = 0;
        // CurValueStr[Electricity_h                       ].val = 0;
        // CurValueStr[Electricity_l                       ].val = 0;
        // CurValueStr[Sidebrace                       ].val = 0;
        // CurValueStr[Cruise                       ].val = 0;
        // CurValueStr[ABS                       ].val = 0;
        // CurValueStr[TCS                       ].val = 0;
        // CurValueStr[Tire_pressure                       ].val = 0;
        // CurValueStr[Bluetooth                       ].val = 0;
        // CurValueStr[GPS                       ].val = 0;
        // CurValueStr[Callalert                       ].val = 0x01;
        // CurValueStr[GMS                       ].val = 0;
        // CurValueStr[Parallelsignals                       ].val = 0;
        // CurValueStr[Enginefailure                       ].val = 0;
        // CurValueStr[P_dang                       ].val = 0x03;
        
                    CurValueStr[Vvspeed_L                  ].val = 0;
                    CurValueStr[Power                      ].val = 0;
                    CurValueStr[Electricity_H              ].val = 0;
                    CurValueStr[Electricity_L              ].val = 0;
                    CurValueStr[Cruise_H                  ].val = 0;
                    CurValueStr[Cruise                    ].val = 0;
                    CurValueStr[Power_Tem                    ].val = 0;
                    CurValueStr[Gear                       ].val =0;
                    CurValueStr[ABS_off                    ].val=0;
                    CurValueStr[Ready                      ].val=0;
                    CurValueStr[Charge                     ].val=0;
                    CurValueStr[Charge_H                   ].val=0;
                    CurValueStr[ABS                         ].val=0;
                    CurValueStr[Tubro                         ].val=0;
                    CurValueStr[Malfunction                         ].val=0;
                    CurValueStr[Support                         ].val=0;
                    CurValueStr[L_Power                         ].val=0;
                    CurValueStr[Throttle_117                        ].val=0;
                    CurValueStr[Throttle_317                         ].val=0;
                    CurValueStr[RaiseHead                           ].val=0;
                    CurValueStr[LeftHand                           ].val=0;
                     CurValueStr[Parking                          ].val=0;
            #if 1      
            // if(Key.Flag_1 == 1)
            // {                 
            switch(Key.CAN_Step)
            {
                case 0:
                {
                CurValueStr[Vvspeed_L                  ].val = 0x00;
                    CurValueStr[Power                      ].val = 0x00;
                     CurValueStr[Power_H                   ].val = 0x00;
                    CurValueStr[Electricity_H              ].val = 0x00;
                    CurValueStr[Electricity_L              ].val = 0x00;
                    CurValueStr[Cruise_H                  ].val = 0x00;
                    CurValueStr[Cruise                    ].val = 0x00;
                    CurValueStr[Power_Tem                    ].val = 0x00;
                    CurValueStr[Gear                       ].val =0x00;
                    CurValueStr[ABS_off                    ].val=0x00;
                    CurValueStr[Ready                      ].val=0x00;
                    CurValueStr[Charge                     ].val=0x00;
                    CurValueStr[Charge_H                   ].val=0x00;
                    CurValueStr[ABS                         ].val=0x00;
                    CurValueStr[Tubro                         ].val=0x00;
                    CurValueStr[Malfunction                         ].val=0x00;
                    CurValueStr[Support                         ].val=0x00;
                    CurValueStr[L_Power                         ].val=0x00;
                    CurValueStr[Throttle_117                        ].val=0x00;
                    CurValueStr[Throttle_317                         ].val=0x00;
                    CurValueStr[RaiseHead                           ].val=0x00;
                    CurValueStr[LeftHand                           ].val=0x00;
                     CurValueStr[Parking                          ].val=0x00;
                }
                case 1:
                {   
                    CurValueStr[Vvspeed_L                  ].val = 0xFF;
                    CurValueStr[Power                      ].val = 0x06;
                     CurValueStr[Power_H                   ].val = 0x00;
                    CurValueStr[Electricity_H              ].val = 0x03;
                    CurValueStr[Electricity_L              ].val = 0xE8;
                    CurValueStr[Cruise_H                  ].val = 0xC7;
                    CurValueStr[Cruise                    ].val = 0x01;
                    CurValueStr[Power_Tem                    ].val = 0x0A;
                    CurValueStr[Gear                       ].val =0x00;
                    CurValueStr[ABS_off                    ].val=0x00;
                    CurValueStr[Ready                      ].val=0x00;
                    CurValueStr[Charge                     ].val=0x00;
                    CurValueStr[Charge_H                   ].val=0x00;
                    CurValueStr[ABS                         ].val=0x00;
                    CurValueStr[Tubro                         ].val=0x00;
                    CurValueStr[Malfunction                         ].val=0x00;
                    CurValueStr[Support                         ].val=0x00;
                    CurValueStr[L_Power                         ].val=0x00;
                    CurValueStr[Throttle_117                        ].val=0x00;
                    CurValueStr[Throttle_317                         ].val=0x00;
                    CurValueStr[RaiseHead                           ].val=0x00;
                    CurValueStr[LeftHand                           ].val=0x00;
                     CurValueStr[Parking                          ].val=0x00;
                }
                break;
                case 2:    
                {   
                    CurValueStr[Vvspeed_L                  ].val = 0xFF;
                    CurValueStr[Power                  ].val = 0x04;
                     CurValueStr[Power_H                   ].val = 0x00;
                    CurValueStr[Electricity_H              ].val = 0x07;
                    CurValueStr[Electricity_L              ].val = 0xD0;
                
                    CurValueStr[Cruise_H                  ].val = 0xC7;
                    CurValueStr[Cruise                    ].val = 0x01;
                    CurValueStr[Power_Tem                    ].val = 0x14;
                    CurValueStr[Gear                       ].val =0x01;
                    CurValueStr[ABS_off                    ].val=0x20;
                    CurValueStr[Ready                      ].val=0x00;
                    CurValueStr[Charge                     ].val=0x00;
                    CurValueStr[Charge_H                   ].val=0x00;
                    CurValueStr[ABS                         ].val=0x00;
                     CurValueStr[Tubro                         ].val=0x00;
                     CurValueStr[Malfunction                         ].val=0x00;
                     CurValueStr[Support                         ].val=0x00;
                     CurValueStr[L_Power                         ].val=0x00;
                        CurValueStr[Throttle_117                        ].val=0x00;
                    CurValueStr[Throttle_317                         ].val=0x00;
                     CurValueStr[RaiseHead                           ].val=0x00;
                     CurValueStr[LeftHand                           ].val=0x00;
                     CurValueStr[Parking                          ].val=0x00;
                }
                break;
                case 3:
                {   
                    CurValueStr[Vvspeed_L                  ].val = 0xFF;
                    CurValueStr[Power                      ].val = 0x02;
                     CurValueStr[Power_H                   ].val = 0x00;
                    CurValueStr[Electricity_H              ].val = 0x0B;
                    CurValueStr[Electricity_L              ].val = 0xB8;
                    CurValueStr[Cruise_H                  ].val = 0xC7;
                    CurValueStr[Cruise                    ].val = 0x01;
                    CurValueStr[Power_Tem                    ].val = 0x21;
                    CurValueStr[Gear                       ].val =0x03;
                    CurValueStr[ABS_off                    ].val=0x00;
                    CurValueStr[Ready                      ].val=0x01;
                    CurValueStr[Charge                     ].val=0x00;
                    CurValueStr[Charge_H                   ].val=0x00;
                    CurValueStr[ABS                         ].val=0x00;
                     CurValueStr[Tubro                         ].val=0x00;
                     CurValueStr[Malfunction                         ].val=0x00;
                     CurValueStr[Support                         ].val=0x00;
                     CurValueStr[L_Power                         ].val=0x00;
                        CurValueStr[Throttle_117                        ].val=0x00;
                    CurValueStr[Throttle_317                         ].val=0x00;
                     CurValueStr[RaiseHead                           ].val=0x00;
                     CurValueStr[LeftHand                           ].val=0x00;
                     CurValueStr[Parking                          ].val=0x00;
                }break;

                case 4:
                {   
                    CurValueStr[Vvspeed_L                  ].val = 0xFF;
                    CurValueStr[Power                  ].val = 0x00;
                     CurValueStr[Power_H                   ].val = 0x00;
                    CurValueStr[Electricity_H              ].val = 0x0F;
                    CurValueStr[Electricity_L              ].val = 0xA0;
           
                    CurValueStr[Cruise_H                  ].val = 0xC7;
                    CurValueStr[Cruise                    ].val = 0x01;
                    CurValueStr[Power_Tem                    ].val = 0x22;
                    CurValueStr[Gear                       ].val =0x09;
                    CurValueStr[ABS_off                    ].val=0x00;
                    CurValueStr[Ready                      ].val=0x00;
                    CurValueStr[Charge                     ].val=0xCD;
                    CurValueStr[Charge_H                   ].val=0x0C;
                    CurValueStr[ABS                         ].val=0x20;
                     CurValueStr[Tubro                         ].val=0x00;
                     CurValueStr[Malfunction                         ].val=0x00;
                     CurValueStr[Support                         ].val=0x00;
                     CurValueStr[L_Power                         ].val=0x00;
                        CurValueStr[Throttle_117                        ].val=0x00;
                    CurValueStr[Throttle_317                         ].val=0x00;
                     CurValueStr[RaiseHead                           ].val=0x00;
                     CurValueStr[LeftHand                           ].val=0x00;
                     CurValueStr[Parking                          ].val=0x00;
                  
                }break;

                case 5:
                {   
                    CurValueStr[Vvspeed_L                  ].val = 0xFF;
                    CurValueStr[Power                      ].val = 0XFE;
                    CurValueStr[Power_H                    ].val = 0XFF;
                    CurValueStr[Electricity_H              ].val = 0X13;
                    CurValueStr[Electricity_L              ].val = 0X88;
                    CurValueStr[Cruise_H                   ].val = 0xC7;
                    CurValueStr[Cruise                     ].val = 0x01;
                    CurValueStr[Power_Tem                  ].val = 0x32;
                    CurValueStr[Gear                       ].val =0x05;
                    CurValueStr[ABS_off                    ].val=0x00;
                    CurValueStr[Ready                      ].val=0x00;
                    CurValueStr[Charge                     ].val=0x00;
                    CurValueStr[Charge_H                   ].val=0x00;
                    CurValueStr[ABS                         ].val=0x00;
                     CurValueStr[Tubro                         ].val=0x01;
                     CurValueStr[Malfunction                         ].val=0x00;
                     CurValueStr[Support                         ].val=0x00;
                     CurValueStr[L_Power                         ].val=0x00;
                        CurValueStr[Throttle_117                        ].val=0x00;
                    CurValueStr[Throttle_317                         ].val=0x00;
                     CurValueStr[RaiseHead                           ].val=0x00;
                     CurValueStr[LeftHand                           ].val=0x00;
                     CurValueStr[Parking                          ].val=0x00;


                }
                break;

                case 6:
                {   
                    CurValueStr[Vvspeed_L                  ].val = 0xFF;
                    CurValueStr[Power                      ].val = 0XFE;
                    CurValueStr[Power_H                    ].val = 0XFF;
                    CurValueStr[Electricity_L              ].val = 0x70;
                    CurValueStr[Electricity_H              ].val = 0x17;
                    CurValueStr[Cruise_H                   ].val = 0xC7;
                    CurValueStr[Cruise                     ].val = 0x01;
                    CurValueStr[Power_Tem                  ].val = 0x42;
                    CurValueStr[Gear                       ].val =0x04;
                    CurValueStr[ABS_off                    ].val=0x00;
                    CurValueStr[Ready                      ].val=0x00;
                    CurValueStr[Charge                     ].val=0x00;
                    CurValueStr[Charge_H                   ].val=0x00;
                    CurValueStr[ABS                         ].val=0x00;
                     CurValueStr[Tubro                         ].val=0x00;
                     CurValueStr[Malfunction                         ].val=0x01;
                     CurValueStr[Support                         ].val=0x10;
                     CurValueStr[L_Power                         ].val=0x00;
                        CurValueStr[Throttle_117                        ].val=0x00;
                    CurValueStr[Throttle_317                         ].val=0x00;
                     CurValueStr[RaiseHead                           ].val=0x00;
                     CurValueStr[LeftHand                           ].val=0x00;
                     CurValueStr[Parking                          ].val=0x00;
                }
                break;
                
                case 7:
                {   
                    CurValueStr[Vvspeed_L                   ].val = 0xFF;
                    CurValueStr[Power                       ].val = 0XFA;
                    CurValueStr[Power_H                     ].val = 0XFF;
                    CurValueStr[Electricity_H               ].val = 0x1B;
                    CurValueStr[Electricity_L               ].val = 0x58;
         
                    CurValueStr[Cruise_H                    ].val = 0xC7;
                    CurValueStr[Cruise                      ].val = 0x01;
                    CurValueStr[Power_Tem                   ].val = 0x43;
                    CurValueStr[Gear                        ].val =0x02;
                    CurValueStr[ABS_off                     ].val =0x00;
                    CurValueStr[Ready                      ].val=0x00;
                    CurValueStr[Charge                     ].val=0x00;
                    CurValueStr[Charge_H                   ].val=0x00;
                    CurValueStr[ABS                         ].val=0x00;
                     CurValueStr[Tubro                         ].val=0x00;
                     CurValueStr[Malfunction                         ].val=0x00;
                     CurValueStr[Support                         ].val=0x00;
                     CurValueStr[L_Power                         ].val=0x01;
                        CurValueStr[Throttle_117                        ].val=0x00;
                    CurValueStr[Throttle_317                         ].val=0x00;
                     CurValueStr[RaiseHead                           ].val=0x00;
                     CurValueStr[LeftHand                           ].val=0x00;
                     CurValueStr[Parking                          ].val=0x00;
                }
                break;

                case 8:
                {   
                    CurValueStr[Vvspeed_L                   ].val = 0xFF;
                    CurValueStr[Power                       ].val = 0XF8;
                    CurValueStr[Power_H                     ].val = 0XFF;
                    CurValueStr[Electricity_H               ].val = 0x1F;
                    CurValueStr[Electricity_L               ].val = 0x40;
              
                    CurValueStr[Cruise_H                    ].val = 0xC7;
                    CurValueStr[Cruise                      ].val = 0x01;
                    CurValueStr[Power_Tem                   ].val = 0x50;
                    CurValueStr[Gear                        ].val =0x06;

                    CurValueStr[ABS_off                     ].val=0x00;
                    CurValueStr[Ready                      ].val=0x00;
                    CurValueStr[Charge                     ].val=0x00;
                    CurValueStr[Charge_H                   ].val=0x00;
                    CurValueStr[ABS                         ].val=0x00;
                     CurValueStr[Tubro                         ].val=0x00;
                     CurValueStr[Malfunction                         ].val=0x00;
                     CurValueStr[Support                         ].val=0x00;
                     CurValueStr[L_Power                         ].val=0x00;
                        CurValueStr[Throttle_117                        ].val=0x10;
                    CurValueStr[Throttle_317                         ].val=0x01;
                     CurValueStr[RaiseHead                           ].val=0x11;
                     CurValueStr[LeftHand                           ].val=0x00;
                     CurValueStr[Parking                          ].val=0x00;
                }
                break;

                case 9:
                {        
                    CurValueStr[Vvspeed_L                   ].val = 0xFF;
                    CurValueStr[Power                       ].val = 0XF6;
                    CurValueStr[Power_H                     ].val = 0XFF;
                    CurValueStr[Electricity_H               ].val = 0x23;
                    CurValueStr[Electricity_L               ].val = 0x28;
         
                    CurValueStr[Cruise_H                    ].val = 0xC7;
                    CurValueStr[Cruise                      ].val = 0x01;
                    CurValueStr[Power_Tem                   ].val = 0x5A;
                    CurValueStr[Gear                        ].val =0x02;

                    CurValueStr[ABS_off                     ].val=0x00;
                    CurValueStr[Ready                      ].val=0x00;
                    CurValueStr[Charge                     ].val=0x00;
                    CurValueStr[Charge_H                   ].val=0x00;
                    CurValueStr[ABS                         ].val=0x00;
                     CurValueStr[Tubro                         ].val=0x00;
                     CurValueStr[Malfunction                         ].val=0x00;
                     CurValueStr[Support                         ].val=0x00;
                     CurValueStr[L_Power                         ].val=0x00;
                        CurValueStr[Throttle_117                        ].val=0x00;
                    CurValueStr[Throttle_317                         ].val=0x00;
                     CurValueStr[RaiseHead                           ].val=0x11;
                     CurValueStr[LeftHand                           ].val=0x01;
                     CurValueStr[Parking                          ].val=0x04;
                }
                break;
                
                case 10:
                {   
                    CurValueStr[Vvspeed_L                   ].val = 0xFF;
                    CurValueStr[Power                       ].val = 0XE8;
                    CurValueStr[Power_H                     ].val = 0XFF;
                    CurValueStr[Electricity_H               ].val = 0x27;
                    CurValueStr[Electricity_L               ].val = 0x10;
                    CurValueStr[Cruise_H                    ].val = 0xC7;
                    CurValueStr[Cruise                      ].val = 0x01;
                    CurValueStr[Power_Tem                   ].val = 0x64;
                    CurValueStr[Gear                        ].val =0x05;
                    CurValueStr[ABS_off                     ].val=0x01;
                    CurValueStr[Ready                      ].val=0x01;
                    CurValueStr[Charge                     ].val=0xCD;
                    CurValueStr[Charge_H                   ].val=0x0C;
                    CurValueStr[ABS                         ].val=0x20;
                    CurValueStr[Tubro                         ].val=0x01;
                    CurValueStr[Malfunction                         ].val=0x01;
                    CurValueStr[Support                         ].val=0x10;
                    CurValueStr[L_Power                         ].val=0x01;
                       CurValueStr[Throttle_117                        ].val=0x10;
                    CurValueStr[Throttle_317                         ].val=0x01;
                     CurValueStr[RaiseHead                           ].val=0x11;
                       CurValueStr[LeftHand                           ].val=0x01;
                     CurValueStr[Parking                          ].val=0x04;
                }
                break;
            }
            // else if(Key.Flag_1 =0 1)

                #if 0
                case 12:
                {   
                    CurValueStr[ENUM_VSpeed         ].val = speed_value;//????
                    CurValueStr[ENUM_RSpeed         ].val = 12000;
                    CurValueStr[ENUM_WaterTemp      ].val = water_value;//???
                    if(direction_espeed==1)
                    {
                        CurValueStr[ISG_Power      ].val = 0;
                        CurValueStr[ISG_Power_Enable      ].val = 0;
                        CurValueStr[TCS_Warning_Lamp      ].val = 1;
                        CurValueStr[TCS_Work_Mode      ].val = 0;                              
                    }
                    else
                    {
                        CurValueStr[ISG_Ready      ].val = 1; 
                        CurValueStr[TCS_Warning_Lamp      ].val = 0;
                        CurValueStr[TCS_Work_Mode      ].val = 1;                                                 
                    }      
                }break;
                #endif
            }
            #endif
        }
    }
// }


void Message_ClearDatas(CAN_message *Message, unsigned char StartByte, unsigned char StartBit, unsigned char len, unsigned char Format){
    unsigned char pBit, pByte, i;

    pBit = StartBit;
    pByte = StartByte;

    switch(Format){
        case Motorola:{
            for(i = 0; i < len; i++){
                __RESET_WATCHDOG();
                Message->Msg[pByte] &= ~(1 << pBit);
                pBit++;
                if(pBit >= 8){
                    pBit = 0;
                    if(pByte > 0){
                        pByte--;
                    }else{
                        break;
                    }
                }
            }
        }break;

        case Intel:{
            for(i = 0; i < len; i++){
                __RESET_WATCHDOG();
                Message->Msg[pByte] &= ~(1 << pBit);
                pBit++;
                if(pBit >= 8){
                    pBit = 0;
                    if(pByte < 7){
                        pByte++;
                    }else{
                        break;
                    }
                }
            }
        }break;

        default:{
            ;
        }
    }
}

void Message_FillDatas(CAN_message *Message, unsigned char StartByte, unsigned char StartBit, unsigned char len, unsigned char Format, unsigned long MessageValue){
    unsigned char pBit, pByte, i;

    pBit = StartBit;
    pByte = StartByte;
    MessageValue = MessageValue << pBit;

    switch(Format){
        case Motorola:{
            for(i = 0; i < len; i++){
                __RESET_WATCHDOG();
                Message->Msg[pByte] |= MessageValue & (1 << pBit);
                pBit++;
                if(pBit >= 8){
                    pBit = 0;
                    if(pByte > 0){
                        pByte--;
                        MessageValue = MessageValue >> 8;
                    }else{
                        break;
                    }
                }
            }
        }break;

        case Intel:{
            for(i = 0; i < len; i++){
                __RESET_WATCHDOG();
                Message->Msg[pByte] |= MessageValue & (1 << pBit);
                pBit++;
                if(pBit >= 8){
                    pBit = 0;
                    if(pByte < 7){
                        pByte++;
                        MessageValue = MessageValue >> 8;
                    }else{
                        break;
                    }
                }
            }
        }break;

        default:{
            ;
        }
    }
}



void Message_Value_Calculate(s_CAN_List list)
{

    CAN_message *CanMessage;
    INT8U Start_Byte, Start_Bit, len, Offset_Flag, Format_Flag;
    INT16U Offset, Factor_1, Factor_2, CurValue, Value_Flag;

    INT32U temp;
    INT32U Message_Clear;
    INT8U  Byte_Count;
    INT8U  i;

    CanMessage = list.canMsg;
    Start_Byte = list.StartByte;
    Start_Bit = list.StartBit;
    len = list.SignalLen;
    Offset_Flag = list.fOffset;
    Format_Flag = list.fFormat;
    Offset = list.Offset;
    Factor_1 = list.Factor_1;
    Factor_2 = list.Factor_2;

    CurValue = list.CurValue->val;
    Value_Flag = list.CurValue->fval;



    temp = CurValue;

    //璁＄畻鍋忕Щ锟??
    if(Offset != 0){
        if(Offset_Flag  == Offset_Minus){
            if(Value_Flag == Value_Minus){
                if(temp > Offset){
                    temp = 0;               //閿欒??锛屾墍瑕佸疄鐜扮殑鍊煎皬浜庣墿鐞嗘渶灏忥拷?
                }else{
                    temp = Offset - temp;
                }
            }else if(Value_Flag == Value_Plus){
                temp += Offset;
            }else{;}
        }else if(Offset_Flag  == Offset_Plus){
            if(temp < Offset){
                temp = 0;               //閿欒??锛屾墍瑕佸疄鐜扮殑鍊煎皬浜庣墿鐞嗘渶灏忥拷?
            }else{
                temp -= Offset;
            }
        }
        
    }

    temp = temp * Factor_1 / Factor_2;
    //temp = temp << Start_Bit;

    Byte_Count = len / 8;
    if((len % 8) != 0){
        Byte_Count += 1;
    }

    //清脏数据
    Message_ClearDatas(CanMessage, Start_Byte, Start_Bit, len, Format_Flag);
    Message_FillDatas(CanMessage, Start_Byte, Start_Bit, len, Format_Flag, temp);
    
}




void FT_VehSpeedCalc(unsigned char spd){
    unsigned long wTemp;

    wTemp = spd;

    
}


/*zh:*/
/*------------------------------------------------------------------------------------------------
 * function name : Bits_Operation
 * parameter value range : StartByte(0~7)     StartBit(0~7)     Length(1~8)     Value(0~255)
 * notice : Do not span bytes.
 * author : zhouhang
 * date :2022.01.18
--------------------------------------------------------------------------------------------------*/        
void Bits_Operation(CAN_message *Message, unsigned char StartByte, unsigned char StartBit, unsigned char Length, unsigned char Value)  /*Do not span bytes*/
{
    unsigned char i;
    
    for (i = 0; i < Length; i++)
    {
        Message->Msg[StartByte] &= (~(1 << (i + StartBit)));
    }

    Message->Msg[StartByte] |= (Value << StartBit);
}

/*:zh*/


void All_Lamp_TurnOn(void)
{
    ;
}