Skip to content

Commit fab7aeb

Browse files
committed
Moved ev3 protocol files to seperate namespace.
Fixed #27
1 parent eee5269 commit fab7aeb

File tree

28 files changed

+1272
-1237
lines changed

28 files changed

+1272
-1237
lines changed

build/cwc/frameworks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ closureBuilder.build({
5050
]),
5151
deps: glob([
5252
'src/frameworks/internal/runner/runner.js',
53-
'src/protocol/robots/ev3/*.js',
53+
'src/protocol/robots/lego/ev3/*.js',
5454
'src/utils/stack_queue.js',
5555
]),
5656
out: 'genfiles/core/frameworks/internal/ev3_framework.js',

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "Apache-2.0",
77
"private": true,
88
"dependencies": {
9-
"closure-builder": "^2.2.38",
9+
"closure-builder": "^2.2.39",
1010
"command-line-usage": "^5.0.3",
1111
"jasmine-core": "^2.99.1",
1212
"jsdoc": "^3.5.5",
@@ -20,7 +20,7 @@
2020
},
2121
"devDependencies": {
2222
"closure-templates": "latest",
23-
"eslint": "^4.18.2",
23+
"eslint": "^4.19.0",
2424
"eslint-config-google": "^0.9.1",
2525
"http-server": "latest",
2626
"jasmine-core": "latest",

src/addon/message/message.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ cwc.addon.Message.prototype.prepare = function() {
7070
*/
7171
cwc.addon.Message.prototype.eventsModder = function(e) {
7272
let mode = e.data.mode;
73-
let fileName = e.data.file;
74-
this.log_.info('Change Mode', mode, 'for file', fileName);
73+
let filename = e.data.file;
74+
this.log_.info('Change Mode', mode, 'for file', filename);
7575
let file = this.helper.getInstance('file').getFile();
7676
if (!file) return;
7777
let content = file.getMetadata('content', 'message');

src/addon/tutorial/tutorial.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,13 +159,13 @@ cwc.addon.Tutorial.prototype.eventsModder = function(e) {
159159

160160
/**
161161
* Loads file into editor.
162-
* @param {string} file_name Example file name to load.
162+
* @param {string} filename Example file name to load.
163163
* @private
164164
*/
165-
cwc.addon.Tutorial.prototype.loadFile_ = function(file_name) {
165+
cwc.addon.Tutorial.prototype.loadFile_ = function(filename) {
166166
let loaderInstance = this.helper.getInstance('fileLoader');
167167
if (loaderInstance) {
168-
loaderInstance.loadLocalFile(this.resourcesPath_ + file_name);
168+
loaderInstance.loadLocalFile(this.resourcesPath_ + filename);
169169
}
170170
let editorWindow = this.chromeApp_ && chrome.app.window.get('editor');
171171
if (editorWindow) {

src/frameworks/internal/ev3/ev3.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@
2323
goog.provide('cwc.framework.Ev3');
2424

2525
goog.require('cwc.framework.Runner');
26-
goog.require('cwc.protocol.ev3.DeviceName');
27-
goog.require('cwc.protocol.ev3.LedColor');
28-
goog.require('cwc.protocol.ev3.LedMode');
29-
goog.require('cwc.protocol.ev3.RobotType');
30-
goog.require('cwc.protocol.ev3.Robots');
26+
goog.require('cwc.protocol.lego.ev3.DeviceName');
27+
goog.require('cwc.protocol.lego.ev3.LedColor');
28+
goog.require('cwc.protocol.lego.ev3.LedMode');
29+
goog.require('cwc.protocol.lego.ev3.RobotType');
30+
goog.require('cwc.protocol.lego.ev3.Robots');
3131

3232

3333
/**
@@ -85,8 +85,8 @@ cwc.framework.Ev3 = function(code) {
8585
/** @type {number} */
8686
this.ultrasonicSensorValue = 0;
8787

88-
/** @type {cwc.protocol.ev3.RobotType} */
89-
this.robotType = cwc.protocol.ev3.RobotType.UNKNOWN;
88+
/** @type {cwc.protocol.lego.ev3.RobotType} */
89+
this.robotType = cwc.protocol.lego.ev3.RobotType.UNKNOWN;
9090

9191
/** @type {number} */
9292
this.wheelDiameter = 0;
@@ -134,21 +134,21 @@ cwc.framework.Ev3.prototype.setRobotModel = function(model) {
134134
if (model == 'custom') {
135135
return;
136136
}
137-
if (!(model in cwc.protocol.ev3.Robots)) {
137+
if (!(model in cwc.protocol.lego.ev3.Robots)) {
138138
console.error('Unknown robot model: ' + model);
139139
return;
140140
}
141141
console.log('Set robot model to ' + model);
142-
this.setRobotType(cwc.protocol.ev3.Robots[model].type);
143-
this.setWheelDiameter(cwc.protocol.ev3.Robots[model].wheelDiameter);
144-
this.setWheelWidth(cwc.protocol.ev3.Robots[model].wheelWidth);
145-
this.setWheelbase(cwc.protocol.ev3.Robots[model].wheelbase);
142+
this.setRobotType(cwc.protocol.lego.ev3.Robots[model].type);
143+
this.setWheelDiameter(cwc.protocol.lego.ev3.Robots[model].wheelDiameter);
144+
this.setWheelWidth(cwc.protocol.lego.ev3.Robots[model].wheelWidth);
145+
this.setWheelbase(cwc.protocol.lego.ev3.Robots[model].wheelbase);
146146
};
147147

148148

149149
/**
150150
* Sets the EV3 robot type.
151-
* @param {!cwc.protocol.ev3.RobotType<string>} type
151+
* @param {!cwc.protocol.lego.ev3.RobotType<string>} type
152152
* @export
153153
*/
154154
cwc.framework.Ev3.prototype.setRobotType = function(type) {
@@ -329,12 +329,12 @@ cwc.framework.Ev3.prototype.stopUltrasonicSensorEvent = function() {
329329

330330
/**
331331
* Displays the selected file name on the EV3 display.
332-
* @param {!string} file_name
332+
* @param {!string} filename
333333
* @param {number=} opt_delay in msec
334334
* @export
335335
*/
336-
cwc.framework.Ev3.prototype.drawImage = function(file_name, opt_delay) {
337-
this.runner.send('drawImage', {'file': file_name}, opt_delay);
336+
cwc.framework.Ev3.prototype.drawImage = function(filename, opt_delay) {
337+
this.runner.send('drawImage', {'file': filename}, opt_delay);
338338
};
339339

340340

@@ -357,15 +357,15 @@ cwc.framework.Ev3.prototype.playTone = function(frequency, opt_duration,
357357

358358
/**
359359
* Plays a sound file.
360-
* @param {!string} file_name
360+
* @param {!string} filename
361361
* @param {number=} opt_volume
362362
* @param {number=} opt_delay in msec
363363
* @export
364364
*/
365-
cwc.framework.Ev3.prototype.playSound = function(file_name, opt_volume,
365+
cwc.framework.Ev3.prototype.playSound = function(filename, opt_volume,
366366
opt_delay) {
367367
this.runner.send('playSound', {
368-
'file': file_name,
368+
'file': filename,
369369
'volume': opt_volume}, opt_delay);
370370
};
371371

@@ -409,7 +409,7 @@ cwc.framework.Ev3.prototype.movePen = function(steps,
409409
* @export
410410
*/
411411
cwc.framework.Ev3.prototype.moveSteps = function(steps, opt_speed, opt_delay) {
412-
if (this.robotType == cwc.protocol.ev3.RobotType.ARM) {
412+
if (this.robotType == cwc.protocol.lego.ev3.RobotType.ARM) {
413413
this.customMoveSteps(steps, undefined, opt_speed, opt_delay);
414414
} else {
415415
let delay = /** @type {number|undefined} */ (
@@ -487,7 +487,7 @@ cwc.framework.Ev3.prototype.rotateSteps = function(steps,
487487
*/
488488
cwc.framework.Ev3.prototype.rotateAngle = function(angle,
489489
opt_speed, opt_delay) {
490-
if (this.robotType == cwc.protocol.ev3.RobotType.ARM) {
490+
if (this.robotType == cwc.protocol.lego.ev3.RobotType.ARM) {
491491
this.customRotateAngle(angle, undefined, opt_speed, opt_delay);
492492
} else {
493493
let rotateDistance = this.rotateCircumference / 360;
@@ -604,8 +604,8 @@ cwc.framework.Ev3.prototype.setUltrasonicSensorMode = function(mode,
604604

605605

606606
/**
607-
* @param {cwc.protocol.ev3.LedColor} color
608-
* @param {cwc.protocol.ev3.LedMode=} opt_mode
607+
* @param {cwc.protocol.lego.ev3.LedColor} color
608+
* @param {cwc.protocol.lego.ev3.LedMode=} opt_mode
609609
* @param {number=} opt_delay in msec
610610
* @export
611611
*/
@@ -688,7 +688,7 @@ cwc.framework.Ev3.prototype.handleUpdateUltrasonicSensor_ = function(data) {
688688

689689
/**
690690
* Sets the robot type.
691-
* @param {!cwc.protocol.ev3.RobotType<string>} data
691+
* @param {!cwc.protocol.lego.ev3.RobotType<string>} data
692692
* @private
693693
*/
694694
cwc.framework.Ev3.prototype.handleUpdateRobotType_ = function(data) {

src/frameworks/internal/python/python2.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ cwc.framework.Python2.prototype.showInput = function(opt_msg) {
144144

145145

146146
/**
147-
* @param {!string} file_name
147+
* @param {!string} filename
148148
* @return {Object}
149149
*/
150-
cwc.framework.Python2.prototype.builtinRead = function(file_name) {
150+
cwc.framework.Python2.prototype.builtinRead = function(filename) {
151151
if (Sk.builtinFiles === undefined ||
152-
Sk.builtinFiles['files'][file_name] === undefined) {
153-
throw new Error('File not found: \'' + file_name + '\'');
152+
Sk.builtinFiles['files'][filename] === undefined) {
153+
throw new Error('File not found: \'' + filename + '\'');
154154
}
155-
return Sk.builtinFiles['files'][file_name];
155+
return Sk.builtinFiles['files'][filename];
156156
};

src/mode/ev3/calibration.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
goog.provide('cwc.mode.ev3.Calibration');
2121

22-
goog.require('cwc.protocol.ev3.Robots');
22+
goog.require('cwc.protocol.lego.ev3.Robots');
2323
goog.require('cwc.soy.mode.ev3.Calibration');
2424
goog.require('cwc.ui.Helper');
2525
goog.require('cwc.utils.Events');
@@ -74,7 +74,7 @@ cwc.mode.ev3.Calibration = function(helper, connection, runner) {
7474
/** @type {!cwc.mode.ev3.Connection} */
7575
this.connection = connection;
7676

77-
/** @type {!cwc.protocol.ev3.Api} */
77+
/** @type {!cwc.protocol.lego.ev3.Api} */
7878
this.api = this.connection.getApi();
7979

8080
/** @type {!cwc.mode.ev3.Runner} */
@@ -121,8 +121,8 @@ cwc.mode.ev3.Calibration.prototype.decorate = function() {
121121
this.nodeWheelbase = goog.dom.getElement(this.prefix + 'wheelbase');
122122

123123
// Robot Models
124-
for (let robot in cwc.protocol.ev3.Robots) {
125-
if (cwc.protocol.ev3.Robots.hasOwnProperty(robot)) {
124+
for (let robot in cwc.protocol.lego.ev3.Robots) {
125+
if (cwc.protocol.lego.ev3.Robots.hasOwnProperty(robot)) {
126126
let item = cwc.ui.Helper.getMenuItem(robot, '', this.setType.bind(this));
127127
this.nodeRobotList.appendChild(item);
128128
}
@@ -196,9 +196,9 @@ cwc.mode.ev3.Calibration.prototype.setType = function(event) {
196196
*/
197197
cwc.mode.ev3.Calibration.prototype.setRobotModel = function(model) {
198198
console.log('Set robot model to', model);
199-
console.log('Type:', cwc.protocol.ev3.Robots[model].type);
199+
console.log('Type:', cwc.protocol.lego.ev3.Robots[model].type);
200200

201-
let robotConfig = cwc.protocol.ev3.Robots[model];
201+
let robotConfig = cwc.protocol.lego.ev3.Robots[model];
202202
let fileInstance = this.helper.getInstance('file');
203203
if (fileInstance) {
204204
fileInstance.setModel(model);
@@ -214,7 +214,7 @@ cwc.mode.ev3.Calibration.prototype.setRobotModel = function(model) {
214214
this.nodeRobotType.value = robotConfig.type;
215215

216216
this.helper.dispatchEvent('changeRobotType',
217-
cwc.protocol.ev3.Robots[model].type);
217+
cwc.protocol.lego.ev3.Robots[model].type);
218218
};
219219

220220

src/mode/ev3/connection.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
*/
2020
goog.provide('cwc.mode.ev3.Connection');
2121

22-
goog.require('cwc.protocol.ev3.Api');
22+
goog.require('cwc.protocol.lego.ev3.Api');
2323
goog.require('cwc.utils.Events');
2424

2525
goog.require('goog.Timer');
@@ -45,8 +45,8 @@ cwc.mode.ev3.Connection = function(helper) {
4545
/** @type {!number} */
4646
this.connectMonitorInterval = 5000;
4747

48-
/** @private {!cwc.protocol.ev3.Api} */
49-
this.api_ = new cwc.protocol.ev3.Api();
48+
/** @private {!cwc.protocol.lego.ev3.Api} */
49+
this.api_ = new cwc.protocol.lego.ev3.Api();
5050

5151
/** @private {!cwc.utils.Events} */
5252
this.events_ = new cwc.utils.Events(this.name);
@@ -122,7 +122,7 @@ cwc.mode.ev3.Connection.prototype.getDevices = function() {
122122

123123

124124
/**
125-
* @return {!cwc.protocol.ev3.Api}
125+
* @return {!cwc.protocol.lego.ev3.Api}
126126
* @export
127127
*/
128128
cwc.mode.ev3.Connection.prototype.getApi = function() {

src/mode/ev3/monitor.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
*/
2020
goog.provide('cwc.mode.ev3.Monitor');
2121

22-
goog.require('cwc.protocol.ev3.Api');
23-
goog.require('cwc.protocol.ev3.Events');
24-
goog.require('cwc.protocol.ev3.RobotType');
25-
goog.require('cwc.protocol.ev3.Robots');
22+
goog.require('cwc.protocol.lego.ev3.Api');
23+
goog.require('cwc.protocol.lego.ev3.Events');
24+
goog.require('cwc.protocol.lego.ev3.RobotType');
25+
goog.require('cwc.protocol.lego.ev3.Robots');
2626
goog.require('cwc.soy.mode.ev3.Monitor');
2727
goog.require('cwc.utils.Events');
2828
goog.require('cwc.utils.Helper');
@@ -64,7 +64,7 @@ cwc.mode.ev3.Monitor = function(helper, connection) {
6464
/** @type {!cwc.mode.ev3.Connection} */
6565
this.connection = connection;
6666

67-
/** @type {!cwc.protocol.ev3.Api} */
67+
/** @type {!cwc.protocol.lego.ev3.Api} */
6868
this.api = this.connection.getApi();
6969

7070
/** @type {boolean} */
@@ -76,8 +76,8 @@ cwc.mode.ev3.Monitor = function(helper, connection) {
7676
/** @private {!cwc.utils.Events} */
7777
this.events_ = new cwc.utils.Events(this.name, this.prefix);
7878

79-
/** @private {cwc.protocol.ev3.RobotType} */
80-
this.robotType_ = cwc.protocol.ev3.RobotType.UNKNOWN;
79+
/** @private {cwc.protocol.lego.ev3.RobotType} */
80+
this.robotType_ = cwc.protocol.lego.ev3.RobotType.UNKNOWN;
8181

8282
/** @private {cwc.ui.RunnerMonitor} */
8383
this.runnerMonitor_ = null;
@@ -129,8 +129,8 @@ cwc.mode.ev3.Monitor.prototype.decorate = function() {
129129
// Update event
130130
let eventHandler = this.connection.getEventHandler();
131131
this.events_.listen(eventHandler,
132-
cwc.protocol.ev3.Events.Type.CHANGED_VALUES, this.updateDeviceData, false,
133-
this);
132+
cwc.protocol.lego.ev3.Events.Type.CHANGED_VALUES, this.updateDeviceData,
133+
false, this);
134134

135135
// Custom events
136136
let customEventHandler = this.helper.getEventHandler();
@@ -175,7 +175,7 @@ cwc.mode.ev3.Monitor.prototype.updateDeviceData = function(opt_event) {
175175

176176
/**
177177
* Updates device Data in monitor tab.
178-
* @param {!cwc.protocol.ev3.RobotType} type
178+
* @param {!cwc.protocol.lego.ev3.RobotType} type
179179
*/
180180
cwc.mode.ev3.Monitor.prototype.updateRobotType = function(type) {
181181
this.robotType_ = type;
@@ -271,10 +271,10 @@ cwc.mode.ev3.Monitor.prototype.handleKeyboardShortcut_ = function(event) {
271271

272272
// Motor control commands
273273
switch (this.robotType_) {
274-
case cwc.protocol.ev3.RobotType.ARM:
274+
case cwc.protocol.lego.ev3.RobotType.ARM:
275275
this.handleArmKeyboardShortcut_(event.identifier);
276276
break;
277-
case cwc.protocol.ev3.RobotType.VEHICLE:
277+
case cwc.protocol.lego.ev3.RobotType.VEHICLE:
278278
this.handleVehicleKeyboardShortcut_(event.identifier);
279279
break;
280280
default:

0 commit comments

Comments
 (0)