hsm 1.3.3 copy "hsm: ^1.3.3" to clipboard
hsm: ^1.3.3 copied to clipboard

A Hierarchical State Machine (HSM) library for Dart implementing the Unified DSK (Domain Specific Kit).

example/hsm_example.dart

import 'package:hsm/hsm.dart';

void main() {
  final model = define('TrafficLight', [
    state('Operational', [
      state('Green', [
        transition([on('timer'), target('Yellow')])
      ]),
      state('Yellow', [
        transition([on('timer'), target('Red')])
      ]),
      state('Red', [
        transition([on('timer'), target('Green')])
      ]),
      initial(target('Green'))
    ]),
    initial(target('Operational'))
  ]);

  final sm = HSM(Context(), Instance(), model).start();

  print(sm.state); // /TrafficLight/Operational/Green
  sm.dispatch(Event(name: 'timer'));
  print(sm.state); // /TrafficLight/Operational/Yellow
}
0
likes
140
points
91
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A Hierarchical State Machine (HSM) library for Dart implementing the Unified DSK (Domain Specific Kit).

License

MIT (license)

Dependencies

meta, path

More

Packages that depend on hsm