2024-01-30 03:31:27 +00:00
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include "stm32f10x_rtc.h"
|
|
|
|
|
|
|
|
|
|
#include "CDZ_State.h"
|
|
|
|
|
#include "adc.h"
|
|
|
|
|
#include "KC.h"
|
|
|
|
|
#include "can.h"
|
|
|
|
|
#include "CDZ_DATA.h"
|
|
|
|
|
#include "Err_code.h"
|
|
|
|
|
#include "Err_Info_Process.h"
|
|
|
|
|
#include "SecTimer.h"
|
|
|
|
|
#include "kC_Features.h"
|
|
|
|
|
|
|
|
|
|
CDZ_Sys CDZ_SYS;
|
|
|
|
|
Dcu_State DCU_SendState;
|
|
|
|
|
extern CanRxMsg BMSCAN1Msg;
|
|
|
|
|
struct New_CDZ CDZ_New={0};
|
|
|
|
|
|
|
|
|
|
void Charging_message_sending(void);
|
|
|
|
|
bool StopChargeProcessing(void);
|
|
|
|
|
|
|
|
|
|
static State handleIdleEvent(Event event);
|
|
|
|
|
static State handleInitEvent(Event event);
|
|
|
|
|
static State handleHandEvent(Event event);
|
|
|
|
|
static State handleReadyEvent(Event event);
|
|
|
|
|
static State handleStartEvent(Event event);
|
|
|
|
|
static State handleRunningEvent(Event event);
|
|
|
|
|
static State handleStopEvent(Event event);
|
|
|
|
|
static State handleAC_ChargeEvent(Event event);
|
|
|
|
|
|
|
|
|
|
static void handleIdleState(void);
|
|
|
|
|
static void handleInitState(void);
|
|
|
|
|
static void handleHandState(void);
|
|
|
|
|
static void handleReadyState(void);
|
|
|
|
|
static void handleStartState(void);
|
|
|
|
|
static void handleRunningState(void);
|
|
|
|
|
static void handleStoppedState(void);
|
|
|
|
|
static void handleAC_ChargeState(void);
|
|
|
|
|
|
|
|
|
|
static Event getIdleEvent(void);
|
|
|
|
|
static Event getInitEvent(void);
|
|
|
|
|
static Event getHandEvent(void);
|
|
|
|
|
static Event getReadyEvent(void);
|
|
|
|
|
static Event getStartEvent(void);
|
|
|
|
|
static Event getRunningEvent(void);
|
|
|
|
|
static Event getStopEvent(void);
|
|
|
|
|
static Event getACChagreEvent(void);
|
|
|
|
|
State CDZ_STATE_T1(Event event);
|
|
|
|
|
State CDZ_STATE_T2(Event event);
|
|
|
|
|
State CDZ_STATE_T3(Event event);
|
|
|
|
|
State CDZ_STATE_T4(Event event);
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T5(Event event);
|
|
|
|
|
State CDZ_STATE_T6(Event event);
|
|
|
|
|
State CDZ_STATE_T7(Event event);
|
|
|
|
|
State CDZ_STATE_T8(Event event);
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T9(Event event);
|
|
|
|
|
State CDZ_STATE_T10(Event event);
|
|
|
|
|
State CDZ_STATE_T11(Event event);
|
|
|
|
|
State CDZ_STATE_T12(Event event); //<2F>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T13(Event event);
|
|
|
|
|
State CDZ_STATE_T14(Event event);
|
|
|
|
|
State CDZ_STATE_T15(Event event);
|
|
|
|
|
State CDZ_STATE_T16(Event event);
|
|
|
|
|
// ״̬<D7B4><CCAC> 3 2 ״̬ת<CCAC><D7AA>
|
|
|
|
|
TransitionFunction stateTable[STATE_NUM][EVENT_NUM] = {
|
|
|
|
|
{handleIdleEvent, CDZ_STATE_T1,CDZ_STATE_T15,NULL,NULL,NULL},
|
|
|
|
|
{handleInitEvent, CDZ_STATE_T2,CDZ_STATE_T13,NULL,NULL,NULL},
|
|
|
|
|
{handleHandEvent, CDZ_STATE_T3,CDZ_STATE_T13,CDZ_STATE_T14,NULL,NULL},
|
|
|
|
|
{handleReadyEvent, CDZ_STATE_T4,CDZ_STATE_T9,CDZ_STATE_T13,CDZ_STATE_T14,NULL},
|
|
|
|
|
{handleStartEvent, CDZ_STATE_T5,CDZ_STATE_T10,CDZ_STATE_T11,CDZ_STATE_T14,CDZ_STATE_T13},
|
|
|
|
|
{handleRunningEvent, CDZ_STATE_T6,CDZ_STATE_T8,CDZ_STATE_T12,NULL,NULL},
|
|
|
|
|
{handleStopEvent, CDZ_STATE_T7,NULL,NULL,NULL,NULL},
|
|
|
|
|
{handleAC_ChargeEvent, CDZ_STATE_T16,NULL,NULL,NULL,NULL},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// <20>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ״̬<D7B4><CCAC><EFBFBD><EFBFBD>
|
|
|
|
|
ActionFunction actionTable[STATE_NUM] = {
|
|
|
|
|
handleIdleState,
|
|
|
|
|
handleInitState,
|
|
|
|
|
handleHandState,
|
|
|
|
|
handleReadyState,
|
|
|
|
|
handleStartState,
|
|
|
|
|
handleRunningState,
|
|
|
|
|
handleStoppedState,
|
|
|
|
|
handleAC_ChargeState,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
//<2F>¼<EFBFBD>ת<EFBFBD><D7AA>
|
|
|
|
|
EventFun EventTable[STATE_NUM] = {
|
|
|
|
|
getIdleEvent,
|
|
|
|
|
getInitEvent,
|
|
|
|
|
getHandEvent,
|
|
|
|
|
getReadyEvent,
|
|
|
|
|
getStartEvent,
|
|
|
|
|
getRunningEvent,
|
|
|
|
|
getStopEvent,
|
|
|
|
|
getACChagreEvent,
|
|
|
|
|
};
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫһһ<D2BB><D2BB>Ӧ<EFBFBD><D3A6>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Event getNextEvent(void)
|
|
|
|
|
{
|
|
|
|
|
return EVENT_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct CDZ_Sys SysInfo = {
|
|
|
|
|
.This_State = STATE_IDLE,
|
|
|
|
|
};//<2F><><EFBFBD><EFBFBD>ϵͳ<CFB5><CDB3>Ϣ
|
|
|
|
|
void AppCtrOnoffHandle(void)
|
|
|
|
|
{
|
|
|
|
|
DCDC_emergency_stop();
|
|
|
|
|
|
|
|
|
|
actionTable[SysInfo.This_State](); // <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
Event event = EventTable[SysInfo.This_State](); // <20><>ȡ<EFBFBD><C8A1>һ<EFBFBD><D2BB><EFBFBD>¼<EFBFBD>
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬ת<CCAC><D7AA>
|
|
|
|
|
TransitionFunction transition = stateTable[SysInfo.This_State][event]; //<2F><>ȡָ<C8A1><D6B8>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ij<EFBFBD><C4B3>ʱ<EFBFBD>佫
|
|
|
|
|
if (transition != NULL) {
|
|
|
|
|
SysInfo.This_State = transition(event);//ת<><D7AA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*<2A>¼<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>IDLE״̬<D7B4>µIJ<C2B5><C4B2><EFBFBD>
|
|
|
|
|
void handleIdleState(void)
|
|
|
|
|
{
|
|
|
|
|
// IDLE״̬<D7B4>µIJ<C2B5><C4B2><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
|
|
CDZ_Idle("IDLE״̬\r\n");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleInitState(void)
|
|
|
|
|
{
|
|
|
|
|
// Init״̬<D7B4>µIJ<C2B5><C4B2><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
|
|
CDZ_Init("Init״̬\r\n");
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void handleHandState(void)
|
|
|
|
|
{
|
|
|
|
|
// hand״̬<D7B4>µIJ<C2B5><C4B2><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
CDZ_HAND("Hand״̬\r\n");
|
|
|
|
|
|
|
|
|
|
if((CDZ_ChargeInfo.BmsRcvCode & D_CDZ_HANDING_CHM)!= 0)
|
|
|
|
|
{
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode = 0;
|
|
|
|
|
CDZ_SYS.GB_TYPE = GB2015;
|
|
|
|
|
bms_SendBHM(GetBHM_Vol());//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1><EFBFBD>
|
|
|
|
|
printf("D_CDZ_HANDING_CHM\r\n");
|
|
|
|
|
}
|
|
|
|
|
else if(TickOut(&CDZ_SYS.CHM_timer_count,3000))
|
|
|
|
|
{
|
|
|
|
|
printf("NO Handshake Signal\n\r");
|
|
|
|
|
TickOut(&CDZ_SYS.CHM_timer_count, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define STATE_0 0
|
|
|
|
|
#define STATE_1 1
|
|
|
|
|
#define STATE_2 2
|
|
|
|
|
|
|
|
|
|
typedef void (*Frame_Send)(uint16_t step);
|
|
|
|
|
|
|
|
|
|
void Frame_Send_1(Frame_Send SendData,uint8_t PGN)
|
|
|
|
|
{
|
|
|
|
|
if(TickOut(&CDZ_New.timer[CC_CHARGE_READY_timer], 100)==true)
|
|
|
|
|
{
|
|
|
|
|
SendData(1);
|
|
|
|
|
BMSCAN1Msg.Data[0]=0;
|
|
|
|
|
BMSCAN1Msg.ExtId =0;
|
|
|
|
|
TickOut(&CDZ_New.timer[CC_CHARGE_READY_timer], 0);
|
|
|
|
|
}
|
|
|
|
|
if((BMSCAN1Msg.Data[0]==0x11)&&(BMSCAN1Msg.Data[6]==PGN) &&(BMSCAN1Msg.ExtId & 0xFFFF0000) == CAN_CM_CTRL_ID )
|
|
|
|
|
{
|
|
|
|
|
BMSCAN1Msg.Data[0]=0;
|
|
|
|
|
BMSCAN1Msg.ExtId =0;
|
|
|
|
|
CDZ_SYS.identifystep=STATE_1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Frame_Send_2(Frame_Send SendData)
|
|
|
|
|
{
|
|
|
|
|
SendData(2);
|
|
|
|
|
CDZ_SYS.identifystep=STATE_2;
|
|
|
|
|
TickOut(&CDZ_New.timer[CC_CHARGE_READY_timer1], 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Frame_Send_3(uint8_t PGN)
|
|
|
|
|
{
|
|
|
|
|
if((BMSCAN1Msg.Data[0]==0x13)&&(BMSCAN1Msg.Data[6]==PGN) &&(BMSCAN1Msg.ExtId & 0xFFFF0000) == CAN_CM_CTRL_ID )
|
|
|
|
|
{
|
|
|
|
|
BMSCAN1Msg.Data[0]=0;
|
|
|
|
|
BMSCAN1Msg.ExtId =0;
|
|
|
|
|
CDZ_SYS.identifystep=STATE_0;
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode = 0;
|
|
|
|
|
}
|
|
|
|
|
if(TickOut(&CDZ_New.timer[CC_CHARGE_READY_timer1], 50)==true)
|
|
|
|
|
{
|
|
|
|
|
CDZ_SYS.identifystep=STATE_0;
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleReadyState(void)
|
|
|
|
|
{
|
|
|
|
|
// READY״̬<D7B4>µIJ<C2B5><C4B2><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
CDZ_Ready("READY״̬\r\n");
|
|
|
|
|
|
|
|
|
|
switch(CDZ_SYS.identifystep)
|
|
|
|
|
{
|
|
|
|
|
case STATE_0:Frame_Send_1(bms_SendBRM,0x02);break;
|
|
|
|
|
case STATE_1:Frame_Send_2(bms_SendBRM);break;
|
|
|
|
|
case STATE_2:Frame_Send_3(0x02);break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void handleStartState(void)
|
|
|
|
|
{
|
|
|
|
|
// START״̬<D7B4>µIJ<C2B5><C4B2><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
CDZ_STARTD("STARTD״̬\r\n");
|
|
|
|
|
|
|
|
|
|
uint8_t bmsBROstate = ({
|
|
|
|
|
uint8_t BRO_record = 0;
|
|
|
|
|
if(CDZ_ChargeInfo.REV_CML_FLAG == true\
|
|
|
|
|
&& Charging_Pile_Param() == true\
|
|
|
|
|
&& VCU_Charge_Condition() == Yes\
|
|
|
|
|
&& BMS_Charge_Condition() == true\
|
|
|
|
|
&& Send_BROAA_Condition() == Yes\
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
BRO_record = 0xAA;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
BRO_record = 0x0;
|
|
|
|
|
}
|
|
|
|
|
BRO_record;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if((CDZ_ChargeInfo.BmsRcvCode & D_CDZ_CONFIG_CML)!= 0 && CDZ_ChargeInfo.ready != 0XAA)
|
|
|
|
|
{
|
|
|
|
|
bms_SendBRO(bmsBROstate);
|
|
|
|
|
if(bmsBROstate == 0x00)
|
|
|
|
|
{
|
|
|
|
|
/*****δ<CEB4><D7BC><EFBFBD>õĴ<C3B5><C4B4><EFBFBD>*******/
|
|
|
|
|
CLOSE_DC_RELAY();
|
|
|
|
|
}
|
|
|
|
|
else if(READ_DC_YX2() == false)
|
|
|
|
|
{
|
|
|
|
|
/**********<2A>պ<EFBFBD>DC<44>̵<EFBFBD><CCB5><EFBFBD>*********/
|
|
|
|
|
OPEN_DC_RELAY();
|
|
|
|
|
}
|
|
|
|
|
//CDZ_ChargeInfo.BmsRcvCode &= ~D_CDZ_CONFIG_CML;
|
|
|
|
|
CDZ_ChargeInfo.REV_CML_FLAG = true;
|
|
|
|
|
}
|
|
|
|
|
else if(CDZ_ChargeInfo.REV_CML_FLAG == false)
|
|
|
|
|
{
|
|
|
|
|
switch(CDZ_SYS.identifystep)
|
|
|
|
|
{
|
|
|
|
|
case STATE_0:Frame_Send_1(bms_SendBCP,0x06);break;
|
|
|
|
|
case STATE_1:Frame_Send_2(bms_SendBCP);break;
|
|
|
|
|
case STATE_2:Frame_Send_3(0x06);break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if((CDZ_ChargeInfo.BmsRcvCode & D_CDZ_CONFIG_CTS)!= 0)
|
|
|
|
|
{
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode &= ~D_CDZ_CONFIG_CTS;
|
|
|
|
|
}
|
|
|
|
|
else if((CDZ_ChargeInfo.BmsRcvCode & D_CDZ_CONFIG_CRO)!= 0)
|
|
|
|
|
{
|
|
|
|
|
printf("CDZ_HANDING_CRM AA\n\r");
|
|
|
|
|
CDZ_ChargeInfo.BmsRcvCode &= ~D_CDZ_CONFIG_CRO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>RUNNING״̬<D7B4>µIJ<C2B5><C4B2><EFBFBD>
|
|
|
|
|
void handleRunningState(void)
|
|
|
|
|
{
|
|
|
|
|
// RUNNING״̬<D7B4>µIJ<C2B5><C4B2><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
CDZ_Running("RUNNING״̬\r\n");
|
|
|
|
|
Charging_message_sending();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>STOPPED״̬<D7B4>µIJ<C2B5><C4B2><EFBFBD>
|
|
|
|
|
void handleStoppedState(void)
|
|
|
|
|
{
|
|
|
|
|
// STOPPED״̬<D7B4>µIJ<C2B5><C4B2><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
CDZ_Stopped("STOPPED״̬\r\n");
|
|
|
|
|
CDZ_SYS.GB_TYPE = 0;
|
|
|
|
|
if(TickOut(&CDZ_New.timer[CHARGEING_timer], 50)==true)
|
|
|
|
|
{
|
|
|
|
|
bms_SendBST(0);
|
|
|
|
|
TickOut(&CDZ_New.timer[CHARGEING_timer], 0);
|
|
|
|
|
}
|
|
|
|
|
if(TickOut(&CDZ_New.timer[end_timer], 250)==true)
|
|
|
|
|
{
|
|
|
|
|
bms_SendBSD(0);
|
|
|
|
|
TickOut(&CDZ_New.timer[end_timer], 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>纯<EFBFBD><E7BAAF>
|
|
|
|
|
void handleAC_ChargeState(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><>ȡ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
Event getIdleEvent(void)
|
|
|
|
|
{
|
|
|
|
|
work_mode This_WorkState = Get_Sampl_Data.WorkMode();
|
|
|
|
|
// printf("e=%d\r\n",This_WorkState);
|
|
|
|
|
if(This_WorkState== DC_Charging)
|
|
|
|
|
{
|
|
|
|
|
if(BMSDefaultParameters.parenr->Get_Car_Working_Mode(BMSDefaultParameters.parenr) == DC_charge_mode)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n");
|
|
|
|
|
return EVENT_1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(This_WorkState == AC_Charging)
|
|
|
|
|
{
|
|
|
|
|
memset((char *)&SecTimer,0,sizeof(SecTimer));
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>뽻<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\r\n");
|
|
|
|
|
return EVENT_2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EVENT_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Event getInitEvent(void)
|
|
|
|
|
{
|
|
|
|
|
if((CDZ_ChargeInfo.BmsRcvCode & D_CDZ_HANDING_CHM)!= 0 || (CDZ_ChargeInfo.BmsRcvCode & D_CDZ_HANDING_CRM)!= 0)
|
|
|
|
|
{
|
|
|
|
|
ErrClearSequence();//<2F><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
memset((char *)&CDZ_ChargeInfo,0,sizeof(CDZ_ChargeInfo));
|
|
|
|
|
memset((char *)&SecTimer,0,sizeof(SecTimer));
|
|
|
|
|
return EVENT_1;
|
|
|
|
|
}
|
|
|
|
|
else if(Get_Sampl_Data.WorkMode() != DC_Charging)
|
|
|
|
|
{
|
|
|
|
|
return EVENT_2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EVENT_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Event getHandEvent(void)
|
|
|
|
|
{
|
|
|
|
|
if((CDZ_ChargeInfo.BmsRcvCode & D_CDZ_HANDING_CRM)!= 0 && CDZ_SYS.GB_TYPE == GB2015)
|
|
|
|
|
{
|
|
|
|
|
printf("BMS_PROTOCAL_GB2015\n\r");
|
|
|
|
|
return EVENT_1;
|
|
|
|
|
}
|
|
|
|
|
else if((CDZ_ChargeInfo.BmsRcvCode & D_CDZ_HANDING_CRM)!= 0)
|
|
|
|
|
{
|
|
|
|
|
CDZ_SYS.GB_TYPE = GB2011;
|
|
|
|
|
printf("BMS_PROTOCAL_GB2011\n\r");
|
|
|
|
|
return EVENT_1;
|
|
|
|
|
}
|
|
|
|
|
else if(Get_Sampl_Data.WorkMode() != DC_Charging)
|
|
|
|
|
{
|
|
|
|
|
return EVENT_2;
|
|
|
|
|
}
|
|
|
|
|
else if(SecStar(&SecTimer[Hand_SecTimerNUM],10))//10S<30>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>ֽ<D6BD>
|
|
|
|
|
{
|
|
|
|
|
SecStop(&SecTimer[Hand_SecTimerNUM]);
|
|
|
|
|
return EVENT_3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EVENT_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Event getReadyEvent(void)
|
|
|
|
|
{
|
|
|
|
|
if(CDZ_ChargeInfo.identify ==0xAA) //<2F><>ʶ<EFBFBD><CAB6>
|
|
|
|
|
{
|
|
|
|
|
printf("REV D_CDZ_HANDING_CRM AA\n\r");
|
|
|
|
|
return EVENT_1;
|
|
|
|
|
}
|
|
|
|
|
else if(REV_Pile_TimeOut()==false)
|
|
|
|
|
{
|
|
|
|
|
printf("Ready-State Received The Charging Pile Abort Message\n\r");
|
|
|
|
|
return EVENT_2;
|
|
|
|
|
}
|
|
|
|
|
else if(Get_Sampl_Data.WorkMode() != DC_Charging)
|
|
|
|
|
{
|
|
|
|
|
return EVENT_3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EVENT_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Event getStartEvent(void)
|
|
|
|
|
{
|
|
|
|
|
if(CDZ_ChargeInfo.ready == 0XAA)
|
|
|
|
|
{
|
|
|
|
|
printf("CDZ__CRO AA to Charging\n\r");
|
|
|
|
|
return EVENT_1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(REV_Pile_TimeOut()==false)
|
|
|
|
|
{
|
|
|
|
|
printf("Start-State Received The Charging Pile Abort Message\n\r");
|
|
|
|
|
return EVENT_3;
|
|
|
|
|
}
|
|
|
|
|
else if(Err_Read(40) == true\
|
|
|
|
|
|| Err_Read(6) == true\
|
|
|
|
|
|| Err_Read(28) == true\
|
|
|
|
|
|| Err_Read(33) == true\
|
|
|
|
|
|| Err_Read(9) == true\
|
|
|
|
|
|| Err_Read(10) == true\
|
|
|
|
|
|| Err_Read(38) == true\
|
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
//printf("Falut Code!!!!\n\r");
|
|
|
|
|
return EVENT_3;
|
|
|
|
|
}
|
|
|
|
|
else if(Get_Sampl_Data.WorkMode() != DC_Charging)
|
|
|
|
|
{
|
|
|
|
|
return EVENT_5;
|
|
|
|
|
}
|
|
|
|
|
// else if(SecStar(&SecTimer[Start2_SecTimerNUM],5) == true && VCU_Charge_Condition() == false)
|
|
|
|
|
// {
|
|
|
|
|
// SecStop(&SecTimer[Start2_SecTimerNUM]);
|
|
|
|
|
// printf("NO HV!!!\n\r");
|
|
|
|
|
// return EVENT_3;
|
|
|
|
|
// }
|
|
|
|
|
else if(SecStar(&SecTimer[Start1_SecTimerNUM],60))//60S<30>˳<EFBFBD><CBB3><EFBFBD><EFBFBD>ý<C3BD>
|
|
|
|
|
{
|
|
|
|
|
SecStop(&SecTimer[Start1_SecTimerNUM]);
|
|
|
|
|
return EVENT_4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EVENT_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Event getRunningEvent(void)
|
|
|
|
|
{
|
|
|
|
|
if(REV_Pile_TimeOut()==false)
|
|
|
|
|
{
|
|
|
|
|
printf("Running-State Received The Charging Pile Abort Message\n\r");
|
|
|
|
|
return EVENT_3;
|
|
|
|
|
}
|
|
|
|
|
else if(StopChargeProcessing() == false)
|
|
|
|
|
{
|
|
|
|
|
return EVENT_1;
|
|
|
|
|
}
|
|
|
|
|
// else if(Get_Sampl_Data.WorkMode() != DC_Charging)
|
|
|
|
|
// {
|
|
|
|
|
// return EVENT_3;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return EVENT_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Event getStopEvent(void)
|
|
|
|
|
{
|
|
|
|
|
if(SecStar(&SecTimer[Stop_SecTimerNUM],10))//10S<30>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
SecStop(&SecTimer[Stop_SecTimerNUM]);
|
|
|
|
|
return EVENT_1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EVENT_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Event getACChagreEvent(void)
|
|
|
|
|
{
|
|
|
|
|
uint8_t OncConSt_Status = BMSDefaultParameters.parenr->Get_Car_OncConSt_Status(BMSDefaultParameters.parenr);
|
|
|
|
|
// printf("CarWork %d\r\n",CarWork);
|
|
|
|
|
if(OncConSt_Status == No_connect && SecStar(&SecTimer[ACCharg_SecTimerNUM],2) == true)
|
|
|
|
|
{
|
|
|
|
|
SecStop(&SecTimer[ACCharg_SecTimerNUM]);
|
|
|
|
|
return EVENT_1;
|
|
|
|
|
}
|
|
|
|
|
else if(OncConSt_Status == Half_connect)//OBC<42><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɿ<EFBFBD><C9BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
{
|
|
|
|
|
SecStop(&SecTimer[ACCharg_SecTimerNUM]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return EVENT_0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*T <20><> Start */
|
|
|
|
|
State CDZ_STATE_T1(Event event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("T1\r\n");
|
|
|
|
|
/******<2A><>ʼ<EFBFBD><CABC>Ĭ<EFBFBD><C4AC>********/
|
|
|
|
|
CLOSE_DC_RELAY();
|
|
|
|
|
CLOSE_AC_RELAY();
|
|
|
|
|
CLOSE_CC2_CC_RELAY();
|
|
|
|
|
OPEN_CC1_CP_RELAY();
|
|
|
|
|
/***********************/
|
|
|
|
|
return STATE_INIT;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T2(Event event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("T2\r\n");
|
|
|
|
|
OPEN_CC1_CP_RELAY();//<2F>л<EFBFBD><D0BB><EFBFBD>CC1<43><31><EFBFBD>ó<EFBFBD><C3B3><EFBFBD>ʶ<D7AE><CAB6><EFBFBD><EFBFBD>ǹ
|
|
|
|
|
return STATE_HAND;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T3(Event event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("T3\r\n");
|
|
|
|
|
return STATE_READY;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T4(Event event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
CDZ_ChargeInfo.REV_CML_FLAG = false;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ýΰѱ<CEB0>־λ<D6BE><CEBB><EFBFBD><EFBFBD>
|
|
|
|
|
printf("T4\r\n");
|
|
|
|
|
return STATE_START;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T5(Event event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("T5\r\n");
|
|
|
|
|
return STATE_RUNNING;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T6(Event event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("T6\r\n");
|
|
|
|
|
return STATE_STOPPED;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T7(Event event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("T7\r\n");
|
|
|
|
|
CLOSE_DC_RELAY();
|
|
|
|
|
OPEN_AC_RELAY();
|
|
|
|
|
CLOSE_CC1_CP_RELAY();
|
|
|
|
|
return STATE_IDLE;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T8(Event event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("T8\r\n");
|
|
|
|
|
return STATE_HAND;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T9(Event event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("T9\r\n");
|
|
|
|
|
return STATE_HAND;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T10(Event event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("T10\r\n");
|
|
|
|
|
return STATE_HAND;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
State CDZ_STATE_T11(Event event)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("T11\r\n");
|
|
|
|
|
return STATE_STOPPED;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
State CDZ_STATE_T12(Event event) //<2F>쳣<EFBFBD><ECB3A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("T12\r\n");
|
|
|
|
|
return STATE_STOPPED;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
State CDZ_STATE_T13(Event event) //δ<><CEB4>ֱ<EFBFBD><D6B1>ת<EFBFBD><D7AA>ͷ
|
|
|
|
|
{
|
|
|
|
|
printf("T13\r\n");
|
|
|
|
|
CLOSE_DC_RELAY();
|
|
|
|
|
return STATE_IDLE;
|
|
|
|
|
}
|
|
|
|
|
State CDZ_STATE_T14(Event event) //<2F><><EFBFBD><EFBFBD><EFBFBD>γ<D7B6>ʱ
|
|
|
|
|
{
|
|
|
|
|
printf("T14\r\n");
|
|
|
|
|
CLOSE_DC_RELAY();
|
|
|
|
|
return STATE_INIT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
State CDZ_STATE_T15(Event event)
|
|
|
|
|
{
|
|
|
|
|
printf("T15\r\n");
|
|
|
|
|
//<2F><><EFBFBD>뽻<EFBFBD><EBBDBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
OPEN_AC_RELAY();
|
|
|
|
|
OPEN_CC2_CC_RELAY();
|
|
|
|
|
CLOSE_CC1_CP_RELAY();
|
|
|
|
|
OPEN_GUN_TEMP_RELAY();
|
|
|
|
|
return STATE_AC_Charge;
|
|
|
|
|
}
|
|
|
|
|
State CDZ_STATE_T16(Event event)
|
|
|
|
|
{
|
|
|
|
|
printf("T16\r\n");
|
|
|
|
|
CLOSE_GUN_TEMP_RELAY();
|
|
|
|
|
CLOSE_CC2_CC_RELAY();
|
|
|
|
|
OPEN_CC1_CP_RELAY();
|
|
|
|
|
extern enum GUNState This_GUNState;
|
|
|
|
|
extern work_mode This_State_work;
|
|
|
|
|
extern work_mode last_Stat_work;
|
|
|
|
|
extern enum GUNState SUMStateLast;
|
|
|
|
|
This_State_work = Normal_operation;
|
|
|
|
|
last_Stat_work= Normal_operation;
|
|
|
|
|
This_GUNState = NO_GUN;
|
|
|
|
|
|
|
|
|
|
return STATE_IDLE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*T <20><> END */
|
|
|
|
|
/* EVENT 0 <20>¼<EFBFBD><C2BC><EFBFBD>ת */
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
State handleIdleEvent(Event event) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
|
|
|
|
|
CDZ_Idle("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬\r\n");
|
|
|
|
|
return STATE_IDLE; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>״̬
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD>¼<EFBFBD>
|
|
|
|
|
State handleInitEvent(Event event) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
CDZ_Init("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>\r\n");
|
|
|
|
|
return STATE_INIT; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>״̬
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
State handleHandEvent(Event event) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
CDZ_HAND("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>\r\n");
|
|
|
|
|
return STATE_HAND; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>״̬
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><D7BC><EFBFBD>¼<EFBFBD>
|
|
|
|
|
State handleReadyEvent(Event event) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
return STATE_READY; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>״̬
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>¼<EFBFBD>
|
|
|
|
|
State handleStartEvent(Event event) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
return STATE_START; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>״̬
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
State handleRunningEvent(Event event) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
return STATE_RUNNING; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>״̬
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ֹͣ<CDA3>¼<EFBFBD>
|
|
|
|
|
State handleStopEvent(Event event) {
|
|
|
|
|
// <20><><EFBFBD><EFBFBD>ֹͣ<CDA3>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// ...
|
|
|
|
|
return STATE_STOPPED; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>״̬
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
State handleAC_ChargeEvent(Event event)
|
|
|
|
|
{
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
return STATE_AC_Charge; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>״̬
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/************<2A><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*******/
|
|
|
|
|
|
|
|
|
|
//<2F><>ͣ
|
|
|
|
|
bool DCDC_emergency_stop(void)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool StopChargeProcessing(void)
|
|
|
|
|
{
|
|
|
|
|
if(BMS_Charge_Condition()==false)
|
|
|
|
|
{
|
|
|
|
|
printf("BMS The Charging Phase Stops Abnormally\n\r");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if(DCU_Time_Out_Handl()==false)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if(DCU_Fault_SelfTest()==false)
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else if((CDZ_ChargeInfo.BmsRcvCode & D_CDZ_CHARGE_CCS) != 0 && CDZ_Charging_Condition() == false)//CCS <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
printf("CCS No Charging Allowedn\r");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Charging_message_sending(void)
|
|
|
|
|
{
|
|
|
|
|
switch(CDZ_SYS.identifystep)
|
|
|
|
|
{
|
|
|
|
|
case STATE_0:Frame_Send_1(bms_SendBCS,0x11);break;
|
|
|
|
|
case STATE_1:Frame_Send_2(bms_SendBCS);break;
|
|
|
|
|
case STATE_2:Frame_Send_3(0x011);break;
|
|
|
|
|
}
|
|
|
|
|
if(TickOut(&CDZ_New.timer[CHARGEING_timer], 50)==true)
|
|
|
|
|
{
|
|
|
|
|
bms_SendBCL();
|
|
|
|
|
TickOut(&CDZ_New.timer[CHARGEING_timer], 0);
|
|
|
|
|
}
|
|
|
|
|
if(TickOut(&CDZ_New.timer[CHARGEING_timer2], 250)==true)
|
|
|
|
|
{
|
|
|
|
|
bms_SendBSM(1);
|
|
|
|
|
TickOut(&CDZ_New.timer[CHARGEING_timer2], 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|