Classes |
struct | fsm_event |
| Type for FSM events. More...
|
struct | fsm_main_loop |
struct | robo_fsm |
| Structure describing FSM. More...
|
Defines |
#define | EV_NOEVENT __COMMON_EV_NOEVENT |
#define | EV_ENTRY __COMMON_EV_ENTRY |
#define | EV_EXIT __COMMON_EV_EXIT |
#define | EV_RETURN __COMMON_EV_RETURN |
#define | EV_TIMER __COMMON_EV_TIMER |
#define | FSM_EVENT_QUEUE_LEN 10 |
#define | FSM_FLAG_EVENT_LOST 0x01 |
| Set on event queue overrun, never zeroed.
|
#define | FSM_FLAG_FINISH 0x02 |
| Set by fsm_exit().
|
#define | FSM_WAIT_FOREVER -1l |
#define | FSM_SIGNAL(fsm_id, event, data) |
| Sends an event to another FSM, which may run in another thread.
|
#define | DBG_STATE() DBG_FSM_STATE(__FUNCTION__) |
#define | DBG_FSM_STATE(name) do { if (fsm->debug_states) printf("fsm %s: %s(%s)\n", fsm->debug_name, name, fsm_event_str(fsm->events[fsm->ev_head])); } while(0) |
#define | DBG_PRINT_EVENT(msg) printf("fsm %s %s %s: %s\n", fsm->debug_name, fsm->state_name, fsm_event_str(fsm->events[fsm->ev_head]), msg) |
| Prints current event in a human readable form.
|
#define | FSM_STATE_VISIBILITY |
| Specifies state function visibility.
|
#define | ___fsm_func_name(fsm, state, suf) fsm_state_##fsm##_##state##suf |
#define | __fsm_func_name(fsm, state, suf) ___fsm_func_name(fsm, state, suf) |
#define | FSM_STATE(name) error_FSM_XXX_not_defined |
| Defines a state function for finite state machine.
|
#define | FSM_STATE_DECL(name) error_FSM_XXX_not_defined |
| Declares a prototype of state function defined later.
|
#define | FSM_STATE_FULL_DECL(fsm_name, name) int __fsm_func_name(fsm_name, name,)(struct robo_fsm *fsm) |
| Declares a prototype of state function of given FSM.
|
#define | FSM_TIMER(ms) |
| Sets FSM's one-shot timer.
|
#define | FSM_TIMER_STOP() __fsm_timer_stop(fsm) |
| Stops the timer.
|
#define | __FSM_EVENT_ENUM enum fsm_common_events |
#define | FSM_EVENT ((__FSM_EVENT_ENUM)(fsm->events[fsm->ev_head].id)) |
| Value of current event in state functions.
|
#define | FSM_EVENT_PTR (fsm->events[fsm->ev_head].data) |
| Value of the pointer sent together with the event.
|
#define | FSM_EVENT_INT ((long int)(fsm->events[fsm->ev_head].data)) |
| Value of the integer data sent together with the event.
|
#define | FSM_TRANSITION(next) error_FSM_XXX_not_defined |
| Sets current state to next .
|
#define | SUBFSM_TRANSITION(substate, data) error_FSM_XXX_not_defined |
| Invoke state transition to sub-FSM.
|
#define | SUBFSM_RET(data) |
| Return from sub-FSM.
|
|
|
#define | RC_WAIT 0 |
| After return, FSM thread starts waiting for the new event.
|
#define | RC_PROC 1 |
| After return, current state function (fnc_act) will be immediately called again.
|
Typedefs |
typedef struct fsm_event | fsm_event |
| Type for FSM events.
|
typedef int(* | robo_fsm_state_t )(struct robo_fsm *fsm) |
| Event handler function for FSM.
|
Functions |
void | fsm_main_loop_init (struct fsm_main_loop *loop) |
| Initializes main loop.
|
void | fsm_init (struct robo_fsm *fsm, char *debug_name, struct fsm_main_loop *loop) |
| FSM initialization.
|
int | fsm_start (struct fsm_main_loop *loop, pthread_attr_t *attr) |
| Starts previously initialized FSM main loop in a separate thread.
|
void | fsm_exit (struct robo_fsm *fsm) |
| Signals FSM to exit.
|
void | fsm_destroy (struct robo_fsm *fsm) |
| Deallocates all resources allocated by fsm_init().
|
void | fsm_main_loop (struct fsm_main_loop *loop) |
| FSM main event loop.
|
void | __fsm_timespec_add_ms (struct timespec *ts, struct timespec *now, long ms) |
| Set timespec to some time from now.
|
void | __fsm_timespec_invalidate (struct timespec *ts) |
int | __fsm_timespec_cmp (struct timespec *ts1, struct timespec *ts2) |
int | fsm_nop_state (struct robo_fsm *fsm) |
| Non operative state, do nothing.
|
const char * | fsm_event_str (fsm_event ev) |
| Returns string with the name of event submitted as parameter.
|
const char * | fsm_common_event_str (fsm_event ev) |
void | __fsm_timer_stop (struct robo_fsm *) |