Skip to content

Commit

Permalink
Merge pull request #1786 from OpenC3/limits_widgets
Browse files Browse the repository at this point in the history
Nice error message for widget items without limits
  • Loading branch information
jmthomas authored Dec 20, 2024
2 parents 91f43eb + c368633 commit 3467e57
Show file tree
Hide file tree
Showing 9 changed files with 80 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</v-tooltip>
</div>
</v-toolbar>
<v-card-text>
<v-card-text style="max-height: 90vh">
<v-row class="mt-3"> Upload a screen file. </v-row>
<v-row no-gutters align="center">
<v-btn
Expand Down Expand Up @@ -88,10 +88,13 @@
</v-list>
</v-menu>
</v-row>
<v-row v-for="(error, index) in editErrors" :key="index" class="my-3">
<span class="text-red" v-text="error"></span>
<!-- Make the error messages a max height and scrollable -->
<v-row style="max-height: 120px; overflow-y: auto">
<div v-for="(error, index) in editErrors" :key="index">
<span class="text-red" v-text="error"></span>
</div>
</v-row>
<v-row>
<v-row class="mt-5">
<span
>Ctrl-space brings up autocomplete. Right click keywords for
documentation.</span
Expand Down Expand Up @@ -168,10 +171,8 @@ export default {
if (this.errors.length !== 0) {
let messages = new Set()
let result = []
this.errors.sort((a, b) => a.lineNumber - b.lineNumber)
for (const error of this.errors) {
if (messages.has(error.message)) {
continue
}
let msg = `At ${error.lineNumber}: (${error.line}) ${error.message}.`
if (error.usage) {
msg += ` Usage: ${error.usage}`
Expand Down Expand Up @@ -322,7 +323,7 @@ export default {
</style>
<style scoped>
.editor {
height: 50vh;
height: 45vh;
width: 75vw;
position: relative;
font-size: 16px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
/>

<!-- Error dialog -->
<v-dialog v-model="errorDialog" max-width="600">
<v-dialog v-model="errorDialog" width="60vw">
<v-toolbar height="24">
<v-spacer />
<span> Screen: {{ target }} {{ screen }} Errors </span>
Expand Down Expand Up @@ -778,5 +778,7 @@ export default {
}
.v-textarea :deep(textarea) {
padding: 5px;
-webkit-mask-image: unset;
mask-image: unset;
}
</style>
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ export default {
},
methods: {
modifyLimits(limitsSettings) {
if (!limitsSettings) {
return
}
// By default the red bars take 10% of the display
this.redLow = 10
this.redHigh = 10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
:settings="[...appliedSettings]"
:screen-values="screenValues"
:widget-index="2"
:line="line"
:lineNumber="lineNumber"
/>
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
:settings="[...appliedSettings]"
:screen-values="screenValues"
:widget-index="2"
:line="line"
:lineNumber="lineNumber"
/>
<value-widget
v-bind="$attrs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,34 @@ export default {
computed: {
limitsRange() {
let values = this.limitsSettings[this.selectedLimitsSet]
// Format like the DetailsDialog formatLimit function
if (values.length === 4) {
return `RL/${values[0]} YL/${values[1]} YH/${values[2]} RH/${values[3]}`
if (values) {
// Format like the DetailsDialog formatLimit function
if (values.length === 4) {
return `RL/${values[0]} YL/${values[1]} YH/${values[2]} RH/${values[3]}`
} else {
return `RL/${values[0]} YL/${values[1]} YH/${values[2]} RH/${values[3]} GL/${values[4]} GH/${values[5]}`
}
} else {
return `RL/${values[0]} YL/${values[1]} YH/${values[2]} RH/${values[3]} GL/${values[4]} GH/${values[5]}`
// See errorCaptured in Openc3Screen.vue for how this is parsed
throw {
line: this.line,
lineNumber: this.lineNumber,
keyword: 'LIMITSBAR',
parameters: this.parameters,
message: 'Item has no limits settings',
usage: 'Only items with limits',
}
}
},
},
created() {
this.verifyNumParams(
'LIMITSBAR',
3,
6,
'LIMITSBAR <TARGET> <PACKET> <ITEM> <TYPE> <WIDTH> <HEIGHT>',
)
},
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,42 @@ export default {
let limits = this.modifyLimits(
this.limitsSettings[this.selectedLimitsSet],
)
this.calcLimits(limits)
return {
'--height': this.height + 'px',
'--width': this.width + 'px',
'--container-width': this.width - 5 + 'px',
'--position': this.calcPosition(value, limits) + '%',
'--redlow-height': this.redLow + '%',
'--redhigh-height': this.redHigh + '%',
'--yellowlow-height': this.yellowLow + '%',
'--yellowhigh-height': this.yellowHigh + '%',
'--greenlow-height': this.greenLow + '%',
'--greenhigh-height': this.greenHigh + '%',
'--blue-height': this.blue + '%',
if (limits) {
this.calcLimits(limits)
return {
'--height': this.height + 'px',
'--width': this.width + 'px',
'--container-width': this.width - 5 + 'px',
'--position': this.calcPosition(value, limits) + '%',
'--redlow-height': this.redLow + '%',
'--redhigh-height': this.redHigh + '%',
'--yellowlow-height': this.yellowLow + '%',
'--yellowhigh-height': this.yellowHigh + '%',
'--greenlow-height': this.greenLow + '%',
'--greenhigh-height': this.greenHigh + '%',
'--blue-height': this.blue + '%',
}
} else {
// See errorCaptured in Openc3Screen.vue for how this is parsed
throw {
line: this.line,
lineNumber: this.lineNumber,
keyword: 'LIMITSCOLUMN',
parameters: this.parameters,
message: 'Item has no limits settings',
usage: 'Only items with limits',
}
}
},
},
created() {
this.verifyNumParams(
'LIMITSCOLUMN',
3,
6,
'LIMITSCOLUMN <TARGET> <PACKET> <ITEM> <TYPE> <WIDTH> <HEIGHT>',
)
},
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
:settings="[...appliedSettings]"
:screen-values="screenValues"
:widget-index="1"
:line="line"
:lineNumber="lineNumber"
/>
</div>
</template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
:settings="[...appliedSettings]"
:screen-values="screenValues"
:widget-index="1"
:line="line"
:lineNumber="lineNumber"
/>
<value-widget
v-bind="$attrs"
Expand Down

0 comments on commit 3467e57

Please sign in to comment.