diff --git a/src/libs/actions/data-lake.ts b/src/libs/actions/data-lake.ts index b0f7edad7..d48600e8a 100644 --- a/src/libs/actions/data-lake.ts +++ b/src/libs/actions/data-lake.ts @@ -53,18 +53,28 @@ export const getCockpitActionVariableData = (id: string): string | number | bool return cockpitActionVariableData[id] } -export const setCockpitActionVariableData = (id: string, data: string | number | boolean): void => { +export const setCockpitActionVariableData = (id: string, data: object | string | number | boolean): void => { // console.log(`Setting cockpit action variable ${id} to ${data}`) + let newData = data + if (data === null) { + return + } if (cockpitActionVariableData[id] === undefined) { - console.warn(`Cockpit action variable with id '${id}' does not exist. Creating it.`) + //console.warn(`Cockpit action variable with id '${id}' does not exist. Creating it.`) const type_of_variable = typeof(data) - if (type_of_variable !== 'string' && type_of_variable !== 'number' ) { - console.warn(`attempting to create a variable with type ${type_of_variable}. Skipping`) + if (type_of_variable === 'object') { + // TODO: support strings + } + if (type_of_variable !== 'string' && type_of_variable !== 'number' ) { + //console.warn(`attempting to create a variable with type ${type_of_variable}. Skipping`) return } createCockpitActionVariable(new CockpitActionVariable(id, id, typeof(data))) } - cockpitActionVariableData[id] = data + if (newData === undefined) { + return + } + cockpitActionVariableData[id] = newData notifyCockpitActionVariableListeners(id) } diff --git a/src/libs/vehicle/ardupilot/ardupilot.ts b/src/libs/vehicle/ardupilot/ardupilot.ts index 3c08660dd..ff462eae1 100644 --- a/src/libs/vehicle/ardupilot/ardupilot.ts +++ b/src/libs/vehicle/ardupilot/ardupilot.ts @@ -300,6 +300,12 @@ export abstract class ArduPilotVehicle extends Vehicle.AbstractVehicle { + const fullPath = `${messageName}/${key}` + setCockpitActionVariableData(fullPath, value) + }) + // Update our internal messages this._messages.set(mavlink_message.message.type, { ...mavlink_message.message, epoch: new Date().getTime() })