b61c21c648
Signed-off-by: lidun <1084178170@qq.com>
804 lines
17 KiB
C
804 lines
17 KiB
C
#include <stdio.h>
|
||
#include <stdint.h>
|
||
#include <string.h>
|
||
|
||
#include "stm32f10x_rtc.h"
|
||
#include "Filtering.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); //Òì³£½øÈë½áÊø½×¶Î
|
||
|
||
State CDZ_STATE_T13(Event event);
|
||
State CDZ_STATE_T14(Event event);
|
||
State CDZ_STATE_T15(Event event);
|
||
State CDZ_STATE_T16(Event event);
|
||
// ״̬±í 3 2 ״̬ת»»
|
||
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},
|
||
};
|
||
|
||
// ʼþ´¦Àíº¯Êý±í ״̬²Ù×÷
|
||
ActionFunction actionTable[STATE_NUM] = {
|
||
handleIdleState,
|
||
handleInitState,
|
||
handleHandState,
|
||
handleReadyState,
|
||
handleStartState,
|
||
handleRunningState,
|
||
handleStoppedState,
|
||
handleAC_ChargeState,
|
||
};
|
||
|
||
//ʼþת»»
|
||
EventFun EventTable[STATE_NUM] = {
|
||
getIdleEvent,
|
||
getInitEvent,
|
||
getHandEvent,
|
||
getReadyEvent,
|
||
getStartEvent,
|
||
getRunningEvent,
|
||
getStopEvent,
|
||
getACChagreEvent,
|
||
};
|
||
//Èý¸ö±íÊÇÒªÒ»Ò»¶ÔÓ¦µÄ
|
||
|
||
|
||
Event getNextEvent(void)
|
||
{
|
||
return EVENT_0;
|
||
}
|
||
|
||
struct CDZ_Sys SysInfo = {
|
||
.This_State = STATE_IDLE,
|
||
};//³äµçϵͳÐÅÏ¢
|
||
void AppCtrOnoffHandle(void)
|
||
{
|
||
DCDC_emergency_stop();
|
||
|
||
actionTable[SysInfo.This_State](); // ´¦Àíʼþ
|
||
Event event = EventTable[SysInfo.This_State](); // »ñÈ¡ÏÂÒ»¸öʼþ
|
||
|
||
// ¸ù¾Ý״̬±í½øÐÐ״̬ת»»
|
||
TransitionFunction transition = stateTable[SysInfo.This_State][event]; //»ñÈ¡Ö¸Õë,Èç¹û·¢Éúij¸öʱ¼ä½«
|
||
if (transition != NULL) {
|
||
SysInfo.This_State = transition(event);//ת»»Ê±ºòµÄʼþ´¦Àí
|
||
}
|
||
}
|
||
|
||
/*ʼþ״̬´¦Àíº¯Êý±í*/
|
||
// ´¦ÀíIDLE״̬ϵIJÙ×÷
|
||
void handleIdleState(void)
|
||
{
|
||
// IDLE״̬ϵIJÙ×÷
|
||
// ...
|
||
|
||
CDZ_Idle("IDLE״̬\r\n");
|
||
}
|
||
|
||
void handleInitState(void)
|
||
{
|
||
// Init״̬ϵIJÙ×÷
|
||
// ...
|
||
|
||
CDZ_Init("Init״̬\r\n");
|
||
|
||
}
|
||
|
||
|
||
void handleHandState(void)
|
||
{
|
||
// hand״̬ϵIJÙ×÷
|
||
// ...
|
||
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());//·¢ËÍÎÕÊÖ±¨ÎÄ
|
||
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״̬ϵIJÙ×÷
|
||
// ...
|
||
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;
|
||
}
|
||
}
|
||
|
||
uint8_t BROAA_Count()
|
||
{
|
||
SysInfo.BROAA_Count++;
|
||
if(SysInfo.BROAA_Count >= 200)
|
||
{
|
||
return 0xAA;
|
||
}
|
||
return 0x00;
|
||
}
|
||
|
||
void handleStartState(void)
|
||
{
|
||
// START״̬ϵIJÙ×÷
|
||
// ...
|
||
CDZ_STARTD("STARTD״̬\r\n");
|
||
|
||
uint8_t bmsBROstate = ({
|
||
uint8_t BRO_record = 0;
|
||
if(SysInfo.REV_CML_FLAG == true\
|
||
&& Charging_Pile_Param() == true\
|
||
&& VCU_Charge_Condition() == Yes\
|
||
&& BMS_Charge_Condition() == true\
|
||
&& Send_BROAA_Condition() == Yes\
|
||
&& DCU_SendState.DC_Relay_State_Filter == true\
|
||
)
|
||
{
|
||
BRO_record = BROAA_Count();
|
||
// BRO_record = 0xAA;
|
||
}
|
||
else
|
||
{
|
||
BRO_record = 0x0;
|
||
}
|
||
BRO_record;
|
||
});
|
||
|
||
if((CDZ_ChargeInfo.BmsRcvCode & D_CDZ_CONFIG_CML)!= 0 || (SysInfo.REV_CML_FLAG == true && CDZ_ChargeInfo.ready != 0XAA))
|
||
{
|
||
bms_SendBRO(bmsBROstate);
|
||
if(BMSDefaultParameters.parenr->Get_Car_Working_Status(BMSDefaultParameters.parenr) == true && DCU_SendState.DC_Relay_State_Filter == false)
|
||
{
|
||
/**********±ÕºÏDC¼ÌµçÆ÷*********/
|
||
OPEN_DC_RELAY();
|
||
}
|
||
SysInfo.REV_CML_FLAG = true;
|
||
CDZ_ChargeInfo.BmsRcvCode &= ~D_CDZ_CONFIG_CML;
|
||
}
|
||
else if(SysInfo.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;
|
||
}
|
||
|
||
}
|
||
|
||
// ´¦ÀíRUNNING״̬ϵIJÙ×÷
|
||
void handleRunningState(void)
|
||
{
|
||
// RUNNING״̬ϵIJÙ×÷
|
||
// ...
|
||
CDZ_Running("RUNNING״̬\r\n");
|
||
Charging_message_sending();
|
||
}
|
||
|
||
#include <stdlib.h>
|
||
|
||
// ´¦ÀíSTOPPED״̬ϵIJÙ×÷
|
||
void handleStoppedState(void)
|
||
{
|
||
// STOPPED״̬ϵIJÙ×÷
|
||
// ...
|
||
|
||
CDZ_Stopped("STOPPED״̬\r\n");
|
||
|
||
uint16_t Curr = abs(BMSDefaultParameters.parenr->Charg_Curr);//È¡ÕýÊý
|
||
bool Value = FilteringScan(&ContinuousFiltering[Charging_Pile_Input_Current_Filter],&Curr);//Â˲¨
|
||
|
||
if(DCU_SendState.DC_Relay_State_Filter == true && Value == true)
|
||
{
|
||
CLOSE_DC_RELAY();
|
||
}
|
||
|
||
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);
|
||
}
|
||
}
|
||
|
||
//½»Á÷³äµçº¯Êý
|
||
void handleAC_ChargeState(void)
|
||
{
|
||
|
||
}
|
||
|
||
// »ñȡʼþ²Ù×÷
|
||
Event getIdleEvent(void)
|
||
{
|
||
work_mode This_WorkState = Get_Sampl_Data.WorkMode();
|
||
// printf("e=%d\r\n",This_WorkState);
|
||
if(This_WorkState== DC_Charging)
|
||
{
|
||
SysInfo.Enter_AC_State_count = 0;
|
||
if(BMSDefaultParameters.parenr->Get_Car_Working_Mode(BMSDefaultParameters.parenr) == DC_charge_mode)
|
||
{
|
||
printf("½øÈëÖ±Á÷³äµçÁ÷³Ì\r\n");
|
||
return EVENT_1;
|
||
}
|
||
}
|
||
else if(This_WorkState == AC_Charging)
|
||
{
|
||
memset((char *)&SecTimer,0,sizeof(SecTimer));
|
||
printf("½øÈë½»Á÷³äµçÁ÷³Ì\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();//Çå³ýÈ«²¿¹ÊÕÏÂë
|
||
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Í˳öÎÕÊֽ׶Î
|
||
{
|
||
SecStop(&SecTimer[Hand_SecTimerNUM]);
|
||
return EVENT_3;
|
||
}
|
||
|
||
return EVENT_0;
|
||
}
|
||
|
||
Event getReadyEvent(void)
|
||
{
|
||
if(CDZ_ChargeInfo.identify ==0xAA) //±æʶµ½
|
||
{
|
||
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\
|
||
)
|
||
{
|
||
return EVENT_3;
|
||
}
|
||
else if(Get_Sampl_Data.WorkMode() != DC_Charging)
|
||
{
|
||
return EVENT_5;
|
||
}
|
||
else if(SecStar(&SecTimer[Start1_SecTimerNUM],60))//60SÍ˳öÅäÖý׶Î
|
||
{
|
||
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],5))//10SÍ˳ö½áÊøÁ÷³Ì
|
||
{
|
||
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);
|
||
uint8_t OBCConSt_Status = FilteringScan(&ContinuousFiltering[OncConSt_Status_Filter],&OncConSt_Status);
|
||
// printf("CarWork %d\r\n",CarWork);
|
||
if(OBCConSt_Status == true && SecStar(&SecTimer[ACCharg_SecTimerNUM],2) == true)
|
||
{
|
||
SysInfo.Enter_AC_State_count++;
|
||
SecStop(&SecTimer[ACCharg_SecTimerNUM]);
|
||
return EVENT_1;
|
||
}
|
||
else if(OBCConSt_Status == false)//OBCËÉ¿ª»á³öÏÖÆäËû²»Îȶ¨×´Ì¬,µ±³öÏÖʱÇå³ý¼ÆÊýÖµ
|
||
{
|
||
SysInfo.Enter_AC_State_count = 0;
|
||
SecStop(&SecTimer[ACCharg_SecTimerNUM]);
|
||
}
|
||
|
||
// else if(OncConSt_Status == Half_connect)//OBC°ëÁ¬½ÓËÉ¿ª»á³öÏÖÎÞÁ¬½Ó,µ±°ëÁ¬½ÓʱÇå³ý¼ÆÊýÖµ
|
||
// {
|
||
// SysInfo.Enter_AC_State_count = 0;
|
||
// SecStop(&SecTimer[ACCharg_SecTimerNUM]);
|
||
// }
|
||
|
||
return EVENT_0;
|
||
}
|
||
|
||
/*T ±í Start */
|
||
State CDZ_STATE_T1(Event event)
|
||
{
|
||
|
||
printf("T1\r\n");
|
||
/******³õʼ»¯Ä¬ÈÏ********/
|
||
CLOSE_DC_RELAY();
|
||
CLOSE_AC_RELAY();
|
||
CLOSE_CC2_CC_RELAY();
|
||
OPEN_CC1_CP_RELAY();
|
||
OPEN_GUN_TEMP_RELAY();
|
||
/***********************/
|
||
return STATE_INIT;
|
||
|
||
}
|
||
|
||
State CDZ_STATE_T2(Event event)
|
||
{
|
||
|
||
printf("T2\r\n");
|
||
OPEN_CC1_CP_RELAY();//Çл»µ½CC1£¬Èóäµç׮ʶ±ð²åǹ
|
||
return STATE_HAND;
|
||
|
||
}
|
||
|
||
State CDZ_STATE_T3(Event event)
|
||
{
|
||
|
||
printf("T3\r\n");
|
||
return STATE_READY;
|
||
|
||
}
|
||
|
||
State CDZ_STATE_T4(Event event)
|
||
{
|
||
//½øÈëÅäÖý׶ÎÇ°°Ñ±ê־λÇå³ý
|
||
SysInfo.REV_CML_FLAG = false;
|
||
SysInfo.BROAA_Count = 0;
|
||
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");
|
||
CDZ_SYS.GB_TYPE = 0;//Çå³ý¹ú±êÀàÐÍ
|
||
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) //Òì³£½øÈë½áÊø½×¶Î
|
||
{
|
||
|
||
printf("T12\r\n");
|
||
return STATE_STOPPED;
|
||
|
||
}
|
||
State CDZ_STATE_T13(Event event) //δ²åÖ±Á÷ת½ÓÍ·
|
||
{
|
||
printf("T13\r\n");
|
||
OPEN_AC_RELAY();
|
||
CLOSE_DC_RELAY();
|
||
return STATE_IDLE;
|
||
}
|
||
State CDZ_STATE_T14(Event event) //³äµç½×¶Î³¬Ê±
|
||
{
|
||
printf("T14\r\n");
|
||
CLOSE_DC_RELAY();
|
||
return STATE_INIT;
|
||
}
|
||
|
||
State CDZ_STATE_T15(Event event)
|
||
{
|
||
printf("T15\r\n");
|
||
//½øÈë½»Á÷³äµçÁ÷³Ì
|
||
OPEN_AC_RELAY();
|
||
OPEN_CC2_CC_RELAY();
|
||
CLOSE_CC1_CP_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 ±í END */
|
||
/* EVENT 0 ʼþÌøת */
|
||
|
||
// ´¦Àí¿ÕÏÐʼþ
|
||
State handleIdleEvent(Event event) {
|
||
// ´¦Àí¿ªÊ¼Ê¼þµÄÂß¼
|
||
// ...
|
||
|
||
CDZ_Idle("¿ÕÏÐ״̬\r\n");
|
||
return STATE_IDLE; // ·µ»ØÏÂÒ»¸ö״̬
|
||
}
|
||
|
||
|
||
// ´¦Àí³õʼ»¯Ê¼þ
|
||
State handleInitEvent(Event event) {
|
||
// ´¦Àí¿ªÊ¼Ê¼þµÄÂß¼
|
||
// ...
|
||
CDZ_Init("´¦Àí³õʼ»¯Ê¼þ\r\n");
|
||
return STATE_INIT; // ·µ»ØÏÂÒ»¸ö״̬
|
||
}
|
||
|
||
// ´¦ÀíÎÕÊÖʼþ
|
||
State handleHandEvent(Event event) {
|
||
// ´¦Àí¿ªÊ¼Ê¼þµÄÂß¼
|
||
// ...
|
||
CDZ_HAND("´¦ÀíÎÕÊÖʼþ\r\n");
|
||
return STATE_HAND; // ·µ»ØÏÂÒ»¸ö״̬
|
||
}
|
||
|
||
// ´¦Àí×¼±¸Ê¼þ
|
||
State handleReadyEvent(Event event) {
|
||
// ´¦Àí¿ªÊ¼Ê¼þµÄÂß¼
|
||
// ...
|
||
return STATE_READY; // ·µ»ØÏÂÒ»¸ö״̬
|
||
}
|
||
|
||
// ´¦Àí¿ªÊ¼Ê¼þ
|
||
State handleStartEvent(Event event) {
|
||
// ´¦Àí¿ªÊ¼Ê¼þµÄÂß¼
|
||
// ...
|
||
return STATE_START; // ·µ»ØÏÂÒ»¸ö״̬
|
||
}
|
||
|
||
// ´¦Àí½øÐÐÖÐʼþ
|
||
State handleRunningEvent(Event event) {
|
||
// ´¦Àí¿ªÊ¼Ê¼þµÄÂß¼
|
||
// ...
|
||
return STATE_RUNNING; // ·µ»ØÏÂÒ»¸ö״̬
|
||
}
|
||
|
||
// ´¦Àíֹͣʼþ
|
||
State handleStopEvent(Event event) {
|
||
// ´¦ÀíֹͣʼþµÄÂß¼
|
||
// ...
|
||
return STATE_STOPPED; // ·µ»ØÏÂÒ»¸ö״̬
|
||
}
|
||
|
||
State handleAC_ChargeEvent(Event event)
|
||
{
|
||
// ½»Á÷³äµçÊÂÏî
|
||
|
||
return STATE_AC_Charge; // ·µ»ØÏÂÒ»¸ö״̬
|
||
}
|
||
|
||
|
||
/************ÒÔÏÂΪ»ù´¡¹¹½¨*******/
|
||
|
||
//¼±Í£
|
||
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 ²»ÔÊÐí³äµç
|
||
{
|
||
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((CDZ_ChargeInfo.BmsRcvCode & D_CDZ_CHARGE_CCS)!= 0)
|
||
{
|
||
CDZ_ChargeInfo.BmsRcvCode &= ~D_CDZ_CHARGE_CCS;
|
||
if(TickOut(&CDZ_New.timer[CHARGEING_timer2], 250)==true)
|
||
{
|
||
bms_SendBSM(1);
|
||
TickOut(&CDZ_New.timer[CHARGEING_timer2], 0);
|
||
}
|
||
}
|
||
}
|
||
|
||
|