At the moment the data logging and charting is handled by using a print() statement to print sensor log values to the the display window using statements of the form print('Light_left: ' + str(colorLeft.reflected_light_intensity)).
These values are then used to update:
the live data log chart display (if it is enabled) via outf() in templates/studio.js;
the Ev3DevWidget.results_log in ev3devsim_nb.py; this object is itself updated via the report_callback() function defined via Ev3DevWidget.read() and called from within the outf() function in templates/studio.js.
It might be more convenient to define a Skulpt function that we can use to log sensors rather more formally and naturally. For example, in something like a Skulpt src/lib/simlogger.js. Does the following provide a start? (I'm not sure how best to define either the py interface, or the Javascript function that handles it.)
function datalog (channel, obj) {
//obj.$jsstr()
//???
}
var $builtinmodule = function(name)
{
var mod = {};
mod.datalog = new Sk.builtin.func(function(channel, obj){
datalog(channel, obj);
return new Sk.builtin.none;
})
return mod;
}
//from simlogger import datalog
//Maybe something like:
//datalog("left_light", colorLeft.reflected_light_intensity)
At the moment the data logging and charting is handled by using a
print()
statement to print sensor log values to the the display window using statements of the formprint('Light_left: ' + str(colorLeft.reflected_light_intensity))
.These values are then used to update:
outf()
intemplates/studio.js
;Ev3DevWidget.results_log
inev3devsim_nb.py
; this object is itself updated via thereport_callback()
function defined viaEv3DevWidget.read()
and called from within theoutf()
function intemplates/studio.js
.It might be more convenient to define a Skulpt function that we can use to log sensors rather more formally and naturally. For example, in something like a Skulpt
src/lib/simlogger.js
. Does the following provide a start? (I'm not sure how best to define either the py interface, or the Javascript function that handles it.)