CELIS/HARDWARE/CDZ/CDZ_State.h

162 lines
3.0 KiB
C
Raw Normal View History

#ifndef __CDZ_State_H
#define __CDZ_State_H
#include <stdbool.h>
#include <stdint.h>
enum GB_Types
{
GB2015=1,
GB2011=2
};
// <20><><EFBFBD><EFBFBD>״̬
typedef enum {
STATE_IDLE,
STATE_INIT,
STATE_HAND,
STATE_READY,
STATE_START,
STATE_RUNNING,
STATE_STOPPED,
STATE_AC_Charge,
STATE_NUM,
} State;
// <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
typedef enum {
EVENT_0,//<2F>¼<EFBFBD>0<EFBFBD><30>Ϊ<EFBFBD><CEAA>û<EFBFBD><C3BB><EFBFBD>κ<EFBFBD><CEBA><EFBFBD>ת
EVENT_1,//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ״̬
EVENT_2,
EVENT_3,
EVENT_4,
EVENT_5,
EVENT_NUM
} Event;
// ״̬ת<CCAC><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
typedef State (*TransitionFunction)(Event);
// ״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
typedef void (*ActionFunction)(void);
// <20>¼<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
typedef Event (*EventFun)(void);
extern ActionFunction actionTable[];
extern TransitionFunction stateTable[][EVENT_NUM];
extern Event getNextEvent(void);
extern EventFun EventTable[STATE_NUM];
typedef struct
{
bool AC_Relay_State;
bool DC_Relay_State;
bool CP_CC1_State;
bool CC_CC2_State;
uint8_t Falut;
}Dcu_State;
extern Dcu_State DCU_SendState;
typedef struct CDZ_Sys
{
State This_State;//<2F><>¼<EFBFBD><C2BC>ǰ<EFBFBD><C7B0>״̬
uint8_t KCOpenFlag;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><D8B4><EFBFBD>
uint16_t poweron_delay_time;//<2F><>Դ<EFBFBD><D4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ??
uint8_t identifystep;//<2F><><EFBFBD>ͱ<EFBFBD><CDB1><EFBFBD>״̬<D7B4><CCAC>־λ?!
uint8_t GB_TYPE;
uint32_t CHM_timer_count;
uint16_t timer_count;
uint8_t work_pattern;
uint8_t Enter_AC_State_count;
}CDZ_Sys;
extern struct CDZ_Sys SysInfo;
/***********<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>**********/
enum Time_CDZ
{
CDZ_TIMEER,
Timer_print,
CC_CHARGE_READY_timer,
CC_CHARGE_READY_timer1,
START_timer,
START_timer1,
CHARGEING_timer,
CHARGEING_timer1,
CHARGEING_timer2,
timer_print,
end_timer,
ACChagre_timer,
VCU_Charging_Mode_time,
Timer_Number
};
struct New_CDZ{
uint32_t timer[Timer_Number];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
};
void AppCtrOnoffHandle(void);
bool DCDC_emergency_stop(void);
extern CDZ_Sys CDZ_SYS;
/**<2A><><EFBFBD>׶εĵ<CEB5><C4B5><EFBFBD><EFBFBD><EFBFBD>Ϣ**/
//#define CDZ_Idle_DEBUG
//#define CDZ_Init_DEBUG
//#define CDZ_HAND_DEBUG
//#define CDZ_Ready_DEBUG
//#define CDZ_STARTD_DEBUG
//#define CDZ_Running_DEBUG
//#define CDZ_Stopped_DEBUG
#ifdef CDZ_Idle_DEBUG
#define CDZ_Idle(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define CDZ_Idle(fmt, ...)
#endif
#ifdef CDZ_Init_DEBUG
#define CDZ_Init(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define CDZ_Init(fmt, ...)
#endif
#ifdef CDZ_HAND_DEBUG
#define CDZ_HAND(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define CDZ_HAND(fmt, ...)
#endif
#ifdef CDZ_Ready_DEBUG
#define CDZ_Ready(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define CDZ_Ready(fmt, ...)
#endif
#ifdef CDZ_STARTD_DEBUG
#define CDZ_STARTD(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define CDZ_STARTD(fmt, ...)
#endif
#ifdef CDZ_Running_DEBUG
#define CDZ_Running(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define CDZ_Running(fmt, ...)
#endif
#ifdef CDZ_Stopped_DEBUG
#define CDZ_Stopped(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#define CDZ_Stopped(fmt, ...)
#endif
#endif