

#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;
    unsigned char StartByte;
    unsigned char StartBit;
    unsigned char SignalLen;
    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, 
    // 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,
    // Vvspeed_H,
    // Vvspeed_L,
    // Electricity_H,
    // Electricity_L,
    // Electricity_h,
    // Electricity_l,
    // Sidebrace,      //侧撑
    // cruise,        //巡航
    // ABS,
    // TCS,
    // Tire_pressure,
    // Bluetooth,
    // GPS,
    // Callalert,      //来电提醒
    // GMS,      //来电提醒
    // Parallelsignals,       //并联信号
    // Enginefailure,     //发动机故障
    // P_dang,
    Engine_water_temperature_display_L = 0,
    Engine_water_temperature_display_H,
    Engine_water_temperature_display_state,
    // EVpeed_H,
    // EVpeed_L,
    Compass,        //指南针
    Compass_H,
    Compass_flag,
    Temperature_Swtich,     //发动机水温显示与大气温度切换
    CAN_List_Num,
};

EXTERN_APP_TEST volatile s_CurValue CurValueStr[CAN_List_Num];

static const s_CAN_List CAN_List[] = 
{
    // {&CanMsg_101, 2, 0, 16,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},
    {&CanMsg_101, 5, 0, 8, 0, Offset_Plus, 1, 10, &CurValueStr[Engine_water_temperature_display_L  ], Motorola},
    {&CanMsg_101, 4, 0, 8, 0, Offset_Plus, 1, 10, &CurValueStr[Engine_water_temperature_display_H  ], Motorola},
    {&CanMsg_101, 6, 7, 1, 0, Offset_Plus, 1, 1, &CurValueStr[Engine_water_temperature_display_state  ], Motorola},
    // {&CanMsg_522, 4, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[EVpeed_L             ], Motorola},
    // {&CanMsg_522, 5, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[EVpeed_H             ], Motorola},

    {&CanMsg_621, 1, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Compass             ], Motorola},
    {&CanMsg_621, 2, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Compass_H           ], Motorola},
    {&CanMsg_621, 3, 0, 8, 0, Offset_Plus, 1, 1, &CurValueStr[Compass_flag              ], Motorola},
    {&CanMsg_621, 4, 3, 1, 0, Offset_Plus, 1, 1, &CurValueStr[Temperature_Swtich        ], Intel},
};
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_ */
