feat: 新增必要数据结构
This commit is contained in:
32
fsm.h
32
fsm.h
@@ -3,8 +3,36 @@
|
|||||||
//
|
//
|
||||||
#ifndef QF_FSM_FSM_H
|
#ifndef QF_FSM_FSM_H
|
||||||
#define QF_FSM_FSM_H
|
#define QF_FSM_FSM_H
|
||||||
|
#include <stdint.h>
|
||||||
struct qf_fsm
|
typedef enum
|
||||||
{
|
{
|
||||||
|
FSM_OK,
|
||||||
|
FSM_FAIL
|
||||||
|
} fsm_result_e;
|
||||||
|
|
||||||
|
typedef fsm_result_e (*fsm_cb)(void *userdata);
|
||||||
|
typedef struct qf_fsm_state
|
||||||
|
{
|
||||||
|
uint16_t state;
|
||||||
|
fsm_cb on_exit;
|
||||||
|
fsm_cb on_entry;
|
||||||
|
void *user_data;
|
||||||
|
} fsm_state_t;
|
||||||
|
typedef struct qf_fsm_transition
|
||||||
|
{
|
||||||
|
uint16_t state;
|
||||||
|
uint16_t event;
|
||||||
|
fsm_cb on_action;
|
||||||
|
} fsm_transition_t;
|
||||||
|
struct qf_fsm_event
|
||||||
|
{
|
||||||
|
uint16_t event;
|
||||||
|
void *user_data;
|
||||||
};
|
};
|
||||||
|
typedef struct qf_fsm
|
||||||
|
{
|
||||||
|
uint16_t current_state;
|
||||||
|
fsm_state_t *p_state_list;
|
||||||
|
|
||||||
|
} fsm_handle_t;
|
||||||
#endif // QF_FSM_FSM_H
|
#endif // QF_FSM_FSM_H
|
||||||
|
|||||||
Reference in New Issue
Block a user