Skip to content

Commit

Permalink
ORA-675 add power range test in simulation, ORA-674 fix createListblo…
Browse files Browse the repository at this point in the history
…ck bug, ORA-670 fix codeButton in simulation
  • Loading branch information
bjost2s committed Sep 23, 2015
1 parent 5821362 commit cef9512
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 21 deletions.
12 changes: 5 additions & 7 deletions OpenRobertaServer/staticResources/blockly/blocks/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,11 +176,12 @@ Blockly.Blocks['robLists_create_with'] = {
this.sourceBlock_.updateType_(option);
}
});
listType.setValue(this.listType_);
if (num == 1) {
if (this.itemCount_ == 0) {
this.removeInput('EMPTY');
this.appendValueInput('ADD0').appendField(Blockly.Msg.LISTS_CREATE_TITLE).appendField(':').appendField(listType, 'LIST_TYPE').appendField(
Blockly.RTL ? '\u2192' : '\u2190').setCheck('Number');
Blockly.RTL ? '\u2192' : '\u2190').setCheck(this.listType_);
this.setInputsInline(false);
this.setMutatorMinus(new Blockly.MutatorMinus(this));
} else {
Expand Down Expand Up @@ -380,8 +381,7 @@ Blockly.Blocks['lists_getIndex'] = {
});
},
/**
* Create XML to represent whether the block is a statement or a value. Also
* represent whether there is an 'AT' input.
* Create XML to represent whether the block is a statement or a value. Also represent whether there is an 'AT' input.
*
* @return {Element} XML storage element.
* @this Blockly.Block
Expand Down Expand Up @@ -412,8 +412,7 @@ Blockly.Blocks['lists_getIndex'] = {
* Switch between a value block and a statement block.
*
* @param {boolean}
* newStatement True if the block should be a statement. False if
* the block should be a value.
* newStatement True if the block should be a statement. False if the block should be a value.
* @private
* @this Blockly.Block
*/
Expand Down Expand Up @@ -621,8 +620,7 @@ Blockly.Blocks['lists_getSublist'] = {
this.updateAt_(2, isAt2);
},
/**
* Create or delete an input for a numeric index. This block has two such
* inputs, independant of each other.
* Create or delete an input for a numeric index. This block has two such inputs, independant of each other.
*
* @param {number}
* n Specify first or second input (1 or 2).
Expand Down
14 changes: 7 additions & 7 deletions OpenRobertaServer/staticResources/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,24 +34,24 @@
<script type="text/javascript" src="/common/jquery/jquery.dataTables.min.js" charset="utf-8"></script>
<script type="text/javascript" src="/common/bootstrap/bootstrap-3.3.1-dist/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/roberta/user.js"></script>
<script type="text/javascript" src="/roberta/robot.js"></script>
<!-- <script type="text/javascript" src="/roberta/robot.js"></script>
<script type="text/javascript" src="/roberta/program.js"></script>
<script type="text/javascript" src="/roberta/configuration.js"></script>
<script type="text/javascript" src="/roberta/util.js"></script>
<script type="text/javascript" src="/roberta/roberta.js"></script>
<!-- <script type="text/javascript" src="/roberta/roberta.min.js"></script> -->
<script type="text/javascript" src="/roberta/roberta.js"></script> -->
<script type="text/javascript" src="/roberta/roberta.min.js"></script>

<!-- <script type="text/javascript" src="/simulation/simulationLogic/robot.js"></script>
<script type="text/javascript" src="/simulation/simulationLogic/robot.js"></script>
<script type="text/javascript" src="/simulation/simulationLogic/scene.js"></script>
<script type="text/javascript" src="/simulation/simulationLogic/simMath.js"></script>
<script type="text/javascript" src="/simulation/simulationLogic/simulation.js"></script> -->
<script type="text/javascript" src="/simulation/simulationLogic/simulationLogic.min.js"></script>
<script type="text/javascript" src="/simulation/simulationLogic/simulation.js"></script>
<!-- <script type="text/javascript" src="/simulation/simulationLogic/simulationLogic.min.js"></script> -->

<script type="text/javascript" src="/blockly/blockly_compressed.js"></script>
<script type="text/javascript" src="/blockly/blocks_compressed.js"></script>
<script type="text/javascript" src="blockly/msg/js/en.js"></script>
<script type="text/javascript" src="blockly/core/help.js"></script>
<script type="text/javascript" src="blockly/core/bubble.js"></script>
<script type="text/javascript" src="blockly/blocks/lists.js"></script>

<link rel="stylesheet" type="text/css" href="/common/bootstrap/bootstrap-3.3.1-dist/dist/css/bootstrap.min.css"></link>
<!-- <link rel="stylesheet" type="text/css" href="/common/jquery.dataTables.min.css"></link> -->
Expand Down
37 changes: 34 additions & 3 deletions OpenRobertaServer/staticResources/roberta/roberta.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ function showUserInfo() {
*/
function showRobotInfo() {
if (userState.robotName) {
$("#robotName").text(userState.robotName);
if (userState.robot === "oraSim") {
$("#robotName").text("ORSim");
} else {
$("#robotName").text(userState.robotName);
}
if (userState.robotState === "wait") {
$("#robotStateWait").css('display', 'inline');
$("#robotStateDisconnected").css('display', 'none');
Expand Down Expand Up @@ -239,6 +243,13 @@ function injectBlockly(toolbox, opt_programBlocks, opt_readOnly) {
initProgramEnvironment(opt_programBlocks);
setRobotState(toolbox);
}
if (userState.robot === "ev3") {
$('#menuShowCode').parent().removeClass('disabled');
Blockly.getMainWorkspace().codeButton.enable();
} else {
$('#menuShowCode').parent().addClass('disabled');
Blockly.getMainWorkspace().codeButton.disable();
}
}
}

Expand Down Expand Up @@ -1150,11 +1161,32 @@ function switchToBrickly() {
$('#tabBrickly').click();
bricklyActive = true;
}
/**
* Init robot
*/
function initRobot() {
ROBOT.setRobot(userState.robot, function(result) {
response(result);
if (result.rc === "ok") {
setConfiguration("EV3basis");
loadToolbox(userState.toolbox);
$('#blocklyDiv').removeClass('simBackground');
$('#menuEv3').parent().addClass('disabled');
$('#menuSim').parent().removeClass('disabled');
$('#menuConnect').parent().removeClass('disabled');
$('#iconDisplayRobotState').removeClass('typcn-Roberta');
$('#iconDisplayRobotState').addClass('typcn-ev3');
$('#menuShowCode').parent().removeClass('disabled');
}
});
}

/**
* Switch robot
*/
function switchRobot(robot) {
if (robot === userState.robot)
return;
ROBOT.setRobot(robot, function(result) {
if (result.rc === "ok") {
userState.robot = robot;
Expand All @@ -1171,7 +1203,6 @@ function switchRobot(robot) {
Blockly.getMainWorkspace().codeButton.enable();
UTIL.getBricklyFrame('#bricklyFrame').loadToolboxAndConfiguration();
} else if (robot === "oraSim") {
userState.robotName = "ORSim";
setConfiguration("ORSim");
$('#blocklyDiv').addClass('simBackground');
$('#menuEv3').parent().removeClass('disabled');
Expand Down Expand Up @@ -2100,7 +2131,7 @@ function init() {
// TODO do more?
}
});
switchRobot(userState.robot);
initRobot();
COMM.json("/toolbox", {
"cmd" : "loadT",
"name" : userState.toolbox,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,20 @@ var SIM = (function() {
}

function setOutput() {
output.left = ACTORS.getLeftMotor().getPower() * MAXPOWER || 0;
output.right = ACTORS.getRightMotor().getPower() * MAXPOWER || 0;
var left = ACTORS.getLeftMotor().getPower();
if (left > 100) {
left = 100;
} else if (left < -100) {
left = -100
}
var right = ACTORS.getRightMotor().getPower();
if (right > 100) {
right = 100;
} else if (right < -100) {
right = -100
}
output.left = left * MAXPOWER || 0;
output.right = right * MAXPOWER || 0;

robot.led.mode = output.ledMode = LIGHT.getMode() || "OFF";
if (LIGHT.getMode() && LIGHT.getMode() == "OFF") {
Expand Down

Large diffs are not rendered by default.

0 comments on commit cef9512

Please sign in to comment.