function saveTrainingData() {
    // get latest samples for slottime from all channels
    console.log("trainvolts: " + trainvolts.length);
    let sendvolts = trainvolts.slice(-settings.slotsize);
    console.log("sendvolts: " + sendvolts.length);

    //save to file
    let values = sendvolts.map((v) => v.channelData);
    let record = JSON.stringify(values);
    fs.writeFile("data/mind/training-" + trainingCmd + ".json", record, reportTrainingsData(trainingCmd));
    // Save baseline
    if (!baseline) {
        if (trainvolts.length > 3 * settings.slotsize) {
            let baselinevolts = trainvolts.slice(-3 * settings.slotsize, -settings.slotsize);
            console.log("baseline: " + baselinevolts.length);
            //save to file
            let baselineValues = baselinevolts.map((v) => v.channelData);
            let baselineRecord = JSON.stringify(baselineValues);
            fs.writeFile("data/mind/training-baseline.json", baselineRecord, reportTrainingsData("baseline"));
            baseline = true;
        }
    }

}
/**
 * on trainingCmd save samples for past trainingtime to file
 *
 */
on trainingCmd save samples for past trainingtime to file
on trainingCmd save samples for past trainingtime to file
function saveTrainingData() {
    console.log("trainvolts: " + trainvolts.length);
    let sendvolts = trainvolts.slice(-settings.slotsize);
    console.log("sendvolts: " + sendvolts.length);
    let values = sendvolts.map((v) => v.channelData);
    let record = JSON.stringify(values);
    fs.writeFile("data/mind/training-" + trainingCmd + ".json", record, reportTrainingsData(trainingCmd));
    if (!baseline) {
        if (trainvolts.length > 3 * settings.slotsize) {
            let baselinevolts = trainvolts.slice(-3 * settings.slotsize, -settings.slotsize);
            console.log("baseline: " + baselinevolts.length);
            let baselineValues = baselinevolts.map((v) => v.channelData);
            let baselineRecord = JSON.stringify(baselineValues);
            fs.writeFile("data/mind/training-baseline.json", baselineRecord, reportTrainingsData("baseline"));
            baseline = true;
        }
    }
}
function saveTrainingData ( ) { console . log ( "trainvolts: " + trainvolts . length ) ; let sendvolts = trainvolts . slice ( - settings . slotsize ) ; console . log ( "sendvolts: " + sendvolts . length ) ; let values = sendvolts . map ( ( v ) => v . channelData ) ; let record = JSON . stringify ( values ) ; fs . writeFile ( "data/mind/training-" + trainingCmd + ".json" , record , reportTrainingsData ( trainingCmd ) ) ; if ( ! baseline ) { if ( trainvolts . length > 3 * settings . slotsize ) { let baselinevolts = trainvolts . slice ( - 3 * settings . slotsize , - settings . slotsize ) ; console . log ( "baseline: " + baselinevolts . length ) ; let baselineValues = baselinevolts . map ( ( v ) => v . channelData ) ; let baselineRecord = JSON . stringify ( baselineValues ) ; fs . writeFile ( "data/mind/training-baseline.json" , baselineRecord , reportTrainingsData ( "baseline" ) ) ; baseline = true ; } } }
on trainingCmd save samples for past trainingtime to file
on trainingCmd save samples for past trainingtime to file
// get latest samples for slottime from all channels //save to file // Save baseline //save to file