From 56808f51cced08bd7f84f90f261934c8666ab1be Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Wed, 21 Feb 2024 14:28:25 -0300 Subject: [PATCH] sensors-logging: Allow changing the interval between log points --- src/libs/sensors-logging.ts | 30 +++++++++++++++++++++++++++-- src/views/ConfigurationLogsView.vue | 29 ++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/libs/sensors-logging.ts b/src/libs/sensors-logging.ts index 559f76c19..576dc5946 100644 --- a/src/libs/sensors-logging.ts +++ b/src/libs/sensors-logging.ts @@ -74,12 +74,12 @@ class DataLogger { currentCockpitLog: CockpitStandardLog = [] variablesBeingUsed: DatalogVariable[] = [] selectedVariablesToShow = useStorage('cockpit-datalogger-overlay-variables', []) + logInterval = useStorage('cockpit-datalogger-log-interval', 1000) /** * Start an intervaled logging - * @param {number} interval - The time to wait between two logs */ - startLogging(interval = 1000): void { + startLogging(): void { if (this.logging()) { Swal.fire({ title: 'Error', text: 'A log is already being generated.', icon: 'error', timer: 3000 }) return @@ -158,6 +158,32 @@ class DataLogger { return this.shouldBeLogging } + /** + * Set the interval between log points + * @param {number} interval The interval in milliseconds. Default is 1000 and minimum is 1 + */ + setInterval(interval: number): void { + if (interval < 1) { + Swal.fire({ text: 'Minimum log interval is 1 millisecond (1000 Hz).', icon: 'error' }) + return + } + + this.logInterval.value = interval + } + + /** + * Set the frequency of log points + * @param {number} frequency The frequency in hertz. Default is 1 Hz, minimum is 0.1 Hz and maximum is 1000 Hz + */ + setFrequency(frequency: number): void { + if (frequency > 1000 || frequency < 0.1) { + Swal.fire({ text: 'Log frequency should stay between 0.1 Hz and 1000 Hz.', icon: 'error' }) + return + } + + this.setInterval(1000 / frequency) + } + /** * Update state of a given variable * @param {DatalogVariable} variable - Name of the variable being updated diff --git a/src/views/ConfigurationLogsView.vue b/src/views/ConfigurationLogsView.vue index 38955329a..6efbe183a 100644 --- a/src/views/ConfigurationLogsView.vue +++ b/src/views/ConfigurationLogsView.vue @@ -12,12 +12,41 @@ :value="variable" > +

Frequency of the telemetry log

+ + Values between 1 and 100Hz are more common and can be set with the slider. + + + You can go as low as 0.1 Hz and as far as 1000 Hz using the text input. + +
+ + + + +