From e79c2ee0cb22bbdca9edc01e0cd31964cd43d8bd Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Sat, 18 Nov 2023 11:30:10 -0300 Subject: [PATCH] wip --- src/stores/mainVehicle.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/stores/mainVehicle.ts b/src/stores/mainVehicle.ts index 77061f8b7..575d28f69 100644 --- a/src/stores/mainVehicle.ts +++ b/src/stores/mainVehicle.ts @@ -1,4 +1,5 @@ import { useStorage, useTimestamp } from '@vueuse/core' +import { differenceInSeconds } from 'date-fns' import { defineStore } from 'pinia' import { computed, onBeforeUnmount, reactive, ref, watch } from 'vue' @@ -452,6 +453,24 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => { setInterval(() => updateMavlinkButtonsPrettyNames(), 1000) + // Generate datalog + const loggedVariables = { + 'roll': 'ATTITUDE.roll', + 'pitch': 'ATTITUDE.pitch', + 'heading': 'ATTITUDE.yaw', + 'altitude': 'AHRS2.altitude', + } + const initialTime = new Date() + // eslint-disable-next-line jsdoc/require-jsdoc + const dataLog = {} + // const dataLog: { [epoch: number]; seconds: number; data: Record } = {} + setInterval(() => { + const secondsNow = differenceInSeconds(new Date(), initialTime) + dataLog[secondsNow] = {} + Object.entries(loggedVariables).forEach((entry) => (dataLog[secondsNow][entry[0]] = genericVariables[entry[1]])) + console.log(dataLog) + }, 1000) + return { arm, disarm,