Commit c55e7090 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

Stop running script interactively

The script is now run as a SlapOS service and not manually.
parent 50afd61b
...@@ -4,16 +4,11 @@ ...@@ -4,16 +4,11 @@
*/ */
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */ /*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
/*global console, me*/ /*global me*/
(function (console, me) { (function (me) {
"use strict"; "use strict";
me.onStart = function () {
me.f = me.fdopen(me.in, "r");
console.log("Use q to quit");
};
me.onUpdate = function (timestamp) { me.onUpdate = function (timestamp) {
var drone_dict = {}; var drone_dict = {};
Object.entries(me.getDroneDict()).forEach(function ([id, drone]) { Object.entries(me.getDroneDict()).forEach(function ([id, drone]) {
...@@ -24,7 +19,8 @@ ...@@ -24,7 +19,8 @@
yaw: drone.yaw.toFixed(2), yaw: drone.yaw.toFixed(2),
speed: drone.speed.toFixed(2), speed: drone.speed.toFixed(2),
climbRate: drone.climbRate.toFixed(2), climbRate: drone.climbRate.toFixed(2),
timestamp: drone.timestamp timestamp: drone.timestamp,
log: drone.log
}; };
}); });
me.writeWebsocketMessage(JSON.stringify({drone_dict: drone_dict})); me.writeWebsocketMessage(JSON.stringify({drone_dict: drone_dict}));
...@@ -42,8 +38,7 @@ ...@@ -42,8 +38,7 @@
me.sendMsg(JSON.stringify({status: "stopped"})); me.sendMsg(JSON.stringify({status: "stopped"}));
break; break;
case "switch": case "switch":
leader_id = leader_id == 0 ? 1 : 0; me.sendMsg(JSON.stringify({status: "switch"}));
me.sendMsg(JSON.stringify({leader_id: leader_id, status: "switch"}));
break; break;
default: default:
me.writeWebsocketMessage("Unknown instruction " + msg); me.writeWebsocketMessage("Unknown instruction " + msg);
...@@ -53,4 +48,4 @@ ...@@ -53,4 +48,4 @@
me.onGetMsg = function (msg) { me.onGetMsg = function (msg) {
me.writeWebsocketMessage(msg); me.writeWebsocketMessage(msg);
}; };
}(console, me)); }(me));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment