

#ifdef GLOBALS_APP_TEST
#define EXTERN_APP_TEST

#else
#define EXTERN_APP_TEST extern
#endif

#ifndef APP_TEDT_H_
#define APP_TEDT_H_

#define Motorola 0
#define Intel 1

#define Offset_Minus 0
#define Offset_Plus 1

#define Value_Minus 0
#define Value_Plus 1

typedef struct
{
    int val;
    unsigned char fval;
} s_CurValue;

typedef struct
{
    CAN_message *canMsg;//ID
    unsigned char StartByte;//开始字节
    unsigned char StartBit;//开始位
    unsigned char SignalLen;//几个字节（1个字节，填8，证明8位）
    unsigned int Offset;//偏移量
    unsigned char fOffset;//分辨率
    unsigned int Factor_1; //分辨率，分子  /*Denominator of Resolution*/ /*???????*/
    unsigned int Factor_2; //分辨率，分母  /*Numerator of Resolution*/   /*????????*/
    s_CurValue *CurValue;
    unsigned char fFormat;
} s_CAN_List;

enum
{
    ENUM_VSpeed = 0, // ????
    ECM_FaultIndicator,
    ECM_StautsInvalid,
    ECM_MotorOver,
    ECM_ReadyIndicator,
    ECM_ChargeStatus,
    ECM_CruiseStatus,
    ECM_GearPositionStatus,
    PFC_Relag,                    
    LLC_UnderOutput,              
    LLC_OverOutput,               
    LLC_OutPut,                   
    PFC_LLC_Interal_Communication,
    LLC_Temp,                     
    Battery_status,
    Battery_Current,
    Battery_SOC,    
    Vspeed,
    hour,
    minute,
    electricity,
    fault, 
    Charge,
    Charge_H,
    Ready,
    Energy_recovery,
    Energy_recovery_level,
    Side_brackets,
    TCS_close,
    TCS_crotrul,
    TCS_mode,
    TCS_light,
    signal_4G,
    Battery_over,
    Motor_overheating,
    Cruise_control,
    Gear,
    Bluetooth_phone,
    year,
    Power,
    Tubro,
    Power_H,
    L_Power,
    Throttle_117,
    Throttle_317,
    LeftHand,
    Vvspeed_L,
    Electricity_H,
    Electricity_L,
    Electricity_h,
    Electricity_l,
    Sidebrace,      //???
    Cruise,
     Cruise_H  ,     //???
     Power_Tem,
     RaiseHead,
    ABS,
    Malfunction,
    Support,
    ABS_off,
    Parking,
    TCS,
    Tire_pressure,
    Bluetooth,
    GPS,
    Callalert,      //????????
    GMS,      //????????
    Parallelsignals,       //???????
    Enginefailure,     //??????????
    P_dang,
    CAN_List_Num,

};

EXTERN_APP_TEST volatile s_CurValue CurValueStr[CAN_List_Num];

