View Source Finitomata.Transition (Finitomata v0.5.0)

The internal representation of Transition.

It includes from and to states, and the event, all represented as atoms.

Link to this section Summary

Types

The event in FSM

The state of FSM

t()

The transition is represented by from and to states and the event.

Functions

Returns the list of all the transitions, matching the from state and the event.

Returns true if the transition fromto is allowed, false otherwise.

Returns the state after starting one, so-called entry state.

Returns true if the state from hsa an outgoing transition with event, false otherwise.

Returns the not ordered list of states, excluding the starting and ending states :*.

Link to this section Types

@type event() :: atom()

The event in FSM

@type state() :: atom()

The state of FSM

@type t() :: %Finitomata.Transition{from: state(), to: state(), event: event()}

The transition is represented by from and to states and the event.

Link to this section Functions

Link to this function

allowed(transitions, from, event \\ nil)

View Source
@spec allowed([t()], state(), nil | event()) :: [state()]

Returns the list of all the transitions, matching the from state and the event.

Used internally for the validations.

iex> {:ok, transitions} =
...>   Finitomata.PlantUML.parse("[*] --> s1 : foo\ns1 --> s2 : ok\ns2 --> [*] : ko")
...> Finitomata.Transition.allowed(transitions, :s1, :foo)
[:s2]
...> Finitomata.Transition.allowed(transitions, :s1, :*)
[]
Link to this function

allowed?(transitions, from, to)

View Source
@spec allowed?([t()], state(), state()) :: boolean()

Returns true if the transition fromto is allowed, false otherwise.

iex> {:ok, transitions} =
...>   Finitomata.PlantUML.parse("[*] --> s1 : foo\ns1 --> s2 : ok\ns2 --> [*] : ko")
...> Finitomata.Transition.allowed?(transitions, :s1, :s2)
true
...> Finitomata.Transition.allowed?(transitions, :s1, :*)
false
@spec entry([t()]) :: state()

Returns the state after starting one, so-called entry state.

iex> {:ok, transitions} =
...>   Finitomata.PlantUML.parse("[*] --> s1 : foo\ns1 --> s2 : ok\ns2 --> [*] : ko")
...> Finitomata.Transition.entry(transitions)
:s1
Link to this function

responds?(transitions, from, event)

View Source
@spec responds?([t()], state(), event()) :: boolean()

Returns true if the state from hsa an outgoing transition with event, false otherwise.

iex> {:ok, transitions} =
...>   Finitomata.PlantUML.parse("[*] --> s1 : foo\ns1 --> s2 : ok\ns2 --> [*] : ko")
...> Finitomata.Transition.responds?(transitions, :s1, :ok)
true
...> Finitomata.Transition.responds?(transitions, :s1, :ko)
false
@spec states([t()]) :: [state()]

Returns the not ordered list of states, excluding the starting and ending states :*.

iex> {:ok, transitions} =
...>   Finitomata.PlantUML.parse("[*] --> s1 : foo\ns1 --> s2 : ok\ns2 --> [*] : ko")
...> Finitomata.Transition.states(transitions)
[:s1, :s2]