core/include/sm_manager.h File Reference

State Machine Manager. More...

Functions

os_result_t os_sm_manager_init (os_thread_prio_t prio, unsigned short stack_size)
 Initiates State Machine Manager.
os_result_t os_sm_manager_sm_activate (os_state_machine_t *state_machine)
 Activates states machine.
os_result_t os_sm_manager_sm_deactivate (os_state_machine_t *state_machine)
 Deactivates state machine, removes it from state machine list.
os_result_t os_sm_manager_send_event (os_state_machine_t *sm, os_event_t ev)
 sends event to state machine (do not call this from interrupts)
os_result_t os_sm_manager_send_event_intr (os_state_machine_t *sm, os_event_t ev)
 sends event to state machine (this version is only for calling from interrupt)

Detailed Description

State Machine Manager.

Author:
Piotr Romaniuk, (c) ELESOFTROM
Version:
1.1 Nov 8, 2013
state_machine_manager_dioneos.png
State Machine Manager is responsible for management of the state machines. A collection of active state machines is kept by the manager. Each state machine has its own event queue, where pending events are stored. If there is any event waiting in these queues, the manager executes its processing by calling a function (handler) of corresponding state machine. State machines are scheduled according to the Round-Robin rule. Each time one event is processed.
State machine manager has separated thread. If no events are in all queues the thread performs non-busy waiting on internat semaphore intended for this purpose.

Function Documentation

os_result_t os_sm_manager_init ( os_thread_prio_t  prio,
unsigned short  stack_size 
)

Initiates State Machine Manager.

creates and initiates state machine manager, starts common thread for event processing

os_result_t os_sm_manager_send_event ( os_state_machine_t sm,
os_event_t  ev 
)

sends event to state machine (do not call this from interrupts)

Must be done through state machine manager, because of common waiting semaphore

Parameters:
[in]smstate machine
[in]evevent
Returns:
OS_STATUS_OK when event has been inserted into state machine queue
os_result_t os_sm_manager_send_event_intr ( os_state_machine_t sm,
os_event_t  ev 
)

sends event to state machine (this version is only for calling from interrupt)

Must be done through state machine manager, because of common waiting semaphore

Parameters:
[in]smstate machine
[in]evevent
Returns:
OS_STATUS_OK when event has been inserted into state machine queue
os_result_t os_sm_manager_sm_activate ( os_state_machine_t state_machine)

Activates states machine.

it is added to state machine manager list and is ready to be scheduled

Warning:
Do not call it from interrupt
Parameters:
[in]state_machinepointer to state machine structure
Returns:
returns OS_STATUS_OK if activation has been successful
os_result_t os_sm_manager_sm_deactivate ( os_state_machine_t state_machine)

Deactivates state machine, removes it from state machine list.

Warning:
Do not call it from interrupt
Parameters:
[in]state_machinepointer to state machine structure
Returns:
always OS_STATUS_OK