Permalink
Browse files

Intermediate commit. Eliminating and refactoring.

  • Loading branch information...
1 parent cc6ad9d commit faab3520529cc1168cb5143c826c85a9004ec53d @jbeard4 committed Mar 27, 2012
View
View
@@ -1,28 +1,36 @@
-var fs = require('fs');
+var xml2jsonml = require('xml2jsonml'),
+ annotator = require('../lib/util/annotate-scxml-json'),
+ json2model = require('../lib/scxml/json2model'),
+ scxml = require('../lib/scxml/SCXML');
-var s = fs.readFileSync('build/basic1.annotated.scxml.json','utf8');
-var annotatedScxmlJson = JSON.parse(s);
-var scion = require('scion');
+//1 - 2. get the xml file and convert it to jsonml
+xml2jsonml.parseFile(process.argv[2],function(scxmlJson){
-//4. Convert the SCXML-JSON document to a statechart object model. This step essentially converts id labels to object references, parses JavaScript scripts and expressions embedded in the SCXML as js functions, and does some validation for correctness.
-var model = scion.json2model(annotatedScxmlJson);
-console.log("model",model);
+ //3. annotate jsonml
+ var annotatedScxmlJson = annotator.transform(scxmlJson,true,true,true,true);
-//5. Use the statechart object model to instantiate an instance of the statechart interpreter. Optionally, we can pass to the construct an object to be used as the context object (the 'this' object) in script evaluation. Lots of other parameters are available.
-var interpreter = new scion.NodeInterpreter(model);
-console.log("interpreter",interpreter);
+ //4. Convert the SCXML-JSON document to a statechart object model. This step essentially converts id labels to object references, parses JavaScript scripts and expressions embedded in the SCXML as js functions, and does some validation for correctness.
+ var model = json2model(annotatedScxmlJson);
+ console.log("model",model);
-//6. We would connect relevant event listeners to the statechart instance here.
+ //5. Use the statechart object model to instantiate an instance of the statechart interpreter. Optionally, we can pass to the construct an object to be used as the context object (the 'this' object) in script evaluation. Lots of other parameters are available.
+ var interpreter = new scxml.NodeInterpreter(model);
+ console.log("interpreter",interpreter);
-//7. Call the start method on the new intrepreter instance to start execution of the statechart.
-interpreter.start()
+ //6. We would connect relevant event listeners to the statechart instance here.
-//let's test it by printing current state
-console.log("initial configuration",interpreter.getConfiguration());
+ //7. Call the start method on the new intrepreter instance to start execution of the statechart.
+ interpreter.start();
-//send an event, inspect new configuration
-console.log("sending event t");
-interpreter.gen(new scion.Event("t"));
+ //let's test it by printing current state
+ console.log("initial configuration",interpreter.getConfiguration());
+
+ //send an event, inspect new configuration
+ console.log("sending event t");
+ interpreter.gen({name : "t"});
+
+ console.log("next configuration",interpreter.getConfiguration());
+
+});
-console.log("next configuration",interpreter.getConfiguration());
View
@@ -1,17 +0,0 @@
-npm install scion
-
-mkdir build
-
-#1. Get the SCXML document. Nothing to do for now...
-
-#2. Convert the XML to JsonML using XSLT or DOM, and parse the JSON to an SCXML-JSON document.
-scxml-to-json basic1.scxml > build/basic1.scxml.json
-
-#3. Annotate and transform the SCXML-JSON document so that it is in a form more congenial to interpretation, creating an annotated SCXML-JSON document
-annotate-scxml-json build/basic1.scxml.json build/basic1.annotated.scxml.json
-
-#note: you could also combine the above steps as follows:
-#scxml-to-json basic1.scxml | annotate-scxml-json - build/basic1.annotated.scxml.json
-
-#call into node to do the rest
-node test.js
Oops, something went wrong.

0 comments on commit faab352

Please sign in to comment.