Sha256: 54a1284aaea1b6bccda51cdc60031dee671cdd71895ee53e599cf07bf3908774

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 KB

Contents

// FSM definition
var lampSwitchFsm = api.define('Lamp switch FSM', function(fsm){

	fsm.state('some fake intact state w/o transitions');

	fsm.state('Light is OFF')
			.on('turn switch on').transitsTo('ON click sound produced')
			.withEntryAction('turn off', function(){
				SomeAPIforExample.turnOff();
			})
			;

	fsm.state('ON click sound produced')
			.immediateTransitsTo('Light is ON')
			.withEntryAction('do click', function(){
				SomeAPIforExample.doClick();
			})
			.withEntryAction('one more action', function(){
				//something else..
			})
			;

	fsm.state('Light is ON')
			.on('turn switch off').transitsTo('OFF click sound produced');

	fsm.state('OFF click sound produced')
			.immediateTransitsTo('Light is OFF')
			.withEntryAction('turn on', function(){
				SomeAPIforExample.turnOn();
			})
			;

}).withInitialState('Light is OFF').reset();


// render fsm to DOT
var dot = lampSwitchFsm.renderAsDot();

// It returns graph definition in a DOT notation, then it could
// be rendered to an image file using Graphviz tool. Look at
// http://www.graphviz.org for Graphviz.
//
// Here is fsm-sample.png file rendered from lampSwitchFsm.
 

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rhoconnect-client-7.6.0 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-7.5.1 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-7.4.1 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-7.1.17 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-6.2.0 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-6.0.11 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-5.5.18 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-5.5.17 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-5.5.15 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-5.5.0.22 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-5.5.2 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-5.5.0.7 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-5.5.0.3 ./rhoconnect-client/JavaScript/doc/fsm-sample.js
rhoconnect-client-5.5.0 ./rhoconnect-client/JavaScript/doc/fsm-sample.js