wificomms.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  1. 'use strict';
  2. goog.provide('Blockly.Blocks.wificomms');
  3. goog.require('Blockly.Blocks');
  4. goog.require('Blockly.Types');
  5. Blockly.Blocks.wificomms.HUE = "#db3e37";
  6. Blockly.Blocks['wificomms_setup'] = {
  7. init: function() {
  8. this.appendDummyInput()
  9. // .appendField(new Blockly.FieldImage("http://cocorobo.cn/cocoblockly/blockly/media/cocomod_blockly_wifi.png", 140, 40, "0"));
  10. .appendField(new Blockly.FieldImage("./../blockly/media/wifi-data_transfer.png", 50, 40, "0"));
  11. this.appendDummyInput()
  12. .appendField(Blockly.Msg.WIFI_SETUP);
  13. this.setColour(Blockly.Blocks.wificomms.HUE);
  14. this.setTooltip("");
  15. this.setHelpUrl("");
  16. },
  17. };
  18. /*send message from main_comtrol to wifi */
  19. Blockly.Blocks['wificomms_sendMsg'] = {
  20. init: function() {
  21. this.appendDummyInput()
  22. .appendField(Blockly.Msg.WIFI_SENDMSG)
  23. .appendField(new Blockly.FieldVariable("dataOut"), "dataVar");
  24. this.setColour(Blockly.Blocks.wificomms.HUE);
  25. // this.setOutput(true,Blockly.Types.BOOLEAN.output);
  26. this.setPreviousStatement(true, null);
  27. this.setNextStatement(true, null);
  28. this.setInputsInline(true);
  29. this.setTooltip("");
  30. this.setHelpUrl("");
  31. },
  32. getVarType: function(varName) {
  33. return Blockly.Types.ARRAY;
  34. }
  35. };
  36. /*receive message from main_comtrol to wifi */
  37. Blockly.Blocks['wificomms_receiveMsg'] = {
  38. init: function() {
  39. this.appendDummyInput()
  40. .appendField(Blockly.Msg.WIFI_RECEIVEMSG)
  41. .appendField(new Blockly.FieldVariable("dataIn"), "dataVar");
  42. this.setColour(Blockly.Blocks.wificomms.HUE);
  43. // this.setOutput(true,Blockly.Types.BOOLEAN.output);
  44. this.setPreviousStatement(true, null);
  45. this.setNextStatement(true, null);
  46. this.setInputsInline(true);
  47. this.setTooltip("");
  48. this.setHelpUrl("");
  49. },
  50. getVarType: function(varName) {
  51. return Blockly.Types.ARRAY;
  52. }
  53. };
  54. /*check if sucessfully receive message from main_comtrol to wifi */
  55. Blockly.Blocks['wificomms_receiveMsg_isSuccessed'] = {
  56. init: function() {
  57. this.appendDummyInput()
  58. .appendField(Blockly.Msg.WIFI_RECEIVEMSG_ISSUCCESS);
  59. this.setColour(Blockly.Blocks.wificomms.HUE);
  60. this.setOutput(true, Blockly.Types.BOOLEAN.output);
  61. // this.setInputsInline(true);
  62. this.setTooltip("");
  63. this.setHelpUrl("");
  64. },
  65. };
  66. /*************************
  67. * version 2 *
  68. * eaysmode *
  69. *************************/
  70. /*wifi easymode
  71. * wifi-2-main transfer
  72. * send msg from wifi to main
  73. */
  74. Blockly.Blocks['wifiTransfer_send_old'] = {
  75. init: function() {
  76. this.appendDummyInput()
  77. // .appendField(new Blockly.FieldImage("http://cocorobo.cn/cocoblockly/blockly/media/cocomod_blockly_wifi.png", 140, 40, "0"));
  78. .appendField(new Blockly.FieldImage("./../blockly/media/transfer-2.png", 50, 40, "0"));
  79. // this.appendDummyInput()
  80. // .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_SEND)
  81. // .appendField(new Blockly.FieldDropdown([
  82. // ["txData", "txData"]
  83. // ]), "DATAMAIN");
  84. this.appendDummyInput()
  85. .appendField("old "+Blockly.Msg.WIFIEASYMODE_TRANSFER_SEND_LINE2);
  86. this.appendValueInput("ADD0")
  87. .appendField(Blockly.Msg.WIFIEASYMODE_TRANSFER_SEND_VALUE + "0")
  88. this.setColour(220);
  89. this.setPreviousStatement(true, null);
  90. this.setNextStatement(true, null);
  91. // this.setInputsInline(true);
  92. this.setTooltip("");
  93. this.setHelpUrl("");
  94. this.itemCount_ = 1;
  95. this.updateShape_();
  96. this.setMutator(new Blockly.Mutator(['Transfer_create_with_item']));
  97. },
  98. mutationToDom: function() {
  99. var container = document.createElement('mutation');
  100. container.setAttribute('items', this.itemCount_);
  101. return container;
  102. },
  103. /**
  104. * Parse XML to restore the inputs.
  105. * @param {!Element} xmlElement XML storage element.
  106. * @this Blockly.Block
  107. */
  108. domToMutation: function(xmlElement) {
  109. this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
  110. this.updateShape_();
  111. },
  112. /**
  113. * Populate the mutator's dialog with this block's components.
  114. * @param {!Blockly.Workspace} workspace Mutator's workspace.
  115. * @return {!Blockly.Block} Root block in mutator.
  116. * @this Blockly.Block
  117. */
  118. decompose: function(workspace) {
  119. var containerBlock = workspace.newBlock('Transfer_create_with_container');
  120. containerBlock.initSvg();
  121. var connection = containerBlock.getInput('STACK').connection;
  122. for (var i = 0; i < this.itemCount_; i++) {
  123. var itemBlock = workspace.newBlock('Transfer_create_with_item');
  124. itemBlock.initSvg();
  125. connection.connect(itemBlock.previousConnection);
  126. connection = itemBlock.nextConnection;
  127. }
  128. return containerBlock;
  129. },
  130. /**
  131. * Reconfigure this block based on the mutator dialog's components.
  132. * @param {!Blockly.Block} containerBlock Root block in mutator.
  133. * @this Blockly.Block
  134. */
  135. compose: function(containerBlock) {
  136. var itemBlock = containerBlock.getInputTargetBlock('STACK');
  137. // Count number of inputs.
  138. var connections = [];
  139. while (itemBlock) {
  140. connections.push(itemBlock.valueConnection_);
  141. itemBlock = itemBlock.nextConnection &&
  142. itemBlock.nextConnection.targetBlock();
  143. }
  144. // Disconnect any children that don't belong.
  145. for (var i = 0; i < this.itemCount_; i++) {
  146. var connection = this.getInput('ADD' + i).connection.targetConnection;
  147. if (connection && connections.indexOf(connection) == -1) {
  148. connection.disconnect();
  149. }
  150. }
  151. this.itemCount_ = connections.length;
  152. this.updateShape_();
  153. // Reconnect any child blocks.
  154. for (var i = 0; i < this.itemCount_; i++) {
  155. Blockly.Mutator.reconnect(connections[i], this, 'ADD' + i);
  156. }
  157. },
  158. /**
  159. * Store pointers to any connected child blocks.
  160. * @param {!Blockly.Block} containerBlock Root block in mutator.
  161. * @this Blockly.Block
  162. */
  163. saveConnections: function(containerBlock) {
  164. var itemBlock = containerBlock.getInputTargetBlock('STACK');
  165. var i = 0;
  166. while (itemBlock) {
  167. var input = this.getInput('ADD' + i);
  168. itemBlock.valueConnection_ = input && input.connection.targetConnection;
  169. i++;
  170. itemBlock = itemBlock.nextConnection &&
  171. itemBlock.nextConnection.targetBlock();
  172. }
  173. },
  174. /**
  175. * Modify this block to have the correct number of inputs.
  176. * @private
  177. * @this Blockly.Block
  178. */
  179. updateShape_: function() {
  180. // if (this.itemCount_ && this.getInput('EMPTY')) {
  181. // this.removeInput('EMPTY');
  182. // } else if (!this.itemCount_ && !this.getInput('EMPTY')) {
  183. // this.appendDummyInput('EMPTY')
  184. // .appendField(this.newQuote_(true))
  185. // .appendField(this.newQuote_(false));
  186. // }
  187. var i = 1;
  188. while (this.getInput('ADD' + i)) {
  189. this.removeInput('ADD' + i);
  190. i++;
  191. }
  192. // Add new inputs.
  193. for (var i = 0; i < this.itemCount_; i++) {
  194. if (!this.getInput('ADD' + i)) {
  195. var input = this.appendValueInput('ADD' + i)
  196. .appendField(Blockly.Msg.WIFIEASYMODE_TRANSFER_SEND_VALUE + i);
  197. }
  198. }
  199. // Remove deleted inputs.
  200. while (this.getInput('ADD' + i)) {
  201. this.removeInput('ADD' + i);
  202. i++;
  203. }
  204. },
  205. };
  206. Blockly.Blocks['Transfer_create_with_container'] = {
  207. /**
  208. * Mutator block for list container.
  209. * @this Blockly.Block
  210. */
  211. init: function() {
  212. this.setColour(Blockly.Blocks.wificomms.HUE);
  213. this.appendDummyInput()
  214. .appendField(Blockly.Msg.THINGSPEAK_CREATE_WITH_CONTAINER_TITLE_ADD);
  215. this.appendStatementInput('STACK');
  216. this.setTooltip('');
  217. this.contextMenu = false;
  218. }
  219. };
  220. Blockly.Blocks['Transfer_create_with_item'] = {
  221. /**
  222. * Mutator bolck for adding items.
  223. * @this Blockly.Block
  224. */
  225. init: function() {
  226. this.setColour(Blockly.Blocks.wificomms.HUE);
  227. this.appendDummyInput()
  228. .appendField(Blockly.Msg.THINGSPEAK_CREATE_WITH_ITEM_TITLE);
  229. this.setPreviousStatement(true);
  230. this.setNextStatement(true);
  231. this.setTooltip('');
  232. this.contextMenu = false;
  233. }
  234. };
  235. /*wifi easymode
  236. * wifi-2-main transfer
  237. * receive msg from main to wifi
  238. */
  239. Blockly.Blocks['wifiTransfer_receive_old'] = {
  240. init: function() {
  241. this.appendDummyInput()
  242. // .appendField(new Blockly.FieldImage("http://cocorobo.cn/cocoblockly/blockly/media/cocomod_blockly_wifi.png", 140, 40, "0"));
  243. .appendField(new Blockly.FieldImage("./../blockly/media/transfer-2.png", 50, 40, "0"));
  244. this.appendDummyInput()
  245. .appendField("old "+ Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE)
  246. // this.appendDummyInput()
  247. // .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE_LINE2)
  248. // .appendField(new Blockly.FieldDropdown([
  249. // ["rxData", "rxData"]
  250. // ]), "DATAMAIN");
  251. this.appendDummyInput()
  252. .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE_LINE3)
  253. .appendField(new Blockly.FieldDropdown([
  254. ["1", "1"],
  255. ["2", "2"],
  256. ["3", "3"],
  257. ["4", "4"],
  258. ["5", "5"],
  259. ["6", "6"],
  260. ["7", "7"],
  261. ["8", "8"],
  262. ["9", "9"],
  263. ["10", "10"],
  264. ["11", "11"],
  265. ["12", "12"],
  266. ]), "LENGTH");
  267. this.setColour(220);
  268. this.setPreviousStatement(true, null);
  269. this.setNextStatement(true, null);
  270. // this.setInputsInline(true);
  271. this.setTooltip("");
  272. this.setHelpUrl("");
  273. },
  274. getVarType: function(varName) {
  275. let vartype = Blockly.Types.ARRAY;
  276. return vartype;
  277. }
  278. }
  279. /*wifi easymode
  280. * wifi-2-main transfer
  281. * get data from dataMain
  282. * @param {dataMain} :where data tranferred stored in
  283. */
  284. Blockly.Blocks['wifiTransfer_receive_getValue_old'] = {
  285. init: function() {
  286. this.appendDummyInput()
  287. // .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE_GET)
  288. // .appendField(new Blockly.FieldDropdown([
  289. // ["rxData", "rxData"]
  290. // ]), "DATAMAIN")
  291. .appendField("old "+ Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE_GET_LINE2)
  292. .appendField(new Blockly.FieldDropdown([
  293. ["0", "0"],
  294. ["1", "1"],
  295. ["2", "2"],
  296. ["3", "3"],
  297. ["4", "4"],
  298. ["5", "5"],
  299. ["6", "6"],
  300. ["7", "7"],
  301. ["8", "8"],
  302. ["9", "9"],
  303. ["10", "10"],
  304. ["11", "11"],
  305. ]), "INDEX")
  306. .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE_GET_LINE3)
  307. // .appendField(new Blockly.FieldDropdown([
  308. // ["String", ""],
  309. // ["Number", ".toInt()"],
  310. // ["Float", ".toFloat()"],
  311. // ]), "TYPE")
  312. // .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE_GET_LINE4)
  313. this.setColour(220);
  314. this.setOutput(true)
  315. // this.setInputsInline(true);
  316. this.setTooltip("");
  317. this.setHelpUrl("");
  318. },
  319. getBlockType: function() {
  320. var type = this.getFieldValue("TYPE");
  321. switch (type) {
  322. case "" :
  323. return Blockly.Types.TEXT;
  324. case ".toInt()":
  325. return Blockly.Types.NUMBER;
  326. case ".toFloat()":
  327. return Blockly.Types.LARGE_NUMBER;
  328. }
  329. return Blockly.Types.NUMBER;
  330. },
  331. getOutputType: function() {
  332. var type = this.getFieldValue("TYPE");
  333. switch (type) {
  334. case "" :
  335. return Blockly.Types.TEXT.output
  336. case ".toInt()":
  337. return Blockly.Types.NUMBER.output;
  338. case ".toFloat()":
  339. return Blockly.Types.LARGE_NUMBER.output;
  340. }
  341. return Blockly.Types.NUMBER.output;
  342. }
  343. }
  344. /*************************
  345. * version 3 *
  346. * eaysmode *
  347. *************************/
  348. /*wifi easymode
  349. * wifi-2-main transfer
  350. * send msg from wifi to main
  351. */
  352. Blockly.Blocks['wifiTransfer_send'] = {
  353. init: function() {
  354. this.appendDummyInput()
  355. // .appendField(new Blockly.FieldImage("http://cocorobo.cn/cocoblockly/blockly/media/cocomod_blockly_wifi.png", 140, 40, "0"));
  356. .appendField(new Blockly.FieldImage("./../blockly/media/transfer-2.png", 50, 40, "0"));
  357. // this.appendDummyInput()
  358. // .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_SEND)
  359. // .appendField(new Blockly.FieldDropdown([
  360. // ["txData", "txData"]
  361. // ]), "DATAMAIN");
  362. this.appendDummyInput()
  363. .appendField(Blockly.Msg.WIFIEASYMODE_TRANSFER_SEND_LINE2);
  364. this.appendValueInput("ADD0")
  365. .appendField(Blockly.Msg.WIFIEASYMODE_TRANSFER_SEND_VALUE + "0")
  366. this.setColour(Blockly.Blocks.wificomms.HUE);
  367. this.setPreviousStatement(true, null);
  368. this.setNextStatement(true, null);
  369. // this.setInputsInline(true);
  370. this.setTooltip("");
  371. this.setHelpUrl("");
  372. this.itemCount_ = 1;
  373. this.updateShape_();
  374. this.setMutator(new Blockly.Mutator(['Transfer_create_with_item']));
  375. },
  376. mutationToDom: function() {
  377. var container = document.createElement('mutation');
  378. container.setAttribute('items', this.itemCount_);
  379. return container;
  380. },
  381. /**
  382. * Parse XML to restore the inputs.
  383. * @param {!Element} xmlElement XML storage element.
  384. * @this Blockly.Block
  385. */
  386. domToMutation: function(xmlElement) {
  387. this.itemCount_ = parseInt(xmlElement.getAttribute('items'), 10);
  388. this.updateShape_();
  389. },
  390. /**
  391. * Populate the mutator's dialog with this block's components.
  392. * @param {!Blockly.Workspace} workspace Mutator's workspace.
  393. * @return {!Blockly.Block} Root block in mutator.
  394. * @this Blockly.Block
  395. */
  396. decompose: function(workspace) {
  397. var containerBlock = workspace.newBlock('Transfer_create_with_container');
  398. containerBlock.initSvg();
  399. var connection = containerBlock.getInput('STACK').connection;
  400. for (var i = 0; i < this.itemCount_; i++) {
  401. var itemBlock = workspace.newBlock('Transfer_create_with_item');
  402. itemBlock.initSvg();
  403. connection.connect(itemBlock.previousConnection);
  404. connection = itemBlock.nextConnection;
  405. }
  406. return containerBlock;
  407. },
  408. /**
  409. * Reconfigure this block based on the mutator dialog's components.
  410. * @param {!Blockly.Block} containerBlock Root block in mutator.
  411. * @this Blockly.Block
  412. */
  413. compose: function(containerBlock) {
  414. var itemBlock = containerBlock.getInputTargetBlock('STACK');
  415. // Count number of inputs.
  416. var connections = [];
  417. while (itemBlock) {
  418. connections.push(itemBlock.valueConnection_);
  419. itemBlock = itemBlock.nextConnection &&
  420. itemBlock.nextConnection.targetBlock();
  421. }
  422. // Disconnect any children that don't belong.
  423. for (var i = 0; i < this.itemCount_; i++) {
  424. var connection = this.getInput('ADD' + i).connection.targetConnection;
  425. if (connection && connections.indexOf(connection) == -1) {
  426. connection.disconnect();
  427. }
  428. }
  429. this.itemCount_ = connections.length;
  430. this.updateShape_();
  431. // Reconnect any child blocks.
  432. for (var i = 0; i < this.itemCount_; i++) {
  433. Blockly.Mutator.reconnect(connections[i], this, 'ADD' + i);
  434. }
  435. },
  436. /**
  437. * Store pointers to any connected child blocks.
  438. * @param {!Blockly.Block} containerBlock Root block in mutator.
  439. * @this Blockly.Block
  440. */
  441. saveConnections: function(containerBlock) {
  442. var itemBlock = containerBlock.getInputTargetBlock('STACK');
  443. var i = 0;
  444. while (itemBlock) {
  445. var input = this.getInput('ADD' + i);
  446. itemBlock.valueConnection_ = input && input.connection.targetConnection;
  447. i++;
  448. itemBlock = itemBlock.nextConnection &&
  449. itemBlock.nextConnection.targetBlock();
  450. }
  451. },
  452. /**
  453. * Modify this block to have the correct number of inputs.
  454. * @private
  455. * @this Blockly.Block
  456. */
  457. updateShape_: function() {
  458. // if (this.itemCount_ && this.getInput('EMPTY')) {
  459. // this.removeInput('EMPTY');
  460. // } else if (!this.itemCount_ && !this.getInput('EMPTY')) {
  461. // this.appendDummyInput('EMPTY')
  462. // .appendField(this.newQuote_(true))
  463. // .appendField(this.newQuote_(false));
  464. // }
  465. var i = 1;
  466. while (this.getInput('ADD' + i)) {
  467. this.removeInput('ADD' + i);
  468. i++;
  469. }
  470. // Add new inputs.
  471. for (var i = 0; i < this.itemCount_; i++) {
  472. if (!this.getInput('ADD' + i)) {
  473. var input = this.appendValueInput('ADD' + i)
  474. .appendField(Blockly.Msg.WIFIEASYMODE_TRANSFER_SEND_VALUE + i);
  475. }
  476. }
  477. // Remove deleted inputs.
  478. while (this.getInput('ADD' + i)) {
  479. this.removeInput('ADD' + i);
  480. i++;
  481. }
  482. },
  483. };
  484. Blockly.Blocks['Transfer_create_with_container'] = {
  485. /**
  486. * Mutator block for list container.
  487. * @this Blockly.Block
  488. */
  489. init: function() {
  490. this.setColour(Blockly.Blocks.wificomms.HUE);
  491. this.appendDummyInput()
  492. .appendField(Blockly.Msg.THINGSPEAK_CREATE_WITH_CONTAINER_TITLE_ADD);
  493. this.appendStatementInput('STACK');
  494. this.setTooltip('');
  495. this.contextMenu = false;
  496. }
  497. };
  498. Blockly.Blocks['Transfer_create_with_item'] = {
  499. /**
  500. * Mutator bolck for adding items.
  501. * @this Blockly.Block
  502. */
  503. init: function() {
  504. this.setColour(Blockly.Blocks.wificomms.HUE);
  505. this.appendDummyInput()
  506. .appendField(Blockly.Msg.THINGSPEAK_CREATE_WITH_ITEM_TITLE);
  507. this.setPreviousStatement(true);
  508. this.setNextStatement(true);
  509. this.setTooltip('');
  510. this.contextMenu = false;
  511. }
  512. };
  513. /*wifi easymode
  514. * wifi-2-main transfer
  515. * receive msg from main to wifi
  516. */
  517. Blockly.Blocks['wifiTransfer_receive'] = {
  518. init: function() {
  519. this.appendDummyInput()
  520. // .appendField(new Blockly.FieldImage("http://cocorobo.cn/cocoblockly/blockly/media/cocomod_blockly_wifi.png", 140, 40, "0"));
  521. .appendField(new Blockly.FieldImage("./../blockly/media/transfer-2.png", 50, 40, "0"));
  522. this.appendDummyInput()
  523. .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE)
  524. // this.appendDummyInput()
  525. // .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE_LINE2)
  526. // .appendField(new Blockly.FieldDropdown([
  527. // ["rxData", "rxData"]
  528. // ]), "DATAMAIN");
  529. this.appendDummyInput()
  530. .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE_LINE3)
  531. .appendField(new Blockly.FieldDropdown([
  532. ["1", "1"],
  533. ["2", "2"],
  534. ["3", "3"],
  535. ["4", "4"],
  536. ["5", "5"],
  537. ["6", "6"],
  538. ["7", "7"],
  539. ["8", "8"],
  540. ["9", "9"],
  541. ["10", "10"],
  542. ["11", "11"],
  543. ["12", "12"],
  544. ]), "LENGTH");
  545. this.setColour(Blockly.Blocks.wificomms.HUE);
  546. this.setPreviousStatement(true, null);
  547. this.setNextStatement(true, null);
  548. // this.setInputsInline(true);
  549. this.setTooltip("");
  550. this.setHelpUrl("");
  551. },
  552. getVarType: function(varName) {
  553. let vartype = Blockly.Types.ARRAY;
  554. return vartype;
  555. }
  556. }
  557. /*wifi easymode
  558. * wifi-2-main transfer
  559. * get data from dataMain
  560. * @param {dataMain} :where data tranferred stored in
  561. */
  562. Blockly.Blocks['wifiTransfer_receive_getValue'] = {
  563. init: function() {
  564. this.appendDummyInput()
  565. // .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE_GET)
  566. // .appendField(new Blockly.FieldDropdown([
  567. // ["rxData", "rxData"]
  568. // ]), "DATAMAIN")
  569. .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE_GET_LINE2)
  570. .appendField(new Blockly.FieldDropdown([
  571. ["0", "0"],
  572. ["1", "1"],
  573. ["2", "2"],
  574. ["3", "3"],
  575. ["4", "4"],
  576. ["5", "5"],
  577. ["6", "6"],
  578. ["7", "7"],
  579. ["8", "8"],
  580. ["9", "9"],
  581. ["10", "10"],
  582. ["11", "11"],
  583. ]), "INDEX")
  584. .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE_GET_LINE3)
  585. .appendField(new Blockly.FieldDropdown([
  586. ["String", ""],
  587. ["Number", ".toInt()"],
  588. ["Float", ".toFloat()"],
  589. ]), "TYPE")
  590. .appendField(" " + Blockly.Msg.WIFIEASYMODE_TRANSFER_RECEIVE_GET_LINE4)
  591. this.setColour(Blockly.Blocks.wificomms.HUE);
  592. this.setOutput(true)
  593. // this.setInputsInline(true);
  594. this.setTooltip("");
  595. this.setHelpUrl("");
  596. },
  597. getBlockType: function() {
  598. var type = this.getFieldValue("TYPE");
  599. switch (type) {
  600. case "" :
  601. return Blockly.Types.TEXT;
  602. case ".toInt()":
  603. return Blockly.Types.NUMBER;
  604. case ".toFloat()":
  605. return Blockly.Types.LARGE_NUMBER;
  606. }
  607. return Blockly.Types.NUMBER;
  608. },
  609. getOutputType: function() {
  610. var type = this.getFieldValue("TYPE");
  611. switch (type) {
  612. case "" :
  613. return Blockly.Types.TEXT.output
  614. case ".toInt()":
  615. return Blockly.Types.NUMBER.output;
  616. case ".toFloat()":
  617. return Blockly.Types.LARGE_NUMBER.output;
  618. }
  619. return Blockly.Types.NUMBER.output;
  620. }
  621. }