Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export default Vue.extend({
return
}
if (this.param?.rebootRequired) {
autopilot_data.setRebootRequired(false)
autopilot_data.setRebootRequired(true)
}
this.last_sent_value = value
mavlink2rest.setParam(this.param.name, value, autopilot_data.system_id, this.param.paramType.type)
Expand Down
27 changes: 16 additions & 11 deletions core/frontend/src/components/parameter-editor/ParameterLabel.vue
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
<template>
<div class="d-flex align-center">
<span>{{ label }}</span>
<span :class="{ 'text--disabled': !param }">{{ label }}</span>
<v-tooltip bottom>
<template #activator="{ on, attrs }">
<v-icon
small
class="ml-2"
:color="param ? undefined : 'warning'"
v-bind="attrs"
v-on="on"
>
mdi-information
{{ param ? 'mdi-information' : 'mdi-alert-circle-outline' }}
</v-icon>
</template>
<div>
<strong>{{ param?.name }}</strong><br>
<span v-if="param?.description">Description: {{ param.description }}<br></span>
<span v-if="param?.range">Range: {{ param.range.low }} to {{ param.range.high }}<br></span>
<span v-if="param?.units">Units: {{ param.units }}<br></span>
<span v-if="param?.options">Options: {{ formatOptions ?? formattedOptions }}<br></span>
<span v-if="param?.rebootRequired">Requires reboot</span>
<div v-if="param">
<strong>{{ param.name }}</strong><br>
<span v-if="param.description">Description: {{ param.description }}<br></span>
<span v-if="param.range">Range: {{ param.range.low }} to {{ param.range.high }}<br></span>
<span v-if="param.units">Units: {{ param.units }}<br></span>
<span v-if="param.options">Options: {{ formatOptions ?? formattedOptions }}<br></span>
<span v-if="param.rebootRequired">Requires reboot</span>
</div>
<div v-else>
Parameter not found. It may not be available on this vehicle or firmware version.
</div>
</v-tooltip>
</div>
Expand All @@ -37,8 +41,9 @@ export default Vue.extend({
required: true,
},
param: {
type: Object as PropType<Parameter>,
required: true,
type: Object as PropType<Parameter | undefined>,
default: undefined,
required: false,
},
formatOptions: {
type: String as PropType<string | null>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<template>
<v-card
v-if="all_required_params_are_available"
v-if="all_required_params_are_available || dependency_unmet"
elevation="2"
:class="{ 'disabled-failsafe': is_disabled }"
:class="{
'disabled-failsafe': is_disabled && !dependency_unmet,
'unavailable-failsafe': dependency_unmet,
}"
class="mb-4 mt-4 pa-4 d-flex flex-row flex-grow-0 justify-left failsafe-card"
>
<div class="ma-4">
Expand All @@ -15,7 +18,7 @@
<v-card-text>
{{ failsafeDefinition.generalDescription }}
</v-card-text>
<div>
<div v-if="!dependency_unmet">
<div v-for="param in available_params" :key="param.name">
<v-row class="justify-right">
<v-col :key="param.name" class="action-col" cols="7">
Expand All @@ -35,6 +38,15 @@
</v-row>
</div>
</div>
<v-alert
v-else
type="warning"
text
dense
class="mx-4 mb-2"
>
{{ dependency_message }}
</v-alert>
</div>
</v-card>
</template>
Expand Down Expand Up @@ -87,6 +99,22 @@ export default Vue.extend({
}
return this.params[controlParam.name].value === 0
},
dependency_unmet(): boolean {
const dep = this.failsafeDefinition.dependsOn
if (!dep) {
return false
}
// If the dependency parameter itself hasn't loaded yet, don't show a
// spurious notice; once params load, this re-evaluates to the truth.
const depParam = autopilot_data.parameters.find((p) => p.name === dep.paramName)
if (!depParam) {
return false
}
return depParam.value === dep.disabledValue
},
dependency_message(): string {
return this.failsafeDefinition.dependsOn?.message ?? ''
},
actionParamName(): string | undefined {
return this.findControlParam()?.name
},
Expand Down Expand Up @@ -135,18 +163,20 @@ i.svg-icon svg {
margin: auto;
}

.disabled-failsafe {
.disabled-failsafe,
.unavailable-failsafe {
border: 1px solid var(--v-warning-base) !important;
position: relative;
}

.disabled-failsafe:hover {
.disabled-failsafe:hover,
.unavailable-failsafe:hover {
border-color: var(--v-warning-lighten1) !important;
box-shadow: 0 2px 8px rgba(224, 166, 0, 0.2);
}

.disabled-failsafe::after {
content: 'DISABLED';
.disabled-failsafe::after,
.unavailable-failsafe::after {
position: absolute;
top: 8px;
right: 8px;
Expand All @@ -161,7 +191,16 @@ i.svg-icon svg {
pointer-events: none;
}

.disabled-failsafe .svg-icon {
.disabled-failsafe::after {
content: 'DISABLED';
}

.unavailable-failsafe::after {
content: 'UNAVAILABLE';
}

.disabled-failsafe .svg-icon,
.unavailable-failsafe .svg-icon {
opacity: 0.7;
filter: grayscale(30%);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ export default {
generalDescription: 'Triggers when the voltage goes below specified thresholds.\n This can help to avoid '
+ 'damage to the battery and potentially loss of the vehicle.',
image: (await import('@/assets/img/configuration/failsafes/battery.svg')).default as string,
dependsOn: {
paramName: 'BATT_MONITOR',
disabledValue: 0,
message: 'Battery monitoring is disabled (BATT_MONITOR = 0). '
+ 'Enable a battery monitor on the Power configuration page '
+ 'to use the low-battery failsafe.',
},
params: [
// TODO: add support for the MAH params and coloumb counting
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,16 @@ export interface ParamDefinitions {
icon?: string
}

export interface FailsafeDependency {
paramName: string,
disabledValue: number,
message: string,
}

export interface FailsafeDefinition {
name: string,
generalDescription: string,
params: ParamDefinitions[],
image: string,
dependsOn?: FailsafeDependency,
}
Loading
Loading