It can be extremely useful to visualise you FSM and with that in mind FSM2 is able to export your FSM to the smcat format and then convert that to an svg file (image).
Desktop application for viewing all the svg pages of your FSM.
Page Breaks
When you FSM gets large it can be had to analyse the entire statemachine one page.
FSM2 allows you to put page breaks into rendered image.
You can add a page break at any state of coregion.
In the above example the 'Dead' will appear on two pages. It will appear on page 1 as a simple state and it will appear on page 1 as the parent state of any nested children. The blue border indicates a parent state whose contents is displayed on the next page.
Page 1
Page 2
Watch and refresh
Whilst working on you fsm it can be handy to see the latest version of the FSM.
You can use the fsm2 watch option to regenerate and display the latest svg file:
Now each time you regenerate the smcat file fsm2 will launch firefox with the latest version.
Script it
You can use dcli to re-generate and display your smcat file on demand.
Dcli is a library and tooling for creating cli apps using dart.
Dcli will create a sample script and a pubspec.yaml in the tool directory. Edit the pubspec.yaml in the tool directory to include your own project:
Replace the contents of gen_smcat.dart with:
To generate and visualise your FSM.
Open two terminal windows
Use the first terminal window to regenerate the smcat file each time you change your fsm.
Use the second terminal to have fsm2 watch for changes and automatically display them.
#! /usr/bin/env dcli
import 'dart:io';
import 'package:dcli/dcli.dart';
/// path to script that generates fsm
import '../cleaning_air_fsm.dart';
void main(List<String> args) {
// replace 'createMachine' with a call to your method
// that creates your fsm.
var machine = createMachine();
machine.export('cleaning_air.smcat');
}