add multi interval feature
This commit is contained in:
		
							parent
							
								
									b74aef8167
								
							
						
					
					
						commit
						5901caa278
					
				| @ -1,11 +1,9 @@ | |||||||
| import Blockly from 'blockly/core'; | import Blockly from "blockly/core"; | ||||||
| import { getColour } from '../helpers/colour'; | import { getColour } from "../helpers/colour"; | ||||||
| import * as Types from '../helpers/types'; | import * as Types from "../helpers/types"; | ||||||
| import { getCompatibleTypes } from '../helpers/types'; | import { getCompatibleTypes } from "../helpers/types"; | ||||||
| 
 | 
 | ||||||
| 
 | Blockly.Blocks["controls_if"] = { | ||||||
| 
 |  | ||||||
| Blockly.Blocks['controls_if'] = { |  | ||||||
|   /** |   /** | ||||||
|    * Block for if/elseif/else condition. |    * Block for if/elseif/else condition. | ||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
| @ -13,15 +11,17 @@ Blockly.Blocks['controls_if'] = { | |||||||
|   init: function () { |   init: function () { | ||||||
|     this.setHelpUrl(Blockly.Msg.CONTROLS_IF_HELPURL); |     this.setHelpUrl(Blockly.Msg.CONTROLS_IF_HELPURL); | ||||||
|     this.setColour(getColour().logic); |     this.setColour(getColour().logic); | ||||||
|         this.appendValueInput('IF0') |     this.appendValueInput("IF0") | ||||||
|             .setCheck(Types.getCompatibleTypes('boolean')) |       .setCheck(Types.getCompatibleTypes("boolean")) | ||||||
|       .appendField(Blockly.Msg.CONTROLS_IF_MSG_IF); |       .appendField(Blockly.Msg.CONTROLS_IF_MSG_IF); | ||||||
|         this.appendStatementInput('DO0') |     this.appendStatementInput("DO0").appendField( | ||||||
|             .appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN); |       Blockly.Msg.CONTROLS_IF_MSG_THEN | ||||||
|  |     ); | ||||||
|     this.setPreviousStatement(true); |     this.setPreviousStatement(true); | ||||||
|     this.setNextStatement(true); |     this.setNextStatement(true); | ||||||
|         this.setMutator(new Blockly.Mutator(['controls_if_elseif', |     this.setMutator( | ||||||
|             'controls_if_else'])); |       new Blockly.Mutator(["controls_if_elseif", "controls_if_else"]) | ||||||
|  |     ); | ||||||
|     // Assign 'this' to a variable for use in the tooltip closure below.
 |     // Assign 'this' to a variable for use in the tooltip closure below.
 | ||||||
|     var thisBlock = this; |     var thisBlock = this; | ||||||
|     this.setTooltip(function () { |     this.setTooltip(function () { | ||||||
| @ -34,7 +34,7 @@ Blockly.Blocks['controls_if'] = { | |||||||
|       } else if (thisBlock.elseifCount_ && thisBlock.elseCount_) { |       } else if (thisBlock.elseifCount_ && thisBlock.elseCount_) { | ||||||
|         return Blockly.Msg.CONTROLS_IF_TOOLTIP_4; |         return Blockly.Msg.CONTROLS_IF_TOOLTIP_4; | ||||||
|       } |       } | ||||||
|             return ''; |       return ""; | ||||||
|     }); |     }); | ||||||
|     this.elseifCount_ = 0; |     this.elseifCount_ = 0; | ||||||
|     this.elseCount_ = 0; |     this.elseCount_ = 0; | ||||||
| @ -48,12 +48,12 @@ Blockly.Blocks['controls_if'] = { | |||||||
|     if (!this.elseifCount_ && !this.elseCount_) { |     if (!this.elseifCount_ && !this.elseCount_) { | ||||||
|       return null; |       return null; | ||||||
|     } |     } | ||||||
|         var container = document.createElement('mutation'); |     var container = document.createElement("mutation"); | ||||||
|     if (this.elseifCount_) { |     if (this.elseifCount_) { | ||||||
|             container.setAttribute('elseif', this.elseifCount_); |       container.setAttribute("elseif", this.elseifCount_); | ||||||
|     } |     } | ||||||
|     if (this.elseCount_) { |     if (this.elseCount_) { | ||||||
|             container.setAttribute('else', 1); |       container.setAttribute("else", 1); | ||||||
|     } |     } | ||||||
|     return container; |     return container; | ||||||
|   }, |   }, | ||||||
| @ -63,8 +63,8 @@ Blockly.Blocks['controls_if'] = { | |||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
|    */ |    */ | ||||||
|   domToMutation: function (xmlElement) { |   domToMutation: function (xmlElement) { | ||||||
|         this.elseifCount_ = parseInt(xmlElement.getAttribute('elseif'), 10) || 0; |     this.elseifCount_ = parseInt(xmlElement.getAttribute("elseif"), 10) || 0; | ||||||
|         this.elseCount_ = parseInt(xmlElement.getAttribute('else'), 10) || 0; |     this.elseCount_ = parseInt(xmlElement.getAttribute("else"), 10) || 0; | ||||||
|     this.updateShape_(); |     this.updateShape_(); | ||||||
|   }, |   }, | ||||||
|   /** |   /** | ||||||
| @ -74,17 +74,17 @@ Blockly.Blocks['controls_if'] = { | |||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
|    */ |    */ | ||||||
|   decompose: function (workspace) { |   decompose: function (workspace) { | ||||||
|         var containerBlock = workspace.newBlock('controls_if_if'); |     var containerBlock = workspace.newBlock("controls_if_if"); | ||||||
|     containerBlock.initSvg(); |     containerBlock.initSvg(); | ||||||
|     var connection = containerBlock.nextConnection; |     var connection = containerBlock.nextConnection; | ||||||
|     for (var i = 1; i <= this.elseifCount_; i++) { |     for (var i = 1; i <= this.elseifCount_; i++) { | ||||||
|             var elseifBlock = workspace.newBlock('controls_if_elseif'); |       var elseifBlock = workspace.newBlock("controls_if_elseif"); | ||||||
|       elseifBlock.initSvg(); |       elseifBlock.initSvg(); | ||||||
|       connection.connect(elseifBlock.previousConnection); |       connection.connect(elseifBlock.previousConnection); | ||||||
|       connection = elseifBlock.nextConnection; |       connection = elseifBlock.nextConnection; | ||||||
|     } |     } | ||||||
|     if (this.elseCount_) { |     if (this.elseCount_) { | ||||||
|             var elseBlock = workspace.newBlock('controls_if_else'); |       var elseBlock = workspace.newBlock("controls_if_else"); | ||||||
|       elseBlock.initSvg(); |       elseBlock.initSvg(); | ||||||
|       connection.connect(elseBlock.previousConnection); |       connection.connect(elseBlock.previousConnection); | ||||||
|     } |     } | ||||||
| @ -105,28 +105,28 @@ Blockly.Blocks['controls_if'] = { | |||||||
|     var elseStatementConnection = null; |     var elseStatementConnection = null; | ||||||
|     while (clauseBlock) { |     while (clauseBlock) { | ||||||
|       switch (clauseBlock.type) { |       switch (clauseBlock.type) { | ||||||
|                 case 'controls_if_elseif': |         case "controls_if_elseif": | ||||||
|           this.elseifCount_++; |           this.elseifCount_++; | ||||||
|           valueConnections.push(clauseBlock.valueConnection_); |           valueConnections.push(clauseBlock.valueConnection_); | ||||||
|           statementConnections.push(clauseBlock.statementConnection_); |           statementConnections.push(clauseBlock.statementConnection_); | ||||||
|           break; |           break; | ||||||
|                 case 'controls_if_else': |         case "controls_if_else": | ||||||
|           this.elseCount_++; |           this.elseCount_++; | ||||||
|           elseStatementConnection = clauseBlock.statementConnection_; |           elseStatementConnection = clauseBlock.statementConnection_; | ||||||
|           break; |           break; | ||||||
|         default: |         default: | ||||||
|                     throw new Error('Unknown block type.'); |           throw new Error("Unknown block type."); | ||||||
|       } |       } | ||||||
|             clauseBlock = clauseBlock.nextConnection && |       clauseBlock = | ||||||
|                 clauseBlock.nextConnection.targetBlock(); |         clauseBlock.nextConnection && clauseBlock.nextConnection.targetBlock(); | ||||||
|     } |     } | ||||||
|     this.updateShape_(); |     this.updateShape_(); | ||||||
|     // Reconnect any child blocks.
 |     // Reconnect any child blocks.
 | ||||||
|     for (var i = 1; i <= this.elseifCount_; i++) { |     for (var i = 1; i <= this.elseifCount_; i++) { | ||||||
|             Blockly.Mutator.reconnect(valueConnections[i], this, 'IF' + i); |       Blockly.Mutator.reconnect(valueConnections[i], this, "IF" + i); | ||||||
|             Blockly.Mutator.reconnect(statementConnections[i], this, 'DO' + i); |       Blockly.Mutator.reconnect(statementConnections[i], this, "DO" + i); | ||||||
|     } |     } | ||||||
|         Blockly.Mutator.reconnect(elseStatementConnection, this, 'ELSE'); |     Blockly.Mutator.reconnect(elseStatementConnection, this, "ELSE"); | ||||||
|   }, |   }, | ||||||
|   /** |   /** | ||||||
|    * Store pointers to any connected child blocks. |    * Store pointers to any connected child blocks. | ||||||
| @ -139,25 +139,25 @@ Blockly.Blocks['controls_if'] = { | |||||||
|     var inputDo; |     var inputDo; | ||||||
|     while (clauseBlock) { |     while (clauseBlock) { | ||||||
|       switch (clauseBlock.type) { |       switch (clauseBlock.type) { | ||||||
|                 case 'controls_if_elseif': |         case "controls_if_elseif": | ||||||
|                     var inputIf = this.getInput('IF' + i); |           var inputIf = this.getInput("IF" + i); | ||||||
|                     inputDo = this.getInput('DO' + i); |           inputDo = this.getInput("DO" + i); | ||||||
|           clauseBlock.valueConnection_ = |           clauseBlock.valueConnection_ = | ||||||
|             inputIf && inputIf.connection.targetConnection; |             inputIf && inputIf.connection.targetConnection; | ||||||
|           clauseBlock.statementConnection_ = |           clauseBlock.statementConnection_ = | ||||||
|             inputDo && inputDo.connection.targetConnection; |             inputDo && inputDo.connection.targetConnection; | ||||||
|           i++; |           i++; | ||||||
|           break; |           break; | ||||||
|                 case 'controls_if_else': |         case "controls_if_else": | ||||||
|                     inputDo = this.getInput('ELSE'); |           inputDo = this.getInput("ELSE"); | ||||||
|           clauseBlock.statementConnection_ = |           clauseBlock.statementConnection_ = | ||||||
|             inputDo && inputDo.connection.targetConnection; |             inputDo && inputDo.connection.targetConnection; | ||||||
|           break; |           break; | ||||||
|         default: |         default: | ||||||
|                     throw new Error('Unknown block type.'); |           throw new Error("Unknown block type."); | ||||||
|       } |       } | ||||||
|             clauseBlock = clauseBlock.nextConnection && |       clauseBlock = | ||||||
|                 clauseBlock.nextConnection.targetBlock(); |         clauseBlock.nextConnection && clauseBlock.nextConnection.targetBlock(); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   /** |   /** | ||||||
| @ -167,290 +167,296 @@ Blockly.Blocks['controls_if'] = { | |||||||
|    */ |    */ | ||||||
|   updateShape_: function () { |   updateShape_: function () { | ||||||
|     // Delete everything.
 |     // Delete everything.
 | ||||||
|         if (this.getInput('ELSE')) { |     if (this.getInput("ELSE")) { | ||||||
|             this.removeInput('ELSE'); |       this.removeInput("ELSE"); | ||||||
|     } |     } | ||||||
|     var j = 1; |     var j = 1; | ||||||
|         while (this.getInput('IF' + j)) { |     while (this.getInput("IF" + j)) { | ||||||
|             this.removeInput('IF' + j); |       this.removeInput("IF" + j); | ||||||
|             this.removeInput('DO' + j); |       this.removeInput("DO" + j); | ||||||
|       j++; |       j++; | ||||||
|     } |     } | ||||||
|     // Rebuild block.
 |     // Rebuild block.
 | ||||||
|     for (var i = 1; i <= this.elseifCount_; i++) { |     for (var i = 1; i <= this.elseifCount_; i++) { | ||||||
|             this.appendValueInput('IF' + i) |       this.appendValueInput("IF" + i) | ||||||
|                 .setCheck(Types.getCompatibleTypes('boolean')) |         .setCheck(Types.getCompatibleTypes("boolean")) | ||||||
|         .appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF); |         .appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF); | ||||||
|             this.appendStatementInput('DO' + i) |       this.appendStatementInput("DO" + i).appendField( | ||||||
|                 .appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN); |         Blockly.Msg.CONTROLS_IF_MSG_THEN | ||||||
|  |       ); | ||||||
|     } |     } | ||||||
|     if (this.elseCount_) { |     if (this.elseCount_) { | ||||||
|             this.appendStatementInput('ELSE') |       this.appendStatementInput("ELSE").appendField( | ||||||
|                 .appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE); |         Blockly.Msg.CONTROLS_IF_MSG_ELSE | ||||||
|         } |       ); | ||||||
|     } |     } | ||||||
|  |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['controls_if_if'] = { | Blockly.Blocks["controls_if_if"] = { | ||||||
|   /** |   /** | ||||||
|    * Mutator block for if container. |    * Mutator block for if container. | ||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
|    */ |    */ | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.setColour(getColour().logic); |     this.setColour(getColour().logic); | ||||||
|         this.appendDummyInput() |     this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF); | ||||||
|             .appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF); |  | ||||||
|     this.setNextStatement(true); |     this.setNextStatement(true); | ||||||
|     this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP); |     this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP); | ||||||
|     this.contextMenu = false; |     this.contextMenu = false; | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['controls_if_elseif'] = { | Blockly.Blocks["controls_if_elseif"] = { | ||||||
|   /** |   /** | ||||||
|    * Mutator bolck for else-if condition. |    * Mutator bolck for else-if condition. | ||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
|    */ |    */ | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.setColour(getColour().logic); |     this.setColour(getColour().logic); | ||||||
|         this.appendDummyInput() |     this.appendDummyInput().appendField( | ||||||
|             .appendField(Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF); |       Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF | ||||||
|  |     ); | ||||||
|     this.setPreviousStatement(true); |     this.setPreviousStatement(true); | ||||||
|     this.setNextStatement(true); |     this.setNextStatement(true); | ||||||
|     this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP); |     this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP); | ||||||
|     this.contextMenu = false; |     this.contextMenu = false; | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['controls_if_else'] = { | Blockly.Blocks["controls_if_else"] = { | ||||||
|   /** |   /** | ||||||
|    * Mutator block for else condition. |    * Mutator block for else condition. | ||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
|    */ |    */ | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.setColour(getColour().logic); |     this.setColour(getColour().logic); | ||||||
|         this.appendDummyInput() |     this.appendDummyInput().appendField( | ||||||
|             .appendField(Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE); |       Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE | ||||||
|  |     ); | ||||||
|     this.setPreviousStatement(true); |     this.setPreviousStatement(true); | ||||||
|     this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP); |     this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP); | ||||||
|     this.contextMenu = false; |     this.contextMenu = false; | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | Blockly.defineBlocksWithJsonArray([ | ||||||
| Blockly.defineBlocksWithJsonArray([  // BEGIN JSON EXTRACT
 |   // BEGIN JSON EXTRACT
 | ||||||
|   // Block for boolean data type: true and false.
 |   // Block for boolean data type: true and false.
 | ||||||
|   { |   { | ||||||
|         "type": "logic_boolean", |     type: "logic_boolean", | ||||||
|         "message0": "%1", |     message0: "%1", | ||||||
|         "args0": [ |     args0: [ | ||||||
|       { |       { | ||||||
|                 "type": "field_dropdown", |         type: "field_dropdown", | ||||||
|                 "name": "BOOL", |         name: "BOOL", | ||||||
|                 "options": [ |         options: [ | ||||||
|           ["%{BKY_LOGIC_BOOLEAN_TRUE}", "TRUE"], |           ["%{BKY_LOGIC_BOOLEAN_TRUE}", "TRUE"], | ||||||
|                     ["%{BKY_LOGIC_BOOLEAN_FALSE}", "FALSE"] |           ["%{BKY_LOGIC_BOOLEAN_FALSE}", "FALSE"], | ||||||
|                 ] |  | ||||||
|             } |  | ||||||
|         ], |         ], | ||||||
|         "output": Types.BOOLEAN.typeName, |       }, | ||||||
|         "style": "logic_blocks", |     ], | ||||||
|         "tooltip": "%{BKY_LOGIC_BOOLEAN_TOOLTIP}", |     output: Types.BOOLEAN.typeName, | ||||||
|         "helpUrl": "%{BKY_LOGIC_BOOLEAN_HELPURL}" |     style: "logic_blocks", | ||||||
|  |     tooltip: "%{BKY_LOGIC_BOOLEAN_TOOLTIP}", | ||||||
|  |     helpUrl: "%{BKY_LOGIC_BOOLEAN_HELPURL}", | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|         "type": "controls_ifelse", |     type: "controls_ifelse", | ||||||
|         "message0": "%{BKY_CONTROLS_IF_MSG_IF} %1", |     message0: "%{BKY_CONTROLS_IF_MSG_IF} %1", | ||||||
|         "args0": [ |     args0: [ | ||||||
|       { |       { | ||||||
|                 "type": "input_value", |         type: "input_value", | ||||||
|                 "name": "IF0", |         name: "IF0", | ||||||
|                 "check": Types.getCompatibleTypes('boolean') |         check: Types.getCompatibleTypes("boolean"), | ||||||
|             } |       }, | ||||||
|     ], |     ], | ||||||
|         "message1": "%{BKY_CONTROLS_IF_MSG_THEN} %1", |     message1: "%{BKY_CONTROLS_IF_MSG_THEN} %1", | ||||||
|         "args1": [ |     args1: [ | ||||||
|       { |       { | ||||||
|                 "type": "input_statement", |         type: "input_statement", | ||||||
|                 "name": "DO0" |         name: "DO0", | ||||||
|             } |       }, | ||||||
|     ], |     ], | ||||||
|         "message2": "%{BKY_CONTROLS_IF_MSG_ELSE} %1", |     message2: "%{BKY_CONTROLS_IF_MSG_ELSE} %1", | ||||||
|         "args2": [ |     args2: [ | ||||||
|       { |       { | ||||||
|                 "type": "input_statement", |         type: "input_statement", | ||||||
|                 "name": "ELSE" |         name: "ELSE", | ||||||
|             } |       }, | ||||||
|     ], |     ], | ||||||
|         "previousStatement": null, |     previousStatement: null, | ||||||
|         "nextStatement": null, |     nextStatement: null, | ||||||
|         "style": "logic_blocks", |     style: "logic_blocks", | ||||||
|         "tooltip": "%{BKYCONTROLS_IF_TOOLTIP_2}", |     tooltip: "%{BKYCONTROLS_IF_TOOLTIP_2}", | ||||||
|         "helpUrl": "%{BKY_CONTROLS_IF_HELPURL}", |     helpUrl: "%{BKY_CONTROLS_IF_HELPURL}", | ||||||
|         "extensions": ["controls_if_tooltip"] |     extensions: ["controls_if_tooltip"], | ||||||
|   }, |   }, | ||||||
|   // Block for comparison operator.
 |   // Block for comparison operator.
 | ||||||
|   { |   { | ||||||
|         "type": "logic_compare", |     type: "logic_compare", | ||||||
|         "message0": "%1 %2 %3", |     message0: "%1 %2 %3", | ||||||
|         "args0": [ |     args0: [ | ||||||
|       { |       { | ||||||
|                 "type": "input_value", |         type: "input_value", | ||||||
|                 "name": "A" |         name: "A", | ||||||
|       }, |       }, | ||||||
|       { |       { | ||||||
|                 "type": "field_dropdown", |         type: "field_dropdown", | ||||||
|                 "name": "OP", |         name: "OP", | ||||||
|                 "options": [ |         options: [ | ||||||
|           ["=", "EQ"], |           ["=", "EQ"], | ||||||
|           ["\u2260", "NEQ"], |           ["\u2260", "NEQ"], | ||||||
|           ["\u200F<", "LT"], |           ["\u200F<", "LT"], | ||||||
|           ["\u200F\u2264", "LTE"], |           ["\u200F\u2264", "LTE"], | ||||||
|           ["\u200F>", "GT"], |           ["\u200F>", "GT"], | ||||||
|                     ["\u200F\u2265", "GTE"] |           ["\u200F\u2265", "GTE"], | ||||||
|                 ] |         ], | ||||||
|       }, |       }, | ||||||
|       { |       { | ||||||
|                 "type": "input_value", |         type: "input_value", | ||||||
|                 "name": "B" |         name: "B", | ||||||
|             } |       }, | ||||||
|     ], |     ], | ||||||
|         "inputsInline": true, |     inputsInline: true, | ||||||
|         "output": Types.BOOLEAN.typeName, |     output: Types.BOOLEAN.typeName, | ||||||
|         "style": "logic_blocks", |     style: "logic_blocks", | ||||||
|         "helpUrl": "%{BKY_LOGIC_COMPARE_HELPURL}", |     helpUrl: "%{BKY_LOGIC_COMPARE_HELPURL}", | ||||||
|         "extensions": ["logic_compare", "logic_op_tooltip"] |     extensions: ["logic_compare", "logic_op_tooltip"], | ||||||
|   }, |   }, | ||||||
|   // Block for logical operations: 'and', 'or'.
 |   // Block for logical operations: 'and', 'or'.
 | ||||||
|   { |   { | ||||||
|         "type": "logic_operation", |     type: "logic_operation", | ||||||
|         "message0": "%1 %2 %3", |     message0: "%1 %2 %3", | ||||||
|         "args0": [ |     args0: [ | ||||||
|       { |       { | ||||||
|                 "type": "input_value", |         type: "input_value", | ||||||
|                 "name": "A", |         name: "A", | ||||||
|                 "check": Types.getCompatibleTypes('boolean') |         check: Types.getCompatibleTypes("boolean"), | ||||||
|       }, |       }, | ||||||
|       { |       { | ||||||
|                 "type": "field_dropdown", |         type: "field_dropdown", | ||||||
|                 "name": "OP", |         name: "OP", | ||||||
|                 "options": [ |         options: [ | ||||||
|           ["%{BKY_LOGIC_OPERATION_AND}", "AND"], |           ["%{BKY_LOGIC_OPERATION_AND}", "AND"], | ||||||
|                     ["%{BKY_LOGIC_OPERATION_OR}", "OR"] |           ["%{BKY_LOGIC_OPERATION_OR}", "OR"], | ||||||
|                 ] |         ], | ||||||
|       }, |       }, | ||||||
|       { |       { | ||||||
|                 "type": "input_value", |         type: "input_value", | ||||||
|                 "name": "B", |         name: "B", | ||||||
|                 "check": Types.getCompatibleTypes('boolean') |         check: Types.getCompatibleTypes("boolean"), | ||||||
|             } |       }, | ||||||
|     ], |     ], | ||||||
|         "inputsInline": true, |     inputsInline: true, | ||||||
|         "output": Types.BOOLEAN.typeName, |     output: Types.BOOLEAN.typeName, | ||||||
|         "style": "logic_blocks", |     style: "logic_blocks", | ||||||
|         "helpUrl": "%{BKY_LOGIC_OPERATION_HELPURL}", |     helpUrl: "%{BKY_LOGIC_OPERATION_HELPURL}", | ||||||
|         "extensions": ["logic_op_tooltip"] |     extensions: ["logic_op_tooltip"], | ||||||
|   }, |   }, | ||||||
|   // Block for negation.
 |   // Block for negation.
 | ||||||
|   { |   { | ||||||
|         "type": "logic_negate", |     type: "logic_negate", | ||||||
|         "message0": "%{BKY_LOGIC_NEGATE_TITLE}", |     message0: "%{BKY_LOGIC_NEGATE_TITLE}", | ||||||
|         "args0": [ |     args0: [ | ||||||
|       { |       { | ||||||
|                 "type": "input_value", |         type: "input_value", | ||||||
|                 "name": "BOOL", |         name: "BOOL", | ||||||
|                 "check": Types.getCompatibleTypes('boolean'), |         check: Types.getCompatibleTypes("boolean"), | ||||||
|             } |       }, | ||||||
|     ], |     ], | ||||||
|         "output": Types.BOOLEAN.typeName, |     output: Types.BOOLEAN.typeName, | ||||||
|         "style": "logic_blocks", |     style: "logic_blocks", | ||||||
|         "tooltip": "%{BKY_LOGIC_NEGATE_TOOLTIP}", |     tooltip: "%{BKY_LOGIC_NEGATE_TOOLTIP}", | ||||||
|         "helpUrl": "%{BKY_LOGIC_NEGATE_HELPURL}" |     helpUrl: "%{BKY_LOGIC_NEGATE_HELPURL}", | ||||||
|   }, |   }, | ||||||
|   // Block for null data type.
 |   // Block for null data type.
 | ||||||
|   { |   { | ||||||
|         "type": "logic_null", |     type: "logic_null", | ||||||
|         "message0": "%{BKY_LOGIC_NULL}", |     message0: "%{BKY_LOGIC_NULL}", | ||||||
|         "output": null, |     output: null, | ||||||
|         "style": "logic_blocks", |     style: "logic_blocks", | ||||||
|         "tooltip": "%{BKY_LOGIC_NULL_TOOLTIP}", |     tooltip: "%{BKY_LOGIC_NULL_TOOLTIP}", | ||||||
|         "helpUrl": "%{BKY_LOGIC_NULL_HELPURL}" |     helpUrl: "%{BKY_LOGIC_NULL_HELPURL}", | ||||||
|   }, |   }, | ||||||
|   // Block for ternary operator.
 |   // Block for ternary operator.
 | ||||||
|   { |   { | ||||||
|         "type": "logic_ternary", |     type: "logic_ternary", | ||||||
|         "message0": "%{BKY_LOGIC_TERNARY_CONDITION} %1", |     message0: "%{BKY_LOGIC_TERNARY_CONDITION} %1", | ||||||
|         "args0": [ |     args0: [ | ||||||
|       { |       { | ||||||
|                 "type": "input_value", |         type: "input_value", | ||||||
|                 "name": "IF", |         name: "IF", | ||||||
|                 "check": Types.getCompatibleTypes('boolean'), |         check: Types.getCompatibleTypes("boolean"), | ||||||
|             } |       }, | ||||||
|     ], |     ], | ||||||
|         "message1": "%{BKY_LOGIC_TERNARY_IF_TRUE} %1", |     message1: "%{BKY_LOGIC_TERNARY_IF_TRUE} %1", | ||||||
|         "args1": [ |     args1: [ | ||||||
|       { |       { | ||||||
|                 "type": "input_value", |         type: "input_value", | ||||||
|                 "name": "THEN", |         name: "THEN", | ||||||
|                 "check": Types.getCompatibleTypes('boolean'), |         check: Types.getCompatibleTypes("boolean"), | ||||||
|             } |       }, | ||||||
|     ], |     ], | ||||||
|         "message2": "%{BKY_LOGIC_TERNARY_IF_FALSE} %1", |     message2: "%{BKY_LOGIC_TERNARY_IF_FALSE} %1", | ||||||
|         "args2": [ |     args2: [ | ||||||
|       { |       { | ||||||
|                 "type": "input_value", |         type: "input_value", | ||||||
|                 "name": "ELSE", |         name: "ELSE", | ||||||
|                 "check": Types.getCompatibleTypes('boolean'), |         check: Types.getCompatibleTypes("boolean"), | ||||||
|             } |       }, | ||||||
|     ], |     ], | ||||||
|         "output": null, |     output: null, | ||||||
|         "style": "logic_blocks", |     style: "logic_blocks", | ||||||
|         "tooltip": "%{BKY_LOGIC_TERNARY_TOOLTIP}", |     tooltip: "%{BKY_LOGIC_TERNARY_TOOLTIP}", | ||||||
|         "helpUrl": "%{BKY_LOGIC_TERNARY_HELPURL}", |     helpUrl: "%{BKY_LOGIC_TERNARY_HELPURL}", | ||||||
|         "extensions": ["logic_ternary"] |     extensions: ["logic_ternary"], | ||||||
|     } |   }, | ||||||
| ]); // END JSON EXTRACT (Do not delete this comment.)
 | ]); // END JSON EXTRACT (Do not delete this comment.)
 | ||||||
