05-18-2020 03:56 PM
Hello!
I want to log some datapoints to file while riding. Accessing these values should not make any troubles to me. But writing these to file.. I really don't know how to get started with "local storage".
I'm not an Java or HTML developer, I only have some basic knowlage. So I'm dependent on help.
I want to take the grid Example and would like to write every 5 seconds Speed and User Power to a new line, separated with tabulator.
for now the filename could be hardcodet, but do I have to specify a path? or how does the SDK know where to write the file?
Thanks in advance
Dennis
05-20-2020 09:47 AM
Hello dkeipp,
Thank you for posting your question.
If we understand it correctly, your goal is to persist some data (the speed and the user power). Unfortunately, it is not possible to write directly to a file using HTML5 technologies. Your options would be the following:
The easiest solution to get started probably is #1. As you probably now, localStorage is a piece of memory in your browser, in which the stored data is saved across browser sessions.
You would probably implement something as follows:
function SaveDataToLocalStorage(currentSpeed, currentUserPower)
{
var speedValues = [];
var userPowerValues = []:
// Parse the serialized data back into an aray of objects
speedValues = JSON.parse(localStorage.getItem('speedData')) || [];
userPowerValues = JSON.parse(localStorage.getItem('userPowerData')) || [];
// Push the new data (whether it be an object or anything else) onto the array
speedValues.push(currentSpeed);
userPowerData.push(currentUserPower);
// Re-serialize the array back into a string and store it in localStorage
localStorage.setItem('speedData', JSON.stringify(speedValues));
localStorage.setItem('userPowerData', JSON.stringify(userPowerValues));
}
05-20-2020 03:12 PM
Thanks for this snippet! I think it will help me.
I'm not sure the script is running in the background (Not tested anything yet). So if I switch for example to navigation my module will not be executed anymore.. is that correct? if so, can I do anything that my module (the datalogger) will be executed in the background?
07-02-2020 11:15 AM
Hello,
In the current version of the SDK, the experiences are fully modular. This means that once you leave the module there is no more data being transmitted to your script in the background.
11-10-2020 03:25 PM
Dear dkeipp,
Thanks in advance, and hope you'll answer me because I'm really stuck...
Can ESER.