static const s_CAN_List CAN_List[] = 
{

    {&CanMsg_112, 1, 0, 16, 0, Offset_Plus, 1, 1, &CurValueStr[Vvspeed_L], Motorola},
    {&CanMsg_103, 6, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Power], Motorola},
    {&CanMsg_103, 7, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Power_H], Motorola},
    {&CanMsg_104,1,0,8,0,Offset_Plus,1,1,&CurValueStr[Electricity_H],Motorola},
    {&CanMsg_104,0,0,8,0,Offset_Plus,1,1,&CurValueStr[Electricity_L],Motorola},
    {&CanMsg_116,0,0,2,0,Offset_Plus,1,1,&CurValueStr[Cruise],Motorola},
    {&CanMsg_116,1,0,8,0,Offset_Plus,1,1,&CurValueStr[Cruise_H],Motorola},
    {&CanMsg_113,6,0,8,0,Offset_Plus,1,1,&CurValueStr[Power_Tem],Motorola},
    {&CanMsg_113,5,0,8,0,Offset_Plus,1,1,&CurValueStr[Gear],Motorola},
    {&CanMsg_12F,1,0,8,0,Offset_Plus,1,1,&CurValueStr[ABS_off],Motorola},
    {&CanMsg_113,1,0,8,0,Offset_Plus,1,1,&CurValueStr[Ready],Motorola},
    {&CanMsg_331,2,0,8,0,Offset_Plus,1,1,&CurValueStr[Charge],Motorola},   
    {&CanMsg_331,3,0,8,0,Offset_Plus,1,1,&CurValueStr[Charge_H],Motorola},
    {&CanMsg_12F,0,0,8,0,Offset_Plus,1,1,&CurValueStr[ABS],Motorola},
    {&CanMsg_113,3,0,8,0,Offset_Plus,1,1,&CurValueStr[Tubro],Motorola},
    {&CanMsg_012,0,0,8,0,Offset_Plus,1,1,&CurValueStr[Malfunction],Motorola},
    {&CanMsg_115,1,0,8,0,Offset_Plus,1,1,&CurValueStr[Support],Motorola},
    {&CanMsg_113,7,0,8,0,Offset_Plus,1,1,&CurValueStr[L_Power],Motorola},
    {&CanMsg_117,2,0,8,0,Offset_Plus,1,1,&CurValueStr[Throttle_117],Motorola},
    {&CanMsg_317,3,0,4,0,Offset_Plus,1,1,&CurValueStr[Throttle_317],Motorola},
     {&CanMsg_116,2,0,8,0,Offset_Plus,1,1,&CurValueStr[RaiseHead],Motorola},
     {&CanMsg_317,5,0,4,0,Offset_Plus,1,1,&CurValueStr[LeftHand],Motorola},
     {&CanMsg_115,3,0,8,0,Offset_Plus,1,1,&CurValueStr[Parking],Motorola},
    // {&CanMsg_113, 0, 0, 0, 0, Offset_Plus, 1, 1, &CurValueStr[ABS], Motorola},
  //  {&CanMsg_101, 3, 0, 8,0,Offset_Plus, 1, 1, &CurValueStr[ENUM_VSpeed                    ], Motorola},
    // {&CanMsg_067, 2, 0, 16, 0,Offset_Plus, 1, 1, &CurValueStr[ECM_FaultIndicator            ], Motorola},
    // {&CanMsg_067, 3, 0, 2, 0, Offset_Plus, 1, 1, &CurValueStr[ECM_StautsInvalid             ], Motorola},
    // {&CanMsg_067, 3, 2, 2, 0, Offset_Plus, 1, 1, &CurValueStr[ECM_MotorOver                 ], Motorola},
    // {&CanMsg_067, 3, 4, 1, 0, Offset_Plus, 1, 1, &CurValueStr[ECM_ReadyIndicator            ], Motorola},
    // {&CanMsg_067, 3, 6, 1, 0, Offset_Plus, 1, 1, &CurValueStr[ECM_ChargeStatus              ], Motorola},
    // {&CanMsg_067, 4, 2, 1, 0, Offset_Plus, 1, 1, &CurValueStr[ECM_CruiseStatus              ], Motorola},
    // {&CanMsg_067, 5, 0, 3, 0, Offset_Plus, 1, 1, &CurValueStr[ECM_GearPositionStatus        ], Motorola},
    // {&CanMsg_600, 0, 0, 1, 0, Offset_Plus, 1, 1, &CurValueStr[PFC_Relag                     ], Motorola},
    // {&CanMsg_600, 0, 1, 1, 0, Offset_Plus, 1, 1, &CurValueStr[LLC_UnderOutput               ], Motorola},
    // {&CanMsg_600, 0, 2, 1, 0, Offset_Plus, 1, 1, &CurValueStr[LLC_OverOutput                ], Motorola},
    // {&CanMsg_600, 0, 3, 1, 0, Offset_Plus, 1, 1, &CurValueStr[LLC_OutPut                    ], Motorola},
    // {&CanMsg_600, 0, 4, 1, 0, Offset_Plus, 1, 1, &CurValueStr[PFC_LLC_Interal_Communication ], Motorola},
    // {&CanMsg_600, 0, 5, 1, 0, Offset_Plus, 1, 1, &CurValueStr[LLC_Temp                      ], Motorola},
    // {&CanMsg_610, 0, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Battery_status                ], Motorola},
    // {&CanMsg_610,2,0, 16,255,Offset_Minus, 10, 1, &CurValueStr[Battery_Current              ], Motorola},
    // {&CanMsg_611, 0, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Battery_SOC                   ], Motorola},
    // {&CanMsg_200, 2, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Vspeed                        ], Motorola},
    // {&CanMsg_481, 3, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[hour                          ], Motorola},
    // {&CanMsg_481, 4, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[minute                        ], Motorola},
    // {&CanMsg_020, 3, 0, 16, 0, Offset_Plus, 1, 1, &CurValueStr[electricity                  ], Motorola},
    // {&CanMsg_202, 2, 2, 1, 0, Offset_Plus, 1, 1, &CurValueStr[fault                         ], Motorola},
    // {&CanMsg_202, 1, 4, 2, 0, Offset_Plus, 1, 1, &CurValueStr[Ready                         ], Motorola},
    // {&CanMsg_280, 3, 0, 1, 0, Offset_Plus, 1, 1, &CurValueStr[Energy_recovery               ], Motorola},
    // {&CanMsg_280, 3, 5, 2, 0, Offset_Plus, 1, 1, &CurValueStr[Energy_recovery_level         ], Motorola},
    // {&CanMsg_280, 3, 3, 1, 0, Offset_Plus, 1, 1, &CurValueStr[Side_brackets                 ], Motorola},
    // {&CanMsg_280, 4, 4, 1, 0, Offset_Plus, 1, 1, &CurValueStr[TCS_close                     ], Motorola},
    // {&CanMsg_042, 2, 7, 1, 0, Offset_Plus, 1, 1, &CurValueStr[TCS_crotrul                   ], Motorola},
    // {&CanMsg_042, 2, 6, 1, 0, Offset_Plus, 1, 1, &CurValueStr[TCS_mode                      ], Motorola},
    // {&CanMsg_042, 2, 0, 4, 0, Offset_Plus, 1, 1, &CurValueStr[TCS_light                     ], Motorola},
    // {&CanMsg_480, 1, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[GPS                           ], Motorola},
    // {&CanMsg_480, 0, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[signal_4G                     ], Motorola},
    // {&CanMsg_021, 5, 7, 1, 0, Offset_Plus, 1, 1, &CurValueStr[Battery_over                  ], Motorola},
    // {&CanMsg_202, 1, 6, 1, 0, Offset_Plus, 1, 1, &CurValueStr[Cruise_control                ], Motorola},
    // {&CanMsg_202, 0, 2, 2, 0, Offset_Plus, 1, 1, &CurValueStr[Gear                          ], Motorola},
    // {&CanMsg_480, 2, 6, 1, 0, Offset_Plus, 1, 1, &CurValueStr[Bluetooth_phone               ], Motorola},
    // {&CanMsg_481, 0, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[year                          ], Motorola},


    // {&CanMsg_0A33FFE3, 0, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Vvspeed_L             ], Motorola},
    // {&CanMsg_0A33FFE3, 1, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Vvspeed_H             ], Motorola},

    // {&CanMsg_0A10FFE0, 3, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Electricity_H             ], Motorola},
    // {&CanMsg_0A10FFE0, 2, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Electricity_L             ], Motorola},

    // {&CanMsg_0A10FFE1, 3, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Electricity_h             ], Motorola},
    // {&CanMsg_0A10FFE1, 2, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Electricity_l             ], Motorola},

    // {&CanMsg_0A20FFE2, 1, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Sidebrace             ], Motorola},
    // {&CanMsg_0A20FFE2, 4, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[cruise             ], Motorola},

    // {&CanMsg_0A30FFE8, 0, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[ABS             ], Motorola},

    // {&CanMsg_0A31FFE3, 4, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Tire_pressure             ], Motorola},

    // {&CanMsg_0A30FFE3, 7, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Bluetooth             ], Motorola},

    // {&CanMsg_0A32FFE4, 0, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[GPS             ], Motorola},

    // {&CanMsg_0A37FFE3, 7, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Callalert             ], Motorola},

    // {&CanMsg_0A18FFE0, 0, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Parallelsignals             ], Motorola},

    // {&CanMsg_0A40FFE2, 0, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Enginefailure             ], Motorola},

    // {&CanMsg_0A20FFE2, 0, 4, 2, 0, Offset_Plus, 1, 1, &CurValueStr[P_dang             ], Motorola},

};
extern unsigned int Key_Dodging_flag;
extern unsigned int lost_flag;
extern unsigned int CAN_init_flag; 
extern unsigned int water_value;
extern unsigned int count_flag_a;
extern unsigned int speed_value;
extern unsigned int  electricityclose;
EXTERN_APP_TEST void APP_Button_Proc(void);
EXTERN_APP_TEST void Message_Value_Calculate(s_CAN_List list);

void Bits_Operation(CAN_message *Message, unsigned char StartByte, unsigned char StartBit, unsigned char Length, unsigned char Value); /*Do not span bytes*/

#endif /* API_CAN_H_ */
