Data_CoolantTemperature.c 5.15 KB
Newer Older
hu's avatar
hu committed
1 2 3 4
#include "Data_CoolantTemperature.h"
#include "CAN_Communication_Matrix.h"
#include "GaugesInterface.h"
#include "GPIO.h"
hu's avatar
hu committed
5 6 7 8

#include "DisplaySch_user.h"
#include "DispSch.h"

hu's avatar
hu committed
9
//-------------------------------------------
hu's avatar
hu committed
10
//水温数据处理
hu's avatar
hu committed
11 12 13
//-------------------------------------------
//断码显示
//-------------------------------------------
hu's avatar
hu committed
14
//344 - 3.1.1.  水温计显示
hu's avatar
hu committed
15 16 17
//-------------------------------------------
static struct
{
hu's avatar
hu committed
18 19 20 21
    uint8_t Value ;
    uint8_t Valid ;
    uint8_t CurSeg ;
} CoolantVariable ;
hu's avatar
hu committed
22

hu's avatar
hu committed
23
static uint8_t CalCoolant_CurSeg(uint8_t Valid, uint8_t Temp);
hu's avatar
hu committed
24 25 26 27 28 29 30 31 32 33
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_KL30_Init
 * Description    : 水温KL30初始化
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
void Coolant_KL30_Init(void)
{
hu's avatar
hu committed
34 35 36
    CoolantVariable.Valid = 0 ;
    CoolantVariable.Value = 0 ;
    CoolantVariable.CurSeg = 0 ;
hu's avatar
hu committed
37 38 39 40

}
void Coolant_KL15_ON_Init(void)
{
hu's avatar
hu committed
41 42 43
    CoolantVariable.Valid = 0 ;
    CoolantVariable.Value = 0 ;
    CoolantVariable.CurSeg = 0 ;
hu's avatar
hu committed
44 45 46
}
void Coolant_KL15_OFF_Init(void)
{
hu's avatar
hu committed
47 48 49
    CoolantVariable.Valid = 0 ;
    CoolantVariable.Value = 0 ;
    CoolantVariable.CurSeg = 0 ;
hu's avatar
hu committed
50 51 52
}
void Coolant_Wakeup_Init(void)
{
hu's avatar
hu committed
53 54 55
    CoolantVariable.Valid = 0 ;
    CoolantVariable.Value = 0 ;
    CoolantVariable.CurSeg = 0 ;
hu's avatar
hu committed
56 57 58
}
void Coolant_Sleep_Init(void)
{
hu's avatar
hu committed
59 60 61
    CoolantVariable.Valid = 0 ;
    CoolantVariable.Value = 0 ;
    CoolantVariable.CurSeg = 0 ;
hu's avatar
hu committed
62 63 64 65 66 67 68 69 70 71 72
}
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_Processing_Service
 * Description    : 水温
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
void Coolant_Processing_Service(void)
{
hu's avatar
hu committed
73 74
    static uint8_t Timer2s = 0 ;
    uint8_t TargetSeg = 0 ;
hu's avatar
hu committed
75 76
    uint8_t Msg_CoolTemp = 0u ;
    uint8_t CanStatus = 0u;
hu's avatar
hu committed
77

hu's avatar
hu committed
78
    CanStatus = CAN_MSG_Status(ID_CanMsg18FEEE00_Msg_Count);
hu's avatar
hu committed
79

hu's avatar
hu committed
80
    if (CanStatus == CAN_SIG_LOST)
hu's avatar
hu committed
81 82
    {
        CoolantVariable.Valid = 0 ;
hu's avatar
hu committed
83
        CoolantVariable.Value = 0u;
hu's avatar
hu committed
84 85 86 87 88
        Timer2s = 0 ;
    }
    else
    {
        Msg_CoolTemp = Get_ID_18FEEE00_Sig_Engine_Coolant_Temperature();
hu's avatar
hu committed
89

hu's avatar
hu committed
90
        if (Msg_CoolTemp > 0xFAu)
hu's avatar
hu committed
91
        {
hu's avatar
hu committed
92 93
            CoolantVariable.Valid = 0u ;
            TargetSeg = 0u;
hu's avatar
hu committed
94 95 96 97
        }
        else
        {
            Timer2s = 0 ;
hu's avatar
hu committed
98
            CoolantVariable.Valid = 1u;
hu's avatar
hu committed
99

hu's avatar
hu committed
100 101 102 103 104 105 106 107
            if (Msg_CoolTemp >= 40)
            {
                CoolantVariable.Value = Msg_CoolTemp - 40u;
            }
            else
            {
                CoolantVariable.Value  = 0u;
            }
hu's avatar
hu committed
108 109 110
        }
    }

hu's avatar
hu committed
111
    CoolantVariable.CurSeg = CalCoolant_CurSeg(CoolantVariable.Valid, CoolantVariable.Value);
hu's avatar
hu committed
112 113 114 115 116 117 118 119 120
}
/*-------------------------------------------------------------------------
 * Function Name  : CalCoolant_CurSeg
 * Description    : 计算当前段
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
hu's avatar
hu committed
121
static uint8_t CalCoolant_CurSeg(uint8_t Valid, uint8_t Temp)
hu's avatar
hu committed
122
{
hu's avatar
hu committed
123
    uint8_t u8Result = 0u;
hu's avatar
hu committed
124

hu's avatar
hu committed
125 126 127 128 129 130 131 132 133 134
    if (Valid)
    {
        SetGaugesPara(TempGauges, Temp);
        u8Result = GetGaugesCurrentPos(TempGauges) ;
    }
    else
    {
        //范围外/CAN中断
        u8Result = 0 ;
    }
hu's avatar
hu committed
135

hu's avatar
hu committed
136
    return u8Result ;
hu's avatar
hu committed
137 138 139 140 141 142 143 144 145 146 147 148
}
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_Get_ActualValue
 * Description    : 水温值.结果带偏移 - 40
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
uint8_t Coolant_Get_ActualValue(void)
{
    uint8_t u8Result = 0u;
hu's avatar
hu committed
149
    u8Result = CoolantVariable.Value ;
hu's avatar
hu committed
150 151 152 153
    return u8Result;
}
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_Get_Valid
hu's avatar
hu committed
154
 * Description    :
hu's avatar
hu committed
155 156 157 158 159 160 161 162
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
uint8_t Coolant_Get_Valid(void)
{
    uint8_t u8Result = 0u;
hu's avatar
hu committed
163
    u8Result = CoolantVariable.Valid ;
hu's avatar
hu committed
164 165 166 167 168 169 170 171 172 173 174 175 176
    return u8Result;
}
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_Get_CurSeg
 * Description    : 水温当前段
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
uint8_t Coolant_Get_CurSeg(void)
{
    uint8_t u8Result = 0u;
hu's avatar
hu committed
177 178 179 180 181 182 183 184 185 186 187 188
    UElib_uint16_t HMI_MENU_Sta = 0u;

    HMI_MENU_Sta = Get_Cur_HMI();

    if (HMI_MENU_Sta != Display_StartAnimation)
    {
        u8Result = CoolantVariable.CurSeg ;
    }
    else
    {
        u8Result = 0;
    }
hu's avatar
hu committed
189
    return u8Result;
hu's avatar
hu committed
190
}