#include "Check_Ctrl.h"
#include "TYW_stdint.h"
#include "RTE_GPIO.h"
#include "UDS_ISO14229_Server.h"
#include "string.h"
#include "Display_Info.h"
#include "Analog_Signals.h"
#include "CAN_Communication_Matrix.h"
#include "COM_CAN.h"
#include "GenDelay.h"
LIN_Flag_T LIN_Flag={.LIN_LEFT_Flag=0,
                 .LIN_RIGHT_Flag=0,
                 .LIN_F_Right_Flag=0};
uint32_t NO_IPK_EXIST_Status;
uint32_t NO_IPK_EXIST;
//uint32_t NO_IPK_EXIST_Back;
uint32_t NO_IPK_EXIST_TIMER;

uint8_t InterNal_Version [ 128 ];
uint8_t SW_Version [ 128 ];
uint8_t HW_Version [ 128 ];
uint8_t Part_Version [ 128 ];
uint8_t Risk_Evade [ 128 ];
uint8_t Evade_ODO  [ 128 ];
uint8_t Line_IN_St [ 128 ];
uint8_t Res_St [ 128 ];
uint8_t Made_Date [ 128 ];//制造日期
uint8_t SUPPLIER [ 128 ];//供应商代码
uint8_t Voltage_UDS [ 128 ];
uint8_t BCM_2014 [ 128 ];
//uint8_t InterNal_Version [ 128 ];

uint32_t LCD_CHECN_BEGIN;
uint32_t LCD_CHECN_Retry;

uint32_t LINE_IN_CHECK_BEGIN;
uint32_t LINE_IN_CHECK_Retry;

uint32_t TFT_CHECN_BEGIN;
uint32_t TFT_CHECN_Retry;

uint32_t VOICE_BACK_BEGIN;
uint32_t VOICE_BACK_Retry;

uint32_t VOICE_CHECK_BEGIN;
uint32_t VOICE_CHECK_Retry;

uint32_t VOICE_CHECN_BEGIN;
uint32_t VOICE_CHECN_Retry;

uint32_t LINE_ODO_CLEAR_BEGIN;
uint32_t VOICE_ODO_CLEAR_Retry;

uint32_t RES_CHECK_BEGIN;
uint32_t RES_CHECK_Retry;

uint32_t UnLock_Flag = 0;
uint32_t UnLock_Retry;

uint8_t  KEYBUFFER [ 4 ];

uint32_t CAN_Msg_Tx_Enable;


uint32_t MENU_CHECK_STEP;

uint32_t Global_Session = 0;
uint32_t loc_Step;


void Function_Check_Ctrl(uint32_t cmd);

void MENU_CHECK_STEP_ADD(void)
{
    if(MENU_CHECK_STEP > 8)
    {
        MENU_CHECK_STEP = 0;
    }
    else
    {
        MENU_CHECK_STEP++;
    }
    
}
void MENU_CHECK_STEP_SUB(void)
{
    if ( MENU_CHECK_STEP != 0 )
        MENU_CHECK_STEP--;
}

void MENU_CHECK_Init(void)
{
    MENU_CHECK_STEP = 0;
}



uint8_t Get_DID_High_Byte(uint16_t Input_DID)
{
    uint16_t Res = 0;

    Res = (Input_DID >> 8);

    return  (uint8_t)(Res);
}

uint8_t Get_DID_Low_Byte(uint16_t Input_DID)
{
    uint16_t Res = 0;

    Res = (Input_DID & 0xFF);

    return  (uint8_t)(Res);
}







void HW_CHECK_IPK_EXIST(void)
{

    uint8_t DIAG_BUFER [ 2 ];

    DIAG_BUFER [ 0 ] = 0x3E;
    DIAG_BUFER [ 1 ] = 0x00;
    // UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 2);
    
    SET_IPK_NONE( );
}

void SET_IPK_NONE(void)
{
    NO_IPK_EXIST_TIMER = 12;
    NO_IPK_EXIST       = 12345678;
}
void Clear_IPK_NONE(void)   //CAN在线
{
    NO_IPK_EXIST        = 0;
    NO_IPK_EXIST_Status = 0x55667788;
}
uint8_t ClearFlag = 0;
uint8_t ClearFlagBack = 0;

