[Time Conductor] Avoid exception

Avoid exception when trying to generate a single datum in
cases where there is no data yet available.
This commit is contained in:
Victor Woeltjen 2015-09-25 11:05:13 -07:00
parent cbaf45afe9
commit 2848a8458b

View File

@ -110,20 +110,23 @@ define(
* Get the latest telemetry datum for this domain object. This * Get the latest telemetry datum for this domain object. This
* will be from real-time telemetry, unless an index is specified, * will be from real-time telemetry, unless an index is specified,
* in which case it will be pulled from the historical telemetry * in which case it will be pulled from the historical telemetry
* series at the specified index. * series at the specified index. If there is no latest available
* datum, this will return undefined.
* *
* @param {DomainObject} domainObject the object of interest * @param {DomainObject} domainObject the object of interest
* @param {number} [index] the index of the data of interest * @param {number} [index] the index of the data of interest
* @returns {TelemetryDatum} the most recent datum * @returns {TelemetryDatum} the most recent datum
*/ */
self.getDatum = function (telemetryObject, index) { self.getDatum = function (telemetryObject, index) {
function makeNewDatum(series) {
return series ?
subscription.makeDatum(telemetryObject, series, index) :
undefined;
}
return typeof index !== 'number' ? return typeof index !== 'number' ?
subscription.getDatum(telemetryObject) : subscription.getDatum(telemetryObject) :
subscription.makeDatum( makeNewDatum(this.getSeries(telemetryObject));
telemetryObject,
this.getSeries(telemetryObject),
index
);
}; };
return self; return self;