Skip to content

Commit 27cd6cf

Browse files
mavlink: Allow user to decide on creating data-lake variables for non-main components
1 parent edf8b03 commit 27cd6cf

3 files changed

Lines changed: 48 additions & 5 deletions

File tree

src/libs/vehicle/mavlink/vehicle.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ export abstract class MAVLinkVehicle<Modes> extends Vehicle.AbstractVehicle<Mode
9494
onOutgoingMAVLinkMessage = new SignalTyped()
9595
_flying = false
9696

97+
shouldCreateDatalakeVariablesFromOtherSystems = false
98+
9799
protected currentSystemId = 1
98100

99101
/**
@@ -313,15 +315,20 @@ export abstract class MAVLinkVehicle<Modes> extends Vehicle.AbstractVehicle<Mode
313315
return
314316
}
315317

316-
// Inject variables from the MAVLink messages into the DataLake
317-
this.addPackageVariablesToDataLake(mavlink_message)
318-
319318
const { system_id, component_id } = mavlink_message.header
320319

321320
if (system_id !== this.currentSystemId || component_id !== 1) {
321+
// For non-main systems, only inject variables from the MAVLink messages into the DataLake if the user wants to
322+
if (this.shouldCreateDatalakeVariablesFromOtherSystems) {
323+
this.addPackageVariablesToDataLake(mavlink_message)
324+
}
325+
322326
return
323327
}
324328

329+
// For the main vehicle, always inject variables from the MAVLink messages into the DataLake
330+
this.addPackageVariablesToDataLake(mavlink_message)
331+
325332
// Update our internal messages
326333
this._messages.set(mavlink_message.message.type, { ...mavlink_message.message, epoch: new Date().getTime() })
327334

src/stores/mainVehicle.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
161161
defaultMessageIntervalsOptions
162162
)
163163

164+
// Store setting to enable/disable creation of datalake variables from other MAVLink systems
165+
const enableDatalakeVariablesFromOtherSystems = useBlueOsStorage(
166+
'cockpit-enable-datalake-variables-from-other-systems',
167+
false
168+
)
169+
164170
const MAVLink2RestWebsocketURI = computed(() => {
165171
const queryURI = new URLSearchParams(window.location.search).get('MAVLink2RestWebsocketURI')
166172
const customURI = customMAVLink2RestWebsocketURI.value.enabled
@@ -193,6 +199,11 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
193199
currentlyConnectedVehicleId.value = undefined
194200
})
195201

202+
watch(enableDatalakeVariablesFromOtherSystems, (newValue) => {
203+
if (!mainVehicle.value) return
204+
mainVehicle.value.shouldCreateDatalakeVariablesFromOtherSystems = newValue
205+
})
206+
196207
watch(
197208
globalAddress,
198209
(newAddress) => {
@@ -497,6 +508,9 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
497508
icon.value = mainVehicle.value.icon()
498509
configurationPages.value = mainVehicle.value.configurationPages()
499510

511+
// Set callback to check if datalake variables from other systems should be created
512+
mainVehicle.value.shouldCreateDatalakeVariablesFromOtherSystems = enableDatalakeVariablesFromOtherSystems.value
513+
500514
mainVehicle.value.onAltitude.add((newAltitude: Altitude) => {
501515
Object.assign(altitude, newAltitude)
502516
})
@@ -932,5 +946,6 @@ export const useMainVehicleStore = defineStore('main-vehicle', () => {
932946
setHomeWaypoint,
933947
vehiclePayloadParameters,
934948
vehiclePositionMaxSampleRate,
949+
enableDatalakeVariablesFromOtherSystems,
935950
}
936951
})

src/views/ConfigurationMAVLinkView.vue

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,29 @@
22
<BaseConfigurationView>
33
<template #title>MAVLink configuration</template>
44
<template #content>
5-
<div class="max-h-[85vh] w-[710px] overflow-y-auto">
6-
<ExpansiblePanel no-top-divider no-bottom-divider :is-expanded="!interfaceStore.isOnPhoneScreen">
5+
<div class="max-h-[80vh] w-[710px] overflow-y-auto">
6+
<ExpansiblePanel no-top-divider :is-expanded="!interfaceStore.isOnPhoneScreen">
7+
<template #title>DataLake variables creation</template>
8+
<template #info>
9+
<p class="max-w-[500px]">
10+
Enable the creation of DataLake variables from MAVLink messages originating from systems/components other
11+
than the main vehicle (System ID {{ mainVehicleStore.mainVehicle?.systemId }}, Component ID 1). When
12+
enabled, variables from all MAVLink systems on the network will be available in the DataLake. When
13+
disabled, only variables from the main vehicle will be created.
14+
</p>
15+
</template>
16+
<template #content>
17+
<div class="flex w-full px-2 mb-3">
18+
<v-switch
19+
v-model="mainVehicleStore.enableDatalakeVariablesFromOtherSystems"
20+
color="white"
21+
label="Enable DataLake variables from other systems"
22+
hide-details
23+
/>
24+
</div>
25+
</template>
26+
</ExpansiblePanel>
27+
<ExpansiblePanel no-bottom-divider :is-expanded="!interfaceStore.isOnPhoneScreen">
728
<template #title>Message intervals</template>
829
<template #info>
930
<p class="max-w-[500px]">

0 commit comments

Comments
 (0)