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).
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.
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:
fsm2 -s -w /path/to/file.smcat
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.
pub global activate dcli
cd /your/projectroot/tool
dcli create gen_smcat.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:
#! /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');
}
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.
tool/gen_smcat.dart
Use the second terminal to have fsm2 watch for changes and automatically display them.