CELIS/HARDWARE/CDZ/CDZ_State.h

197 lines
3.6 KiB
C
Raw Normal View History

2024-08-09 06:24:48 +00:00
#ifndef __CDZ_State_H
#define __CDZ_State_H
#include <stdbool.h>
#include <stdint.h>
/**********************<2A><EFBFBD>Ź<EFBFBD><C5B9><EFBFBD>*******************/
#define MAJOR_VERSION A
#define MINOR_VERSION 40
#define PATCH_VERSION U
#define Version_number 60
#define STRINGIFY(x) #x
#define VERSION_STRING(major, minor, patch,num) STRINGIFY(major) STRINGIFY(minor) STRINGIFY(patch) \
STRINGIFY(num)
#define Version() VERSION_STRING(MAJOR_VERSION, MINOR_VERSION, PATCH_VERSION,Version_number)
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
{
/****<2A>˲<EFBFBD><CBB2><EFBFBD>****/
int8_t GUN_TEMP_Filter;
bool HV_DSG_CHECJ_Signal_Filter;
bool HV_DSG_CHECJ_2_Signal_Filter;
bool AC_Relay_State_Filter;
bool DC_Relay_State_Filter;
/****<2A>̵<EFBFBD><CCB5><EFBFBD>״̬****/
bool AC_Relay_State;
bool DC_Relay_State;
bool CP_CC1_State;
bool CC_CC2_State;
bool L_Relay_State;
/****<2A><><EFBFBD>Ե<EFBFBD>****/
uint8_t Falut;
uint8_t DC_Realy_N;
uint8_t DC_Realy_P;
}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;
/****<2A><><EFBFBD><EFBFBD>****/
uint8_t Enter_AC_State_count;
uint16_t BROAA_Count;
/****<2A><>־λ****/
bool Stop_BSD_Send_Falg;
bool REV_CML_FLAG;
bool REV_CCS_FLAG;
}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