我是靠谱客的博主 眼睛大白云,这篇文章主要介绍C语言项目设计——状态机设计(一)状态机设计——Hard code 模式(二)状态机设计——宏文件注册模式,现在分享给大家,希望可以做个参考。

C语言项目设计——状态机设计

  • (一)状态机设计——Hard code 模式
  • (二)状态机设计——宏文件注册模式

(一)状态机设计——Hard code 模式

设计二维状态机,pipeline.h

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef _PIPELINE_H_ #define _PIPELINE_H_ #include "deftype.h" /********************************************************************************** * Global Declaration ***********************************************************************************/ /**@enum enum_state * @brief 定义状态机的状态类型 */ enum enum_state { EM_STATE_DEFAULT, EM_STATE_ONE, EM_STATE_TWO, EM_END }; typedef int_32(*func)(void* pstcontext); /**@struct st_app_list * @brief using the app list to define a pipeline n * 定义存储一个状态机对应的pipe的函数列表 */ typedef struct _st_app_list { enum enum_state state; func* pfun; }st_app_list; /**@struct st_pipe * @brief define struct of pipe n * 定义存储一个pipe的结构 */ typedef struct _st_pipe { enum enum_state state; void* context; } st_pipe; /********************************************************************************** * Global Variable Declaration ***********************************************************************************/ /**@name 状态机全局参数 * @brief 等全局参数 * @{ */ extern st_app_list gpst_state_table[EM_END]; //2D state machine extern func app_list_default[]; //EM_STATE_DEFAULT extern func app_list_one[]; //EM_STATE_ONE extern func app_list_two[]; //EM_STATE_TWO /** @} 状态机全局参数 */ #endif // !_PIPELINE_H_

设计二维状态机,pipeline.c

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#include"../inc/pipeline.h" #inclue "app_config.h" /********************************************************************************** * Local Variable ***********************************************************************************/ /********************************************************************************** * Global Variable ***********************************************************************************/ func app_list_default[] = { isp_gamma, NULL }; func app_list_one[] = { isp_gamma, NULL }; func app_list_two[] = { isp_gamma, NULL }; st_app_list gpst_state_table[EM_END] = { {EM_STATE_DEFAULT, app_list_default}, {EM_STATE_ONE, app_list_one}, {EM_STATE_TWO, app_list_two} }; /********************************************************************************** * Local Funcation Declaration ***********************************************************************************/ /********************************************************************************** * Global Funcation ***********************************************************************************/ /********************************************************************************** * Local Funcation ***********************************************************************************/

(二)状态机设计——宏文件注册模式

最后

以上就是眼睛大白云最近收集整理的关于C语言项目设计——状态机设计(一)状态机设计——Hard code 模式(二)状态机设计——宏文件注册模式的全部内容,更多相关C语言项目设计——状态机设计(一)状态机设计——Hard内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(55)

评论列表共有 0 条评论

立即
投稿
返回
顶部