0.33: Ensure that a new file is always created if the stuff that's being recorded has changed (fix #3081)
parent
6789ced709
commit
dd96e33774
|
|
@ -38,4 +38,5 @@
|
||||||
0.30: Add clock info for showing and toggling recording state
|
0.30: Add clock info for showing and toggling recording state
|
||||||
0.31: Ensure that background-drawn tracks can get cancelled, and draw less at a time to make updates smoother
|
0.31: Ensure that background-drawn tracks can get cancelled, and draw less at a time to make updates smoother
|
||||||
plotTrack now draws the current track even if you're not actively recording
|
plotTrack now draws the current track even if you're not actively recording
|
||||||
0.32: Add cadence data to output files
|
0.32: Add cadence data to output files
|
||||||
|
0.33: Ensure that a new file is always created if the stuff that's being recorded has changed (fix #3081)
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "recorder",
|
"id": "recorder",
|
||||||
"name": "Recorder",
|
"name": "Recorder",
|
||||||
"shortName": "Recorder",
|
"shortName": "Recorder",
|
||||||
"version": "0.32",
|
"version": "0.33",
|
||||||
"description": "Record GPS position, heart rate and more in the background, then download to your PC.",
|
"description": "Record GPS position, heart rate and more in the background, then download to your PC.",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"tags": "tool,outdoors,gps,widget,clkinfo",
|
"tags": "tool,outdoors,gps,widget,clkinfo",
|
||||||
|
|
|
||||||
|
|
@ -159,6 +159,21 @@
|
||||||
return recorders;
|
return recorders;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let getActiveRecorders = function() {
|
||||||
|
let activeRecorders = [];
|
||||||
|
let recorders = getRecorders();
|
||||||
|
settings.record.forEach(r => {
|
||||||
|
var recorder = recorders[r];
|
||||||
|
if (!recorder) {
|
||||||
|
console.log(/*LANG*/"Recorder for "+E.toJS(r)+/*LANG*/"+not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
activeRecorders.push(recorder());
|
||||||
|
});
|
||||||
|
return activeRecorders;
|
||||||
|
};
|
||||||
|
let getCSVHeaders = activeRecorders => ["Time"].concat(activeRecorders.map(r=>r.fields));
|
||||||
|
|
||||||
let writeLog = function() {
|
let writeLog = function() {
|
||||||
entriesWritten++;
|
entriesWritten++;
|
||||||
WIDGETS["recorder"].draw();
|
WIDGETS["recorder"].draw();
|
||||||
|
|
@ -189,17 +204,9 @@
|
||||||
|
|
||||||
if (settings.recording) {
|
if (settings.recording) {
|
||||||
// set up recorders
|
// set up recorders
|
||||||
var recorders = getRecorders(); // TODO: order??
|
activeRecorders = getActiveRecorders();
|
||||||
settings.record.forEach(r => {
|
activeRecorders.forEach(activeRecorder => {
|
||||||
var recorder = recorders[r];
|
|
||||||
if (!recorder) {
|
|
||||||
console.log(/*LANG*/"Recorder for "+E.toJS(r)+/*LANG*/"+not found");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var activeRecorder = recorder();
|
|
||||||
activeRecorder.start();
|
activeRecorder.start();
|
||||||
activeRecorders.push(activeRecorder);
|
|
||||||
// TODO: write field names?
|
|
||||||
});
|
});
|
||||||
WIDGETS["recorder"].width = 15 + ((activeRecorders.length+1)>>1)*12; // 12px per recorder
|
WIDGETS["recorder"].width = 15 + ((activeRecorders.length+1)>>1)*12; // 12px per recorder
|
||||||
// open/create file
|
// open/create file
|
||||||
|
|
@ -209,9 +216,7 @@
|
||||||
} else {
|
} else {
|
||||||
storageFile = require("Storage").open(settings.file,"w");
|
storageFile = require("Storage").open(settings.file,"w");
|
||||||
// New file - write headers
|
// New file - write headers
|
||||||
var fields = ["Time"];
|
storageFile.write(getCSVHeaders(activeRecorders).join(",")+"\n");
|
||||||
activeRecorders.forEach(recorder => fields.push.apply(fields,recorder.fields));
|
|
||||||
storageFile.write(fields.join(",")+"\n");
|
|
||||||
}
|
}
|
||||||
// start recording...
|
// start recording...
|
||||||
WIDGETS["recorder"].draw();
|
WIDGETS["recorder"].draw();
|
||||||
|
|
@ -246,7 +251,8 @@
|
||||||
// if no filename set or date different, set up a new filename
|
// if no filename set or date different, set up a new filename
|
||||||
settings.file = getTrackFilename();
|
settings.file = getTrackFilename();
|
||||||
}
|
}
|
||||||
if (require("Storage").list(settings.file).length){ // if file exists
|
var headers = require("Storage").open(settings.file,"r").readLine();
|
||||||
|
if (headers && headers.trim()==getCSVHeaders(getActiveRecorders()).join(",")){ // if file exists AND the headers match (#3081)
|
||||||
if (!options.force) { // if not forced, ask the question
|
if (!options.force) { // if not forced, ask the question
|
||||||
g.reset(); // work around bug in 2v17 and earlier where bg color wasn't reset
|
g.reset(); // work around bug in 2v17 and earlier where bg color wasn't reset
|
||||||
return E.showPrompt(
|
return E.showPrompt(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue