Compare commits
	
		
			14 Commits
		
	
	
		
			nav-after-
			...
			telemetry-
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | 1dbc064457 | ||
|   | ec13b0e493 | ||
|   | b38532044c | ||
|   | 9ce699e857 | ||
|   | 5774ad9023 | ||
|   | 6d8cbe863a | ||
|   | aa0357b9f1 | ||
|   | c34982ba9e | ||
|   | eb57f61aa3 | ||
|   | 9c25156c73 | ||
|   | 867b874525 | ||
|   | 9af46dbad6 | ||
|   | 67a545c121 | ||
|   | ee4f094d05 | 
| @@ -281,7 +281,7 @@ define([ | ||||
|      * (start, end, etc.), sort order, and strategies for retrieving | ||||
|      * telemetry (aggregation, latest available, etc.). | ||||
|      * | ||||
|      * @method requestTelemetryCollection | ||||
|      * @method requestCollection | ||||
|      * @memberof module:openmct.TelemetryAPI~TelemetryProvider# | ||||
|      * @param {module:openmct.DomainObject} domainObject the object | ||||
|      *        which has associated telemetry | ||||
| @@ -289,7 +289,7 @@ define([ | ||||
|      *        options for this telemetry collection request | ||||
|      * @returns {TelemetryCollection} a TelemetryCollection instance | ||||
|      */ | ||||
|     TelemetryAPI.prototype.requestTelemetryCollection = function (domainObject, options = {}) { | ||||
|     TelemetryAPI.prototype.requestCollection = function (domainObject, options = {}) { | ||||
|         return new TelemetryCollection( | ||||
|             this.openmct, | ||||
|             domainObject, | ||||
|   | ||||
| @@ -603,7 +603,7 @@ describe('Telemetry API', function () { | ||||
|         }); | ||||
|  | ||||
|         it('when requested, returns an instance of telemetry collection', () => { | ||||
|             const telemetryCollection = telemetryAPI.requestTelemetryCollection(domainObject); | ||||
|             const telemetryCollection = telemetryAPI.requestCollection(domainObject); | ||||
|  | ||||
|             expect(telemetryCollection).toBeInstanceOf(TelemetryCollection); | ||||
|         }); | ||||
|   | ||||
| @@ -23,6 +23,11 @@ | ||||
| import _ from 'lodash'; | ||||
| import EventEmitter from 'EventEmitter'; | ||||
|  | ||||
| const ERRORS = { | ||||
|     TIMESYSTEM_KEY: 'All telemetry metadata must have a telemetry value with a key that matches the key of the active time system.', | ||||
|     LOADED: 'Telemetry Collection has already been loaded.' | ||||
| }; | ||||
|  | ||||
| /** Class representing a Telemetry Collection. */ | ||||
|  | ||||
| export class TelemetryCollection extends EventEmitter { | ||||
| @@ -57,7 +62,7 @@ export class TelemetryCollection extends EventEmitter { | ||||
|      */ | ||||
|     load() { | ||||
|         if (this.loaded) { | ||||
|             throw new Error('Telemetry Collection has already been loaded.'); | ||||
|             this._error(ERRORS.LOADED); | ||||
|         } | ||||
|  | ||||
|         this._timeSystem(this.openmct.time.timeSystem()); | ||||
| @@ -123,13 +128,13 @@ export class TelemetryCollection extends EventEmitter { | ||||
|  | ||||
|         try { | ||||
|             this.requestAbort = new AbortController(); | ||||
|             this.options.abortSignal = this.requestAbort.signal; | ||||
|             this.options.signal = this.requestAbort.signal; | ||||
|             historicalData = await this.historicalProvider.request(this.domainObject, this.options); | ||||
|             this.requestAbort = undefined; | ||||
|         } catch (error) { | ||||
|             console.error('Error requesting telemetry data...'); | ||||
|             this.requestAbort = undefined; | ||||
|             throw new Error(error); | ||||
|             this._error(error); | ||||
|         } | ||||
|  | ||||
|         this._processNewTelemetry(historicalData); | ||||
| @@ -189,7 +194,7 @@ export class TelemetryCollection extends EventEmitter { | ||||
|                     if (endIndex > startIndex) { | ||||
|                         let potentialDupes = this.boundedTelemetry.slice(startIndex, endIndex); | ||||
|  | ||||
|                         isDuplicate = potentialDupes.some(_.isEqual(undefined, datum)); | ||||
|                         isDuplicate = potentialDupes.some(_.isEqual.bind(undefined, datum)); | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
| @@ -307,8 +312,16 @@ export class TelemetryCollection extends EventEmitter { | ||||
|      * @private | ||||
|      */ | ||||
|     _timeSystem(timeSystem) { | ||||
|         this.timeKey = timeSystem.key; | ||||
|         let metadataValue = this.metadata.value(this.timeKey) || { format: this.timeKey }; | ||||
|         let domains = this.metadata.valuesForHints(['domain']); | ||||
|         let domain = domains.find((d) => d.key === timeSystem.key); | ||||
|  | ||||
|         if (domain === undefined) { | ||||
|             this._error(ERRORS.TIMESYSTEM_KEY); | ||||
|         } | ||||
|  | ||||
|         // timeKey is used to create a dummy datum used for sorting | ||||
|         this.timeKey = domain.source; // this defaults to key if no source is set | ||||
|         let metadataValue = this.metadata.value(timeSystem.key) || { format: timeSystem.key }; | ||||
|         let valueFormatter = this.openmct.telemetry.getValueFormatter(metadataValue); | ||||
|  | ||||
|         this.parseTime = (datum) => { | ||||
| @@ -363,4 +376,13 @@ export class TelemetryCollection extends EventEmitter { | ||||
|     _unwatchTimeSystem() { | ||||
|         this.openmct.time.off('timeSystem', this._timeSystem, this); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * will throw a new Error, for passed in message | ||||
|      * @param  {string} message Message describing the error | ||||
|      * @private | ||||
|      */ | ||||
|     _error(message) { | ||||
|         throw new Error(message); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -149,7 +149,7 @@ define([ | ||||
|             this.removeTelemetryCollection(keyString); | ||||
|  | ||||
|             this.telemetryCollections[keyString] = this.openmct.telemetry | ||||
|                 .requestTelemetryCollection(telemetryObject, requestOptions); | ||||
|                 .requestCollection(telemetryObject, requestOptions); | ||||
|  | ||||
|             this.telemetryCollections[keyString].on('remove', telemetryRemover); | ||||
|             this.telemetryCollections[keyString].on('add', telemetryProcessor); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user