Simple extension of SCION by Jacob Beard
This SCION wrapper provides some additional functionalities with respect to the original implementation.
Those includes:
- UMD enabled
- Loader uses jQuery Deferreds
- Convenient getter functions such as
getActiveEvents()
which returns all accepted events at a current configuration including those subsumed by valid parent states - The SCION interpreter takes account for the attribute "name" of the state that can be obtained by the function
getStateName()
- The SCION interpreter takes account for the attribute "type" of the state that can be obtained by the function
getStateType()
- Additional tweaks during runtime behavior such as a toggle switching on/off script execution inside SCXML:
ignoreScript()
andevaluateScript()
Install the module with: npm install scion-x
var config = {
doc: 'http://localhost:9995/scxml.xml', // url locates the SCXML document
evalScript: true, // default value for script execution
// using SCION inbuilt listener to report engine activities
scionListener: {
statesActive: [],
onEntry: function(stateName) {
console.debug('entry', stateName);
// some additional code
},
onExit: function(stateName) {∂
console.debug('exit', stateName);
// some additional code
},
onTransition: function(sourceState, targetStates) {
console.debug(sourceState, 'transits to', targetStates);
// some additional code
}
},
// using scion-x to report engine activities
onraise: function(e) {
console.debug('current state:', this.getState());
console.debug('active states:', this.getActiveStates());
console.debug('active events:', this.getActiveEvents());
}
};
(function(global, factory) {
if (typeof module === 'object') {
module.exports = factory(require('scionx'));
} else if (typeof define === 'function' && define.amd) {
define(['scionx'], factory);
} else {
factory(scionx);
}
})(this, function(scion) {
scion(config).init(function(_engine) {
_engine.start();
// some additional code
});
});
- Set the path to your node_modules containing the required grunt plugins (see package.json) inside Gruntfile.js
- Type in your command line:
grunt
You can also just execute with node usage
. Though, before you need to start the file server that serves the SCXML document. To this end you go to the folder scxml and type in your terminal: node file-server
- Set the path to your node_modules containing the required grunt plugins (see package.json) inside Gruntfile.js
- Adapt comment as below
- Type in your command line:
grunt serve:browser
<script type="text/javascript" src="lib/scionWrapper.js"></script>
<script type="text/javascript" src="node_modules/umd-logger/lib/umd-logger.js"></script>
<script type="text/javascript" src="usage.js"></script>
- Set the path to your node_modules containing the required grunt plugins (see package.json) inside Gruntfile.js
- Adapt index.html as below
- Type in your command line:
grunt serve:browser
<script type="text/javascript">
var require = {
paths: {
'umd-logger': './node_modules/umd-logger/lib/umd-logger',
'scionx': './lib/scionLoader',
'scionWrapper': './lib/scionWrapper',
'scion': './node_modules/scion/dist/scion'
},
deps: ['usage']
}
</script>
<script type="text/javascript" src="require.js"></script>
Copyright (c) 2014 Christian H. Schulz
Licensed under the MIT license.