#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>0.747&&RValue<0.913) { R_GUNState = DC_GUN; } else if(RValue < 3.8f && RValue>0.1) { R_GUNState = AC_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; }