From 2c3ff8a6d9ee7b570bd8372a7ba0138350d14c32 Mon Sep 17 00:00:00 2001 From: David Tsay Date: Wed, 24 Jan 2024 20:14:16 -0800 Subject: [PATCH 1/8] temporarily enable source maps --- .webpack/webpack.prod.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.webpack/webpack.prod.js b/.webpack/webpack.prod.js index 46bc12dd..b736257b 100644 --- a/.webpack/webpack.prod.js +++ b/.webpack/webpack.prod.js @@ -26,6 +26,6 @@ import common from './webpack.common.js'; /** @type {import('webpack').Configuration} */ const prodConfig = { mode: 'production', - devtool: 'source-map' + devtool: 'eval-source-map' } export default merge(common, prodConfig); From cf3e6ca8963e16f809e5f41bdcc7bb6797b56e2d Mon Sep 17 00:00:00 2001 From: David Tsay Date: Thu, 25 Jan 2024 14:52:30 -0800 Subject: [PATCH 2/8] pass in cacheStrategy to objectProvider --- src/providers/object-provider.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/providers/object-provider.js b/src/providers/object-provider.js index de499d49..9da16ce2 100644 --- a/src/providers/object-provider.js +++ b/src/providers/object-provider.js @@ -39,7 +39,7 @@ const YAMCS_API_MAP = { const operatorStatusParameter = new OperatorStatusParameter(); export default class YamcsObjectProvider { - constructor(openmct, url, instance, folderName, roleStatusTelemetry, pollQuestionParameter, pollQuestionTelemetry, realtimeTelemetryProvider, processor = 'realtime') { + constructor(openmct, url, instance, folderName, roleStatusTelemetry, pollQuestionParameter, pollQuestionTelemetry, realtimeTelemetryProvider, processor = 'realtime', cacheStrategy = {}) { this.openmct = openmct; this.url = url; this.instance = instance; @@ -55,6 +55,8 @@ export default class YamcsObjectProvider { this.roleStatusTelemetry = roleStatusTelemetry; this.pollQuestionParameter = pollQuestionParameter; this.pollQuestionTelemetry = pollQuestionTelemetry; + this.options = {}; + this.cacheStrategy = cacheStrategy; this.#initialize(); } @@ -193,8 +195,13 @@ export default class YamcsObjectProvider { const operation = 'parameters?details=yes&limit=1000'; const parameterUrl = this.url + 'api/mdb/' + this.instance + '/' + operation; const url = this.#getMdbUrl('space-systems'); - const spaceSystems = await accumulateResults(url, {}, 'spaceSystems', []); - const parameters = await accumulateResults(parameterUrl, {}, 'parameters', []); + + if (this.cacheStrategy) { + this.options = { ...this.options, ...this.cacheStrategy }; + } + + const spaceSystems = await accumulateResults(url, this.options, 'spaceSystems', []); + const parameters = await accumulateResults(parameterUrl, this.options, 'parameters', []); /* Sort the space systems by name, so that the children of the root object are in sorted order. */ From 34eb1f7685d2b6206a1d3b3a2935eef274d184a4 Mon Sep 17 00:00:00 2001 From: David Tsay Date: Thu, 25 Jan 2024 14:53:05 -0800 Subject: [PATCH 3/8] remove unused parameters --- src/providers/object-provider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/object-provider.js b/src/providers/object-provider.js index 9da16ce2..977ad270 100644 --- a/src/providers/object-provider.js +++ b/src/providers/object-provider.js @@ -182,7 +182,7 @@ export default class YamcsObjectProvider { #getTelemetryDictionary() { if (!this.dictionaryPromise) { - this.dictionaryPromise = this.#loadTelemetryDictionary(this.url, this.instance, this.folderName) + this.dictionaryPromise = this.#loadTelemetryDictionary() .finally(() => { this.roleStatusTelemetry.dictionaryLoadComplete(); }); From 9d6f16960716c294f023e6a8a4f3d661068bdc46 Mon Sep 17 00:00:00 2001 From: David Tsay Date: Thu, 25 Jan 2024 16:41:01 -0800 Subject: [PATCH 4/8] change cache strategy to be dynamic --- src/openmct-yamcs.js | 8 ++++++-- src/providers/object-provider.js | 14 +++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/openmct-yamcs.js b/src/openmct-yamcs.js index d0503eb0..45b4f912 100644 --- a/src/openmct-yamcs.js +++ b/src/openmct-yamcs.js @@ -38,7 +38,10 @@ import PollQuestionParameter from './providers/user/poll-question-parameter.js'; import PollQuestionTelemetry from './providers/user/poll-question-telemetry.js'; import ExportToCSVActionPlugin from './actions/exportToCSV/plugin.js'; -export default function install(configuration) { +export default function install( + configuration, + dictionaryRequestCacheStrategyPromise +){ return (openmct) => { openmct.install(openmct.plugins.ISOTimeFormat()); @@ -126,7 +129,8 @@ export default function install(configuration) { pollQuestionParameter, pollQuestionTelemetry, realtimeTelemetryProvider, - configuration.yamcsProcessor + configuration.yamcsProcessor, + dictionaryRequestCacheStrategyPromise ); openmct.objects.addRoot({ diff --git a/src/providers/object-provider.js b/src/providers/object-provider.js index 977ad270..81891a49 100644 --- a/src/providers/object-provider.js +++ b/src/providers/object-provider.js @@ -39,7 +39,7 @@ const YAMCS_API_MAP = { const operatorStatusParameter = new OperatorStatusParameter(); export default class YamcsObjectProvider { - constructor(openmct, url, instance, folderName, roleStatusTelemetry, pollQuestionParameter, pollQuestionTelemetry, realtimeTelemetryProvider, processor = 'realtime', cacheStrategy = {}) { + constructor(openmct, url, instance, folderName, roleStatusTelemetry, pollQuestionParameter, pollQuestionTelemetry, realtimeTelemetryProvider, processor = 'realtime', dictionaryRequestCacheStrategyPromise = Promise.resolve({})) { this.openmct = openmct; this.url = url; this.instance = instance; @@ -52,11 +52,10 @@ export default class YamcsObjectProvider { this.dictionary = {}; this.limitOverrides = {}; this.dictionaryPromise = null; + this.dictionaryRequestCacheStrategyPromise = dictionaryRequestCacheStrategyPromise; this.roleStatusTelemetry = roleStatusTelemetry; this.pollQuestionParameter = pollQuestionParameter; this.pollQuestionTelemetry = pollQuestionTelemetry; - this.options = {}; - this.cacheStrategy = cacheStrategy; this.#initialize(); } @@ -195,13 +194,10 @@ export default class YamcsObjectProvider { const operation = 'parameters?details=yes&limit=1000'; const parameterUrl = this.url + 'api/mdb/' + this.instance + '/' + operation; const url = this.#getMdbUrl('space-systems'); + const requestOptions = await this.dictionaryRequestCacheStrategyPromise; - if (this.cacheStrategy) { - this.options = { ...this.options, ...this.cacheStrategy }; - } - - const spaceSystems = await accumulateResults(url, this.options, 'spaceSystems', []); - const parameters = await accumulateResults(parameterUrl, this.options, 'parameters', []); + const spaceSystems = await accumulateResults(url, requestOptions, 'spaceSystems', []); + const parameters = await accumulateResults(parameterUrl, requestOptions, 'parameters', []); /* Sort the space systems by name, so that the children of the root object are in sorted order. */ From 71e0530f94ac57ecbe116f69539ea701b15fad73 Mon Sep 17 00:00:00 2001 From: David Tsay Date: Fri, 26 Jan 2024 12:10:05 -0800 Subject: [PATCH 5/8] disable eval-source-map in prod --- .webpack/webpack.prod.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.webpack/webpack.prod.js b/.webpack/webpack.prod.js index b736257b..46bc12dd 100644 --- a/.webpack/webpack.prod.js +++ b/.webpack/webpack.prod.js @@ -26,6 +26,6 @@ import common from './webpack.common.js'; /** @type {import('webpack').Configuration} */ const prodConfig = { mode: 'production', - devtool: 'eval-source-map' + devtool: 'source-map' } export default merge(common, prodConfig); From 0a0ee405847f3145fa76df019a53562cd6dab377 Mon Sep 17 00:00:00 2001 From: David Tsay Date: Fri, 26 Jan 2024 14:15:27 -0800 Subject: [PATCH 6/8] lint fix --- src/openmct-yamcs.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/openmct-yamcs.js b/src/openmct-yamcs.js index 45b4f912..9ddcd5df 100644 --- a/src/openmct-yamcs.js +++ b/src/openmct-yamcs.js @@ -41,7 +41,7 @@ import ExportToCSVActionPlugin from './actions/exportToCSV/plugin.js'; export default function install( configuration, dictionaryRequestCacheStrategyPromise -){ +) { return (openmct) => { openmct.install(openmct.plugins.ISOTimeFormat()); From 7b678c6c62ec4df33cfd5f9e33f50368da482a72 Mon Sep 17 00:00:00 2001 From: David Tsay Date: Fri, 26 Jan 2024 15:22:53 -0800 Subject: [PATCH 7/8] fix lint error --- src/providers/limit-provider.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/limit-provider.js b/src/providers/limit-provider.js index 54722ed6..e864c188 100644 --- a/src/providers/limit-provider.js +++ b/src/providers/limit-provider.js @@ -100,7 +100,7 @@ export default class LimitProvider { const limits = domainObject.configuration.limits; return { - limits: async () => limits + limits: () => Promise.resolve(limits) }; } From 8d8ffb69eab7f3eafbe848af476c06aa4ea6ed60 Mon Sep 17 00:00:00 2001 From: David Tsay Date: Mon, 29 Jan 2024 14:46:38 -0800 Subject: [PATCH 8/8] add README section explaining new feature --- README.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/README.md b/README.md index 7f7c315a..4c0e07f7 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,24 @@ openmct.install(installYamcsPlugin({ | yamcsInstance | The name of the instance configured in YAMCS that you wish to connect to. | myproject | | yamcsFolder | The name of the instance configured in YAMCS that you wish to connect to. | myproject | +## dictionaryRequestCacheStrategyPromise +installYamcsPlugin also accepts an optional promise argument `dictionaryRequestCacheStrategyPromise`. This strategy is passed to the request for loading the YAMCS dictionary, or the `#loadTelemetryDictionary` function in `object-provider.js`. An example of how to make use of this is below. +``` +let cacheStrategy; +const cacheStrategyPromise = new Promise(resolve => cacheStrategy) + +openmct.install(installYamcsPlugin( + configuration, + cacheStrategryPromise +)) + +if (DICTIONARY_VERSION_IS_NEW) { // some check to determine dictionary version + cacheStrategy({cache: 'reload'}) +} else { + cacheStrategy({}) +} +``` + ## Special XTCE features If you are using an XTCE configuration in Yamcs, there are two special