改用单维及二维数组的写法
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

51 lines
940 B

/*
* fsm.c
*
* Created on: 2025年7月14日
* Author: akeguo
*/
#include "fsm_state.h"
#include "stdint.h"
void fsm_state_run(transition_t* p_this)
{
// turnstile_pass(&turnstile)
if (p_this->p_state->robotRun!= NULL)
{
p_this->p_state->robotRun(p_this);
}
}
//修改状态机状态,若状态机修改后,则查看是否有enter 和 exit命令进行运动
void fsm_state_set(transition_t* p_this, transition_state_t* p_new_state)
{
if(p_this==NULL){return;}
// turnstile_pass(&turnstile)
if (p_this->p_state!= p_new_state) /* 状态不等 */
{
if (p_this->p_state->robotExit!=NULL)
{
p_this->p_state->robotExit(p_this);
}
p_this->p_state = p_new_state;
if (p_this->p_state->robotEnter != NULL)
{
p_this->p_state->robotEnter(p_this);
}
//exit
}
}
//状态机初始化设定
void fsm_state_init(transition_t* p_this,transition_state_t* inti_state)
{
p_this->p_state =inti_state;
}