void CHECK_IPK_COUNT(void)
{
    if ( CAN_Msg_Tx_Enable == 1u )
    {
        if ( NO_IPK_EXIST_TIMER != 0 )
        {
            NO_IPK_EXIST_TIMER--;
        }
        else
        {
            if ( NO_IPK_EXIST == 12345678 )
            {
                NO_IPK_EXIST_Status = 0x11223344;
                memset(InterNal_Version, 0xFF, sizeof(InterNal_Version));
                memset(SW_Version, 0xFF, sizeof(SW_Version));
                memset(HW_Version, 0xFF, sizeof(HW_Version));
                memset(Part_Version, 0xFF, sizeof(Part_Version));
                memset(Made_Date, 0xFF, sizeof(Made_Date));
                memset(SUPPLIER, 0xFF, sizeof(SUPPLIER));
                memset(Voltage_UDS, 0xFF, sizeof(Voltage_UDS));
                
                Display_Menu_Type = 0;
                Display_TFT_Clear( );
                Send_Init();                              
                // MENU_CHECK_Init( );
                Global_Session = 0;//掉线时，认为会话模式归零，重连CAN线后，重新将会话模式切到03扩展会话。
            }
            else
            {
                ClearFlag = 0;
            }
        }


    }
}

// 0x11223344 不在线
// 0x55667788 在线

uint32_t Get_IPK_Status(void)
{
    return NO_IPK_EXIST_Status;
}
void Diag_Info_Init(void)
{
    NO_IPK_EXIST_Status = 0x11223344;
    CAN_Msg_Tx_Enable   = 1u;

    memset(InterNal_Version , 0xFF, sizeof(InterNal_Version));
    memset(SW_Version , 0xFF, sizeof(SW_Version));
    memset(HW_Version , 0xFF, sizeof(HW_Version));
    memset(Part_Version , 0xFF, sizeof(Part_Version));
    memset(Risk_Evade, 0xFF, sizeof(Risk_Evade));
    memset(Evade_ODO, 0xFF, sizeof(Evade_ODO));
    memset(Res_St, 0xFF, sizeof(Res_St));
    memset(Made_Date , 0xFF, sizeof(Made_Date));
    memset(SUPPLIER , 0xFF, sizeof(SUPPLIER));
    //memset(Voltage_UDS, 0xFF, sizeof(Voltage_UDS));
    
}
uint8_t Type_Clear = 0;
extern uint8_t BCM_FLAG_2014 = 0;
void Total_Check(void)
{
    uint32_t loc_Type = 0;
    loc_Type          = Get_Display_Type( );
    if ( Type_Clear != loc_Type )
    {
        Type_Clear = loc_Type;
        Display_TFT_Clear();
    }

    POWER_CTRL_KL30_Current = 1u;//静态电流电阻的远仪表端，永远接通总电源。B+~

    BCM_FLAG_2014 = BCM_2014[1] & 0X40 ;

    switch ( loc_Type )
    {
        case 0:
            // POWER_CTRL_KL30   = 1u;  //B+
            // POWER_CTRL_KL15   = 1u;  //KL15
            CAN_Msg_Tx_Enable = 1u;  
            Diag_Info_Init( );       
            Display_Init( );  
            Display_Version_Info(0);             
            Send_Init();
            Send_ODO_Init();          
            Buzzer_Init();            
            Function_Check_Ctrl(1);    //Excel表格发报文。硬线信号  
            
            //Buzzer_Warning();      
            break;

        case 1: 
            // POWER_CTRL_KL30   = 1u;  //B+
            // POWER_CTRL_KL15   = 1u;  //KL15
            CAN_Msg_Tx_Enable = 1u;              
            Display_Version_Info(1);             
            // Send_Init();
            // Send_ODO_Init();
            Function_Check_Ctrl(1);    //Excel表格发报文。硬线信号  
            //FUEL_UDS__Display(3);
            // Buzzer_Warning();      
            break; 
            
            

        case 2: 
            // POWER_CTRL_KL30   = 1u;  //B+
            // POWER_CTRL_KL15   = 1u;  //KL15
            // CAN_Msg_Tx_Enable = 1u;  
            // Diag_Info_Init( );       
            // Display_Init( );  
            // Display_Version_Info(0);             
            // Send_Init();            
            // Display_Send_ODO(0); 
            // Function_Check_Ctrl(1);    //Excel表格发报文。硬线信号  
            // //FUEL_UDS__Display(3);
            // Buzzer_Warning();
            // POWER_CTRL_KL30   = 0u;  //B+
            // POWER_CTRL_KL15   = 0u;  //KL15
            CAN_Msg_Tx_Enable = 1u;  
            if(MENU_CHECK_STEP == 1)
            {
                Display_Version_Info(1);  
            }
            else
            {
                loc_Type_back = 0;
                
            }
            // if((R485_ID4Dh.Sig.ESP322 == 0) && ( R485_ID4Dh.Sig.G0312 == 0))
            // {
            //     MENU_CHECK_STEP = 0;
            // }
            Function_Check_Ctrl(1);    //Excel表格发报文。硬线信号  
            // Diag_Info_Init( );       
            // Display_Init( );            
            // Send_Init();
            // Send_ODO_Init();             
            // Display_Send_ODO(0); 
            //FUEL_UDS__Display(3);
            // Buzzer_Warning();    
            break;              
            
        case 3:   
            if ( BCM_FLAG_2014 == 0x40 )      //全CAN,不做外发，此页为静态电流测试
            {
                // POWER_CTRL_KL30   = 0u;  //B+
                // POWER_CTRL_KL15   = 0u;  //KL15
                CAN_Msg_Tx_Enable = 0u;  
                Diag_Info_Init( );       
                Display_Init( );  
                Display_Version_Info(0);             
                Send_Init();
                Send_ODO_Init(); 
                HW_Static_Current_Check(1); 
            }
            else
            {
                // POWER_CTRL_KL30   = 1u;  //B+
                // POWER_CTRL_KL15   = 1u;  //KL15
                CAN_Msg_Tx_Enable = 1u;  
                Diag_Info_Init( );       
                Display_Init( );  
                Display_Version_Info(0); 
                Send_ODO_Init();             
                Display_Set_Buff(); 
                Function_Check_Ctrl(1);    //Excel表格发报文。硬线信号  
                //FUEL_UDS__Display(3);
                Buzzer_Warning();
            }
            
            
                 
            break;                   
            
        case 4:
            if ( BCM_FLAG_2014 == 0x40 )
            {
                break;
            }
            else
            {
                // POWER_CTRL_KL30   = 0u;  //B+
                // POWER_CTRL_KL15   = 0u;  //KL15
                CAN_Msg_Tx_Enable = 0u;  
                Diag_Info_Init( );       
                Display_Init( );  
                Display_Version_Info(0);             
                Send_Init();
                Send_ODO_Init(); 
                HW_Static_Current_Check(1);  
                break;
            }
            
                  
            

        default:            
            // POWER_CTRL_KL30   = 1u;
            // POWER_CTRL_KL15   = 1u;
            // CAN_Msg_Tx_Enable = 1u;
            // Display_Menu_Type = 0;
            // Diag_Info_Init( );       
            // Display_Init( );  
            // Display_Version_Info(0);             
            // Send_Init();
            // Send_ODO_Init();
            // Buzzer_Init(); 
              
            break;
    }
}