| 
 | 
 | ||||||
| 
 | Blockly.Blocks["logic_compare"] = { | ||||||
| Blockly.Blocks['logic_compare'] = { |  | ||||||
|   /** |   /** | ||||||
|    * Block for comparison operator. |    * Block for comparison operator. | ||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
|    */ |    */ | ||||||
|   init: function () { |   init: function () { | ||||||
|         var OPERATORS = this.RTL ? [ |     var OPERATORS = this.RTL | ||||||
|             ['=', 'EQ'], |       ? [ | ||||||
|             ['\u2260', 'NEQ'], |           ["=", "EQ"], | ||||||
|             ['>', 'LT'], |           ["\u2260", "NEQ"], | ||||||
|             ['\u2265', 'LTE'], |           [">", "LT"], | ||||||
|             ['<', 'GT'], |           ["\u2265", "LTE"], | ||||||
|             ['\u2264', 'GTE'] |           ["<", "GT"], | ||||||
|         ] : [ |           ["\u2264", "GTE"], | ||||||
|                 ['=', 'EQ'], |         ] | ||||||
|                 ['\u2260', 'NEQ'], |       : [ | ||||||
|                 ['<', 'LT'], |           ["=", "EQ"], | ||||||
|                 ['\u2264', 'LTE'], |           ["\u2260", "NEQ"], | ||||||
|                 ['>', 'GT'], |           ["<", "LT"], | ||||||
|                 ['\u2265', 'GTE'] |           ["\u2264", "LTE"], | ||||||
|  |           [">", "GT"], | ||||||
|  |           ["\u2265", "GTE"], | ||||||
|         ]; |         ]; | ||||||
|     this.setHelpUrl(Blockly.Msg.LOGIC_COMPARE_HELPURL); |     this.setHelpUrl(Blockly.Msg.LOGIC_COMPARE_HELPURL); | ||||||
|     this.setColour(getColour().logic); |     this.setColour(getColour().logic); | ||||||
|     this.setOutput(true, Types.BOOLEAN.typeName); |     this.setOutput(true, Types.BOOLEAN.typeName); | ||||||
|         this.appendValueInput('A'); |     this.appendValueInput("A"); | ||||||
|         this.appendValueInput('B') |     this.appendValueInput("B").appendField( | ||||||
|             .appendField(new Blockly.FieldDropdown(OPERATORS), 'OP'); |       new Blockly.FieldDropdown(OPERATORS), | ||||||
|  |       "OP" | ||||||
|  |     ); | ||||||
|     this.setInputsInline(true); |     this.setInputsInline(true); | ||||||
|     // Assign 'this' to a variable for use in the tooltip closure below.
 |     // Assign 'this' to a variable for use in the tooltip closure below.
 | ||||||
|     var thisBlock = this; |     var thisBlock = this; | ||||||
|     this.setTooltip(function () { |     this.setTooltip(function () { | ||||||
|             var op = thisBlock.getFieldValue('OP'); |       var op = thisBlock.getFieldValue("OP"); | ||||||
|       var TOOLTIPS = { |       var TOOLTIPS = { | ||||||
|                 'EQ': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ, |         EQ: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ, | ||||||
|                 'NEQ': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ, |         NEQ: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ, | ||||||
|                 'LT': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT, |         LT: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT, | ||||||
|                 'LTE': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE, |         LTE: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE, | ||||||
|                 'GT': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT, |         GT: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT, | ||||||
|                 'GTE': Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE |         GTE: Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE, | ||||||
|       }; |       }; | ||||||
|       return TOOLTIPS[op]; |       return TOOLTIPS[op]; | ||||||
|     }); |     }); | ||||||
| @ -462,37 +468,44 @@ Blockly.Blocks['logic_compare'] = { | |||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
|    */ |    */ | ||||||
|   onchange: function (e) { |   onchange: function (e) { | ||||||
|         var blockA = this.getInputTargetBlock('A'); |     var blockA = this.getInputTargetBlock("A"); | ||||||
|         var blockB = this.getInputTargetBlock('B'); |     console.log(blockA); | ||||||
|  |     var blockB = this.getInputTargetBlock("B"); | ||||||
|     if (blockA === null && blockB === null) { |     if (blockA === null && blockB === null) { | ||||||
|             this.getInput('A').setCheck(null); |       this.getInput("A").setCheck(null); | ||||||
|             this.getInput('B').setCheck(null); |       this.getInput("B").setCheck(null); | ||||||
|     } |     } | ||||||
|     if (blockA !== null && blockB === null) { |     if (blockA !== null && blockB === null) { | ||||||
|             this.getInput('A').setCheck(getCompatibleTypes(blockA.outputConnection.check_[0])); |       this.getInput("A").setCheck( | ||||||
|             this.getInput('B').setCheck(getCompatibleTypes(blockA.outputConnection.check_[0])); |         getCompatibleTypes(blockA.outputConnection.check_[0]) | ||||||
|  |       ); | ||||||
|  |       this.getInput("B").setCheck( | ||||||
|  |         getCompatibleTypes(blockA.outputConnection.check_[0]) | ||||||
|  |       ); | ||||||
|     } |     } | ||||||
|     if (blockB !== null && blockA === null) { |     if (blockB !== null && blockA === null) { | ||||||
|             this.getInput('B').setCheck(getCompatibleTypes(blockB.outputConnection.check_[0])); |       this.getInput("B").setCheck( | ||||||
|             this.getInput('A').setCheck(getCompatibleTypes(blockB.outputConnection.check_[0])); |         getCompatibleTypes(blockB.outputConnection.check_[0]) | ||||||
|         } |       ); | ||||||
|  |       this.getInput("A").setCheck( | ||||||
|  |         getCompatibleTypes(blockB.outputConnection.check_[0]) | ||||||
|  |       ); | ||||||
|     } |     } | ||||||
|  |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 | Blockly.Blocks["switch_case"] = { | ||||||
| Blockly.Blocks['switch_case'] = { |  | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.setColour(getColour().logic); |     this.setColour(getColour().logic); | ||||||
|     this.setPreviousStatement(true); |     this.setPreviousStatement(true); | ||||||
|     this.setTooltip(Blockly.Msg.cases_tooltip); |     this.setTooltip(Blockly.Msg.cases_tooltip); | ||||||
|     this.setNextStatement(true); |     this.setNextStatement(true); | ||||||
|         this.appendValueInput('CONDITION') |     this.appendValueInput("CONDITION").appendField(Blockly.Msg.cases_switch); | ||||||
|             .appendField(Blockly.Msg.cases_switch); |     this.appendValueInput("CASECONDITION0").appendField( | ||||||
|         this.appendValueInput('CASECONDITION0') |       Blockly.Msg.cases_condition | ||||||
|             .appendField(Blockly.Msg.cases_condition); |     ); | ||||||
|         this.appendStatementInput('CASE0') |     this.appendStatementInput("CASE0").appendField(Blockly.Msg.cases_do); | ||||||
|             .appendField(Blockly.Msg.cases_do); |     this.setMutator(new Blockly.Mutator(["case_incaseof", "case_default"])); | ||||||
|         this.setMutator(new Blockly.Mutator(['case_incaseof', 'case_default'])); |  | ||||||
|     this.caseCount_ = 0; |     this.caseCount_ = 0; | ||||||
|     this.defaultCount_ = 0; |     this.defaultCount_ = 0; | ||||||
|   }, |   }, | ||||||
| @ -501,43 +514,42 @@ Blockly.Blocks['switch_case'] = { | |||||||
|     if (!this.caseCount_ && !this.defaultCount_) { |     if (!this.caseCount_ && !this.defaultCount_) { | ||||||
|       return null; |       return null; | ||||||
|     } |     } | ||||||
|         var container = document.createElement('mutation'); |     var container = document.createElement("mutation"); | ||||||
|     if (this.caseCount_) { |     if (this.caseCount_) { | ||||||
|             container.setAttribute('case', this.caseCount_); |       container.setAttribute("case", this.caseCount_); | ||||||
|     } |     } | ||||||
|     if (this.defaultCount_) { |     if (this.defaultCount_) { | ||||||
|             container.setAttribute('default', 1); |       container.setAttribute("default", 1); | ||||||
|     } |     } | ||||||
|     return container; |     return container; | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   domToMutation: function (xmlElement) { |   domToMutation: function (xmlElement) { | ||||||
|         this.caseCount_ = parseInt(xmlElement.getAttribute('case'), 10); |     this.caseCount_ = parseInt(xmlElement.getAttribute("case"), 10); | ||||||
|         this.defaultCount_ = parseInt(xmlElement.getAttribute('default'), 10); |     this.defaultCount_ = parseInt(xmlElement.getAttribute("default"), 10); | ||||||
|     for (var x = 0; x <= this.caseCount_; x++) { |     for (var x = 0; x <= this.caseCount_; x++) { | ||||||
|             this.appendValueInput('CASECONDITION' + x) |       this.appendValueInput("CASECONDITION" + x).appendField( | ||||||
|                 .appendField(Blockly.Msg.cases_condition); |         Blockly.Msg.cases_condition | ||||||
|             this.appendStatementInput('CASE' + x) |       ); | ||||||
|                 .appendField(Blockly.Msg.cases_do); |       this.appendStatementInput("CASE" + x).appendField(Blockly.Msg.cases_do); | ||||||
|     } |     } | ||||||
|     if (this.defaultCount_) { |     if (this.defaultCount_) { | ||||||
|             this.appendStatementInput('ONDEFAULT') |       this.appendStatementInput("ONDEFAULT").appendField("default"); | ||||||
|                 .appendField('default'); |  | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   decompose: function (workspace) { |   decompose: function (workspace) { | ||||||
|         var containerBlock = workspace.newBlock('control_case'); |     var containerBlock = workspace.newBlock("control_case"); | ||||||
|     containerBlock.initSvg(); |     containerBlock.initSvg(); | ||||||
|         var connection = containerBlock.getInput('STACK').connection; |     var connection = containerBlock.getInput("STACK").connection; | ||||||
|     for (var x = 1; x <= this.caseCount_; x++) { |     for (var x = 1; x <= this.caseCount_; x++) { | ||||||
|             var caseBlock = workspace.newBlock('case_incaseof'); |       var caseBlock = workspace.newBlock("case_incaseof"); | ||||||
|       caseBlock.initSvg(); |       caseBlock.initSvg(); | ||||||
|       connection.connect(caseBlock.previousConnection); |       connection.connect(caseBlock.previousConnection); | ||||||
|       connection = caseBlock.nextConnection; |       connection = caseBlock.nextConnection; | ||||||
|     } |     } | ||||||
|     if (this.defaultCount_) { |     if (this.defaultCount_) { | ||||||
|             var defaultBlock = Blockly.Block.obtain(workspace, 'case_default'); |       var defaultBlock = Blockly.Block.obtain(workspace, "case_default"); | ||||||
|       defaultBlock.initSvg(); |       defaultBlock.initSvg(); | ||||||
|       connection.connect(defaultBlock.previousConnection); |       connection.connect(defaultBlock.previousConnection); | ||||||
|     } |     } | ||||||
| @ -547,23 +559,25 @@ Blockly.Blocks['switch_case'] = { | |||||||
|   compose: function (containerBlock) { |   compose: function (containerBlock) { | ||||||
|     //Disconnect all input blocks and remove all inputs.
 |     //Disconnect all input blocks and remove all inputs.
 | ||||||
|     if (this.defaultCount_) { |     if (this.defaultCount_) { | ||||||
|             this.removeInput('ONDEFAULT'); |       this.removeInput("ONDEFAULT"); | ||||||
|     } |     } | ||||||
|     this.defaultCount_ = 0; |     this.defaultCount_ = 0; | ||||||
|     for (var x = this.caseCount_; x > 0; x--) { |     for (var x = this.caseCount_; x > 0; x--) { | ||||||
|             this.removeInput('CASECONDITION' + x); |       this.removeInput("CASECONDITION" + x); | ||||||
|             this.removeInput('CASE' + x); |       this.removeInput("CASE" + x); | ||||||
|     } |     } | ||||||
|     this.caseCount_ = 0; |     this.caseCount_ = 0; | ||||||
|         var caseBlock = containerBlock.getInputTargetBlock('STACK'); |     var caseBlock = containerBlock.getInputTargetBlock("STACK"); | ||||||
|     while (caseBlock) { |     while (caseBlock) { | ||||||
|       switch (caseBlock.type) { |       switch (caseBlock.type) { | ||||||
|                 case 'case_incaseof': |         case "case_incaseof": | ||||||
|           this.caseCount_++; |           this.caseCount_++; | ||||||
|                     var caseconditionInput = this.appendValueInput('CASECONDITION' + this.caseCount_) |           var caseconditionInput = this.appendValueInput( | ||||||
|                         .appendField(Blockly.Msg.cases_condition); |             "CASECONDITION" + this.caseCount_ | ||||||
|                     var caseInput = this.appendStatementInput('CASE' + this.caseCount_) |           ).appendField(Blockly.Msg.cases_condition); | ||||||
|                         .appendField(Blockly.Msg.cases_do); |           var caseInput = this.appendStatementInput( | ||||||
|  |             "CASE" + this.caseCount_ | ||||||
|  |           ).appendField(Blockly.Msg.cases_do); | ||||||
|           if (caseBlock.valueConnection_) { |           if (caseBlock.valueConnection_) { | ||||||
|             caseconditionInput.connection.connect(caseBlock.valueConnection_); |             caseconditionInput.connection.connect(caseBlock.valueConnection_); | ||||||
|           } |           } | ||||||
| @ -571,78 +585,82 @@ Blockly.Blocks['switch_case'] = { | |||||||
|             caseInput.connection.connect(caseBlock.statementConnection_); |             caseInput.connection.connect(caseBlock.statementConnection_); | ||||||
|           } |           } | ||||||
|           break; |           break; | ||||||
|                 case 'case_default': |         case "case_default": | ||||||
|           this.defaultCount_++; |           this.defaultCount_++; | ||||||
|                     var defaultInput = this.appendStatementInput('ONDEFAULT') |           var defaultInput = this.appendStatementInput("ONDEFAULT").appendField( | ||||||
|                         .appendField('default'); |             "default" | ||||||
|  |           ); | ||||||
|           if (caseBlock.statementConnection_) { |           if (caseBlock.statementConnection_) { | ||||||
|             defaultInput.connection.connect(caseBlock.statementConnection_); |             defaultInput.connection.connect(caseBlock.statementConnection_); | ||||||
|           } |           } | ||||||
|           break; |           break; | ||||||
|         default: |         default: | ||||||
|                     throw new Error('Unknown block type.'); |           throw new Error("Unknown block type."); | ||||||
|       } |       } | ||||||
|             caseBlock = caseBlock.nextConnection && |       caseBlock = | ||||||
|                 caseBlock.nextConnection.targetBlock(); |         caseBlock.nextConnection && caseBlock.nextConnection.targetBlock(); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
| 
 | 
 | ||||||
|   saveConnections: function (containerBlock) { |   saveConnections: function (containerBlock) { | ||||||
|         var caseBlock = containerBlock.getInputTargetBlock('STACK'); |     var caseBlock = containerBlock.getInputTargetBlock("STACK"); | ||||||
|     var x = 1; |     var x = 1; | ||||||
|     while (caseBlock) { |     while (caseBlock) { | ||||||
|       switch (caseBlock.type) { |       switch (caseBlock.type) { | ||||||
|                 case 'case_incaseof': |         case "case_incaseof": | ||||||
|                     var caseconditionInput = this.getInput('CASECONDITION' + x); |           var caseconditionInput = this.getInput("CASECONDITION" + x); | ||||||
|                     var caseInput = this.getInput('CASE' + x); |           var caseInput = this.getInput("CASE" + x); | ||||||
|                     caseBlock.valueConnection_ = caseconditionInput && caseconditionInput.connection.targetConnection; |           caseBlock.valueConnection_ = | ||||||
|                     caseBlock.statementConnection_ = caseInput && caseInput.connection.targetConnection; |             caseconditionInput && | ||||||
|  |             caseconditionInput.connection.targetConnection; | ||||||
|  |           caseBlock.statementConnection_ = | ||||||
|  |             caseInput && caseInput.connection.targetConnection; | ||||||
|           x++; |           x++; | ||||||
|           break; |           break; | ||||||
|                 case 'case_default': |         case "case_default": | ||||||
|                     var defaultInput = this.getInput('ONDEFAULT'); |           var defaultInput = this.getInput("ONDEFAULT"); | ||||||
|                     caseBlock.satementConnection_ = defaultInput && defaultInput.connection.targetConnection; |           caseBlock.satementConnection_ = | ||||||
|  |             defaultInput && defaultInput.connection.targetConnection; | ||||||
|           break; |           break; | ||||||
|         default: |         default: | ||||||
|                     throw new Error('Unknown block type'); |           throw new Error("Unknown block type"); | ||||||
|             } |  | ||||||
|             caseBlock = caseBlock.nextConnection && |  | ||||||
|                 caseBlock.nextConnection.targetBlock(); |  | ||||||
|       } |       } | ||||||
|  |       caseBlock = | ||||||
|  |         caseBlock.nextConnection && caseBlock.nextConnection.targetBlock(); | ||||||
|     } |     } | ||||||
|  |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['control_case'] = { | Blockly.Blocks["control_case"] = { | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.setColour(getColour().logic); |     this.setColour(getColour().logic); | ||||||
|         this.appendDummyInput() |     this.appendDummyInput().appendField(Blockly.Msg.cases_switch); | ||||||
|             .appendField(Blockly.Msg.cases_switch); |     this.appendStatementInput("STACK"); | ||||||
|         this.appendStatementInput('STACK'); |     this.setTooltip("--Placeholder--"); | ||||||
|         this.setTooltip('--Placeholder--'); |  | ||||||
|     this.contextMenu = false; |     this.contextMenu = false; | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['case_incaseof'] = { | Blockly.Blocks["case_incaseof"] = { | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.setColour(getColour().logic); |     this.setColour(getColour().logic); | ||||||
|         this.appendDummyInput() |     this.appendDummyInput().appendField(Blockly.Msg.cases_add); | ||||||
|             .appendField(Blockly.Msg.cases_add); |  | ||||||
|     this.setPreviousStatement(true); |     this.setPreviousStatement(true); | ||||||
|     this.setNextStatement(true); |     this.setNextStatement(true); | ||||||
|         this.setTooltip('--Placeholder--'); |     this.setTooltip("--Placeholder--"); | ||||||
|     this.contextMenu = false; |     this.contextMenu = false; | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['case_default'] = { | Blockly.Blocks["case_default"] = { | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.setColour(getColour().logic); |     this.setColour(getColour().logic); | ||||||
|         this.appendValueInput('default') |     this.appendValueInput("default").appendField("default"); | ||||||
|             .appendField('default'); |  | ||||||
|     this.setPreviousStatement(true); |     this.setPreviousStatement(true); | ||||||
|     this.setNextStatement(false); |     this.setNextStatement(false); | ||||||
|         this.setTooltip('This function will run if there aren\'t any matching cases.'); |     this.setTooltip( | ||||||
|  |       "This function will run if there aren't any matching cases." | ||||||
|  |     ); | ||||||
|     this.contextMenu = false; |     this.contextMenu = false; | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,57 +1,80 @@ | |||||||
| import * as Blockly from 'blockly/core'; | import * as Blockly from "blockly/core"; | ||||||
| import { getColour } from '../helpers/colour'; | import { getColour } from "../helpers/colour"; | ||||||
| 
 | 
 | ||||||
|  | var checkFileName = function (filename) { | ||||||
|  |   var length = filename.length; | ||||||
|  |   if (length > 8) { | ||||||
|  |     alert("dateiname sollte kleiner als 8 Zeichen sein"); | ||||||
|  |     return filename.slice(0, 8); | ||||||
|  |   } | ||||||
|  |   return filename; | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['sensebox_sd_open_file'] = { | Blockly.Blocks["sensebox_sd_open_file"] = { | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.appendDummyInput() |     this.appendDummyInput() | ||||||
|       .appendField(Blockly.Msg.senseBox_sd_open_file) |       .appendField(Blockly.Msg.senseBox_sd_open_file) | ||||||
|       .setAlign(Blockly.ALIGN_LEFT) |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|       .appendField( |       .appendField( | ||||||
|                 new Blockly.FieldTextInput('Data.txt'), |         new Blockly.FieldTextInput("Data", checkFileName), | ||||||
|                 'Filename'); |         "Filename" | ||||||
|         this.appendStatementInput('SD') |       ) | ||||||
|             .setCheck(null); |       .appendField(".") | ||||||
|  |       .appendField( | ||||||
|  |         new Blockly.FieldDropdown([ | ||||||
|  |           ["txt", "txt"], | ||||||
|  |           ["csv", "csv"], | ||||||
|  |         ]), | ||||||
|  |         "extension" | ||||||
|  |       ); | ||||||
|  |     this.appendStatementInput("SD").setCheck(null); | ||||||
|     this.setPreviousStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|     this.setNextStatement(true, null); |     this.setNextStatement(true, null); | ||||||
|     this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|     this.setTooltip(Blockly.Msg.senseBox_sd_open_file_tooltip); |     this.setTooltip(Blockly.Msg.senseBox_sd_open_file_tooltip); | ||||||
|         this.setHelpUrl('https://docs.sensebox.de/hardware/bee-sd/'); |     this.setHelpUrl("https://docs.sensebox.de/hardware/bee-sd/"); | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['sensebox_sd_create_file'] = { | Blockly.Blocks["sensebox_sd_create_file"] = { | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.appendDummyInput() |     this.appendDummyInput() | ||||||
|       .appendField(Blockly.Msg.senseBox_sd_create_file) |       .appendField(Blockly.Msg.senseBox_sd_create_file) | ||||||
|       .setAlign(Blockly.ALIGN_LEFT) |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|             .appendField(Blockly.Msg.senseBox_output_filename) |  | ||||||
|       .appendField( |       .appendField( | ||||||
|                 new Blockly.FieldTextInput('Data.txt'), |         new Blockly.FieldTextInput("Data", checkFileName), | ||||||
|                 'Filename'); |         "Filename" | ||||||
|  |       ) | ||||||
|  |       .appendField(".") | ||||||
|  |       .appendField( | ||||||
|  |         new Blockly.FieldDropdown([ | ||||||
|  |           ["txt", "txt"], | ||||||
|  |           ["csv", "csv"], | ||||||
|  |         ]), | ||||||
|  |         "extension" | ||||||
|  |       ); | ||||||
|     this.setPreviousStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|     this.setNextStatement(true, null); |     this.setNextStatement(true, null); | ||||||
|     this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|     this.setTooltip(Blockly.Msg.senseBox_sd_create_file_tooltip); |     this.setTooltip(Blockly.Msg.senseBox_sd_create_file_tooltip); | ||||||
|         this.setHelpUrl('https://docs.sensebox.de/hardware/bee-sd/'); |     this.setHelpUrl("https://docs.sensebox.de/hardware/bee-sd/"); | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['sensebox_sd_write_file'] = { | Blockly.Blocks["sensebox_sd_write_file"] = { | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.appendDummyInput() |     this.appendDummyInput() | ||||||
|       .appendField(Blockly.Msg.senseBox_sd_write_file) |       .appendField(Blockly.Msg.senseBox_sd_write_file) | ||||||
|       .setAlign(Blockly.ALIGN_LEFT); |       .setAlign(Blockly.ALIGN_LEFT); | ||||||
|         this.appendValueInput('DATA') |     this.appendValueInput("DATA").setCheck(null); | ||||||
|             .setCheck(null); |     this.appendDummyInput("CheckboxText") | ||||||
|         this.appendDummyInput('CheckboxText') |  | ||||||
|       .appendField(Blockly.Msg.senseBox_output_linebreak) |       .appendField(Blockly.Msg.senseBox_output_linebreak) | ||||||
|             .appendField(new Blockly.FieldCheckbox('TRUE'), 'linebreak'); |       .appendField(new Blockly.FieldCheckbox("TRUE"), "linebreak"); | ||||||
|     this.setPreviousStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|     this.setNextStatement(true, null); |     this.setNextStatement(true, null); | ||||||
|     this.setColour(getColour().sensebox); |     this.setColour(getColour().sensebox); | ||||||
|     this.setTooltip(Blockly.Msg.senseBox_sd_write_file_tooltip); |     this.setTooltip(Blockly.Msg.senseBox_sd_write_file_tooltip); | ||||||
|         this.setHelpUrl('https://docs.sensebox.de/hardware/bee-sd/'); |     this.setHelpUrl("https://docs.sensebox.de/hardware/bee-sd/"); | ||||||
|   }, |   }, | ||||||
|   /** |   /** | ||||||
|    * Called whenever anything on the workspace changes. |    * Called whenever anything on the workspace changes. | ||||||
| @ -76,5 +99,5 @@ Blockly.Blocks['sensebox_sd_write_file'] = { | |||||||
|       this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING); |       this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING); | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|     LOOP_TYPES: ['sensebox_sd_open_file'], |   LOOP_TYPES: ["sensebox_sd_open_file"], | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -8,80 +8,75 @@ | |||||||
|  *     The arduino built in functions syntax can be found in |  *     The arduino built in functions syntax can be found in | ||||||
|  *     http://arduino.cc/en/Reference/HomePage
 |  *     http://arduino.cc/en/Reference/HomePage
 | ||||||
|  */ |  */ | ||||||
| import Blockly from 'blockly'; | import Blockly from "blockly"; | ||||||
| import { getColour } from '../helpers/colour' | import { getColour } from "../helpers/colour"; | ||||||
| import * as Types from '../helpers/types' | import * as Types from "../helpers/types"; | ||||||
| 
 | 
 | ||||||
| 
 | Blockly.Blocks["time_delay"] = { | ||||||
| Blockly.Blocks['time_delay'] = { |  | ||||||
|   /** |   /** | ||||||
|    * Delay block definition |    * Delay block definition | ||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
|    */ |    */ | ||||||
|   init: function () { |   init: function () { | ||||||
|         this.setHelpUrl('http://arduino.cc/en/Reference/Delay'); |     this.setHelpUrl("http://arduino.cc/en/Reference/Delay"); | ||||||
|     this.setColour(getColour().time); |     this.setColour(getColour().time); | ||||||
|         this.appendValueInput('DELAY_TIME_MILI') |     this.appendValueInput("DELAY_TIME_MILI") | ||||||
|       .setCheck(Types.NUMBER.checkList) |       .setCheck(Types.NUMBER.checkList) | ||||||
|       .appendField(Blockly.Msg.ARD_TIME_DELAY); |       .appendField(Blockly.Msg.ARD_TIME_DELAY); | ||||||
|         this.appendDummyInput() |     this.appendDummyInput().appendField(Blockly.Msg.ARD_TIME_MS); | ||||||
|             .appendField(Blockly.Msg.ARD_TIME_MS); |  | ||||||
|     this.setInputsInline(true); |     this.setInputsInline(true); | ||||||
|     this.setPreviousStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|     this.setNextStatement(true, null); |     this.setNextStatement(true, null); | ||||||
|     this.setTooltip(Blockly.Msg.ARD_TIME_DELAY_TIP); |     this.setTooltip(Blockly.Msg.ARD_TIME_DELAY_TIP); | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['time_delaymicros'] = { | Blockly.Blocks["time_delaymicros"] = { | ||||||
|   /** |   /** | ||||||
|    * delayMicroseconds block definition |    * delayMicroseconds block definition | ||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
|    */ |    */ | ||||||
|   init: function () { |   init: function () { | ||||||
|         this.setHelpUrl('http://arduino.cc/en/Reference/DelayMicroseconds'); |     this.setHelpUrl("http://arduino.cc/en/Reference/DelayMicroseconds"); | ||||||
|     this.setColour(getColour().time); |     this.setColour(getColour().time); | ||||||
|         this.appendValueInput('DELAY_TIME_MICRO') |     this.appendValueInput("DELAY_TIME_MICRO") | ||||||
|       .setCheck(Types.NUMBER.checkList) |       .setCheck(Types.NUMBER.checkList) | ||||||
|       .appendField(Blockly.Msg.ARD_TIME_DELAY); |       .appendField(Blockly.Msg.ARD_TIME_DELAY); | ||||||
|         this.appendDummyInput() |     this.appendDummyInput().appendField(Blockly.Msg.ARD_TIME_DELAY_MICROS); | ||||||
|             .appendField(Blockly.Msg.ARD_TIME_DELAY_MICROS); |  | ||||||
|     this.setInputsInline(true); |     this.setInputsInline(true); | ||||||
|     this.setPreviousStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|     this.setNextStatement(true, null); |     this.setNextStatement(true, null); | ||||||
|     this.setTooltip(Blockly.Msg.ARD_TIME_DELAY_MICRO_TIP); |     this.setTooltip(Blockly.Msg.ARD_TIME_DELAY_MICRO_TIP); | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['time_millis'] = { | Blockly.Blocks["time_millis"] = { | ||||||
|   /** |   /** | ||||||
|    * Elapsed time in milliseconds block definition |    * Elapsed time in milliseconds block definition | ||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
|    */ |    */ | ||||||
|   init: function () { |   init: function () { | ||||||
|         this.setHelpUrl('http://arduino.cc/en/Reference/Millis'); |     this.setHelpUrl("http://arduino.cc/en/Reference/Millis"); | ||||||
|     this.setColour(getColour().time); |     this.setColour(getColour().time); | ||||||
|         this.appendDummyInput() |     this.appendDummyInput().appendField(Blockly.Msg.ARD_TIME_MILLIS); | ||||||
|             .appendField(Blockly.Msg.ARD_TIME_MILLIS); |  | ||||||
|     this.setOutput(true, Types.LARGE_NUMBER.typeId); |     this.setOutput(true, Types.LARGE_NUMBER.typeId); | ||||||
|     this.setTooltip(Blockly.Msg.ARD_TIME_MILLIS_TIP); |     this.setTooltip(Blockly.Msg.ARD_TIME_MILLIS_TIP); | ||||||
|   }, |   }, | ||||||
|   /** @return {string} The type of return value for the block, an integer. */ |   /** @return {string} The type of return value for the block, an integer. */ | ||||||
|   getBlockType: function () { |   getBlockType: function () { | ||||||
|     return Blockly.Types.LARGE_NUMBER; |     return Blockly.Types.LARGE_NUMBER; | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['time_micros'] = { | Blockly.Blocks["time_micros"] = { | ||||||
|   /** |   /** | ||||||
|    * Elapsed time in microseconds block definition |    * Elapsed time in microseconds block definition | ||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
|    */ |    */ | ||||||
|   init: function () { |   init: function () { | ||||||
|         this.setHelpUrl('http://arduino.cc/en/Reference/Micros'); |     this.setHelpUrl("http://arduino.cc/en/Reference/Micros"); | ||||||
|     this.setColour(getColour().time); |     this.setColour(getColour().time); | ||||||
|         this.appendDummyInput() |     this.appendDummyInput().appendField(Blockly.Msg.ARD_TIME_MICROS); | ||||||
|             .appendField(Blockly.Msg.ARD_TIME_MICROS); |  | ||||||
|     this.setOutput(true, Types.LARGE_NUMBER.typeId); |     this.setOutput(true, Types.LARGE_NUMBER.typeId); | ||||||
|     this.setTooltip(Blockly.Msg.ARD_TIME_MICROS_TIP); |     this.setTooltip(Blockly.Msg.ARD_TIME_MICROS_TIP); | ||||||
|   }, |   }, | ||||||
| @ -91,40 +86,40 @@ Blockly.Blocks['time_micros'] = { | |||||||
|    */ |    */ | ||||||
|   getBlockType: function () { |   getBlockType: function () { | ||||||
|     return Types.LARGE_NUMBER; |     return Types.LARGE_NUMBER; | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['infinite_loop'] = { | Blockly.Blocks["infinite_loop"] = { | ||||||
|   /** |   /** | ||||||
|    * Waits forever, end of program. |    * Waits forever, end of program. | ||||||
|    * @this Blockly.Block |    * @this Blockly.Block | ||||||
|    */ |    */ | ||||||
|   init: function () { |   init: function () { | ||||||
|         this.setHelpUrl(''); |     this.setHelpUrl(""); | ||||||
|     this.setColour(getColour().time); |     this.setColour(getColour().time); | ||||||
|         this.appendDummyInput() |     this.appendDummyInput().appendField(Blockly.Msg.ARD_TIME_INF); | ||||||
|             .appendField(Blockly.Msg.ARD_TIME_INF); |  | ||||||
|     this.setInputsInline(true); |     this.setInputsInline(true); | ||||||
|     this.setPreviousStatement(true); |     this.setPreviousStatement(true); | ||||||
|     this.setTooltip(Blockly.Msg.ARD_TIME_INF_TIP); |     this.setTooltip(Blockly.Msg.ARD_TIME_INF_TIP); | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Blocks['sensebox_interval_timer'] = { | Blockly.Blocks["sensebox_interval_timer"] = { | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.setTooltip(Blockly.Msg.senseBox_interval_timer_tip); |     this.setTooltip(Blockly.Msg.senseBox_interval_timer_tip); | ||||||
|     this.setInputsInline(true); |     this.setInputsInline(true); | ||||||
|         this.setHelpUrl(''); |     this.setHelpUrl(""); | ||||||
|     this.setColour(getColour().time); |     this.setColour(getColour().time); | ||||||
|     this.appendDummyInput() |     this.appendDummyInput() | ||||||
|             .appendField(Blockly.Msg.senseBox_interval_timer); |       .appendField(Blockly.Msg.senseBox_interval_timer) | ||||||
|  |       .appendField(new Blockly.FieldTextInput("name"), "name"); | ||||||
|     this.appendDummyInput() |     this.appendDummyInput() | ||||||
|  |       .appendField(Blockly.Msg.senseBox_interval_time) | ||||||
|       .setAlign(Blockly.ALIGN_LEFT) |       .setAlign(Blockly.ALIGN_LEFT) | ||||||
|       .appendField(new Blockly.FieldTextInput("10000"), "interval") |       .appendField(new Blockly.FieldTextInput("10000"), "interval") | ||||||
|       .appendField(Blockly.Msg.senseBox_interval); |       .appendField(Blockly.Msg.senseBox_interval); | ||||||
|         this.appendStatementInput('DO') |     this.appendStatementInput("DO").setCheck(null); | ||||||
|             .setCheck(null); |  | ||||||
|     this.setPreviousStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|     this.setNextStatement(true, null); |     this.setNextStatement(true, null); | ||||||
|     } |   }, | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,43 +1,43 @@ | |||||||
| import Blockly from 'blockly/core'; | import Blockly from "blockly/core"; | ||||||
| import { getColour } from '../helpers/colour'; | import { getColour } from "../helpers/colour"; | ||||||
| import { getCompatibleTypes } from '../helpers/types' | import { getCompatibleTypes } from "../helpers/types"; | ||||||
| 
 | 
 | ||||||
| 
 | Blockly.Blocks["variables_set_dynamic"] = { | ||||||
| Blockly.Blocks['variables_set_dynamic'] = { |  | ||||||
|   init: function () { |   init: function () { | ||||||
| 
 |  | ||||||
|     // const type = myVar.type;
 |     // const type = myVar.type;
 | ||||||
|     this.setColour(getColour().variables); |     this.setColour(getColour().variables); | ||||||
|     this.setPreviousStatement(true, null); |     this.setPreviousStatement(true, null); | ||||||
|     this.setNextStatement(true, null); |     this.setNextStatement(true, null); | ||||||
|         this.appendValueInput('VALUE') |     this.appendValueInput("VALUE") | ||||||
|             .appendField('set', 'set') |       .appendField("set", "set") | ||||||
|             .appendField('', 'type') |       .appendField("", "type") | ||||||
|             .appendField(new Blockly.FieldVariable('VAR'), 'VAR') |       .appendField(new Blockly.FieldVariable("VAR"), "VAR") | ||||||
|             .appendField('to'); |       .appendField("to"); | ||||||
|   }, |   }, | ||||||
|   onchange: function (e) { |   onchange: function (e) { | ||||||
|         let variableID = this.getFieldValue('VAR'); |     let variableID = this.getFieldValue("VAR"); | ||||||
|         let variable = Blockly.getMainWorkspace().getVariableMap().getVariableById(variableID) |     let variable = Blockly.getMainWorkspace() | ||||||
|         this.getField('type').setValue(variable.type); |       .getVariableMap() | ||||||
|         this.getInput('VALUE').setCheck(getCompatibleTypes(variable.type)); |       .getVariableById(variableID); | ||||||
|  |     this.getField("type").setValue(variable.type); | ||||||
|  |     this.getInput("VALUE").setCheck(getCompatibleTypes(variable.type)); | ||||||
|  |   }, | ||||||
|  | }; | ||||||
| 
 | 
 | ||||||
|     } | Blockly.Blocks["variables_get_dynamic"] = { | ||||||
| } |  | ||||||
| 
 |  | ||||||
| Blockly.Blocks['variables_get_dynamic'] = { |  | ||||||
|   init: function () { |   init: function () { | ||||||
|     this.setColour(getColour().variables); |     this.setColour(getColour().variables); | ||||||
|     this.appendDummyInput() |     this.appendDummyInput() | ||||||
|             .appendField('', 'type') |       .appendField("", "type") | ||||||
|             .appendField(new Blockly.FieldVariable('VAR'), 'VAR'); |       .appendField(new Blockly.FieldVariable("VAR"), "VAR"); | ||||||
|     this.setOutput(true); |     this.setOutput(true); | ||||||
|   }, |   }, | ||||||
|   onchange: function (e) { |   onchange: function (e) { | ||||||
|         let variableID = this.getFieldValue('VAR'); |     let variableID = this.getFieldValue("VAR"); | ||||||
|         let variable = Blockly.getMainWorkspace().getVariableMap().getVariableById(variableID) |     let variable = Blockly.getMainWorkspace() | ||||||
|         this.getField('type').setValue(variable.type); |       .getVariableMap() | ||||||
| 
 |       .getVariableById(variableID); | ||||||
|     } |     this.getField("type").setValue(variable.type); | ||||||
| } |     this.setOutput(true, variable.type); | ||||||
| 
 |   }, | ||||||
|  | }; | ||||||
|  | |||||||
| @ -1,5 +1,4 @@ | |||||||
| import Blockly from 'blockly'; | import Blockly from "blockly"; | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| /* SD-Card Blocks using the Standard SD Library*/ | /* SD-Card Blocks using the Standard SD Library*/ | ||||||
| /** | /** | ||||||
| @ -10,45 +9,49 @@ import Blockly from 'blockly'; | |||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_sd_create_file = function (block) { | Blockly.Arduino.sensebox_sd_create_file = function (block) { | ||||||
|     var filename = this.getFieldValue('Filename'); |   var filename = this.getFieldValue("Filename"); | ||||||
|     var res = filename.slice(0, 4); |   var extension = this.getFieldValue("extension"); | ||||||
|     Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>'; |   var newFileName = filename.concat(".", extension); | ||||||
|     Blockly.Arduino.libraries_['library_sd'] = '#include <SD.h>'; |   Blockly.Arduino.libraries_["library_spi"] = "#include <SPI.h>"; | ||||||
|     Blockly.Arduino.definitions_['define_' + res] = 'File dataFile' + res + ';'; |   Blockly.Arduino.libraries_["library_sd"] = "#include <SD.h>"; | ||||||
|     Blockly.Arduino.setupCode_['sensebox_sd'] = 'SD.begin(28);'; |   Blockly.Arduino.definitions_["define_" + filename] = `File ${filename};`; | ||||||
|     Blockly.Arduino.setupCode_['sensebox_sd' + filename] = 'dataFile' + res + ' = SD.open("' + filename + '", FILE_WRITE);\ndataFile' + res + '.close();\n'; |   Blockly.Arduino.setupCode_["sensebox_sd"] = "SD.begin(28);\n"; | ||||||
|     var code = ''; |   Blockly.Arduino.setupCode_[ | ||||||
|  |     "sensebox_sd" + filename | ||||||
|  |   ] = `${filename} = SD.open("${newFileName}", FILE_WRITE);\n${filename}.close();\n`; | ||||||
|  |   var code = ""; | ||||||
|   return code; |   return code; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_sd_open_file = function (block) { | Blockly.Arduino.sensebox_sd_open_file = function (block) { | ||||||
|     var filename = this.getFieldValue('Filename'); |   var filename = this.getFieldValue("Filename"); | ||||||
|     var res = filename.slice(0, 4); |   var extension = this.getFieldValue("extension"); | ||||||
|     var branch = Blockly.Arduino.statementToCode(block, 'SD'); |   var newFileName = filename.concat(".", extension); | ||||||
|     var code = 'dataFile' + res + ' = SD.open("' + filename + '", FILE_WRITE);\n' |   var branch = Blockly.Arduino.statementToCode(block, "SD"); | ||||||
|  |   var code = `${filename} = SD.open("${newFileName}", FILE_WRITE);\n`; | ||||||
|   code += branch; |   code += branch; | ||||||
|     code += 'dataFile' + res + '.close();\n' |   code += `${filename}.close();\n`; | ||||||
|   return code; |   return code; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_sd_write_file = function (block) { | Blockly.Arduino.sensebox_sd_write_file = function (block) { | ||||||
|   if (this.parentBlock_ != null) { |   if (this.parentBlock_ != null) { | ||||||
|         var filename = this.getSurroundParent().getFieldValue('Filename'); |     var filename = this.getSurroundParent().getFieldValue("Filename"); | ||||||
|   } |   } | ||||||
|     var res = filename.slice(0, 4); |   var branch = | ||||||
|     var text = Blockly.Arduino.valueToCode(this, 'DATA', Blockly.Arduino.ORDER_ATOMIC) || '"Keine Eingabe"'; |     Blockly.Arduino.valueToCode(this, "DATA", Blockly.Arduino.ORDER_ATOMIC) || | ||||||
|     var linebreak = this.getFieldValue('linebreak'); |     '"Keine Eingabe"'; | ||||||
|  |   var linebreak = this.getFieldValue("linebreak"); | ||||||
|   if (linebreak === "TRUE") { |   if (linebreak === "TRUE") { | ||||||
|     linebreak = "ln"; |     linebreak = "ln"; | ||||||
|   } else { |   } else { | ||||||
|     linebreak = ""; |     linebreak = ""; | ||||||
|   } |   } | ||||||
|     var code = ''; |   var code = ""; | ||||||
|     if (text === "gps.getLongitude()" || text === "gps.getLatitude()") { |   if (branch === "gps.getLongitude()" || branch === "gps.getLatitude()") { | ||||||
|         code = 'dataFile' + res + '.print' + linebreak + '(' + text + ',5);\n' |     code = `${filename}.print${linebreak}(${branch},5);\n`; | ||||||
|     } |   } else { | ||||||
|     else { |     code = `${filename}.print${linebreak}(${branch});\n`; | ||||||
|         code = 'dataFile' + res + '.print' + linebreak + '(' + text + ');\n' |  | ||||||
|   } |   } | ||||||
|   return code; |   return code; | ||||||
| }; | }; | ||||||
|  | |||||||
| @ -1,4 +1,4 @@ | |||||||
| import Blockly from 'blockly'; | import Blockly from "blockly"; | ||||||
| 
 | 
 | ||||||
| /** | /** | ||||||
|  * @license Licensed under the Apache License, Version 2.0 (the "License"): |  * @license Licensed under the Apache License, Version 2.0 (the "License"): | ||||||
| @ -16,10 +16,14 @@ import Blockly from 'blockly'; | |||||||
|  * @param {!Blockly.Block} block Block to generate the code from. |  * @param {!Blockly.Block} block Block to generate the code from. | ||||||
|  * @return {string} Completed code. |  * @return {string} Completed code. | ||||||
|  */ |  */ | ||||||
| Blockly.Arduino['time_delay'] = function (block) { | Blockly.Arduino["time_delay"] = function (block) { | ||||||
|     var delayTime = Blockly.Arduino.valueToCode( |   var delayTime = | ||||||
|         block, 'DELAY_TIME_MILI', Blockly.Arduino.ORDER_ATOMIC) || '0'; |     Blockly.Arduino.valueToCode( | ||||||
|     var code = 'delay(' + delayTime + ');\n'; |       block, | ||||||
|  |       "DELAY_TIME_MILI", | ||||||
|  |       Blockly.Arduino.ORDER_ATOMIC | ||||||
|  |     ) || "0"; | ||||||
|  |   var code = "delay(" + delayTime + ");\n"; | ||||||
|   return code; |   return code; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -29,10 +33,14 @@ Blockly.Arduino['time_delay'] = function (block) { | |||||||
|  * @param {!Blockly.Block} block Block to generate the code from. |  * @param {!Blockly.Block} block Block to generate the code from. | ||||||
|  * @return {string} Completed code. |  * @return {string} Completed code. | ||||||
|  */ |  */ | ||||||
| Blockly.Arduino['time_delaymicros'] = function (block) { | Blockly.Arduino["time_delaymicros"] = function (block) { | ||||||
|     var delayTimeMs = Blockly.Arduino.valueToCode( |   var delayTimeMs = | ||||||
|         block, 'DELAY_TIME_MICRO', Blockly.Arduino.ORDER_ATOMIC) || '0'; |     Blockly.Arduino.valueToCode( | ||||||
|     var code = 'delayMicroseconds(' + delayTimeMs + ');\n'; |       block, | ||||||
|  |       "DELAY_TIME_MICRO", | ||||||
|  |       Blockly.Arduino.ORDER_ATOMIC | ||||||
|  |     ) || "0"; | ||||||
|  |   var code = "delayMicroseconds(" + delayTimeMs + ");\n"; | ||||||
|   return code; |   return code; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -42,8 +50,8 @@ Blockly.Arduino['time_delaymicros'] = function (block) { | |||||||
|  * @param {!Blockly.Block} block Block to generate the code from. |  * @param {!Blockly.Block} block Block to generate the code from. | ||||||
|  * @return {array} Completed code with order of operation. |  * @return {array} Completed code with order of operation. | ||||||
|  */ |  */ | ||||||
| Blockly.Arduino['time_millis'] = function (block) { | Blockly.Arduino["time_millis"] = function (block) { | ||||||
|     var code = 'millis()'; |   var code = "millis()"; | ||||||
|   return [code, Blockly.Arduino.ORDER_ATOMIC]; |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -53,8 +61,8 @@ Blockly.Arduino['time_millis'] = function (block) { | |||||||
|  * @param {!Blockly.Block} block Block to generate the code from. |  * @param {!Blockly.Block} block Block to generate the code from. | ||||||
|  * @return {array} Completed code with order of operation. |  * @return {array} Completed code with order of operation. | ||||||
|  */ |  */ | ||||||
| Blockly.Arduino['time_micros'] = function (block) { | Blockly.Arduino["time_micros"] = function (block) { | ||||||
|     var code = 'micros()'; |   var code = "micros()"; | ||||||
|   return [code, Blockly.Arduino.ORDER_ATOMIC]; |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -64,17 +72,22 @@ Blockly.Arduino['time_micros'] = function (block) { | |||||||
|  * @param {!Blockly.Block} block Block to generate the code from. |  * @param {!Blockly.Block} block Block to generate the code from. | ||||||
|  * @return {string} Completed code. |  * @return {string} Completed code. | ||||||
|  */ |  */ | ||||||
| Blockly.Arduino['infinite_loop'] = function (block) { | Blockly.Arduino["infinite_loop"] = function (block) { | ||||||
|     return 'while(true);\n'; |   return "while(true);\n"; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_interval_timer = function (block) { | Blockly.Arduino.sensebox_interval_timer = function (block) { | ||||||
|     var interval = this.getFieldValue('interval'); |   var intervalTime = this.getFieldValue("interval"); | ||||||
|     Blockly.Arduino.variables_['define_interval_variables'] = 'const long interval = ' + interval + ';\nlong time_start = 0;\nlong time_actual = 0;'; |   var intervalName = this.getFieldValue("name"); | ||||||
|     var branch = Blockly.Arduino.statementToCode(block, 'DO'); |   Blockly.Arduino.variables_[`define_interval_variables${intervalName}`] = ` | ||||||
|     var code = 'time_start = millis();\n'; | const long interval${intervalName} = ${intervalTime}; | ||||||
|     code += 'if (time_start > time_actual + interval) {\n  time_actual = millis();\n' | long time_start${intervalName} = 0; | ||||||
|  | long time_actual${intervalName} = 0;`;
 | ||||||
|  |   var branch = Blockly.Arduino.statementToCode(block, "DO"); | ||||||
|  |   var code = `time_start${intervalName} = millis();\n`; | ||||||
|  |   code += ` | ||||||
|  | if (time_start${intervalName} > time_actual${intervalName} + interval${intervalName}) {\n  time_actual${intervalName} = millis();\n`;
 | ||||||
|   code += branch; |   code += branch; | ||||||
|     code += '}\n' |   code += "}\n"; | ||||||
|   return code; |   return code; | ||||||
| }; | }; | ||||||
| @ -1,31 +1,33 @@ | |||||||
| import Blockly from 'blockly'; | import Blockly from "blockly"; | ||||||
| /** | /** | ||||||
|  * Webserver Blocks by Lucas Steinmann |  * Webserver Blocks by Lucas Steinmann | ||||||
|  * |  * | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_initialize_http_server = function (block) { | Blockly.Arduino.sensebox_initialize_http_server = function (block) { | ||||||
|     var box_id = this.getFieldValue('Port'); |   var box_id = this.getFieldValue("Port"); | ||||||
|     Blockly.Arduino.libraries_['library_senseBoxMCU'] = '#include "SenseBoxMCU.h"'; |   Blockly.Arduino.libraries_["library_senseBoxMCU"] = | ||||||
|     Blockly.Arduino.codeFunctions_['define_wifi_server'] = 'WiFiServer server(' + box_id + ');'; |     '#include "SenseBoxMCU.h"'; | ||||||
|     Blockly.Arduino.setupCode_['sensebox_wifi_server_beging'] = 'server.begin();'; |   Blockly.Arduino.codeFunctions_["define_wifi_server"] = | ||||||
|     return ''; |     "WiFiServer server(" + box_id + ");"; | ||||||
|  |   Blockly.Arduino.setupCode_["sensebox_wifi_server_beging"] = "server.begin();"; | ||||||
|  |   return ""; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_http_on_client_connect = function (block) { | Blockly.Arduino.sensebox_http_on_client_connect = function (block) { | ||||||
|     var onConnect = Blockly.Arduino.statementToCode(block, 'ON_CONNECT'); |   var onConnect = Blockly.Arduino.statementToCode(block, "ON_CONNECT"); | ||||||
|     var code = ''; |   var code = ""; | ||||||
|     code += 'WiFiClient client = server.available();\n'; |   code += "WiFiClient client = server.available();\n"; | ||||||
|     code += 'if (client && client.available()) {\n'; |   code += "if (client && client.available()) {\n"; | ||||||
|     code += '  String request_string = listenClient(client);\n'; |   code += "  String request_string = listenClient(client);\n"; | ||||||
|     code += '  Request request;\n'; |   code += "  Request request;\n"; | ||||||
|     code += '  if (parseRequestSafe(request_string, request)) {\n'; |   code += "  if (parseRequestSafe(request_string, request)) {\n"; | ||||||
|   code += onConnect; |   code += onConnect; | ||||||
|     code += '  }\n'; |   code += "  }\n"; | ||||||
|     code += '  delay(1);\n'; |   code += "  delay(1);\n"; | ||||||
|     code += '  client.stop();\n'; |   code += "  client.stop();\n"; | ||||||
|     code += '  delay(1);\n'; |   code += "  delay(1);\n"; | ||||||
|     code += '}\n'; |   code += "}\n"; | ||||||
|   return code; |   return code; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| @ -34,7 +36,6 @@ Blockly.Arduino.sensebox_http_method = function (block) { | |||||||
|   return [code, Blockly.Arduino.ORDER_ATOMIC]; |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| Blockly.Arduino.sensebox_http_uri = function (block) { | Blockly.Arduino.sensebox_http_uri = function (block) { | ||||||
|   var code = "request.uri"; |   var code = "request.uri"; | ||||||
|   return [code, Blockly.Arduino.ORDER_ATOMIC]; |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
| @ -51,64 +52,76 @@ Blockly.Arduino.sensebox_http_user_agent = function (block) { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_generate_html_doc = function (block) { | Blockly.Arduino.sensebox_generate_html_doc = function (block) { | ||||||
|     var header = Blockly.Arduino.valueToCode(block, 'HEADER', Blockly.Arduino.ORDER_NONE) || '""'; |   var header = | ||||||
|     var body = Blockly.Arduino.valueToCode(block, 'BODY', Blockly.Arduino.ORDER_NONE) || '""'; |     Blockly.Arduino.valueToCode(block, "HEADER", Blockly.Arduino.ORDER_NONE) || | ||||||
|     var code = 'buildHTML(' + header + ', ' + body + ')'; |     '""'; | ||||||
|  |   var body = | ||||||
|  |     Blockly.Arduino.valueToCode(block, "BODY", Blockly.Arduino.ORDER_NONE) || | ||||||
|  |     '""'; | ||||||
|  |   var code = "buildHTML(" + header + ", " + body + ")"; | ||||||
|   return [code, Blockly.Arduino.ORDER_ATOMIC]; |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_generate_http_succesful_response = function (block) { | Blockly.Arduino.sensebox_generate_http_succesful_response = function (block) { | ||||||
|     var content = Blockly.Arduino.valueToCode(block, 'CONTENT', Blockly.Arduino.ORDER_NONE) || '""'; |   var content = | ||||||
|     var code = 'client.println(buildSuccessfulResponse(request, ' + content + '));\n'; |     Blockly.Arduino.valueToCode(block, "CONTENT", Blockly.Arduino.ORDER_NONE) || | ||||||
|  |     '""'; | ||||||
|  |   var code = | ||||||
|  |     "client.println(buildSuccessfulResponse(request, " + content + "));\n"; | ||||||
|   return code; |   return code; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_generate_http_not_found_response = function (block) { | Blockly.Arduino.sensebox_generate_http_not_found_response = function (block) { | ||||||
|     var code = 'client.println(buildNotFoundResponse(request));\n'; |   var code = "client.println(buildNotFoundResponse(request));\n"; | ||||||
|   return code; |   return code; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| Blockly.Arduino.sensebox_ip_address = function (block) { | Blockly.Arduino.sensebox_ip_address = function (block) { | ||||||
|   var code = "b->getIpAddress()"; |   var code = "b->getIpAddress()"; | ||||||
|   return [code, Blockly.Arduino.ORDER_ATOMIC]; |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_general_html_tag = function (block) { | Blockly.Arduino.sensebox_general_html_tag = function (block) { | ||||||
|     var tag = this.getFieldValue('TAG'); |   var tag = this.getFieldValue("TAG"); | ||||||
|   var code = 'buildTag("' + tag + '",'; |   var code = 'buildTag("' + tag + '",'; | ||||||
|   var n = 0; |   var n = 0; | ||||||
|     var branch = Blockly.Arduino.valueToCode(block, 'DO' + n, Blockly.Arduino.ORDER_NONE); |   var branch = Blockly.Arduino.valueToCode( | ||||||
|  |     block, | ||||||
|  |     "DO" + n, | ||||||
|  |     Blockly.Arduino.ORDER_NONE | ||||||
|  |   ); | ||||||
|   if (branch.length > 0) { |   if (branch.length > 0) { | ||||||
|         code += '\n ' + branch; |     code += "\n " + branch; | ||||||
|   } else { |   } else { | ||||||
|     code += '""'; |     code += '""'; | ||||||
|   } |   } | ||||||
|   for (n = 1; n <= block.additionalChildCount_; n++) { |   for (n = 1; n <= block.additionalChildCount_; n++) { | ||||||
|         branch = Blockly.Arduino.valueToCode(block, 'DO' + n, Blockly.Arduino.ORDER_NONE); |     branch = Blockly.Arduino.valueToCode( | ||||||
|         code += ' +' + branch; |       block, | ||||||
|  |       "DO" + n, | ||||||
|  |       Blockly.Arduino.ORDER_NONE | ||||||
|  |     ); | ||||||
|  |     code += " +" + branch; | ||||||
|   } |   } | ||||||
|     return [code + ')', Blockly.Arduino.ORDER_ATOMIC]; |   return [code + ")", Blockly.Arduino.ORDER_ATOMIC]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| Blockly.Arduino.sensebox_web_readHTML = function (block) { | Blockly.Arduino.sensebox_web_readHTML = function (block) { | ||||||
|     var filename = this.getFieldValue('FILENAME'); |   var filename = this.getFieldValue("FILENAME"); | ||||||
|     Blockly.Arduino.libraries_['library_spi'] = '#include <SPI.h>'; |   Blockly.Arduino.libraries_["library_spi"] = "#include <SPI.h>"; | ||||||
|     Blockly.Arduino.libraries_['library_sd'] = '#include <SD.h>'; |   Blockly.Arduino.libraries_["library_sd"] = "#include <SD.h>"; | ||||||
|     Blockly.Arduino.codeFunctions_['define_sd' + filename] = 'File webFile;'; |   Blockly.Arduino.codeFunctions_["define_sd" + filename] = "File webFile;"; | ||||||
|     Blockly.Arduino.setupCode_['sensebox_sd'] = 'SD.begin(28);'; |   Blockly.Arduino.setupCode_["sensebox_sd"] = "SD.begin(28);"; | ||||||
|     var func = [ |   Blockly.Arduino.codeFunctions_["generateHTML"] = ` | ||||||
|         'String generateHTML(){', | String generateHTML(){ | ||||||
|         ' webFile = SD.open("' + filename + '", FILE_READ);', |      webFile = SD.open("${filename}", FILE_READ); | ||||||
|         ' String finalString ="";', |    String finalString =""; | ||||||
|         ' while (webFile.available())', |    while (webFile.available()) | ||||||
|         '   {', |      { | ||||||
|         '   finalString+=(char)webFile.read();', |      finalString+=(char)webFile.read(); | ||||||
|         '   }', |      } | ||||||
|         ' return finalString;', |    return finalString; | ||||||
|         '}']; |   }`;
 | ||||||
|     var functionName = Blockly.Arduino.addFunction( |   var code = `generateHTML()`; | ||||||
|         'generateHTML', func.join('\n')); |  | ||||||
|     var code = functionName + '()'; |  | ||||||
|   return [code, Blockly.Arduino.ORDER_ATOMIC]; |   return [code, Blockly.Arduino.ORDER_ATOMIC]; | ||||||
| }; | }; | ||||||
| @ -8,103 +8,110 @@ | |||||||
|  *     types. |  *     types. | ||||||
|  */ |  */ | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
| /** Single character. */ | /** Single character. */ | ||||||
| export const CHARACTER = { | export const CHARACTER = { | ||||||
|     typeId: 'Character', |   typeId: "Character", | ||||||
|     typeName: 'char', |   typeName: "char", | ||||||
|     typeMsgName: 'ARD_TYPE_CHAR', |   typeMsgName: "ARD_TYPE_CHAR", | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| export const BOOLEAN = { | export const BOOLEAN = { | ||||||
|     typeId: 'Boolean', |   typeId: "Boolean", | ||||||
|     typeName: 'boolean', |   typeName: "boolean", | ||||||
|     typeMsgName: 'ARD_TYPE_BOOL', |   typeMsgName: "ARD_TYPE_BOOL", | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| /** Text string. */ | /** Text string. */ | ||||||
| export const TEXT = { | export const TEXT = { | ||||||
|     typeId: 'Text', |   typeId: "Text", | ||||||
|     typeName: 'String', |   typeName: "String", | ||||||
|     typeMsgName: 'ARD_TYPE_TEXT', |   typeMsgName: "ARD_TYPE_TEXT", | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| /** Short integer number. */ | /** Short integer number. */ | ||||||
| export const SHORT_NUMBER = { | export const SHORT_NUMBER = { | ||||||
|     typeId: 'Short_Number', |   typeId: "Short_Number", | ||||||
|     typeName: 'int', |   typeName: "int", | ||||||
|     typeMsgName: 'ARD_TYPE_SHORT', |   typeMsgName: "ARD_TYPE_SHORT", | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| /** Integer number. */ | /** Integer number. */ | ||||||
| export const NUMBER = { | export const NUMBER = { | ||||||
|     typeId: 'Number', |   typeId: "Number", | ||||||
|     typeName: 'int', |   typeName: "int", | ||||||
|     typeMsgName: 'ARD_TYPE_NUMBER', |   typeMsgName: "ARD_TYPE_NUMBER", | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| /** Large integer number. */ | /** Large integer number. */ | ||||||
| export const LARGE_NUMBER = { | export const LARGE_NUMBER = { | ||||||
|     typeId: 'Large Number', |   typeId: "Large Number", | ||||||
|     typeName: 'long', |   typeName: "long", | ||||||
|     typeMsgName: 'ARD_TYPE_LONG', |   typeMsgName: "ARD_TYPE_LONG", | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| /** Decimal/floating point number. */ | /** Decimal/floating point number. */ | ||||||
| export const DECIMAL = { | export const DECIMAL = { | ||||||
|     typeId: 'Decimal', |   typeId: "Decimal", | ||||||
|     typeName: 'float', |   typeName: "float", | ||||||
|     typeMsgName: 'ARD_TYPE_DECIMAL', |   typeMsgName: "ARD_TYPE_DECIMAL", | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| /** Array/List of items. */ | /** Array/List of items. */ | ||||||
| export const ARRAY = { | export const ARRAY = { | ||||||
|     typeId: 'Array', |   typeId: "Array", | ||||||
|     typeName: 'Array', |   typeName: "Array", | ||||||
|     typeMsgName: 'ARD_TYPE_ARRAY', |   typeMsgName: "ARD_TYPE_ARRAY", | ||||||
|     compatibleTypes: [] |   compatibleTypes: [], | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| /** Null indicate there is no type. */ | /** Null indicate there is no type. */ | ||||||
| export const NULL = { | export const NULL = { | ||||||
|     typeId: 'Null', |   typeId: "Null", | ||||||
|     typeName: 'void', |   typeName: "void", | ||||||
|     typeMsgName: 'ARD_TYPE_NULL', |   typeMsgName: "ARD_TYPE_NULL", | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| /** Type not defined, or not yet defined. */ | /** Type not defined, or not yet defined. */ | ||||||
| export const UNDEF = { | export const UNDEF = { | ||||||
|     typeId: 'Undefined', |   typeId: "Undefined", | ||||||
|     typeName: 'undef', |   typeName: "undef", | ||||||
|     typeMsgName: 'ARD_TYPE_UNDEF', |   typeMsgName: "ARD_TYPE_UNDEF", | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| /** Set when no child block (meant to define the variable type) is connected. */ | /** Set when no child block (meant to define the variable type) is connected. */ | ||||||
| export const CHILD_BLOCK_MISSING = { | export const CHILD_BLOCK_MISSING = { | ||||||
|     typeId: 'ChildBlockMissing', |   typeId: "ChildBlockMissing", | ||||||
|     typeMsgName: 'ARD_TYPE_CHILDBLOCKMISSING', |   typeMsgName: "ARD_TYPE_CHILDBLOCKMISSING", | ||||||
|     compatibleTypes: [] |   compatibleTypes: [], | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| const compatibleTypes = { | const compatibleTypes = { | ||||||
|     Array: ['Array'], |   Array: ["Array"], | ||||||
|     boolean: ['boolean'], |   boolean: ["boolean"], | ||||||
|     int: ['int', 'long', 'double', 'float'], |   int: ["int", "long", "double", "float"], | ||||||
|     char: ['char'], |   char: ["char"], | ||||||
|     String: ['String'], |   String: ["String"], | ||||||
|     void: ['void'], |   void: ["void"], | ||||||
|     long: ['int', 'long'], |   long: ["int", "long"], | ||||||
|     double: ['int', 'long', 'double'], |   double: ["int", "long", "double"], | ||||||
|     float: ['int', 'long', 'double', 'float'], |   float: ["int", "long", "double", "float"], | ||||||
|     null: ['null'] |   null: ["null"], | ||||||
| 
 | }; | ||||||
| } |  | ||||||
| 
 | 
 | ||||||
| export const getCompatibleTypes = (type) => { | export const getCompatibleTypes = (type) => { | ||||||
|   return compatibleTypes[type]; |   return compatibleTypes[type]; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export const VARIABLE_TYPES = [['SHORT_NUMBER', 'char'], ['NUMBER', 'int'], ['DECIMAL', 'long'], ['TEXT', 'String'], ['CHARACTER', 'char'], ['BOOLEAN', 'boolean'], ['NULL', 'void'], ['UNDEF', 'undefined']]; | export const VARIABLE_TYPES = [ | ||||||
|  |   ["SHORT_NUMBER", "char"], | ||||||
|  |   ["NUMBER", "int"], | ||||||
|  |   ["DECIMAL", "long"], | ||||||
|  |   ["TEXT", "String"], | ||||||
|  |   ["CHARACTER", "char"], | ||||||
|  |   ["BOOLEAN", "boolean"], | ||||||
|  |   ["NULL", "void"], | ||||||
|  |   ["UNDEF", "undefined"], | ||||||
|  | ]; | ||||||
| 
 | 
 | ||||||
| // /**
 | // /**
 | ||||||
| //  * Some Types have circular dependencies on their compatibilities, so add them
 | //  * Some Types have circular dependencies on their compatibilities, so add them
 | ||||||
| @ -233,7 +240,3 @@ export const VARIABLE_TYPES = [['SHORT_NUMBER', 'char'], ['NUMBER', 'int'], ['DE | |||||||
| //     }
 | //     }
 | ||||||
| //     return Blockly.Types.NULL;
 | //     return Blockly.Types.NULL;
 | ||||||
| // };
 | // };
 | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|  | |||||||
| @ -4,10 +4,13 @@ export const SD = { | |||||||
|    */ |    */ | ||||||
|   senseBox_sd_create_file: "Erstelle Datei auf SD-Karte", |   senseBox_sd_create_file: "Erstelle Datei auf SD-Karte", | ||||||
|   senseBox_sd_write_file: "Schreibe Daten auf SD-Karte", |   senseBox_sd_write_file: "Schreibe Daten auf SD-Karte", | ||||||
|     senseBox_sd_open_file: "Öffne eine Datei auf der SD-Karte", |   senseBox_sd_open_file: "Öffne Datei auf der SD-Karte", | ||||||
|     senseBox_sd_create_file_tooltip: "Erstellt eine Datei auf der Karte. Stecke das SD-Bee auf den Steckplatz **XBEE2**. Die **maximale** Länge des Dateinamen sind **8 Zeichen**. Die Datei sollte zuerst im *Setup()* erstellt werden", |   senseBox_sd_create_file_tooltip: | ||||||
|     senseBox_sd_write_file_tooptip: "Schreibe Daten auf die SD-Karte. Beachte, dass die Datei zuerst geöffnet werden muss.", |     "Erstellt eine Datei auf der Karte. Stecke das SD-Bee auf den Steckplatz **XBEE2**. Die **maximale** Länge des Dateinamen sind **8 Zeichen**. Die Datei sollte zuerst im *Setup()* erstellt werden", | ||||||
|     senseBox_sd_open_file_tooltip: "Öffne die Datei auf der SD-Karte, um Dateien zu speichern. Am Ende der Schleife wird die Datei automatisch wieder geschlossen.", |   senseBox_sd_write_file_tooptip: | ||||||
|  |     "Schreibe Daten auf die SD-Karte. Beachte, dass die Datei zuerst geöffnet werden muss.", | ||||||
|  |   senseBox_sd_open_file_tooltip: | ||||||
|  |     "Öffne die Datei auf der SD-Karte, um Dateien zu speichern. Am Ende der Schleife wird die Datei automatisch wieder geschlossen.", | ||||||
|   sensebox_sd_filename: "Daten", |   sensebox_sd_filename: "Daten", | ||||||
|   senseBox_sd_decimals: "Dezimalen", |   senseBox_sd_decimals: "Dezimalen", | ||||||
| } | }; | ||||||
|  | |||||||
| @ -1,11 +1,11 @@ | |||||||
| export const TIME = { | export const TIME = { | ||||||
| 
 |  | ||||||
|   /** |   /** | ||||||
|    * Interval Block |    * Interval Block | ||||||
|    */ |    */ | ||||||
|     senseBox_interval_timer: "Messintervall", |   senseBox_interval_timer: "Intervall:", | ||||||
|   senseBox_interval: "ms", |   senseBox_interval: "ms", | ||||||
|   senseBox_interval_timer_tip: "Intervall", |   senseBox_interval_timer_tip: "Intervall", | ||||||
|  |   senseBox_interval_time: "Zeit: ", | ||||||
|   ARD_TIME_DELAY: "Warte", |   ARD_TIME_DELAY: "Warte", | ||||||
|   ARD_TIME_DELAY_MICROS: "Mikrosekunden", |   ARD_TIME_DELAY_MICROS: "Mikrosekunden", | ||||||
|   ARD_TIME_DELAY_MICRO_TIP: "Warte eine spezifischen Zeit in Microsekunden", |   ARD_TIME_DELAY_MICRO_TIP: "Warte eine spezifischen Zeit in Microsekunden", | ||||||
| @ -13,8 +13,10 @@ export const TIME = { | |||||||
|   ARD_TIME_INF: "Warte für immer (Beende Programm)", |   ARD_TIME_INF: "Warte für immer (Beende Programm)", | ||||||
|   ARD_TIME_INF_TIP: "Stoppt das Programm.", |   ARD_TIME_INF_TIP: "Stoppt das Programm.", | ||||||
|   ARD_TIME_MICROS: "Bereits vergangen Zeit (Mikrosekunden)", |   ARD_TIME_MICROS: "Bereits vergangen Zeit (Mikrosekunden)", | ||||||
|     ARD_TIME_MICROS_TIP: "Gibt eine Zahl in Microsekunden zurück, die der Zeitdauer des Aktuellen Programms entspricht. Muss als positiven Integer gespeichert werden",  // untranslated
 |   ARD_TIME_MICROS_TIP: | ||||||
|  |     "Gibt eine Zahl in Microsekunden zurück, die der Zeitdauer des Aktuellen Programms entspricht. Muss als positiven Integer gespeichert werden", // untranslated
 | ||||||
|   ARD_TIME_MILLIS: "Bereits vergangen Zeit (Millisekunden)", |   ARD_TIME_MILLIS: "Bereits vergangen Zeit (Millisekunden)", | ||||||
|     ARD_TIME_MILLIS_TIP: "Gibt eine Zahl in Millisekunden zurück, die der Zeitdauer des Aktuellen Programms entspricht. Muss als positiven Integer gespeichert werden",  // untranslated
 |   ARD_TIME_MILLIS_TIP: | ||||||
|  |     "Gibt eine Zahl in Millisekunden zurück, die der Zeitdauer des Aktuellen Programms entspricht. Muss als positiven Integer gespeichert werden", // untranslated
 | ||||||
|   ARD_TIME_MS: "Millisekunden", |   ARD_TIME_MS: "Millisekunden", | ||||||
| } | }; | ||||||
|  | |||||||
| @ -1,8 +1,8 @@ | |||||||
| export const TIME = { | export const TIME = { | ||||||
| 
 |  | ||||||
|   senseBox_interval: "ms", |   senseBox_interval: "ms", | ||||||
|     senseBox_interval_timer: "Measuring interval", |   senseBox_interval_timer: "Interval", | ||||||
|     senseBox_interval_timer_tip: "Setup an Intervall", |   senseBox_interval_timer_tip: "Setup an Interval", | ||||||
|  |   senseBox_interval_time: "time", | ||||||
|   ARD_TIME_DELAY: "wait", |   ARD_TIME_DELAY: "wait", | ||||||
|   ARD_TIME_DELAY_MICROS: "microseconds", |   ARD_TIME_DELAY_MICROS: "microseconds", | ||||||
|   ARD_TIME_DELAY_MICRO_TIP: "Wait specific time in microseconds", |   ARD_TIME_DELAY_MICRO_TIP: "Wait specific time in microseconds", | ||||||
| @ -10,8 +10,10 @@ export const TIME = { | |||||||
|   ARD_TIME_INF: "wait forever (end program)", |   ARD_TIME_INF: "wait forever (end program)", | ||||||
|   ARD_TIME_INF_TIP: "Wait indefinitely, stopping the program.", |   ARD_TIME_INF_TIP: "Wait indefinitely, stopping the program.", | ||||||
|   ARD_TIME_MICROS: "current elapsed Time (microseconds)", |   ARD_TIME_MICROS: "current elapsed Time (microseconds)", | ||||||
|     ARD_TIME_MICROS_TIP: "Returns the number of microseconds since the Arduino board began running the current program. Has to be stored in a positive long integer", |   ARD_TIME_MICROS_TIP: | ||||||
|  |     "Returns the number of microseconds since the Arduino board began running the current program. Has to be stored in a positive long integer", | ||||||
|   ARD_TIME_MILLIS: "current elapsed Time (milliseconds)", |   ARD_TIME_MILLIS: "current elapsed Time (milliseconds)", | ||||||
|     ARD_TIME_MILLIS_TIP: "Returns the number of milliseconds since the Arduino board began running the current program. Has to be stored in a positive long integer", |   ARD_TIME_MILLIS_TIP: | ||||||
|  |     "Returns the number of milliseconds since the Arduino board began running the current program. Has to be stored in a positive long integer", | ||||||
|   ARD_TIME_MS: "milliseconds", |   ARD_TIME_MS: "milliseconds", | ||||||
| } | }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user