1、消息在头文件中定义为如下格式:
enum GameSignals { /* signals used in the game /
TIME_TICK_SIG = Q_USER_SIG, / published from tick ISR /
PLAYER_TRIGGER_SIG, / posted by Player (ISR) to trigger the Missile /
TAKE_OFF_SIG, / from Tunnel to Ship to grant permission to take off /
HIT_WALL_SIG, / from Tunnel to Ship when Ship hits the wall /
HIT_MINE_SIG, / from Mine to Ship or Missile when it hits the mine */
};
2、状态设计的时候,触发消息的填充,去掉第一步定义的SIG,比如
PLAYER_TRIGGER
Q_TIMEOUT
TIME_TICK
HIT_WALL
3、条件分支的习惯约定:
guard可以不起名,但名字下面的框必须填条件,不需要if
(me->blink_ctr & 1U) != 0U
分支的另外一端,可以直接填else,或者没有分支也可以。
4、每一个状态机的entry和exit,最好都加上打印,
entry用来改变成员变量的数据,以及启动timer。
exit用来清除timer。
5、消息处理,放在内部,需要转换状态的,再拉到外面。