void Read_IPK_Session_Type(void)//请求仪表发送 软硬件版本号 等数据。
{
    uint8_t         DIAG_BUFER [ 10 ];

    switch ( loc_Step )
    {
        case 0:
            loc_Step = 5;    
            break;

        case 1:
            if ( Global_Session != 3 )
            {
                DIAG_BUFER [ 0 ] = 0x10;
                DIAG_BUFER [ 1 ] = 0x03;
                UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 2);//让仪表进入 扩展会话 中。
            }
            break;
        case 2:
            //*******************************
            //UnLock_Flag == 0x00   //初始    阶段
            //UnLock_Flag == 0x01   //请求种子阶段
            //UnLock_Flag == 0x02   //得到种子阶段
            //UnLock_Flag == 0x03   //发送密钥阶段
            //UnLock_Flag == 0x55   //解锁成功阶段
            //*******************************
            if ( UnLock_Flag == 0 )
            {
                UnLock_Retry     = 10;
                UnLock_Flag      = 1;//请求种子阶段
                DIAG_BUFER [ 0 ] = 0x27;
                DIAG_BUFER [ 1 ] = 0x03;
                UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 2);    //
            }
            if ( UnLock_Flag == 0x55 )//解锁成功阶段
            {
                loc_Step = 3;
            }
            break;
        case 3:
            if ( UnLock_Flag == 2 )//得到种子阶段
            {
                UnLock_Flag      = 3;//发送密钥阶段
                UnLock_Retry     = 10;
                DIAG_BUFER [ 0 ] = 0x27;
                DIAG_BUFER [ 1 ] = 0x04;
                DIAG_BUFER [ 2 ] = KEYBUFFER [ 0 ];
                DIAG_BUFER [ 3 ] = KEYBUFFER [ 1 ];
                DIAG_BUFER [ 4 ] = KEYBUFFER [ 2 ];
                DIAG_BUFER [ 5 ] = KEYBUFFER [ 3 ];
                UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 4);    //
            }
            if ( UnLock_Flag == 0x55 )//解锁成功阶段
            {
                loc_Step = 4;
            }
            break;
        case 4:

            if ( InterNal_Version [ 0 ] == 0xff )
            {

                DIAG_BUFER [ 0 ] = 0x22;
                DIAG_BUFER [ 1 ] = 0xf0;
                DIAG_BUFER [ 2 ] = 0x86;
                UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 3);    //（工厂版本号）
            }
            loc_Step = 5;
            break;

        case 5:
            if ( SW_Version [ 0 ] == 0xff )
            {

                DIAG_BUFER [ 0 ] = 0x22;
                DIAG_BUFER [ 1 ] = Get_DID_High_Byte(SV_DID);
                DIAG_BUFER [ 2 ] = Get_DID_Low_Byte(SV_DID);
                UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 3);    //请求 软件版本号
                //Execute_Specify_Step(2);
            }
            loc_Step = 6;
            break;

        case 6:
            if ( HW_Version [ 0 ] == 0xff )
            {
                DIAG_BUFER [ 0 ] = 0x22;
                DIAG_BUFER [ 1 ] = Get_DID_High_Byte(HV_DID);
                DIAG_BUFER [ 2 ] = Get_DID_Low_Byte(HV_DID);
                UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 3);    //请求 硬件版本号
            }
            loc_Step = 7;
            break;

        case 7:
            if ( Part_Version [ 0 ] == 0xff )
            {
                DIAG_BUFER [ 0 ] = 0x22;
                DIAG_BUFER [ 1 ] = Get_DID_High_Byte(PV_DID);
                DIAG_BUFER [ 2 ] = Get_DID_Low_Byte(PV_DID);
                UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 3);    //请求 零件号
            }
            loc_Step = 9;
            break;

        case 8:
            if ( Made_Date [ 0 ] == 0xff )
            {
                DIAG_BUFER [ 0 ] = 0x22;
                DIAG_BUFER [ 1 ] = Get_DID_High_Byte(DATE_DID);
                DIAG_BUFER [ 2 ] = Get_DID_Low_Byte(DATE_DID);
                UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 3);    //请求 生产日期
            }
            loc_Step = 9;
            break;
        case 9:
            if ( SUPPLIER [ 0 ] == 0xff )
            {
                DIAG_BUFER [ 0 ] = 0x22;
                DIAG_BUFER [ 1 ] = Get_DID_High_Byte(CODE_DID);
                DIAG_BUFER [ 2 ] = Get_DID_Low_Byte(CODE_DID);
                UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 3);    //请求 制造商代码
            }
            loc_Step = 10;
            break;
        case 10:
            //if ( Voltage_UDS [ 0 ] == 0xff )
            //{
                DIAG_BUFER [ 0 ] = 0x22;
                DIAG_BUFER [ 1 ] = 0x20;
                DIAG_BUFER [ 2 ] = 0x14;
                UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 3);    
            //}
            loc_Step = 11;
            break;
        case 11:
            //if ( Voltage_UDS [ 0 ] == 0xff )
            //{
                DIAG_BUFER [ 0 ] = 0x19;
                DIAG_BUFER [ 1 ] = 0x0A;
                
                UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 2);    
            //}
            loc_Step = 0;
            break;
        
        

        /*case 8:  //22 5008  读取燃油阻值
            if (RES_CHECK_BEGIN == 0) //发燃油信号时置0，下一步的时候若是0则请求读取燃油阻值，回复62，则置2，为2则刷图
            {
                if ( Res_St [ 0 ] == 0xff )
                {
                    RES_CHECK_BEGIN  = 1U;
                    DIAG_BUFER [ 0 ] = 0x22;
                    DIAG_BUFER [ 1 ] = Get_DID_High_Byte(FUEL_DID);
                    DIAG_BUFER [ 2 ] = Get_DID_Low_Byte(FUEL_DID);
                    UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 3);    //请求 燃油阻值
                }
            }*/
            
            
            #if 0
                DIAG_BUFER [ 0 ] = 0x2e;
                DIAG_BUFER [ 1 ] = 0x20;
                DIAG_BUFER [ 2 ] = 0x00;//07 07 F7 0B 

                DIAG_BUFER [ 3 ] = 0x4b;
                DIAG_BUFER [ 4 ] = 0x47;
                DIAG_BUFER [ 5 ] = 0xf7;
                DIAG_BUFER [ 6 ] = 0x6b;
                UDS_S_Data_Request(DIAG_ID_Tx, DIAG_BUFER, 7);    //
            #endif
            
            //loc_Step = 0;
            break;


    }

    if ( (UnLock_Flag == 1) || (UnLock_Flag == 3) )
    {
        if ( UnLock_Retry != 0 )
        {
            UnLock_Retry--;
        }
        else
        {
            if ( UnLock_Flag == 1 )
            {
                UnLock_Flag = 0u;
            }
            else if ( UnLock_Flag == 3 )
            {
                UnLock_Flag = 2;
            }
        }
    }
}
uint8_t LED_Waring = 0;
uint8_t flagtime=0;

