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

software/js-drone: call onStart with a timestamp

The function `onStart`, first function called when running the user script, has
now a timestamp provided to indicate when was the script started.
parent 03c4206c
...@@ -34,7 +34,7 @@ md5sum = 9418396fc75e820b9dd5e913855aafe2 ...@@ -34,7 +34,7 @@ md5sum = 9418396fc75e820b9dd5e913855aafe2
[main] [main]
_update_hash_filename_ = drone-scripts/main.js.jinja2 _update_hash_filename_ = drone-scripts/main.js.jinja2
md5sum = 4d13e382ba6462e19b67aa67207324dc md5sum = af7f13928f5b6ada0ea5c841325b86f2
[pubsub] [pubsub]
_update_hash_filename_ = drone-scripts/pubsub.js.jinja2 _update_hash_filename_ = drone-scripts/pubsub.js.jinja2
...@@ -46,4 +46,4 @@ md5sum = c3858b5ec7373a0932fcda911a8177b5 ...@@ -46,4 +46,4 @@ md5sum = c3858b5ec7373a0932fcda911a8177b5
[worker] [worker]
_update_hash_filename_ = drone-scripts/worker.js.jinja2 _update_hash_filename_ = drone-scripts/worker.js.jinja2
md5sum = 4624b7a0a71c6abe6086b0c628074498 md5sum = 4d6639424300a5f165730de6e267543a
...@@ -177,6 +177,7 @@ import { err, exit, open, out } from "std"; ...@@ -177,6 +177,7 @@ import { err, exit, open, out } from "std";
operator_path: operator_script, operator_path: operator_script,
map_path: map_json, map_path: map_json,
{% endif -%} {% endif -%}
timestamp: Date.now(),
user_path: user_script user_path: user_script
}); });
} }
......
...@@ -203,7 +203,7 @@ import { evalScript, fdopen, loadFile, open } from "std"; ...@@ -203,7 +203,7 @@ import { evalScript, fdopen, loadFile, open } from "std";
return script_content; return script_content;
} }
function loadUserScript(path) { function loadUserScript(path, timestamp) {
var script_content = getFileContent(path); var script_content = getFileContent(path);
try { try {
evalScript( evalScript(
...@@ -221,7 +221,7 @@ import { evalScript, fdopen, loadFile, open } from "std"; ...@@ -221,7 +221,7 @@ import { evalScript, fdopen, loadFile, open } from "std";
// Call the drone onStart function // Call the drone onStart function
if (user_me.hasOwnProperty("onStart")) { if (user_me.hasOwnProperty("onStart")) {
user_me.onStart(); user_me.onStart(timestamp);
} }
} }
...@@ -261,7 +261,7 @@ import { evalScript, fdopen, loadFile, open } from "std"; ...@@ -261,7 +261,7 @@ import { evalScript, fdopen, loadFile, open } from "std";
break; break;
case "load": case "load":
loadUserScript(evt.data.user_path); loadUserScript(evt.data.user_path, evt.data.timestamp);
if (evt.data.hasOwnProperty("operator_path") && evt.data.hasOwnProperty("map_path")) { if (evt.data.hasOwnProperty("operator_path") && evt.data.hasOwnProperty("map_path")) {
loadOperatorScript(evt.data.operator_path, evt.data.map_path); loadOperatorScript(evt.data.operator_path, evt.data.map_path);
} }
......
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