@@ -46,9 +46,6 @@ cwc.framework.Ev3 = function(code) {
46
46
code ( this ) ;
47
47
} . bind ( this ) ;
48
48
49
- /** @type {!cwc.framework.Runner } */
50
- this . runner = new cwc . framework . Runner ( this . code , this ) ;
51
-
52
49
/** @type {Object } */
53
50
this . deviceInfo = { } ;
54
51
@@ -109,19 +106,23 @@ cwc.framework.Ev3 = function(code) {
109
106
/** @type {!number } */
110
107
this . mediumMotorSpeed = 250 / 60 ;
111
108
109
+ /** @private {!cwc.framework.Runner} */
110
+ this . runner_ = new cwc . framework . Runner ( this . code , this ) ;
111
+
112
112
// External commands
113
- this . runner . addCommand ( 'updateColorSensor' , this . handleUpdateColorSensor_ ) ;
114
- this . runner . addCommand ( 'updateDeviceInfo' , this . handleUpdateDeviceInfo_ ) ;
115
- this . runner . addCommand ( 'updateGyroSensor' , this . handleUpdateGyroSensor_ ) ;
116
- this . runner . addCommand ( 'updateIrSensor' , this . handleUpdateIrSensor_ ) ;
117
- this . runner . addCommand ( 'updateTouchSensor' , this . handleUpdateTouchSensor_ ) ;
118
- this . runner . addCommand ( 'updateUltrasonicSensor' ,
113
+ this . runner_ . addCommand ( 'updateColorSensor' , this . handleUpdateColorSensor_ ) ;
114
+ this . runner_ . addCommand ( 'updateDeviceInfo' , this . handleUpdateDeviceInfo_ ) ;
115
+ this . runner_ . addCommand ( 'updateGyroSensor' , this . handleUpdateGyroSensor_ ) ;
116
+ this . runner_ . addCommand ( 'updateIrSensor' , this . handleUpdateIrSensor_ ) ;
117
+ this . runner_ . addCommand ( 'updateTouchSensor' , this . handleUpdateTouchSensor_ ) ;
118
+ this . runner_ . addCommand ( 'updateUltrasonicSensor' ,
119
119
this . handleUpdateUltrasonicSensor_ ) ;
120
- this . runner . addCommand ( 'updateRobotType' , this . handleUpdateRobotType_ ) ;
121
- this . runner . addCommand ( 'updateWheelDiameter' ,
120
+ this . runner_ . addCommand ( 'updateRobotType' , this . handleUpdateRobotType_ ) ;
121
+ this . runner_ . addCommand ( 'updateWheelDiameter' ,
122
122
this . handleUpdateWheelDiameter_ ) ;
123
- this . runner . addCommand ( 'updateWheelWidth' , this . handleUpdateWheelWidth_ ) ;
124
- this . runner . addCommand ( 'updateWheelbase' , this . handleUpdateWheelbase_ ) ;
123
+ this . runner_ . addCommand ( 'updateWheelWidth' , this . handleUpdateWheelWidth_ ) ;
124
+ this . runner_ . addCommand ( 'updateWheelbase' , this . handleUpdateWheelbase_ ) ;
125
+ this . runner_ . addCommand ( '__gamepad__' , this . handleUpdateGamepad_ ) ;
125
126
} ;
126
127
127
128
@@ -334,7 +335,7 @@ cwc.framework.Ev3.prototype.stopUltrasonicSensorEvent = function() {
334
335
* @export
335
336
*/
336
337
cwc . framework . Ev3 . prototype . drawImage = function ( filename , opt_delay ) {
337
- this . runner . send ( 'drawImage' , { 'file' : filename } , opt_delay ) ;
338
+ this . runner_ . send ( 'drawImage' , { 'file' : filename } , opt_delay ) ;
338
339
} ;
339
340
340
341
@@ -348,7 +349,7 @@ cwc.framework.Ev3.prototype.drawImage = function(filename, opt_delay) {
348
349
*/
349
350
cwc . framework . Ev3 . prototype . playTone = function ( frequency , opt_duration ,
350
351
opt_volume , opt_delay ) {
351
- this . runner . send ( 'playTone' , {
352
+ this . runner_ . send ( 'playTone' , {
352
353
'frequency' : frequency ,
353
354
'duration' : opt_duration ,
354
355
'volume' : opt_volume } , opt_delay ) ;
@@ -364,7 +365,7 @@ cwc.framework.Ev3.prototype.playTone = function(frequency, opt_duration,
364
365
*/
365
366
cwc . framework . Ev3 . prototype . playSound = function ( filename , opt_volume ,
366
367
opt_delay ) {
367
- this . runner . send ( 'playSound' , {
368
+ this . runner_ . send ( 'playSound' , {
368
369
'file' : filename ,
369
370
'volume' : opt_volume } , opt_delay ) ;
370
371
} ;
@@ -378,7 +379,7 @@ cwc.framework.Ev3.prototype.playSound = function(filename, opt_volume,
378
379
* @export
379
380
*/
380
381
cwc . framework . Ev3 . prototype . moveServo = function ( steps , opt_speed , opt_delay ) {
381
- this . runner . send ( 'moveServo' , {
382
+ this . runner_ . send ( 'moveServo' , {
382
383
'steps' : steps ,
383
384
'speed' : opt_speed } , opt_delay ) ;
384
385
} ;
@@ -394,7 +395,7 @@ cwc.framework.Ev3.prototype.moveServo = function(steps, opt_speed, opt_delay) {
394
395
*/
395
396
cwc . framework . Ev3 . prototype . movePen = function ( steps ,
396
397
opt_speed , opt_color , opt_delay ) {
397
- this . runner . send ( 'movePen' , {
398
+ this . runner_ . send ( 'movePen' , {
398
399
'steps' : steps ,
399
400
'speed' : opt_speed ,
400
401
'color' : opt_color } , opt_delay ) ;
@@ -415,7 +416,7 @@ cwc.framework.Ev3.prototype.moveSteps = function(steps, opt_speed, opt_delay) {
415
416
let delay = /** @type {number|undefined } */ (
416
417
opt_delay === true ? this . getDelay ( steps , opt_speed ) : opt_delay ) ;
417
418
let distance = Math . round ( ( this . wheelCircumference * ( steps / 360 ) ) / 10 ) ;
418
- this . runner . send ( 'moveSteps' , {
419
+ this . runner_ . send ( 'moveSteps' , {
419
420
'distance' : distance ,
420
421
'steps' : steps ,
421
422
'speed' : opt_speed } , delay ) ;
@@ -435,7 +436,7 @@ cwc.framework.Ev3.prototype.customMoveSteps = function(steps, opt_ports,
435
436
opt_speed , opt_delay ) {
436
437
let delay = /** @type {number|undefined } */ (
437
438
opt_delay === true ? this . getDelay ( steps , opt_speed ) : opt_delay ) ;
438
- this . runner . send ( 'customMoveSteps' , {
439
+ this . runner_ . send ( 'customMoveSteps' , {
439
440
'steps' : steps ,
440
441
'ports' : opt_ports ,
441
442
'speed' : opt_speed } , delay ) ;
@@ -454,7 +455,7 @@ cwc.framework.Ev3.prototype.moveDistance = function(distance, opt_speed,
454
455
let steps = Math . round ( ( distance * 10 / this . wheelCircumference ) * 360 ) ;
455
456
let delay = /** @type {number|undefined } */ (
456
457
opt_delay === true ? this . getDelay ( steps , opt_speed ) : opt_delay ) ;
457
- this . runner . send ( 'moveSteps' , {
458
+ this . runner_ . send ( 'moveSteps' , {
458
459
'distance' : distance ,
459
460
'steps' : steps ,
460
461
'speed' : opt_speed } , delay ) ;
@@ -471,7 +472,7 @@ cwc.framework.Ev3.prototype.moveDistance = function(distance, opt_speed,
471
472
*/
472
473
cwc . framework . Ev3 . prototype . rotateSteps = function ( steps ,
473
474
opt_speed , opt_ratio , opt_delay ) {
474
- this . runner . send ( 'rotateSteps' , {
475
+ this . runner_ . send ( 'rotateSteps' , {
475
476
'steps' : steps ,
476
477
'speed' : opt_speed ,
477
478
'ratio' : opt_ratio } , opt_delay ) ;
@@ -495,7 +496,7 @@ cwc.framework.Ev3.prototype.rotateAngle = function(angle,
495
496
( rotateDistance * angle / this . wheelCircumference ) * 360 ) ;
496
497
let delay = /** @type {number|undefined } */ (
497
498
opt_delay === true ? this . getDelay ( steps , opt_speed ) : opt_delay ) ;
498
- this . runner . send ( 'rotateSteps' , {
499
+ this . runner_ . send ( 'rotateSteps' , {
499
500
'angle' : angle ,
500
501
'steps' : steps ,
501
502
'speed' : opt_speed } , delay ) ;
@@ -518,7 +519,7 @@ cwc.framework.Ev3.prototype.customRotateAngle = function(angle,
518
519
( rotateDistance * angle / this . wheelCircumference ) * 360 ) ;
519
520
let delay = /** @type {number|undefined } */ (
520
521
opt_delay === true ? this . getDelay ( steps , opt_speed ) : opt_delay ) ;
521
- this . runner . send ( 'customRotateSteps' , {
522
+ this . runner_ . send ( 'customRotateSteps' , {
522
523
'angle' : angle ,
523
524
'steps' : steps ,
524
525
'ports' : opt_ports ,
@@ -533,7 +534,7 @@ cwc.framework.Ev3.prototype.customRotateAngle = function(angle,
533
534
* @export
534
535
*/
535
536
cwc . framework . Ev3 . prototype . movePower = function ( power , opt_delay ) {
536
- this . runner . send ( 'movePower' , { 'power' : power } , opt_delay ) ;
537
+ this . runner_ . send ( 'movePower' , { 'power' : power } , opt_delay ) ;
537
538
} ;
538
539
539
540
@@ -546,7 +547,7 @@ cwc.framework.Ev3.prototype.movePower = function(power, opt_delay) {
546
547
*/
547
548
cwc . framework . Ev3 . prototype . rotatePower = function ( power , opt_power ,
548
549
opt_delay ) {
549
- this . runner . send ( 'rotatePower' , {
550
+ this . runner_ . send ( 'rotatePower' , {
550
551
'power' : power ,
551
552
'opt_power' : opt_power } , opt_delay ) ;
552
553
} ;
@@ -558,7 +559,7 @@ cwc.framework.Ev3.prototype.rotatePower = function(power, opt_power,
558
559
* @export
559
560
*/
560
561
cwc . framework . Ev3 . prototype . stop = function ( opt_delay ) {
561
- this . runner . send ( 'stop' , null , opt_delay ) ;
562
+ this . runner_ . send ( 'stop' , null , opt_delay ) ;
562
563
} ;
563
564
564
565
@@ -568,7 +569,7 @@ cwc.framework.Ev3.prototype.stop = function(opt_delay) {
568
569
* @export
569
570
*/
570
571
cwc . framework . Ev3 . prototype . wait = function ( time ) {
571
- this . runner . send ( 'wait' , null , time ) ;
572
+ this . runner_ . send ( 'wait' , null , time ) ;
572
573
} ;
573
574
574
575
@@ -578,7 +579,7 @@ cwc.framework.Ev3.prototype.wait = function(time) {
578
579
* @export
579
580
*/
580
581
cwc . framework . Ev3 . prototype . setColorSensorMode = function ( mode , opt_delay ) {
581
- this . runner . send ( 'setColorSensorMode' , { 'mode' : mode } , opt_delay ) ;
582
+ this . runner_ . send ( 'setColorSensorMode' , { 'mode' : mode } , opt_delay ) ;
582
583
} ;
583
584
584
585
@@ -588,7 +589,7 @@ cwc.framework.Ev3.prototype.setColorSensorMode = function(mode, opt_delay) {
588
589
* @export
589
590
*/
590
591
cwc . framework . Ev3 . prototype . setIrSensorMode = function ( mode , opt_delay ) {
591
- this . runner . send ( 'setIrSensorMode' , { 'mode' : mode } , opt_delay ) ;
592
+ this . runner_ . send ( 'setIrSensorMode' , { 'mode' : mode } , opt_delay ) ;
592
593
} ;
593
594
594
595
@@ -599,7 +600,7 @@ cwc.framework.Ev3.prototype.setIrSensorMode = function(mode, opt_delay) {
599
600
*/
600
601
cwc . framework . Ev3 . prototype . setUltrasonicSensorMode = function ( mode ,
601
602
opt_delay ) {
602
- this . runner . send ( 'setUltrasonicSensorMode' , { 'mode' : mode } , opt_delay ) ;
603
+ this . runner_ . send ( 'setUltrasonicSensorMode' , { 'mode' : mode } , opt_delay ) ;
603
604
} ;
604
605
605
606
@@ -610,7 +611,7 @@ cwc.framework.Ev3.prototype.setUltrasonicSensorMode = function(mode,
610
611
* @export
611
612
*/
612
613
cwc . framework . Ev3 . prototype . setLed = function ( color , opt_mode , opt_delay ) {
613
- this . runner . send ( 'setLed' , {
614
+ this . runner_ . send ( 'setLed' , {
614
615
'color' : color ,
615
616
'mode' : opt_mode } , opt_delay ) ;
616
617
} ;
@@ -622,7 +623,7 @@ cwc.framework.Ev3.prototype.setLed = function(color, opt_mode, opt_delay) {
622
623
* @export
623
624
*/
624
625
cwc . framework . Ev3 . prototype . setStepSpeed = function ( speed , opt_delay ) {
625
- this . runner . send ( 'setStepSpeed' , { 'speed' : speed } , opt_delay ) ;
626
+ this . runner_ . send ( 'setStepSpeed' , { 'speed' : speed } , opt_delay ) ;
626
627
} ;
627
628
628
629
@@ -706,6 +707,15 @@ cwc.framework.Ev3.prototype.handleUpdateWheelDiameter_ = function(data) {
706
707
} ;
707
708
708
709
710
+ /**
711
+ * @param {Object } data
712
+ * @private
713
+ */
714
+ cwc . framework . Ev3 . prototype . handleUpdateGamepad_ = function ( data ) {
715
+ console . log ( data ) ;
716
+ } ;
717
+
718
+
709
719
/**
710
720
* Sets the wheel diameter
711
721
* @param {!number } data
0 commit comments