Skip to content

Commit 3653bb3

Browse files
authored
Merge pull request #720 from OpenC3/dead_tlm
Better handle screen tlm request timeouts
2 parents d63dd94 + 33edfa7 commit 3653bb3

File tree

2 files changed

+62
-21
lines changed

2 files changed

+62
-21
lines changed

openc3-cosmos-init/plugins/packages/openc3-tool-common/src/components/Openc3Screen.vue

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,18 @@
122122
</v-tooltip>
123123
</v-system-bar>
124124
<v-expand-transition v-if="!editDialog">
125-
<div class="pa-1" ref="screen" v-show="expand">
125+
<div
126+
class="pa-1"
127+
style="position: relative"
128+
ref="screen"
129+
v-show="expand"
130+
>
131+
<v-overlay
132+
style="pointer-events: none"
133+
:value="errors.length !== 0"
134+
opacity="0.8"
135+
absolute
136+
/>
126137
<vertical-widget
127138
:key="screenKey"
128139
:widgets="layoutStack[0].widgets"
@@ -151,13 +162,8 @@
151162
<span> Screen: {{ target }} {{ screen }} Errors </span>
152163
<v-spacer />
153164
</v-system-bar>
154-
<v-card class="pa-3">
155-
<v-row class="my-3">
156-
<v-textarea readonly rows="13" :value="error" />
157-
</v-row>
158-
<v-row>
159-
<v-btn block @click="clearErrors"> Clear </v-btn>
160-
</v-row>
165+
<v-card>
166+
<v-textarea class="errors" readonly rows="13" :value="error" />
161167
</v-card>
162168
</v-dialog>
163169
</div>
@@ -263,6 +269,7 @@ export default {
263269
editDialog: false,
264270
expand: true,
265271
configParser: null,
272+
configError: false,
266273
currentLayout: null,
267274
layoutStack: [],
268275
namedWidgets: {},
@@ -341,10 +348,11 @@ export default {
341348
} else {
342349
this.errors.push({
343350
type: 'error',
344-
message: `${err}`,
351+
message: err,
345352
time: new Date().getTime(),
346353
})
347354
}
355+
this.configError = true
348356
return false
349357
},
350358
created() {
@@ -380,6 +388,7 @@ export default {
380388
},
381389
clearErrors: function () {
382390
this.errors = []
391+
this.configError = false
383392
},
384393
updateRefreshInterval: function () {
385394
let refreshInterval = this.pollingPeriod * 1000
@@ -392,7 +401,7 @@ export default {
392401
},
393402
parseDefinition: function () {
394403
// Each time we start over and parse the screen definition
395-
this.errors = []
404+
this.clearErrors()
396405
this.namedWidgets = {}
397406
this.layoutStack = []
398407
this.dynamicWidgets = []
@@ -470,6 +479,7 @@ export default {
470479
lineNumber: lines.join(','),
471480
time: new Date().getTime(),
472481
})
482+
this.configError = true
473483
// Create a simple VerticalWidget to replace the bad widget so
474484
// the layout stack can successfully unwind
475485
this.layoutStack[0] = {
@@ -725,18 +735,31 @@ export default {
725735
})
726736
},
727737
update: function () {
728-
if (this.screenItems.length !== 0 && this.errors.length === 0) {
738+
if (this.screenItems.length !== 0 && this.configError === false) {
729739
this.api
730740
.get_tlm_values(this.screenItems, this.staleTime)
731741
.then((data) => {
742+
this.clearErrors()
732743
this.updateValues(data)
733744
})
734745
.catch((error) => {
735-
this.errors.push({
736-
type: 'usage',
737-
message: error.message,
738-
time: new Date().getTime(),
739-
})
746+
let message = JSON.stringify(error, null, 2)
747+
// Anything other than 'no response received' which means the API server is down
748+
// is an error the user needs to fix so don't request values until they do
749+
if (!message.includes('no response received')) {
750+
this.configError = true
751+
}
752+
if (
753+
!this.errors.find((existing) => {
754+
existing.message === message
755+
})
756+
) {
757+
this.errors.push({
758+
type: 'error',
759+
message: message,
760+
time: new Date().getTime(),
761+
})
762+
}
740763
})
741764
}
742765
},
@@ -760,6 +783,10 @@ export default {
760783
</script>
761784

762785
<style scoped>
786+
.errors {
787+
padding-top: 0px;
788+
margin-top: 0px;
789+
}
763790
.v-card {
764791
background-color: var(--v-tertiary-darken2);
765792
}

openc3-cosmos-init/plugins/packages/openc3-tool-common/src/services/openc3-api.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ export class OpenC3Api {
2727

2828
constructor() {}
2929

30-
async exec(method, params, kwparams = {}, headerOptions = {}) {
30+
async exec(
31+
method,
32+
params,
33+
kwparams = {},
34+
headerOptions = {},
35+
timeout = 60000
36+
) {
3137
try {
3238
let refreshed = await OpenC3Auth.updateToken(
3339
OpenC3Auth.defaultMinValidity
@@ -56,6 +62,7 @@ export class OpenC3Api {
5662
'Content-Type': 'application/json-rpc',
5763
...headerOptions,
5864
},
65+
timeout: timeout,
5966
}
6067
)
6168
// var data = response.data
@@ -79,12 +86,13 @@ export class OpenC3Api {
7986
// is an instance of XMLHttpRequest in the browser and an instance
8087
// of http.ClientRequest in Node.js
8188
err.name = 'Request error'
89+
// NOTE: Openc3Screen.vue uses this specific message to determine
90+
// if the CmdTlmApi server is down. Don't change unless also changing there.
8291
err.message = 'Request error, no response received'
8392
} else {
8493
// Something happened in setting up the request and triggered an Error
8594
err.name = 'Unknown error'
8695
}
87-
// console.log(error)
8896
throw err
8997
}
9098
}
@@ -305,9 +313,15 @@ export class OpenC3Api {
305313
}
306314

307315
async get_tlm_values(items, stale_time = 30) {
308-
const data = await this.exec('get_tlm_values', [items], {
309-
stale_time: stale_time,
310-
})
316+
const data = await this.exec(
317+
'get_tlm_values',
318+
[items],
319+
{
320+
stale_time: stale_time,
321+
},
322+
{},
323+
10000 // 10s timeout ... should never be this long
324+
)
311325
var len = data[0].length
312326
var converted = null
313327
for (var i = 0; i < len; i++) {

0 commit comments

Comments
 (0)