Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani committed Dec 13, 2024
1 parent 38ef42f commit c4a8f32
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/libs/actions/data-lake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
6 changes: 6 additions & 0 deletions src/libs/vehicle/ardupilot/ardupilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ export abstract class ArduPilotVehicle<Modes> extends Vehicle.AbstractVehicle<Mo
return
}

const messageName = mavlink_message.message.type
Object.entries(mavlink_message.message).forEach(([key, value]) => {
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() })

Expand Down

0 comments on commit c4a8f32

Please sign in to comment.