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 diff --git a/src/openmct-yamcs.js b/src/openmct-yamcs.js index c3d94c0c..249d19e9 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()); @@ -129,7 +132,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 de499d49..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') { + constructor(openmct, url, instance, folderName, roleStatusTelemetry, pollQuestionParameter, pollQuestionTelemetry, realtimeTelemetryProvider, processor = 'realtime', dictionaryRequestCacheStrategyPromise = Promise.resolve({})) { this.openmct = openmct; this.url = url; this.instance = instance; @@ -52,6 +52,7 @@ export default class YamcsObjectProvider { this.dictionary = {}; this.limitOverrides = {}; this.dictionaryPromise = null; + this.dictionaryRequestCacheStrategyPromise = dictionaryRequestCacheStrategyPromise; this.roleStatusTelemetry = roleStatusTelemetry; this.pollQuestionParameter = pollQuestionParameter; this.pollQuestionTelemetry = pollQuestionTelemetry; @@ -180,7 +181,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(); }); @@ -193,8 +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 spaceSystems = await accumulateResults(url, {}, 'spaceSystems', []); - const parameters = await accumulateResults(parameterUrl, {}, 'parameters', []); + const requestOptions = await this.dictionaryRequestCacheStrategyPromise; + + 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. */