diff --git a/support/client/lib/vwf/model/blockly.js b/support/client/lib/vwf/model/blockly.js index 5bdea9eac..27ead98a0 100644 --- a/support/client/lib/vwf/model/blockly.js +++ b/support/client/lib/vwf/model/blockly.js @@ -63,7 +63,8 @@ define( [ "module", "vwf/model", "vwf/utility", "defaultXml": undefined, "code": undefined, "lastLineExeTime": undefined, - "timeBetweenLines": 1, + "timeBetweenLines": 0.5, + "baseExecutionSpeed": 1, "interpreter": undefined, "interpreterStatus": "" }; @@ -226,9 +227,30 @@ define( [ "module", "vwf/model", "vwf/utility", case "blockly_code": value = node.code = propertyValue; break; - + + case "new_xml": + node.blocks = propertyValue; + value = propertyValue; + break; + case "blockly_xml": - value = node.blocks = propertyValue; + node.blocks = propertyValue; + value = propertyValue; + break; + + case "blockly_timeBetweenLines": + this.state.blockly.node.timeBetweenLines = propertyValue; + break; + + case "blockly_baseExecutionSpeed": + + if ( propertyValue > 0 && propertyValue <= 10 ) { + this.state.blockly.node.baseExecutionSpeed = propertyValue; + } else { + this.logger.errorx("baseExecutionSpeed", "Blockly node with", nodeID, + "must be in the range (0,10)."); + } + break; case "blockly_executing": @@ -307,7 +329,7 @@ define( [ "module", "vwf/model", "vwf/utility", // -- callingMethod -------------------------------------------------------------------------- - callingMethod: function( nodeID, methodName /* [, parameter1, parameter2, ... ] */ ) { // TODO: parameters + callingMethod: function( nodeID, methodName, methodParameters ) { var node = this.state.nodes[ nodeID ]; if ( this.debug.methods ) { @@ -317,7 +339,7 @@ define( [ "module", "vwf/model", "vwf/utility", if ( nodeID == this.kernel.application() ) { switch ( methodName ) { - + case "stopAllExecution": for ( var id in this.state.executingBlocks ) { this.state.executingBlocks[ id ].interpreterStatus = "completed"; @@ -332,8 +354,6 @@ define( [ "module", "vwf/model", "vwf/utility", this.kernel.fireEvent( id, "blocklyStarted", [ true ] ); } break; - - } } else if ( node !== undefined ) { switch ( methodName ) { @@ -344,6 +364,17 @@ define( [ "module", "vwf/model", "vwf/utility", this.kernel.setProperty( nodeID, "blockly_xml", '' ); } break; + case "stopExecution": + var currBlockly3Node = this.state.executingBlocks[ nodeID ]; + if ( currBlockly3Node ) { + currBlockly3Node.interpreterStatus = "completed"; + this.kernel.setProperty( nodeID, 'blockly_executing', false ); + this.kernel.fireEvent( nodeID, "blocklyStopped", [ true ] ); + } else { + this.logger.errorx("stopExecutionForNode", "Node with", nodeID, + "is not currently executing Blockly!"); + } + break; } } }, @@ -367,8 +398,9 @@ define( [ "module", "vwf/model", "vwf/utility", for ( var nodeID in this.state.executingBlocks ) { blocklyNode = this.state.executingBlocks[ nodeID ]; - var executeNextLine = false; + var executeNextLine = false; + if ( blocklyNode.interpreter === undefined || blocklyNode.interpreterStatus === "completed" ) { blocklyNode.interpreter = createInterpreter( acorn, blocklyNode.code ); @@ -377,7 +409,7 @@ define( [ "module", "vwf/model", "vwf/utility", executeNextLine = true; } else { var elaspedTime = vwfTime - blocklyNode.lastLineExeTime; - if ( elaspedTime >= blocklyNode.timeBetweenLines ) { + if ( elaspedTime >= ( blocklyNode.timeBetweenLines * blocklyNode.baseExecutionSpeed ) ) { executeNextLine = true; blocklyNode.lastLineExeTime = vwfTime; } @@ -386,10 +418,11 @@ define( [ "module", "vwf/model", "vwf/utility", if ( executeNextLine ) { self.state.executionHalted = false; - nextStep( blocklyNode ); - this.kernel.fireEvent( nodeID, "blocklyExecuted", [ blocklyNode.interpreter.value ] ); + // Does this serve any real purpose? It's not handled in any application. + // Certain blocks, such as repeat blocks, break with the recursive node reference changes. + // this.kernel.fireEvent( nodeID, "blocklyExecuted", [ blocklyNode.interpreter.value ] ); } } } @@ -398,18 +431,6 @@ define( [ "module", "vwf/model", "vwf/utility", } ); - function getPrototypes( extendsID ) { - var prototypes = []; - var id = extendsID; - - while ( id !== undefined ) { - prototypes.push( id ); - id = self.kernel.prototype( id ); - } - - return prototypes; - } - function isBlockly3Node( nodeID ) { return self.kernel.test( nodeID, "self::element(*,'http://vwf.example.com/blockly/controller.vwf')", diff --git a/support/client/lib/vwf/model/blockly/blockly_compressed.js b/support/client/lib/vwf/model/blockly/blockly_compressed.js index 9a0ab7c43..8b6d0159c 100644 --- a/support/client/lib/vwf/model/blockly/blockly_compressed.js +++ b/support/client/lib/vwf/model/blockly/blockly_compressed.js @@ -1,233 +1,366 @@ // Do not edit this file; automatically generated by build.py. "use strict"; -var COMPILED=!0,goog=goog||{};goog.global=this;goog.exportPath_=function(a,b,c){a=a.split(".");c=c||goog.global;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)a.length||void 0===b?c=c[d]?c[d]:c[d]={}:c[d]=b};goog.define=function(a,b){var c=b;COMPILED||goog.global.CLOSURE_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES,a)&&(c=goog.global.CLOSURE_DEFINES[a]);goog.exportPath_(a,c)};goog.DEBUG=!0;goog.LOCALE="en";goog.TRUSTED_SITE=!0; -goog.provide=function(a){if(!COMPILED){if(goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');delete goog.implicitNamespaces_[a];for(var b=a;(b=b.substring(0,b.lastIndexOf(".")))&&!goog.getObjectByName(b);)goog.implicitNamespaces_[b]=!0}goog.exportPath_(a)};goog.setTestOnly=function(a){if(COMPILED&&!goog.DEBUG)throw a=a||"",Error("Importing test-only code into non-debug environment"+a?": "+a:".");}; -COMPILED||(goog.isProvided_=function(a){return!goog.implicitNamespaces_[a]&&!!goog.getObjectByName(a)},goog.implicitNamespaces_={});goog.getObjectByName=function(a,b){for(var c=a.split("."),d=b||goog.global,e;e=c.shift();)if(goog.isDefAndNotNull(d[e]))d=d[e];else return null;return d};goog.globalize=function(a,b){var c=b||goog.global,d;for(d in a)c[d]=a[d]}; -goog.addDependency=function(a,b,c){if(goog.DEPENDENCIES_ENABLED){var d;a=a.replace(/\\/g,"/");for(var e=goog.dependencies_,f=0;d=b[f];f++)e.nameToPath[d]=a,a in e.pathToNames||(e.pathToNames[a]={}),e.pathToNames[a][d]=!0;for(d=0;b=c[d];d++)a in e.requires||(e.requires[a]={}),e.requires[a][b]=!0}};goog.ENABLE_DEBUG_LOADER=!0; -goog.require=function(a){if(!COMPILED&&!goog.isProvided_(a)){if(goog.ENABLE_DEBUG_LOADER){var b=goog.getPathFromDeps_(a);if(b){goog.included_[b]=!0;goog.writeScripts_();return}}a="goog.require could not find: "+a;goog.global.console&&goog.global.console.error(a);throw Error(a);}};goog.basePath="";goog.nullFunction=function(){};goog.identityFunction=function(a,b){return a};goog.abstractMethod=function(){throw Error("unimplemented abstract method");}; -goog.addSingletonGetter=function(a){a.getInstance=function(){if(a.instance_)return a.instance_;goog.DEBUG&&(goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=a);return a.instance_=new a}};goog.instantiatedSingletons_=[];goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER; -goog.DEPENDENCIES_ENABLED&&(goog.included_={},goog.dependencies_={pathToNames:{},nameToPath:{},requires:{},visited:{},written:{}},goog.inHtmlDocument_=function(){var a=goog.global.document;return"undefined"!=typeof a&&"write"in a},goog.findBasePath_=function(){if(goog.global.CLOSURE_BASE_PATH)goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_())for(var a=goog.global.document.getElementsByTagName("script"),b=a.length-1;0<=b;--b){var c=a[b].src,d=c.lastIndexOf("?"),d=-1==d?c.length: -d;if("base.js"==c.substr(d-7,7)){goog.basePath=c.substr(0,d-7);break}}},goog.importScript_=function(a){var b=goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_;!goog.dependencies_.written[a]&&b(a)&&(goog.dependencies_.written[a]=!0)},goog.writeScriptTag_=function(a){if(goog.inHtmlDocument_()){var b=goog.global.document;if("complete"==b.readyState){if(/\bdeps.js$/.test(a))return!1;throw Error('Cannot write "'+a+'" after document load');}b.write('