Skip to content

Instantly share code, notes, and snippets.

@mogsie
Created May 21, 2018 19:57
Show Gist options
  • Save mogsie/1f155877db6e93b3463df8bc314b7e8d to your computer and use it in GitHub Desktop.
Save mogsie/1f155877db6e93b3463df8bc314b7e8d to your computer and use it in GitHub Desktop.
const scxml = require('scxml');
scxml.pathToModel("transient.xml",function(err,model){
if (err) throw err;
model.prepare(function(err, fnModel) {
if(err) throw err;
//instantiate the interpreter
var sc = new scxml.scion.Statechart(fnModel);
//start the interpreter
sc.start();
//send the init event
console.log(sc.gen({name:"E"}));
});
});
<scxml xmlns="http://www.w3.org/2005/07/scxml"
version="1.0"
profile="ecmascript"
id="root"
initial="m">
<parallel id="m">
<state id="A">
<state id="A1">
<transition event="E" target="A2"/>
</state>
<state id="A2">
<onentry>
<raise event="INT1"/>
</onentry>
</state>
</state>
<state id="B">
<state id="B1">
<transition event="E" target="B2"/>
</state>
<state id="B2">
<onentry>
<raise event="INT2"/>
</onentry>
</state>
</state>
<state id="C">
<state id="C1">
<transition event="INT1" target="C2"/>
<transition event="INT2" target="C3"/>
</state>
<state id="C2">
<transition event="INT2" target="C4"/>
</state>
<state id="C3">
<transition event="INT1" target="C4"/>
</state>
<state id="C4">
</state>
</state>
</parallel>
</scxml>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment