Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gcs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"@mantine/hooks": "^7.17.3",
"@mantine/notifications": "^7.4.0",
"@mantine/spotlight": "^7.15.3",
"@mantine/tiptap": "^7.17.3",
"@mantine/tiptap": "^7.17.4",
"@reduxjs/toolkit": "^2.2.7",
"@robloche/chartjs-plugin-streaming": "^3.1.0",
"@tabler/icons-react": "^2.44.0",
Expand Down
21 changes: 0 additions & 21 deletions gcs/src/components/fla/graph.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,6 @@ export default function Graph({
]
const scales = {}

// Capture current scales if they exist
const currentScales = chartRef.current?.scales

if (yAxisIDs.length === 0) {
scales.y = {
grid: { color: tailwindColors.gray[500] },
Expand All @@ -309,27 +306,9 @@ export default function Graph({
text: yAxisID,
},
}
// Only add min/max if we have existing scales and they're not undefined
if (
data.datasets.length > 0 &&
currentScales[yAxisID]?.min !== undefined
) {
scales[yAxisID].min = currentScales[yAxisID].min
scales[yAxisID].max = currentScales[yAxisID].max
} else {
scales[yAxisID].min = undefined
scales[yAxisID].max = undefined
}
})

scales.x = { ...config.scales.x }
if (data.datasets.length > 0 && currentScales.x?.min !== undefined) {
scales.x.min = currentScales.x.min
scales.x.max = currentScales.x.max
} else {
scales.x.min = undefined
scales.x.max = undefined
}

setConfig({
...config,
Expand Down
21 changes: 18 additions & 3 deletions gcs/src/components/fla/presetCategories.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,26 @@ const dataflashPresetCategories = [
],
},
{
name: "Battery",
name: "Batteries",
filters: [
{
name: "Battery Voltage vs Current",
filters: { BAT: ["Volt", "Curr"] },
name: "Battery 1 Voltage vs Current",
filters: { BAT1: ["Volt", "Curr"] },
aircraftType: ["copter", "plane", "quadplane"],
},
{
name: "Battery 2 Voltage vs Current",
filters: { BAT2: ["Volt", "Curr"] },
aircraftType: ["copter", "plane", "quadplane"],
},
{
name: "Battery 3 Voltage vs Current",
filters: { BAT3: ["Volt", "Curr"] },
aircraftType: ["copter", "plane", "quadplane"],
},
{
name: "Battery 4 Voltage vs Current",
filters: { BAT4: ["Volt", "Curr"] },
aircraftType: ["copter", "plane", "quadplane"],
},
],
Expand Down
65 changes: 64 additions & 1 deletion gcs/src/fla.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,50 @@ export default function FLA() {
delete logMessageFilterDefaultState["ESC"]
}

if (loadedLogMessages["BAT"]) {
let tempLoadedLogMessages = { ...loadedLogMessages }
let tempMsgFormat = { ...loadedLogMessages["format"] }

// Load each BATT data into its own array
loadedLogMessages["BAT"].map((battData) => {
// Check for both "Inst" and "Instance" keys
const instanceValue = battData["Instance"] ?? battData["Inst"]
const battName = `BAT${(instanceValue ?? 0) + 1}`

// Initialize the array if it doesn't exist
if (!tempLoadedLogMessages[battName]) {
tempLoadedLogMessages[battName] = []
}

tempLoadedLogMessages[battName].push({
...battData,
name: battName,
})

// Add filter state for new BATT
if (!logMessageFilterDefaultState[battName])
logMessageFilterDefaultState[battName] = {
...logMessageFilterDefaultState["BAT"],
}

// Add format state for new BATT
if (!tempMsgFormat[battName])
tempMsgFormat[battName] = {
...tempMsgFormat["BAT"],
name: battName,
}

tempLoadedLogMessages["format"] = tempMsgFormat
})

// Remove old BATT motor data
delete tempLoadedLogMessages["BAT"]
delete tempLoadedLogMessages["format"]["BAT"]
delete logMessageFilterDefaultState["BAT"]
updateLogMessages(tempLoadedLogMessages)
updateFormatMessages(tempLoadedLogMessages["format"])
}

// Sort new filters
const sortedLogMessageFilterState = Object.keys(
logMessageFilterDefaultState,
Expand Down Expand Up @@ -817,11 +861,30 @@ export default function FLA() {
)}
{/* Default Presets */}
{presetCategories[logType]?.map((category) => {
// Filter out presets with unavailable keys or fields
const filteredCategory = {
...category,
filters: category.filters.filter((filter) =>
Object.keys(filter.filters).every((key) => {
// Check if the key exists in logMessages
if (!logMessages[key]) return false

// Check if the required fields exist in logMessages["format"][key].fields
const requiredFields = filter.filters[key]
const availableFields =
logMessages["format"]?.[key]?.fields || []
return requiredFields.every((field) =>
availableFields.includes(field),
)
}),
),
}

return (
<Fragment key={category.name}>
<PresetAccordionItem
key={category.name}
category={category}
category={filteredCategory}
selectPresetFunc={selectPreset}
aircraftType={aircraftType}
/>
Expand Down
13 changes: 12 additions & 1 deletion gcs/src/helpers/logMessageDescriptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@ const dataflashLogMessageDescriptions = {
AUXF: "Auxiliary function invocation information",
BARD: "Barometer dynamic data",
BARO: "Gathered Barometer data",
BAT: "Gathered battery data",
BAT1: "Gathered battery data for battery 1",
BAT2: "Gathered battery data for battery 2",
BAT3: "Gathered battery data for battery 3",
BAT4: "Gathered battery data for battery 4",
BAT5: "Gathered battery data for battery 5",
BAT6: "Gathered battery data for battery 6",
BAT7: "Gathered battery data for battery 7",
BAT8: "Gathered battery data for battery 8",
BAT9: "Gathered battery data for battery 9",
BAT10: "Gathered battery data for battery 10",
BAT11: "Gathered battery data for battery 11",
BAT12: "Gathered battery data for battery 12",
BCL: "Battery cell voltage information",
BCL2: "Battery cell voltage information",
BCN: "Beacon information",
Expand Down
Loading