summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-12-14 20:25:32 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2015-12-14 20:25:32 +0100
commit7de6dca9112d292803b801e0d370c45b0ca0eb13 (patch)
treef096bc886d535ecaf5c8e18b2b647080e4decab0
parente7fe28e92a766e0a37cb75d1bee534d476f955ed (diff)
Improve robot screen
-rw-r--r--css/codeq.css12
-rw-r--r--index.html1
-rw-r--r--js/codeq/robot.js20
3 files changed, 26 insertions, 7 deletions
diff --git a/css/codeq.css b/css/codeq.css
index 3a12b85..1775c84 100644
--- a/css/codeq.css
+++ b/css/codeq.css
@@ -159,6 +159,18 @@ div.vertical-line{
padding: 0 4px;
}
+/* robot connection & sensor info */
+#screen_robot .block3 .status {
+ background-color: #666;
+ border: 1px solid #444;
+ color: yellow;
+ font-family: monospace;
+ padding: 0.5em;
+ position: absolute;
+ top: 1em;
+ right: 1em;
+}
+
/* block-toolbar */
.block-toolbar {
position: absolute;
diff --git a/index.html b/index.html
index aff6d4f..d89bdd7 100644
--- a/index.html
+++ b/index.html
@@ -444,6 +444,7 @@
</div>
<div class="col-lg-6 col-md-12 col-sm-12 block block3">
<div class="console"></div>
+ <div class="status"></div>
<div class="block-label" data-tkey="console">Console</div>
</div>
</div>
diff --git a/js/codeq/robot.js b/js/codeq/robot.js
index 0dca6f3..d4fcfcf 100644
--- a/js/codeq/robot.js
+++ b/js/codeq/robot.js
@@ -134,13 +134,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
var makeRobotTerminalHandler = function (jqConsole, editor, problem_id, activityHandler) {
var terminal = codeq.makeConsole(jqConsole, {
- 'greeting': 'CodeQ Robot terminal proxy',
- 'autoHistory': true
+ 'greeting': 'Robot messages\n--------------\n\n',
});
-
- terminal.onInput = function (text) {
- terminal.append('Not implemented.\n', 'output');
- };
+ terminal.inputDisable();
return terminal;
};
@@ -151,7 +147,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
var createRobotHandler = function (problemDef, commonDef, currentSolution) {
var jqDescriptionContent = jqDescription.find('.description'),
jqEditor = jqCode.find('.code_editor'),
+ jqTerminal = jqConsole.find('.console'),
jqHints = jqInfo.find('.hints'),
+ jqStatus = jqConsole.find('.status'),
editor = codeq.makeEditor(jqEditor[0],
{
mode: 'python',
@@ -162,6 +160,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
jqBtnRun.focus();
}),
activityHandler = codeq.makeActivityHandler(editor, problemDef.id),
+ terminal = makeRobotTerminalHandler(jqTerminal, editor, problemDef.id, activityHandler),
hinter = codeq.makeHinter(jqHints, jqEditor, editor, 'robot_hints', problemDef, commonDef),
commError = function (error) {
alert(error);
@@ -173,6 +172,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
// set up the websocket events
socket.on('close', function (data) {
console.log('websocket closed, trying to reopen in 1 s');
+ jqStatus.html('Not connected.');
reconnectTimer = setTimeout(function () {
reconnectTimer = null;
socket.open();
@@ -188,7 +188,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
if (!sensors.hasOwnProperty(sensor)) continue;
text += sensor + ': ' + sensors[sensor] + '<br />\n'
}
- $('div.console').html('<p style="color: lightgreen; font-family: monospace;">'+text+'</p>');
+ jqStatus.html(text);
+ }
+ else if (json_obj.event == 'output') {
+ text = json_obj.text;
+ terminal.append(text, 'output');
}
});
@@ -246,10 +250,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */
var program = editor.getDoc().getValue();
activityHandler.queueTrace({'typ': 'robot_run', 'program': program});
socket.send(JSON.stringify({action: 'run', program: program}));
+ terminal.append('<run>\n', 'output');
});
jqBtnStop.on('click', function () {
activityHandler.queueTrace({'typ': 'robot_stop'});
socket.send(JSON.stringify({action: 'stop'}));
+ terminal.append('<stop>\n', 'output');
});
codeq.comms.loadProblem(problemDef.id).done();