void Function_Check_Ctrl(uint32_t cmd)
{
    uint8_t         p [ 20 ];
    uint8_t         DIAG_BUFER [ 40 ];
    uint32_t        i;
    uint32_t        j;
    static uint32_t status    = 0;
    static uint32_t MENU_BACK = 0xff;
    static uint8_t  UDS_EunD = 0;

    if ( cmd == 0 )
    {
        ;
    }
    else if(cmd == 1)
    {
        

        Display_Send_Vspead(MENU_CHECK_STEP);
        // Display_Send_Vspead(0);
        switch (MENU_CHECK_STEP)
        {
                case 0:       
            {   
                /*负控*/
                // LINE_OUT_NEG_01 = 0;
                // LINE_OUT_NEG_02 = 0;
                // LINE_OUT_NEG_03 = 0;
                // LINE_OUT_NEG_04 = 0;


                // LINE_OUT_NEG_05 = 0;
                // LINE_OUT_NEG_06 = 0;
                // LINE_OUT_NEG_07 = 0;
                // LINE_OUT_NEG_08 = 0;
                // LINE_OUT_NEG_09 = 0;   
                // LINE_OUT_NEG_10 = 0;
                // POWER_CTRL_KL30   = 1u;  //B+
                // POWER_CTRL_KL15   = 1u;  //KL15
                /*正控*/
                LINE_OUT_POS_02 = 0;        //远光
                LINE_FUEL_RES04111 = 0;        //左转
                LINE_FUEL_RES04222 = 0;        //右转
                LINE_OUT_POS_11 = 0;        //防盗
                LINE_OUT_POS_12 = 0;        //机油压力
                /*燃油*/
                FUEL_RES_1 = 0;
                FUEL_RES_2 = 0;
                FUEL_RES_3= 0;
                FUEL_RES_4 = 0;
                //温度
                FUEL_T_1=0;
                FUEL_T_2=0;
                FUEL_T_3=0;
                FUEL_T_4=0;
                LIN_Flag.LIN_LEFT_Flag=0;
                LIN_Flag.LIN_RIGHT_Flag=0;
                flagtime=0;
            
                break;
            }
            case 1:       
            {   
                /*负控*/
                // LINE_OUT_NEG_01 = 0;
                // LINE_OUT_NEG_02 = 0;
                // LINE_OUT_NEG_03 = 0;
                // LINE_OUT_NEG_04 = 0;


                // LINE_OUT_NEG_05 = 0;
                // LINE_OUT_NEG_06 = 0;
                // LINE_OUT_NEG_07 = 0;
                // LINE_OUT_NEG_08 = 0;
                // LINE_OUT_NEG_09 = 0;   
                // LINE_OUT_NEG_10 = 0;
                // POWER_CTRL_KL30   = 1u;  //B+
                // POWER_CTRL_KL15   = 1u;  //KL15
                /*正控*/
                LINE_OUT_POS_02 = 0;        //远光
                LINE_FUEL_RES04111 = 0;        //左转
                LINE_FUEL_RES04222 = 0;        //右转
                LINE_OUT_POS_11 = 0;        //防盗
                LINE_OUT_POS_12 = 0;        //机油压力
                /*燃油*/
                FUEL_RES_1 = 1;
                FUEL_RES_2 = 1;
                FUEL_RES_3= 0;
                FUEL_RES_4 = 0;
                //温度
                FUEL_T_1=0;
                FUEL_T_2=0;
                FUEL_T_3=0;
                FUEL_T_4=0;
                LIN_Flag.LIN_LEFT_Flag=0;
                LIN_Flag.LIN_RIGHT_Flag=0;
                flagtime=0;
            
                break;
            }
            case 2:
            {        
           
                /*负控*/
                // LINE_OUT_NEG_01 = 0;
                // LINE_OUT_NEG_02 = 0;
                // LINE_OUT_NEG_03 = 0;
                // LINE_OUT_NEG_04 = 0;


                // LINE_OUT_NEG_05 = 1;
                // LINE_OUT_NEG_06 = 1;
                // LINE_OUT_NEG_07 = 0;
                // LINE_OUT_NEG_08 = 0;
                // LINE_OUT_NEG_09 = 1;   
                // LINE_OUT_NEG_10 = 0;
                /*正控*/
                if(POWER_CTRL_KL15==1)
                {
                LINE_OUT_POS_02 = 0;        //远光
                LINE_FUEL_RES04111 = 0;        //左转
                LINE_FUEL_RES04222 = 0;        //右转
                LINE_OUT_POS_11 = 0;        //防盗
                LINE_OUT_POS_12 = 0;        //机油压力
                /*燃油5200,93,55,10*/
                 FUEL_RES_1 = 1;
                FUEL_RES_2 = 0;
                FUEL_RES_3 = 1;
                FUEL_RES_4 = 0;
                  //温度
                FUEL_T_1=0;
                FUEL_T_2=0;
                FUEL_T_3=0;
                FUEL_T_4=0;
            }
      
                break;
            } 
            case 3:
            {
                /*负控*/
                // LINE_OUT_NEG_01 = 0;
                // LINE_OUT_NEG_02 = 0;
                // LINE_OUT_NEG_03 = 0;
                // LINE_OUT_NEG_04 = 0;


                // LINE_OUT_NEG_05 = 1;
                // LINE_OUT_NEG_06 = 0;
                // LINE_OUT_NEG_07 = 0;
                // LINE_OUT_NEG_08 = 0;
                // LINE_OUT_NEG_09 = 1;   
                // LINE_OUT_NEG_10 = 0;
                /*正控*/
                if(POWER_CTRL_KL15==1)
                {
                LINE_OUT_POS_02 = 1;        //远光
                // if(LIN_Flag.LIN_RIGHT_Flag==0)
                // {
                     LINE_FUEL_RES04222 = 1;//右转
                     Gen_TimeDelay (200 *1000,50U);
                     LINE_FUEL_RES04222=0;
                    //  LIN_Flag.LIN_RIGHT_Flag++;
                // }
                 LINE_FUEL_RES04111 = 0;//左转
               
                LINE_OUT_POS_11 = 0;        //防盗
                LINE_OUT_POS_12 = 0;        //机油压力
                /*燃油*/
          FUEL_RES_1 = 0;//2格
                FUEL_RES_2 = 1;
                FUEL_RES_3= 1;
                FUEL_RES_4 = 0;
                  //温度
                FUEL_T_1=0;
                FUEL_T_2=1;
                FUEL_T_3=0;
                FUEL_T_4=0;
            }
                break;
            } 
            case 4:
            {
                // LINE_OUT_NEG_01 = 0;
                // LINE_OUT_NEG_02 = 0;
                // LINE_OUT_NEG_03 = 0;
                // LINE_OUT_NEG_04 = 0;                          


                // LINE_OUT_NEG_05 = 1;
                // LINE_OUT_NEG_06 = 0;
                // LINE_OUT_NEG_07 = 1;
                // LINE_OUT_NEG_08 = 0;
                // LINE_OUT_NEG_09 = 0;   
                // LINE_OUT_NEG_10 = 0;
                /*正控*/
                if(POWER_CTRL_KL15==1)
                {
                LINE_RESET=1;
                LINE_OUT_POS_02 = 0;        //远光

                // if(LIN_Flag.LIN_LEFT_Flag==0)
                // {
                     LINE_FUEL_RES04111 = 1;
                     Gen_TimeDelay ( 200 *1000,50U);
                     LINE_FUEL_RES04111=0;
                    //  LIN_Flag.LIN_LEFT_Flag++;
                // }
               
                LINE_FUEL_RES04222 = 0;//右转
                LINE_OUT_POS_11 = 1;        //防盗
                LINE_OUT_POS_12 = 1;        //机油压力
            //    flagtime ++;
            //     }
            //     if(flagtime==3)
            // {
            //    LIN_Flag.LIN_LEFT_Flag=0;
            //     LIN_Flag.LIN_RIGHT_Flag=0;
            // }
                // /*燃油*/
              FUEL_RES_1 = 1;//3格
                FUEL_RES_2 = 1;
                FUEL_RES_3= 1;
                FUEL_RES_4 = 0;
                  //温度
                FUEL_T_1=0;
                FUEL_T_2=0;
                FUEL_T_3=0;
                FUEL_T_4=0;
        }
                break;
            }   
            case 5:
            {
                // LINE_OUT_NEG_01 = 0;
                // LINE_OUT_NEG_02 = 0;
                // LINE_OUT_NEG_03 = 0;
                // LINE_OUT_NEG_04 = 0;


                // LINE_OUT_NEG_05 = 1;
                // LINE_OUT_NEG_06 = 0;
                // LINE_OUT_NEG_07 = 0;
                // LINE_OUT_NEG_08 = 0;
                // LINE_OUT_NEG_09 = 0;   
                // LINE_OUT_NEG_10 = 0;
                // /*正控*/
                // LINE_OUT_POS_01 = 0;
                // LINE_OUT_POS_02 = 0;
                // LINE_OUT_POS_03 = 1;
                // LINE_OUT_POS_04 = 0; 
                // LINE_OUT_POS_04 = 1;        //左转
                LINE_OUT_POS_02 = 0;        //远光
                   LINE_FUEL_RES04111 = 0;//左转
                LINE_FUEL_RES04222 = 0;//右转
                LINE_OUT_POS_11 = 0;        //防盗
                LINE_OUT_POS_12 = 0;        //机油压力
                /*燃油*/
                    // /*燃油*/
                 FUEL_RES_1 = 1;//4格
                FUEL_RES_2 = 0;
                FUEL_RES_3= 0;
                FUEL_RES_4 = 1;
                  //温度
                FUEL_T_1=0;
                FUEL_T_2=0;
                FUEL_T_3=0;
                FUEL_T_4=0;
                break;
            }
            case 6:
            {
                // LINE_OUT_NEG_01 = 0;
                // LINE_OUT_NEG_02 = 0;
                // LINE_OUT_NEG_03 = 1;
                // LINE_OUT_NEG_04 = 0;


                // LINE_OUT_NEG_05 = 1;
                // LINE_OUT_NEG_06 = 0;
                // LINE_OUT_NEG_07 = 0;
                // LINE_OUT_NEG_08 = 1;
                // LINE_OUT_NEG_09 = 0;   
                // LINE_OUT_NEG_10 = 1;
                // /*正控*/
                // LINE_OUT_POS_01 = 0;
                // LINE_OUT_POS_02 = 0;
                // LINE_OUT_POS_03 = 0;
                // LINE_OUT_POS_04 = 0; 
                LINE_OUT_POS_02 = 0;        //远光
                    LINE_FUEL_RES04111 = 0;//左转
                LINE_FUEL_RES04222 = 0;//右转
                LINE_OUT_POS_11 = 0;        //防盗
                LINE_OUT_POS_12 = 0;        //机油压力
                /*燃油*/
                    FUEL_RES_1 = 0;     //5格
                FUEL_RES_2 = 1;
                FUEL_RES_3 = 0;
                FUEL_RES_4 = 1;
                  //温度
                FUEL_T_1=0;
                FUEL_T_2=0;
                FUEL_T_3=0;
                FUEL_T_4=0;
         
                break;
            }
            // case 6:
            // {
            //     // LINE_OUT_NEG_01 = 0;
            //     // LINE_OUT_NEG_02 = 0;
            //     // LINE_OUT_NEG_03 = 0;
            //     // LINE_OUT_NEG_04 = 1;


            //     // LINE_OUT_NEG_05 = 1;
            //     // LINE_OUT_NEG_06 = 0;
            //     // LINE_OUT_NEG_07 = 0;
            //     // LINE_OUT_NEG_08 = 0;
            //     // LINE_OUT_NEG_09 = 0;   
            //     // LINE_OUT_NEG_10 = 1;
            //     // /*正控*/
            //     // LINE_OUT_POS_01 = 0;
            //     // LINE_OUT_POS_02 = 0;
            //     // LINE_OUT_POS_03 = 0;
            //     // LINE_OUT_POS_04 = 0; 
            //     LINE_OUT_POS_02 = 0;        //远光
            //     LINE_FUEL_RES04111 = 0;//左转
            //     LINE_FUEL_RES04222 = 0;//右转
            //     LINE_OUT_POS_11 = 0;        //防盗
            //     LINE_OUT_POS_12 = 0;        //机油压力
            //     /*燃油*/
            //     FUEL_RES_1 = 0;     //5格
            //     FUEL_RES_2 = 0;
            //     FUEL_RES_3 = 1;
            //     FUEL_RES_4 = 1;
            //     break;
            // }
            // case 7:
            // {
            //     // LINE_OUT_NEG_01 = 1;
            //     // LINE_OUT_NEG_02 = 0;
            //     // LINE_OUT_NEG_03 = 0;
            //     // LINE_OUT_NEG_04 = 0;


            //     // LINE_OUT_NEG_05 = 0;
            //     // LINE_OUT_NEG_06 = 1;
            //     // LINE_OUT_NEG_07 = 0;
            //     // LINE_OUT_NEG_08 = 0;
            //     // LINE_OUT_NEG_09 = 1;   
            //     // LINE_OUT_NEG_10 = 0;
            //     // /*正控*/
            //     // LINE_OUT_POS_01 = 0;
            //     // LINE_OUT_POS_02 = 0;
            //     // LINE_OUT_POS_03 = 0;
            //     // LINE_OUT_POS_04 = 0; 
            //     LINE_OUT_POS_02 = 0;        //远光
            //    LINE_FUEL_RES04111 = 0;//左转
            //     LINE_FUEL_RES04222 = 0;//右转
            //     LINE_OUT_POS_11 = 0;        //防盗
            //     LINE_OUT_POS_12 = 0;        //机油压力
            //     /*燃油*/
            //     FUEL_RES_1 = 0;     //5格
            //     FUEL_RES_2 = 0;
            //     FUEL_RES_3 = 1;
            //     FUEL_RES_4 = 1;
            //     break;
            // } 
            // case 8:
            // {
            //     // LINE_OUT_NEG_01 = 0;
            //     // LINE_OUT_NEG_02 = 1;
            //     // LINE_OUT_NEG_03 = 0;
            //     // LINE_OUT_NEG_04 = 0;


            //     // LINE_OUT_NEG_05 = 0;
            //     // LINE_OUT_NEG_06 = 0;
            //     // LINE_OUT_NEG_07 = 0;
            //     // LINE_OUT_NEG_08 = 0;
            //     // LINE_OUT_NEG_09 = 1;   
            //     // LINE_OUT_NEG_10 = 0;
            //     // /*正控*/
            //     // LINE_OUT_POS_01 = 0;
            //     // LINE_OUT_POS_02 = 0;
            //     // LINE_OUT_POS_03 = 0;
            //     // LINE_OUT_POS_04 = 0; 
            //     LINE_OUT_POS_02 = 0;        //远光
            //     LINE_FUEL_RES04111 = 0;//左转
            //     LINE_FUEL_RES04222 = 0;//右转
            //     LINE_OUT_POS_11 = 0;        //防盗
            //     LINE_OUT_POS_12 = 0;        //机油压力
            //     /*燃油*/
            //     FUEL_RES_1 = 0;     //5格
            //     FUEL_RES_2 = 0;
            //     FUEL_RES_3 = 1;
            //     FUEL_RES_4 = 1;
            //     break;
            // }
            case 7:
            {
                   LINE_FUEL_RES04111 = 1;        //左转
                 Gen_TimeDelay (100 *1000,50U);
                 LINE_FUEL_RES04111=0;
                // LINE_OUT_NEG_01 = 0;
                // LINE_OUT_NEG_02 = 0;
                // LINE_OUT_NEG_03 = 0;
                // LINE_OUT_NEG_04 = 0;


                // LINE_OUT_NEG_05 = 0;
                // LINE_OUT_NEG_06 = 0;
                // LINE_OUT_NEG_07 = 1;
                // LINE_OUT_NEG_08 = 0;
                // LINE_OUT_NEG_09 = 0;   
                // LINE_OUT_NEG_10 = 0;
                /*正控*/
                LINE_OUT_POS_02 = 1;        //远光
              
                LINE_OUT_POS_11 = 1;        //防盗
                LINE_OUT_POS_12 = 1;        //机油压力
                /*燃油*/
                FUEL_RES_1 = 1;     //5格
                FUEL_RES_2 = 1;
                FUEL_RES_3 = 1;
                FUEL_RES_4 = 1;
                 FUEL_T_1=0;
                FUEL_T_2=1;
                FUEL_T_3=0;
                FUEL_T_4=0;
                  LINE_FUEL_RES04222 = 1;        //右转
                Gen_TimeDelay (100 *1000,50U);
                LINE_FUEL_RES04222=0;
                break;
            }
            case 8:
            {
                LINE_OUT_POS_02 = 1;        //远光
                LINE_OUT_POS_04 = 0;        //左转
                LINE_OUT_POS_01 = 0;        //右转
                LINE_OUT_POS_11 = 0;        //防盗
                LINE_OUT_POS_12 = 0;        //机油压力
                // POWER_CTRL_KL30   = 0u;     //B+
                // POWER_CTRL_KL15   = 0u;     //KL15
                 FUEL_T_1=0;
                FUEL_T_2=0;
                FUEL_T_3=0;
                FUEL_T_4=0;
                break;
            }
            case 9:
                    LINE_OUT_POS_02 = 0;        //远光
                LINE_OUT_POS_04 = 0;        //左转
                LINE_OUT_POS_01 = 0;        //右转
                LINE_OUT_POS_11 = 0;        //防盗
                LINE_OUT_POS_12 = 0;        //机油压力
                // POWER_CTRL_KL30   = 0u;     //B+
                // POWER_CTRL_KL15   = 0u;     //KL15
                 FUEL_T_1=0;
                FUEL_T_2=0;
                FUEL_T_3=0;
                FUEL_T_4=0;
            break;
        } 
        
       
    }
}


void Get_ODO_Call(void)
{
}
