From efc8515a31603c9aeb8273fd9471b0ac57a0fe98 Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Tue, 9 Sep 2025 15:06:01 +0200 Subject: [PATCH 1/4] blueos: Start moving data-lake variable definitions to its own place --- src/libs/blueos/definitions.ts | 21 +++++++++++++++++++++ src/stores/mainVehicle.ts | 12 +----------- 2 files changed, 22 insertions(+), 11 deletions(-) create mode 100644 src/libs/blueos/definitions.ts diff --git a/src/libs/blueos/definitions.ts b/src/libs/blueos/definitions.ts new file mode 100644 index 0000000000..6288ca7fd1 --- /dev/null +++ b/src/libs/blueos/definitions.ts @@ -0,0 +1,21 @@ +// Register BlueOS variables in the data lake +export const blueOsVariables = { + cpuTemp: { + id: 'blueos/cpu/tempC', + name: 'BlueOS CPU Temperature', + type: 'number', + description: 'The average temperature of the BlueOS CPU cores in °C.', + }, + cpuUsageAverage: { + id: 'blueos/cpu/usageAverage', + name: 'BlueOS CPU Usage', + type: 'number', + description: 'The average usage of the BlueOS CPU cores in %.', + }, + cpuFrequencyAverage: { + id: 'blueos/cpu/frequencyAverage', + name: 'BlueOS CPU Frequency', + type: 'number', + description: 'The average frequency of the BlueOS CPU cores in Hz.', + }, +} diff --git a/src/stores/mainVehicle.ts b/src/stores/mainVehicle.ts index 765f98779c..d6ba72e84e 100644 --- a/src/stores/mainVehicle.ts +++ b/src/stores/mainVehicle.ts @@ -19,6 +19,7 @@ import { getVehicleName, setKeyDataOnCockpitVehicleStorage, } from '@/libs/blueos' +import { blueOsVariables } from '@/libs/blueos/definitions' import * as Connection from '@/libs/connection/connection' import { ConnectionManager } from '@/libs/connection/connection-manager' import type { Package } from '@/libs/connection/m2r/messages/mavlink2rest' @@ -587,17 +588,6 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => { updateVehicleId() - // Register BlueOS variables in the data lake - const blueOsVariables = { - cpuTemp: { id: 'blueos/cpu/tempC', name: 'CPU Temperature', type: 'number' }, - cpuUsageAverage: { id: 'blueos/cpu/usageAverage', name: 'BlueOS CPU Usage (average)', type: 'number' }, - cpuFrequencyAverage: { - id: 'blueos/cpu/frequencyAverage', - name: 'BlueOS CPU Frequency (average)', - type: 'number', - }, - } - const cpuUsageVariableId = (cpuName: string): string => `blueos/${cpuName}/usage` const cpuFrequencyVariableId = (cpuName: string): string => `blueos/${cpuName}/frequency` From b3ce45e098d441ecec28868ae956ee14e4653368 Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Tue, 9 Sep 2025 15:48:43 +0200 Subject: [PATCH 2/4] blueos: Add alerts for CPU usage and temperature --- src/stores/vehicleAlerter.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/stores/vehicleAlerter.ts b/src/stores/vehicleAlerter.ts index cd3f5c030b..1c73edcb72 100644 --- a/src/stores/vehicleAlerter.ts +++ b/src/stores/vehicleAlerter.ts @@ -1,6 +1,9 @@ import { defineStore } from 'pinia' import { watch } from 'vue' +import { useBlueOsStorage } from '@/composables/settingsSyncer' +import { listenDataLakeVariable } from '@/libs/actions/data-lake' +import { blueOsVariables } from '@/libs/blueos/definitions' import { useAlertStore } from '@/stores/alert' import { useMainVehicleStore } from '@/stores/mainVehicle' import { Alert, AlertLevel } from '@/types/alert' @@ -35,4 +38,34 @@ export const useVehicleAlerterStore = defineStore('vehicle-alerter', () => { alertStore.pushAlert(new Alert(alertLevel, `Vehicle ${alertMessage}`)) } ) + + // BlueOS alerts + const blueOsAlertsConfig = useBlueOsStorage('cockpit-blueos-alerts-config', { + 'cpu-temperature': { enabled: true, minInterval: 60000, threshold: 85, level: AlertLevel.Warning }, + 'cpu-usage': { enabled: true, minInterval: 60000, threshold: 80, level: AlertLevel.Warning }, + }) + + // BlueOS CPU Temperature Alert + let lastBlueOsCpuTemperatureAlertTimestamp = 0 + listenDataLakeVariable(blueOsVariables.cpuTemp.id, (data) => { + const tempConfig = blueOsAlertsConfig.value['cpu-temperature'] + const thresholdExceeded = Number(data) > tempConfig.threshold + const minIntervalReached = Date.now() - lastBlueOsCpuTemperatureAlertTimestamp >= tempConfig.minInterval + if (tempConfig.enabled && thresholdExceeded && minIntervalReached) { + alertStore.pushAlert(new Alert(tempConfig.level, `BlueOS CPU Temperature threshold exceeded: ${data} °C`)) + lastBlueOsCpuTemperatureAlertTimestamp = Date.now() + } + }) + + // BlueOS CPU Usage Alert + let lastBlueOsCpuUsageAlertTimestamp = 0 + listenDataLakeVariable(blueOsVariables.cpuUsageAverage.id, (data) => { + const usageConfig = blueOsAlertsConfig.value['cpu-usage'] + const thresholdExceeded = Number(data) > usageConfig.threshold + const minIntervalReached = Date.now() - lastBlueOsCpuUsageAlertTimestamp >= usageConfig.minInterval + if (usageConfig.enabled && thresholdExceeded && minIntervalReached) { + alertStore.pushAlert(new Alert(usageConfig.level, `BlueOS CPU Usage threshold exceeded: ${data} %`)) + lastBlueOsCpuUsageAlertTimestamp = Date.now() + } + }) }) From b20f8e9c2701f8b574ce7c0ef8b31608a061d35f Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Tue, 9 Sep 2025 16:33:33 +0200 Subject: [PATCH 3/4] alerts: Allow customization of BlueOS-related alerts --- .../configuration/BlueOSAlertsConfig.vue | 140 ++++++++++++++++++ src/stores/vehicleAlerter.ts | 4 + src/views/ConfigurationAlertsView.vue | 3 + 3 files changed, 147 insertions(+) create mode 100644 src/components/configuration/BlueOSAlertsConfig.vue diff --git a/src/components/configuration/BlueOSAlertsConfig.vue b/src/components/configuration/BlueOSAlertsConfig.vue new file mode 100644 index 0000000000..54ee2b0693 --- /dev/null +++ b/src/components/configuration/BlueOSAlertsConfig.vue @@ -0,0 +1,140 @@ + + + diff --git a/src/stores/vehicleAlerter.ts b/src/stores/vehicleAlerter.ts index 1c73edcb72..90fc66e7f9 100644 --- a/src/stores/vehicleAlerter.ts +++ b/src/stores/vehicleAlerter.ts @@ -68,4 +68,8 @@ export const useVehicleAlerterStore = defineStore('vehicle-alerter', () => { lastBlueOsCpuUsageAlertTimestamp = Date.now() } }) + + return { + blueOsAlertsConfig, + } }) diff --git a/src/views/ConfigurationAlertsView.vue b/src/views/ConfigurationAlertsView.vue index 497c80cbeb..b7e387d641 100644 --- a/src/views/ConfigurationAlertsView.vue +++ b/src/views/ConfigurationAlertsView.vue @@ -6,6 +6,8 @@ class="flex flex-col justify-around align-start ml-5 max-h-[85vh] overflow-y-auto" :class="interfaceStore.isOnSmallScreen ? 'max-w-[70vw]' : 'max-w-[40vw]'" > + +