7a7daad23a
Signed-off-by: lidun <1084178170@qq.com>
117 lines
2.2 KiB
C
117 lines
2.2 KiB
C
#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 < 1.5f && RValue>0.7f && OBC_Connect == No_connect)
|
|
{
|
|
R_GUNState = DC_GUN;
|
|
}
|
|
else if(RValue < 3.8f && RValue>0.01)
|
|
{
|
|
R_GUNState = AC_GUN;
|
|
}
|
|
else if(RValue>4.0f && RValue < 6.0f)
|
|
{
|
|
R_GUNState = DC_adapter;
|
|
}
|
|
else{
|
|
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 && OBC_Connect == No_connect)
|
|
{
|
|
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;
|
|
|
|
}
|
|
// static uint32_t GUNFLAGCount = 0;
|
|
//
|
|
// if(R_GUNState != last_GUNState)
|
|
// {
|
|
// GUNFLAGCount = 0;
|
|
// last_GUNState = R_GUNState;
|
|
// }
|
|
// else if(R_GUNState == This_GUNState)
|
|
// {
|
|
// GUNFLAGCount = 0;
|
|
// }
|
|
// else
|
|
// {
|
|
// GUNFLAGCount++;
|
|
// if(GUNFLAGCount >=40)
|
|
// {
|
|
// This_GUNState = last_GUNState;
|
|
// GUNFLAGCount = 0;
|
|
// }
|
|
// }
|
|
This_GUNState = FilteringScan(&ContinuousFiltering[CC2_R_Filter],&R_GUNState);
|
|
// printf("g=%d\r\n",This_GUNState);
|
|
return This_GUNState;
|
|
}
|
|
|
|
|
|
|