Skip to content

riddler/statifier

Statifier - SCXML State Machines for Elixir

CI codecov Hex.pm Version Hex Docs

⚠️ Active Development Notice
This project is still under active development and things may change even though it is passed version 1. APIs, features, and behaviors may evolve as we continue improving SCXML compliance and functionality.

An Elixir implementation of SCXML (State Chart XML) state charts with a focus on W3C compliance.

Installation

Add statifier to your list of dependencies in mix.exs:

def deps do
  [
    {:statifier, "~> 1.9"}
  ]
end

For comprehensive examples and usage patterns, see the Getting Started Guide.

Quick Example

# Simple traffic light state machine
xml = """
<scxml initial="red">
  <state id="red">
    <transition event="timer" target="green"/>
  </state>
  <state id="green">
    <transition event="timer" target="yellow"/>
  </state>
  <state id="yellow">
    <transition event="timer" target="red"/>
  </state>
</scxml>
"""

# Parse and initialize
{:ok, document, _warnings} = Statifier.parse(xml)
{:ok, state_chart} = Statifier.initialize(document)

# Check active state
Statifier.active_leaf_states(state_chart)
# MapSet.new(["red"])

# Send events to transition between states  
{:ok, state_chart} = Statifier.send_sync(state_chart, "timer")

# Check active state
Statifier.active_leaf_states(state_chart)
# MapSet.new(["green"])

Documentation

For comprehensive guides, examples, and technical details, see the Statifier Documentation:

Resources

For comprehensive technical details about the implementation, see the Architecture Documentation.

About

StateCharts for Elixir

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages