Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct parameters name in ParameterLoader #2458

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
87 changes: 60 additions & 27 deletions core/frontend/src/components/parameter-editor/ParameterLoader.vue
Expand Up @@ -34,7 +34,7 @@
</v-row>
<!-- display all parameters in a concise table using virtual scroller -->
<v-virtual-scroll
:items="printable(different_param_set)"
:items="parametersFromSet(different_param_set)"
height="300"
item-height="30"
class="virtual-table"
Expand All @@ -49,13 +49,46 @@
/>
</v-col>
<v-col class="virtual-table-cell name-cell">
{{ item.name }}
<v-tooltip bottom>
<template #activator="{ on }">
<div v-on="on">
{{ item.name }}
</div>
</template>
<span>
{{ item.current?.description ?? 'No description provided' }}
</span>
</v-tooltip>
</v-col>
<v-col class="virtual-table-cell">
{{ printParam(item.current_value) }}
<v-tooltip bottom>
<template #activator="{ on }">
<div
class="large-text-cell"
v-on="on"
>
{{ prettyNameFromParameter(item.current) }}
</div>
</template>
<span>
{{ prettyNameFromParameter(item.current) }}
</span>
</v-tooltip>
</v-col>
<v-col class="virtual-table-cell">
{{ printParam(item.value) }}
<v-tooltip bottom>
<template #activator="{ on }">
<div
class="large-text-cell"
v-on="on"
>
{{ prettyNameFromParameter(item.new) }}
</div>
</template>
<span>
{{ prettyNameFromParameter(item.new) }}
</span>
</v-tooltip>
</v-col>
</v-row>
</template>
Expand Down Expand Up @@ -115,6 +148,7 @@ import { Dictionary } from 'vue-router'

import mavlink2rest from '@/libs/MAVLink2Rest'
import autopilot_data from '@/store/autopilot'
import Parameter, { printParam } from '@/types/autopilot/parameter'

export default Vue.extend({
name: 'ParameterLoader',
Expand Down Expand Up @@ -192,22 +226,6 @@ export default Vue.extend({
this.$set(this.param_checkboxes, key, new_value)
}
},
printParam(value: number) {
try {
if (Math.abs(value) > 1e4) {
return value.toExponential(3)
}
if (Math.abs(value) < 0.01 && value !== 0) {
return value.toExponential(3)
}
return value.toFixed(2)
} catch {
return 'N/A'
}
},
printable(paramset: Dictionary<number>) {
return this.createPrintableParams(paramset)
},
writeParams() {
this.writing = true
this.initial_size = this.user_selected_params_length
Expand Down Expand Up @@ -270,12 +288,22 @@ export default Vue.extend({
this.$set(this.param_checkboxes, name, true)
}
},
createPrintableParams(paramset: Dictionary<number>) {
return Object.entries(paramset).map(([name, value]) => ({
name,
value,
current_value: autopilot_data.parameter(name)?.value,
}))
parametersFromSet(paramset: Dictionary<number>) {
return Object.entries(paramset).map(([name, value]) => {
const currentParameter = autopilot_data.parameter(name)

return {
name,
current: currentParameter,
new: { ...currentParameter, value },
}
})
},
prettyNameFromParameter(parameter: Parameter) {
const paramValueText = printParam(parameter)
const paramUnitsText = parameter?.units ? `[${parameter.units}]` : ''

return paramValueText + paramUnitsText
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return paramValueText + paramUnitsText
return paramValueText + ' ' + paramUnitsText

I don't remember the correct syntax, but the idea is to have something like "10 [A]" instead of "10[A]".

edit: it might be better to just prepend a space on the paramUnitsText, otherwise we would have a space appended to the strings that don't have units.

},
},
})
Expand All @@ -297,11 +325,16 @@ button {
flex: 1;
padding: 5px;
height: 30px;
min-width: 100px;
min-width: 150px;
}
.virtual-table-cell .v-input {
margin-top: -6px;
}
.virtual-table-cell .large-text-cell {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.checkbox-label label {
font-weight: 700;
Expand Down
Expand Up @@ -29,7 +29,7 @@
Parameters reset <b>successful</b>. <span v-if="!done"> Please reboot the vehicle to apply changes. </span>
</v-alert>
</v-card-text>
<parameterloader
<ParameterLoader
v-if="selected_paramset"
:parameters="selected_paramset"
@done="selected_paramset = {}"
Expand All @@ -55,7 +55,7 @@
No parameters available for this setup
</p>
</v-card-text>
<parameterloader
<ParameterLoader
v-if="selected_paramset"
:parameters="selected_paramset"
@done="selected_paramset = {}"
Expand All @@ -69,7 +69,7 @@ import { SemVer } from 'semver'
import Vue from 'vue'

import * as AutopilotManager from '@/components/autopilot/AutopilotManagerUpdater'
import parameterloader from '@/components/parameter-editor/ParameterLoader.vue'
import ParameterLoader from '@/components/parameter-editor/ParameterLoader.vue'
import mavlink2rest from '@/libs/MAVLink2Rest'
import { MavCmd } from '@/libs/MAVLink2Rest/mavlink2rest-ts/messages/mavlink2rest-enum'
import Notifier from '@/libs/notifier'
Expand All @@ -84,7 +84,7 @@ const REPOSITORY_URL = 'https://docs.bluerobotics.com/Blueos-Parameter-Repositor
export default Vue.extend({
name: 'ParamSets',
components: {
parameterloader,
ParameterLoader,
},
data: () => ({
all_param_sets: {} as Dictionary<Dictionary<number>>,
Expand Down