CELIS/APPLICATION/GUNDiscriminate/GUNDiscriminate.c
lidun b61c21c648
修改任务优先级
Signed-off-by: lidun <1084178170@qq.com>
2024-03-02 09:58:11 +08:00

100 lines
2.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "GUNDiscriminate.h"
#include "adc.h"
#include "stdio.h"
#include "Filtering.h"
#include "CDZ_State.h"
#include "SecTimer.h"
#include "CDZ_DATA.h"
enum GUNState This_GUNState = NO_GUN;
enum GUNState Get_R_GUNState(float RValue)
{
enum GUNState R_GUNState = NO_GUN;
static enum GUNState last_GUNState = NO_GUN;
// if(RValue>5.5f)
// {
// R_GUNState = NO_GUN;
// printf("g=%d\r\n",R_GUNState);
// printf("r=%f\r\n",RValue);
// return NO_GUN;
// }
// printf("r=%f\r\n",RValue);
enum BMS_OncConSt OBC_Connect = BMSDefaultParameters.parenr->Get_Car_OncConSt_Status(BMSDefaultParameters.parenr);
switch(This_GUNState)
{
case NO_GUN:
if(RValue < 3.8f && RValue>0.01 && SysInfo.Enter_AC_State_count < 2)
{
R_GUNState = AC_GUN;
}
else if(RValue < 1.5f && RValue>0.7f && SysInfo.Enter_AC_State_count >= 2)
{
R_GUNState = DC_GUN;
}
else if(RValue>4.0f && RValue < 6.0f)
{
R_GUNState = DC_adapter;
}
else
{
if(OBC_Connect != No_connect){ //只要OBC识别到插枪就清除计数值不管它是什么枪
SysInfo.Enter_AC_State_count = 0;
}
R_GUNState = NO_GUN;
}
break;
case AC_GUN:
if(RValue < 3.8f && RValue>0.01)
{
R_GUNState = AC_GUN;
}
else
{
R_GUNState = NO_GUN;
}
break;
case DC_adapter:
if(RValue < 1.5f && RValue>0.01f)
{
R_GUNState = DC_GUN;
}
else if(RValue>4.0f && RValue < 6.0f)
{
R_GUNState = DC_adapter;
}
else
{
R_GUNState = NO_GUN;
}
break;
case DC_GUN:
if(RValue < 1.5f && RValue>0.01)
{
R_GUNState = DC_GUN;
}
else if(RValue>4.0f && RValue < 7.0f)
{
R_GUNState = DC_adapter;
}
else
{
R_GUNState = NO_GUN;
}
break;
default:
R_GUNState = NO_GUN;
break;
}
This_GUNState = FilteringScan(&ContinuousFiltering[CC2_R_Filter],&R_GUNState);
// printf("g=%d\r\n",This_GUNState);
return This_GUNState;
}