Skip to content
Oleksiy Kebkal edited this page Jan 24, 2017 · 16 revisions

MODULE

fsm

MODULE SUMMARY

Each agent is explicitly defined in the form of a finite state machine or a pushdown automata and is driven by events generated externally by event handles or timers. Each agent is fault-isolated. Incorrect agent implementation should not affect the behavior of an agent which doesn't have any errors.

Transitions table

Interface Processors

Agents are connected to each other and to external processes via interface processors, converting raw data coming from external interfaces to well-defined messages and messages received from the corresponding agents back to raw data. Each agent specify particular interface processors required to be connected to it.

Interface processors implement role_worker behavior, described in role_worker.

Timers

Event handlers

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