Skip to content
okebkal edited this page Apr 1, 2016 · 16 revisions

MODULE

fsm

MODULE SUMMARY

Generic fsm behaviour

DESCRIPTION

DATA TYPES

time() = {s, integer() > 0} | {ms, integer() > 0} | {us, integer() > 0}

trans() = [state_trans()]

state_trans() = {State :: atom(), [trans_arrow()]}

trans_arrow() =
  {Event :: atom(), State :: atom()} |
  {Event :: atom(), Pop :: atom(), Push :: atom(), State :: atom()}

at() anything that can be accepted by role_at:from_term

EXPORTS

clear_timeout(SM, Event) -> Result

Types

  SM = sm()
  Event = atom()
  Result = sm()
clear_timeouts(SM) -> Result

Types

  SM = sm()
  Result = sm()
clear_timeouts(SM, EventList) -> Result

Types

  SM = sm()
  EventList = [atom()]
  Result = sm()
set_timeout(SM, Time, Event) -> Result

Types

  SM = sm()
  Time = time()
  Event = atom()
  Result = sm()
check_timeout(SM, Event) -> Result

Types

  SM = sm()
  Event = atom()
  Result = true | false
set_event(SM, Event) -> Result

Types

  SM = sm()
  Event = atom()
  Result = sm()
run_event(MiddleMan, SM, Term) -> Result

Types

  MiddleMan = mm()
  SM = sm()
  Term = any()
  Result = sm()
send_at_command(SM, AT) -> Result

Types

  SM = sm()
  AT = at()
  Result = sm()
broadcast(SM, Target, Term) -> Result

Types

  SM = sm()
  Target = atom()
  Term = any()
  Result = sm()
cast(SM, Target, Term) -> Result

Types

  SM = sm()
  Target = atom()
  Term = any()
  Result = sm()

= cast(SM, MM, EOpts, Term, Condition) -> Result

Types

  SM = sm()
  MiddleMan = mm()
  EOpts = any()
  Term = any()
  Condition = fun((MiddleMan, Role :: atom(), EOpts) -> true | false)
  Result = sm()

= role_available(SM, Target) -> Result

Types

  SM = sm()
  Target = atom()
  Result = true | false

CALLBACK FUNCTIONS

The following functions must be exported from a fsm callback module.

EXPORTS

Module:start_link(SM) -> Result

Types

  SM = sm()
  Result = {ok,pid()} | ignore | {error,any()}
Module:init(SM) -> Result

Types

  SM = sm()
  Result = sm()

= Module:stop(SM) -> ok

Types

  SM = sm()
Module:handle_event(MM, SM, Term) -> Result =

Types

  SM = sm()
  MM = mm()
  Term = any()
  Result = sm()
trans() -> Result

Types

  Result = trans()
final() -> Result

Types

  Result = [atom()]
init_event() -> Result

Types

  Result = atom()

SEE ALSO

role_worker, fsm_worker