All Projects → bsutton → fsm2

bsutton / fsm2

Licence: BSD-2-Clause license
FMS2 provides Dart implementation of the core design aspects of the UML state diagrams.

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to fsm2

remachine
[WIP] Reason pattern matching viz
Stars: ✭ 44 (+0%)
Mutual labels:  state-machine
Finite-State-Machines
Implementation of the algorithm in the C#. https://tproger.ru/translations/finite-state-machines-theory-and-implementation/
Stars: ✭ 13 (-70.45%)
Mutual labels:  state-machine
pastafarian
A tiny event-based finite state machine
Stars: ✭ 20 (-54.55%)
Mutual labels:  state-machine
tsm
A Hierarchical State Machine Framework in C++
Stars: ✭ 30 (-31.82%)
Mutual labels:  state-machine
smacha
SMACHA is a meta-scripting, templating, and code generation engine for rapid prototyping of ROS SMACH state machines.
Stars: ✭ 15 (-65.91%)
Mutual labels:  state-machine
workflow-manager
Minimal Workflow orchestrator for AWS Step Functions
Stars: ✭ 20 (-54.55%)
Mutual labels:  state-machine
REstate
Portable state-flows (state-machine based workflows)
Stars: ✭ 35 (-20.45%)
Mutual labels:  state-machine
workflow-activerecord
ActiveRecord/Rails Integration for the Workflow library
Stars: ✭ 24 (-45.45%)
Mutual labels:  state-machine
xstate
State machines and statecharts for the modern web.
Stars: ✭ 21,286 (+48277.27%)
Mutual labels:  state-machine
M2A01 MuSimpron
Small yet powerful state machine coroutine library
Stars: ✭ 34 (-22.73%)
Mutual labels:  state-machine
qp-arduino
QP real-time embedded frameworks/RTOS for Arduino (AVR and SAM)
Stars: ✭ 37 (-15.91%)
Mutual labels:  state-machine
UT Framework
Various advanced tools built for Unreal Engine 4
Stars: ✭ 45 (+2.27%)
Mutual labels:  state-machine
use-state-machine
Use Finite State Machines with React Hooks
Stars: ✭ 28 (-36.36%)
Mutual labels:  state-machine
nxt state machine
A simple but powerful state machine implementation.
Stars: ✭ 14 (-68.18%)
Mutual labels:  state-machine
state-machine-demo
A React state machine demo using xstate
Stars: ✭ 18 (-59.09%)
Mutual labels:  state-machine
Trapheus
This tool automates restoration of RDS database instances from snapshots into any dev, staging or production environments. It supports individual RDS Snapshot as well as cluster snapshot restore operations.
Stars: ✭ 68 (+54.55%)
Mutual labels:  state-machine
tstate-machine
TypeScript implementation of State Manager(like StateMachine)
Stars: ✭ 20 (-54.55%)
Mutual labels:  state-machine
statebot-sh
Statebot for shell-scripts. Write more robust and understandable programs.
Stars: ✭ 14 (-68.18%)
Mutual labels:  state-machine
kstatemachine
KStateMachine is a Kotlin DSL library for creating finite state machines (FSM) and hierarchical state machines (HSM).
Stars: ✭ 63 (+43.18%)
Mutual labels:  state-machine
Flapi
Flapi is an API generator for Java, which generates 'smart' interfaces for improved fluency in your code.
Stars: ✭ 56 (+27.27%)
Mutual labels:  state-machine

FSM2 provides an implementation of the core design aspects of the UML2 state diagrams.

FMS2 supports:

  • Nested States
  • Concurrent Regions
  • Guard Conditions
  • sideEffects
  • onEnter/onExit
  • streams
  • static analysis tools
  • visualisation tools.

Overview

FSM2 uses a builder to delcare each state machine.

Your application may declare as many statemachines as necessary.

Example

import 'package:fsm2/fsm2.dart';

void main() {
  final machine = StateMachine.create((g) => g
    ..initialState(Solid())
    ..state<Solid>((b) => b
      ..on<OnMelted, Liquid>(), sideEffect: (e) => print("I'm melting"))
    ..state<Liquid>((b) {})
 ));

The above examples creates a Finite State Machine (machine) which declares its initial state as being Solid and then declares a single transition which occurs when the event OnMelted event is triggered causing a transition to a new state Liquid.

To trigger an event:

machine.applyEvent(OnMelted());

Documentation

Full documentation is available on gitbooks at:

https://noojee.gitbook.io/fsm2/

Example 2

A simple example showing the life cycle of H2O.

import 'package:fsm2/fsm2.dart';

void main() {
  final machine = StateMachine.create((g) => g
    ..initialState(Solid())
    ..state<Solid>((b) => b
      ..on<OnMelted, Liquid>(sideEffect: (e) => print('Melted'),
          )))
    ..state<Liquid>((b) => b
      ..onEnter((s, e) => print('Entering ${s.runtimeType} State'))
      ..onExit((s, e) => print('Exiting ${s.runtimeType} State'))
      ..on<OnFroze, Solid>(sideEffect: (e) => print('Frozen')))
      ..on<OnVaporized, Gas>(sideEffect: (e) => print('Vaporized'))))
    ..state<Gas>((b) => b
      ..on<OnCondensed, Liquid>(sideEffect: (e) => print('Condensed'))))
    ..onTransition((t) => print(
        'Received Event ${t.event.runtimeType} in State ${t.fromState.runtimeType} transitioning to State ${t.toState.runtimeType}')));

  print(machine.currentState is Solid); // TRUE

  machine.transition(OnMelted());
  print(machine.currentState is Liquid); // TRUE

  machine.transition(OnFroze());
  print(machine.currentState is Solid); // TRUE
}

Credits:

FMS2 is derived from the FSM library which in turn was inspired by Tinder StateMachine library.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].