b61c21c648
Signed-off-by: lidun <1084178170@qq.com>
181 lines
3.3 KiB
C
181 lines
3.3 KiB
C
#ifndef __CDZ_State_H
|
|
#define __CDZ_State_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
enum GB_Types
|
|
{
|
|
GB2015=1,
|
|
GB2011=2
|
|
};
|
|
|
|
// 定义状态
|
|
typedef enum {
|
|
|
|
STATE_IDLE,
|
|
STATE_INIT,
|
|
STATE_HAND,
|
|
STATE_READY,
|
|
|
|
STATE_START,
|
|
STATE_RUNNING,
|
|
STATE_STOPPED,
|
|
STATE_AC_Charge,
|
|
STATE_NUM,
|
|
|
|
} State;
|
|
|
|
// 定义事件
|
|
typedef enum {
|
|
EVENT_0,//事件0认为是没有任何跳转
|
|
EVENT_1,//正常进入下一状态
|
|
EVENT_2,
|
|
EVENT_3,
|
|
|
|
EVENT_4,
|
|
EVENT_5,
|
|
EVENT_NUM
|
|
} Event;
|
|
|
|
// 状态转换函数
|
|
typedef State (*TransitionFunction)(Event);
|
|
|
|
// 状态操作函数
|
|
typedef void (*ActionFunction)(void);
|
|
|
|
// 事件转换函数
|
|
typedef Event (*EventFun)(void);
|
|
|
|
extern ActionFunction actionTable[];
|
|
extern TransitionFunction stateTable[][EVENT_NUM];
|
|
extern Event getNextEvent(void);
|
|
extern EventFun EventTable[STATE_NUM];
|
|
|
|
typedef struct
|
|
{
|
|
/****滤波的****/
|
|
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;
|
|
|
|
/****继电器状态****/
|
|
bool AC_Relay_State;
|
|
bool DC_Relay_State;
|
|
bool CP_CC1_State;
|
|
bool CC_CC2_State;
|
|
|
|
/****调试的****/
|
|
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;//记录当前的状态
|
|
uint8_t KCOpenFlag;//大概是用来计算开关次数
|
|
uint16_t poweron_delay_time;//电源开启延时??
|
|
uint8_t identifystep;//发送报文状态标志位?!
|
|
uint8_t GB_TYPE;
|
|
uint32_t CHM_timer_count;
|
|
uint16_t timer_count;
|
|
uint8_t work_pattern;
|
|
|
|
/****计数****/
|
|
uint8_t Enter_AC_State_count;
|
|
uint16_t BROAA_Count;
|
|
|
|
/****标志位****/
|
|
bool Stop_BSD_Send_Falg;
|
|
bool REV_CML_FLAG;
|
|
}CDZ_Sys;
|
|
extern struct CDZ_Sys SysInfo;
|
|
/***********基础构建**********/
|
|
|
|
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];//软件定时器
|
|
};
|
|
|
|
void AppCtrOnoffHandle(void);
|
|
bool DCDC_emergency_stop(void);
|
|
extern CDZ_Sys CDZ_SYS;
|
|
/**各阶段的调试信息**/
|
|
//#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
|
|
|