User Tools

Site Tools


fsm:use_fsm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
fsm:use_fsm [2007/04/29 14:05] fgmfsm:use_fsm [2020/11/23 17:23] (current) – external edit 127.0.0.1
Line 14: Line 14:
  
 ===== Controlling the FSM operation ===== ===== Controlling the FSM operation =====
- 
- 
- 
 ==== Directed work with the "idle" event ==== ==== Directed work with the "idle" event ====
  
-A special built-in event is "idle" (method f_idle), which always returns true, and can be used to direct the fsm to navigate between preferred states when nothing specific happens by causing events to be generated as above.+A special built-in event is fsm::IDLE_EVENT (method f_idle), which always returns true, and can be used to direct the fsm to navigate between preferred states when nothing specific happens by causing events to be generated as above.
  
-This behaviour can be turned off by setting the FSM "$idle" property to FALSE+This event can be turned off by setting the FSM "$idle" property to FALSE. In that case, submitted fsm::IDLE_EVENT events are silently discarded.
  
 +Syntactic sugar: the idle() method is a shorthand for apply_events(fsm::IDLE_EVENT).
  
 ==== Filtering events ==== ==== Filtering events ====
  
-The OSInet FSM has three event processing modes, controlled by the "$event" property:+The OSInet FSM has three event processing modes, controlled by the {get|set}_event_mode methods:
  
   * fsm::EVENT_NORMAL : receives events, processes them, and fires exit events if applicable. This is the default mode.   * fsm::EVENT_NORMAL : receives events, processes them, and fires exit events if applicable. This is the default mode.
Line 34: Line 32:
     * Switching from fsm::EVENT_QUEUE to fsm::EVENT_SINK empties the event queue accumulated while under fsm::MODE_QUEUE     * Switching from fsm::EVENT_QUEUE to fsm::EVENT_SINK empties the event queue accumulated while under fsm::MODE_QUEUE
  
 +==== Disabling post-events actions ====
  
-===== Disabling post-events actions ===== +Firing of post-event actions is enabled by default, but can be disabled by setting the $allow_actions property to false. 
- +
-Firing of post-event actions is enabled by default, but can be disabled by setting the $action property to false. +
  
 In that case, applications can still decide to fire the event themselves by reading the fsm_action field in the fsm_result returns by fsm::apply_event(). In that case, applications can still decide to fire the event themselves by reading the fsm_action field in the fsm_result returns by fsm::apply_event().
Line 45: Line 42:
 For a very basic FSM going just from initial to final randomly, building the table and transitions can look like: For a very basic FSM going just from initial to final randomly, building the table and transitions can look like:
  
-<php>+<code php>
 class foo extends fsm class foo extends fsm
   {   {
Line 72: Line 69:
     }     }
   }   }
-</php>+</code> 
 + 
  
 Application code not involved in the FSM operation can use the FSM apply_event method($event_name) to submit an event to the FSM. Only allowed events for the given state the FSM is in are allowed: submitting other events throws an exception.  Application code not involved in the FSM operation can use the FSM apply_event method($event_name) to submit an event to the FSM. Only allowed events for the given state the FSM is in are allowed: submitting other events throws an exception. 
fsm/use_fsm.1177855546.txt.gz · Last modified: 2020/11/23 17:23 (external edit)