Data_CoolantTemperature.c 6.16 KB
Newer Older
hu's avatar
hu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
#include "Data_CoolantTemperature.h"
#include "CAN_Communication_Matrix.h"
#include "GaugesInterface.h"
#include "GPIO.h"
//-------------------------------------------
//水温数据处理 wangboyu
//-------------------------------------------
//断码显示
//-------------------------------------------
//344 - 3.1.1.	水温计显示
//-------------------------------------------
static struct
{
	uint8_t Value ;
	uint8_t Valid ;
	uint8_t CurSeg ;
}CoolantVariable ;

static uint8_t CalCoolant_CurSeg(uint8_t Valid,uint8_t Temp);
static uint8_t CalCoolant_TarSeg(uint16_t CanMsg);
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_KL30_Init
 * Description    : 水温KL30初始化
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
void Coolant_KL30_Init(void)
{
	CoolantVariable.Valid = 0 ;
	CoolantVariable.Value = 0 ;
	CoolantVariable.CurSeg = 0 ;

}
void Coolant_KL15_ON_Init(void)
{
	CoolantVariable.Valid = 0 ;
	CoolantVariable.Value = 0 ;
	CoolantVariable.CurSeg = 0 ;
}
void Coolant_KL15_OFF_Init(void)
{
	CoolantVariable.Valid = 0 ;
	CoolantVariable.Value = 0 ;
	CoolantVariable.CurSeg = 0 ;
}
void Coolant_Wakeup_Init(void)
{
	CoolantVariable.Valid = 0 ;
	CoolantVariable.Value = 0 ;
	CoolantVariable.CurSeg = 0 ;
}
void Coolant_Sleep_Init(void)
{
	CoolantVariable.Valid = 0 ;
	CoolantVariable.Value = 0 ;
	CoolantVariable.CurSeg = 0 ;
}
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_Processing_Service
 * Description    : 水温
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
static uint8_t wbyTestSeg = 0 ;
void Coolant_Processing_Service(void)
{
	static uint8_t Timer2s = 0 ;

	uint8_t TargetSeg = 0 ;

	uint8_t Msg_CoolTemp = 0 ;

	if(CAN_MSG_Status(ID_CanMsg18FEEE00_Msg_Count) == 0x55u)
	{//timeout
		CoolantVariable.Valid = 0 ;
		Timer2s = 0 ;
	}
	else
	{
		Msg_CoolTemp = Get_ID_18FEEE00_Sig_Engine_Coolant_Temperature();
		
		if(Msg_CoolTemp > 0xFA)
		{
			//if(Timer2s  < 100)
			//{
			//	Timer2s ++ ;
			//}
			//else
			{
				CoolantVariable.Valid = 0 ;
			}			
		}
		else
		{
			Timer2s = 0 ;
			CoolantVariable.Valid = 1 ;
			CoolantVariable.Value = Msg_CoolTemp ;

			TargetSeg = CalCoolant_TarSeg(Msg_CoolTemp);			
		}
	}

	if(Msg_CoolTemp < 40)
	{
		Msg_CoolTemp = 0 ;
	}
	else
	{
		Msg_CoolTemp -= 40 ;
	}
	//CoolantVariable.CurSeg = CalCoolant_CurSeg(CoolantVariable.Valid,Msg_CoolTemp);
	//TargetSeg - 目标段
	//CoolantVariable.Valid - 有效值
	//CoolantVariable.CurSeg - 当前段
	CoolantVariable.CurSeg = Coolant_Temp_Filter(TargetSeg, CoolantVariable.Valid);
	
}
/*-------------------------------------------------------------------------
 * Function Name  : CalCoolant_TarSeg
 * Description    : 根据有效报文 得到 目标格
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
static uint8_t CalCoolant_TarSeg(uint16_t CanMsg)
{
	uint8_t TargetSeg = 0 ;
	if(CanMsg >= 0x00 && CanMsg <= 0x59)
	{
		TargetSeg = 0 ;
	}
	if(CanMsg >= 0x5A && CanMsg <= 0x5E)
	{
		TargetSeg = 1 ;
	}
	if(CanMsg >= 0x5F && CanMsg <= 0x64)
	{
		TargetSeg = 2 ;
	}
	if(CanMsg >= 0x65 && CanMsg <= 0x69)
	{
		TargetSeg = 3 ;
	}
	if(CanMsg >= 0x6A && CanMsg <= 0x6F)
	{
		TargetSeg = 4 ;
	}
	if(CanMsg >= 0x70 && CanMsg <= 0x74)
	{
		TargetSeg = 5 ;
	}
	if(CanMsg >= 0x75 && CanMsg <= 0x8D)
	{
		TargetSeg = 6 ;
	}
	if(CanMsg >= 0x8E && CanMsg <= 0x8F)
	{
		TargetSeg = 7 ;
	}
	if(CanMsg >= 0x90 && CanMsg <= 0x91)
	{
		TargetSeg = 8 ;
	}
	if(CanMsg >= 0x92 && CanMsg <= 0x93)
	{
		TargetSeg = 9 ;
	}
	if(CanMsg >= 0x94 && CanMsg <= 0x95)
	{
		TargetSeg = 10 ;
	}
	if(CanMsg == 0x96)
	{
		TargetSeg = 11 ;
	}
	if(CanMsg >= 0x97)
	{
		TargetSeg = 12 ;
	}

	return TargetSeg ;
}
/*-------------------------------------------------------------------------
 * Function Name  : CalCoolant_CurSeg
 * Description    : 计算当前段
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
static uint8_t CalCoolant_CurSeg(uint8_t Valid,uint8_t Temp)
{
	uint8_t u8Result = 0u;

	if(Valid)
	{	
		SetGaugesPara(TempGauges,Temp);	
		u8Result = GetGaugesCurrentPos(TempGauges) ;
	}
	else
	{
		//范围外/CAN中断
		u8Result = 0 ;
	}

	return u8Result ;
}
/*-------------------------------------------------------------------------
 * 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;
	u8Result = CoolantVariable.Value ;
    return u8Result;
}
/*-------------------------------------------------------------------------
 * Function Name  : Coolant_Get_Valid
 * Description    : 
 * Input          : None
 * Output         : None
 * Return         : None
 * onther         : None
 --------------------------------------------------------------------------*/
uint8_t Coolant_Get_Valid(void)
{
    uint8_t u8Result = 0u;
	u8Result = CoolantVariable.Valid ;
    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;
	u8Result = CoolantVariable.CurSeg ;
    return u8Result;
}