@@ -211,6 +211,7 @@ export default {
211
211
},
212
212
data () {
213
213
return {
214
+ settings: null ,
214
215
snackText: null ,
215
216
snackbar: false ,
216
217
drawer: false ,
@@ -257,15 +258,16 @@ export default {
257
258
258
259
axios .get (this .$data .CBv1 + ' /config' )
259
260
.then (function (response ) {
260
- let toolbox = response .data .prog_level
261
- this .initBlockly (toolbox)
261
+ var settings = response .data
262
+ this .$data .settings = settings
263
+ this .initBlockly (settings)
262
264
}.bind (this ))
263
265
264
266
},
265
267
methods: {
266
- initBlockly : function (toolboxLevel ) {
268
+ initBlockly : function (settings ) {
269
+ let toolboxLevel = settings .prog_level
267
270
const blocklyDiv = this .$refs .blocklyDiv
268
- // console.log(toolboxLevel)
269
271
var toolbox = require (' ../assets/toolbox_' + toolboxLevel + ' .xml' )
270
272
271
273
// Clean the base64 encoding of the resource, removing meta infos
@@ -300,9 +302,7 @@ export default {
300
302
this .resizeWorkspace ()
301
303
Blockly .svgResize (this .$data .workspace );
302
304
303
-
304
-
305
- this .blocksExtensions ();
305
+ this .blocksExtensions (settings);
306
306
},
307
307
toggleSidebar : function () {
308
308
let currentStatus = this .$store .getters .drawerStatus
@@ -332,7 +332,6 @@ export default {
332
332
a .dataset .downloadurl = [' text/json' , a .download , a .href ].join (' :' );
333
333
e .initEvent (' click' , true , false , window , 0 , 0 , 0 , 0 , 0 , false , false , false , false , 0 , null );
334
334
a .dispatchEvent (e);
335
-
336
335
},
337
336
pickFile () {
338
337
// Manually trigger the file dialog for the hidden file input form
@@ -385,7 +384,6 @@ export default {
385
384
} else {
386
385
this .$data .unvalidName = true
387
386
}
388
-
389
387
},
390
388
loadProgramList () {
391
389
let axios = this .$axios
@@ -475,7 +473,7 @@ export default {
475
473
getProgramCode () {
476
474
if (this .$data .experimental ) {
477
475
this .$data .experimental = false ;
478
- this .blocksExtensions ();
476
+ this .blocksExtensions (this . $data . settings );
479
477
this .$data .experimental = true ;
480
478
}
481
479
@@ -487,7 +485,7 @@ export default {
487
485
this .$data .dialogCode = true
488
486
489
487
if (this .$data .experimental ) {
490
- this .blocksExtensions ();
488
+ this .blocksExtensions (this . $data . settings )
491
489
}
492
490
},
493
491
runProgramExperimental () {
@@ -536,24 +534,27 @@ export default {
536
534
this .$data .generalDialogText = ' Il coderbot risulta offline, non puoi eseguire il programma.'
537
535
}
538
536
},
539
- blocksExtensions () {
540
-
537
+ blocksExtensions (settings ) {
538
+ var settings = this . $data . settings
541
539
var cfg = Object ();
540
+
542
541
// coderbot.cfg data (temp workaround, must be fetched from backend)
543
- var CODERBOT_MOV_FW_DEF_SPEED = 100 ;
544
- var CODERBOT_MOV_FW_DEF_ELAPSE = 1 ; // to check
545
- var CODERBOT_MOV_TR_DEF_SPEED = 85 ;
546
- var CODERBOT_MOV_TR_DEF_ELAPSE = - 1 ; // to check
542
+ var CODERBOT_MOV_FW_DEF_SPEED = settings . move_fw_elapse ;
543
+ var CODERBOT_MOV_FW_DEF_ELAPSE = settings . move_fw_speed ; // to check
544
+ var CODERBOT_MOV_TR_DEF_SPEED = settings . move_tr_speed ;
545
+ var CODERBOT_MOV_TR_DEF_ELAPSE = settings . move_tr_elapse ; // to check
547
546
var CODERBOT_PROG_MOVE_MOTION = true ; // to check
548
547
var CODERBOT_PROG_MOVE_MPU = true ; // to check
549
- var CODERBOT_PROG_LEVEL = " adv" ;
548
+
549
+ var CODERBOT_PROG_LEVEL = settings .prog_level ;
550
+
550
551
var CODERBOT_PROG_SCROLLBARS = true ; // to check
551
552
var CODERBOT_PROG_MAXBLOCKS = - 1 ;
552
553
var CODERBOT_PROG_SAVEONRUN = true ; // to check
553
- var CODERBOT_CTRL_FW_SPEED = 100 ;
554
- var CODERBOT_CTRL_FW_ELAPSE = 1 ;
555
- var CODERBOT_CTRL_TR_SPEED = 80 ;
556
- var CODERBOT_CTRL_TR_ELAPSE = 0.5 ; // to check
554
+ var CODERBOT_CTRL_FW_SPEED = settings . ctrl_fw_speed ;
555
+ var CODERBOT_CTRL_FW_ELAPSE = settings . ctrl_fw_elapse ;
556
+ var CODERBOT_CTRL_TR_SPEED = settings . ctrl_tr_speed ;
557
+ var CODERBOT_CTRL_TR_ELAPSE = settings . ctrl_tr_elapse ; // to check
557
558
var CODERBOT_CTRL_COUNTER = true ; // to check
558
559
var CODERBOT_CTRL_MOVE_MOTION = true ; // t o check
559
560
var CODERBOT_CTRL_MOVE_MPU = true ; // to check
@@ -576,6 +577,7 @@ export default {
576
577
BotMessages .ColorAtPoint = " Color at point: " ;
577
578
BotMessages .ModelTraining = " Model is training, check model lists to monitor training status." ;
578
579
580
+
579
581
// blocks.js
580
582
// Extensions to Blockly's language and Python generator.
581
583
@@ -585,7 +587,7 @@ export default {
585
587
*/
586
588
587
589
588
- ' use strict ' ;
590
+
589
591
590
592
Blockly .HSV_SATURATION = .99 ;
591
593
Blockly .HSV_VALUE = .99 ;
@@ -607,12 +609,12 @@ export default {
607
609
* @this Blockly.Block
608
610
*/
609
611
init : function (self ) {
610
- console . log ( ' test ' )
612
+
611
613
this .setHelpUrl (Blockly .Msg .CONTROLS_REPEAT_HELPURL );
612
614
this .setColour (120 );
613
615
var di = this .appendDummyInput ();
614
616
if (CODERBOT_PROG_LEVEL .indexOf (" basic" ) >= 0 ) {
615
- di .appendField (new Blockly.FieldImage (' /images/blocks/loop_repeat.png' , 32 , 32 , ' *' ));
617
+ di .appendField (new Blockly.FieldImage (' /static/ images/blocks/loop_repeat.png' , 32 , 32 , ' *' ));
616
618
} else {
617
619
di .appendField (Blockly .Msg .CONTROLS_REPEAT_TITLE_REPEAT )
618
620
}
@@ -658,7 +660,7 @@ export default {
658
660
this .setColour (40 );
659
661
var di = this .appendDummyInput ()
660
662
if (CODERBOT_PROG_LEVEL .indexOf (" basic" ) >= 0 ) {
661
- di .appendField (new Blockly.FieldImage (' /images/blocks/move_forward.png' , 32 , 32 , ' *' ));
663
+ di .appendField (new Blockly.FieldImage (' /static/ images/blocks/move_forward.png' , 32 , 32 , ' *' ));
662
664
} else {
663
665
di .appendField (" Hello, World!" )
664
666
}
@@ -686,7 +688,7 @@ export default {
686
688
this .setColour (40 );
687
689
var di = this .appendDummyInput ()
688
690
if (CODERBOT_PROG_LEVEL .indexOf (" basic" ) >= 0 ) {
689
- di .appendField (new Blockly.FieldImage (' /images/blocks/move_backward.png' , 32 , 32 , ' *' ));
691
+ di .appendField (new Blockly.FieldImage (' /static/ images/blocks/move_backward.png' , 32 , 32 , ' *' ));
690
692
} else {
691
693
di .appendField (Blockly .Msg .CODERBOT_MOVE_BACKWARD )
692
694
}
@@ -713,7 +715,7 @@ export default {
713
715
this .setColour (40 );
714
716
var di = this .appendDummyInput ()
715
717
if (CODERBOT_PROG_LEVEL .indexOf (" basic" ) >= 0 ) {
716
- di .appendField (new Blockly.FieldImage (' /images/blocks/move_left.png' , 32 , 32 , ' *' ));
718
+ di .appendField (new Blockly.FieldImage (' /static/ images/blocks/move_left.png' , 32 , 32 , ' *' ));
717
719
} else {
718
720
di .appendField (Blockly .Msg .CODERBOT_MOVE_LEFT );
719
721
}
@@ -741,7 +743,7 @@ export default {
741
743
this .setColour (40 );
742
744
var di = this .appendDummyInput ()
743
745
if (CODERBOT_PROG_LEVEL .indexOf (" basic" ) >= 0 ) {
744
- di .appendField (new Blockly.FieldImage (' /images/blocks/move_right.png' , 32 , 32 , ' *' ));
746
+ di .appendField (new Blockly.FieldImage (' /static/ images/blocks/move_right.png' , 32 , 32 , ' *' ));
745
747
} else {
746
748
di .appendField (Blockly .Msg .CODERBOT_MOVE_RIGHT )
747
749
}
@@ -770,7 +772,7 @@ export default {
770
772
var vi = this .appendValueInput (' TEXT' );
771
773
vi .setCheck ([" String" , " Number" , " Date" ]);
772
774
if (CODERBOT_PROG_LEVEL .indexOf (" basic" ) >= 0 ) {
773
- vi .appendField (new Blockly.FieldImage (' /images/blocks/say.png' , 32 , 32 , ' *' ));
775
+ vi .appendField (new Blockly.FieldImage (' /static/ images/blocks/say.png' , 32 , 32 , ' *' ));
774
776
} else {
775
777
vi .appendField (Blockly .Msg .CODERBOT_SAY );
776
778
}
@@ -995,7 +997,7 @@ export default {
995
997
this .setColour (120 );
996
998
var di = this .appendDummyInput ()
997
999
if (CODERBOT_PROG_LEVEL .indexOf (" basic" ) >= 0 ) {
998
- di .appendField (new Blockly.FieldImage (' /images/blocks/photo_take.png' , 32 , 32 , ' *' ));
1000
+ di .appendField (new Blockly.FieldImage (' /static/ images/blocks/photo_take.png' , 32 , 32 , ' *' ));
999
1001
} else {
1000
1002
di .appendField (Blockly .Msg .CODERBOT_PHOTO_TAKE )
1001
1003
}
@@ -1018,7 +1020,7 @@ export default {
1018
1020
1019
1021
var di = this .appendDummyInput ()
1020
1022
if (CODERBOT_PROG_LEVEL .indexOf (" basic" ) >= 0 ) {
1021
- di .appendField (new Blockly.FieldImage (' /images/blocks/video_rec.png' , 32 , 32 , ' *' ));
1023
+ di .appendField (new Blockly.FieldImage (' /static/ images/blocks/video_rec.png' , 32 , 32 , ' *' ));
1022
1024
} else {
1023
1025
di .appendField (Blockly .Msg .CODERBOT_VIDEO_REC )
1024
1026
}
@@ -1041,7 +1043,7 @@ export default {
1041
1043
1042
1044
var di = this .appendDummyInput ()
1043
1045
if (CODERBOT_PROG_LEVEL .indexOf (" basic" ) >= 0 ) {
1044
- di .appendField (new Blockly.FieldImage (' /images/blocks/video_stop.png' , 32 , 32 , ' *' ));
1046
+ di .appendField (new Blockly.FieldImage (' /static/ images/blocks/video_stop.png' , 32 , 32 , ' *' ));
1045
1047
} else {
1046
1048
di .appendField (Blockly .Msg .CODERBOT_VIDEO_STOP )
1047
1049
}
@@ -1545,7 +1547,7 @@ export default {
1545
1547
var vi = this .appendValueInput (' FILENAME' );
1546
1548
vi .setCheck (" String" );
1547
1549
if (CODERBOT_PROG_LEVEL .indexOf (" basic" ) >= 0 ) {
1548
- vi .appendField (new Blockly.FieldImage (' /images/blocks/play.png' , 32 , 32 , ' *' ));
1550
+ vi .appendField (new Blockly.FieldImage (' /static/ images/blocks/play.png' , 32 , 32 , ' *' ));
1549
1551
} else {
1550
1552
vi .appendField (Blockly .Msg .CODERBOT_AUDIO_PLAY_FILE );
1551
1553
}
0 commit comments