Skip to content

Commit

Permalink
core: frontend: Add correct parameters values name
Browse files Browse the repository at this point in the history
* Change to use correct parameters values and units instead of just
  showing the raw enum value
  • Loading branch information
JoaoMario109 committed Mar 14, 2024
1 parent a74265a commit ed7603f
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 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 @@ -52,10 +52,10 @@
{{ item.name }}
</v-col>
<v-col class="virtual-table-cell">
{{ printParam(item.current_value) }}
{{ printParam(item.current) }} {{ item.current.units ? `[${item.current.units}]` : '' }}
</v-col>
<v-col class="virtual-table-cell">
{{ printParam(item.value) }}
{{ printParam(item.new) }} {{ item.current.units ? `[${item.current.units}]` : '' }}
</v-col>
</v-row>
</template>
Expand Down Expand Up @@ -115,6 +115,7 @@ import { Dictionary } from 'vue-router'
import mavlink2rest from '@/libs/MAVLink2Rest'
import autopilot_data from '@/store/autopilot'
import { printParam } from '@/types/autopilot/parameter'
export default Vue.extend({
name: 'ParameterLoader',
Expand Down Expand Up @@ -192,22 +193,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,13 +255,18 @@ 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 },
}
})
},
printParam,
},
})
</script>
Expand All @@ -297,7 +287,8 @@ button {
flex: 1;
padding: 5px;
height: 30px;
min-width: 100px;
min-width: 150px;
white-space: nowrap;
}
.virtual-table-cell .v-input {
margin-top: -6px;
Expand Down

0 comments on commit ed7603f

Please sign in to comment.