mirror of
https://github.com/nasa/openmct.git
synced 2025-01-18 10:46:42 +00:00
* Fixes #1938 Fixed usage of Telemetry API, use hints to get valueMetadata, use valueMetadata to get formatter * dont circumvent chooseTelemetryKeyToDisplay, which was causing a regression when imagery is added to fp * fix broken tests * pass valueMetaData to limitEvaluator.evaluate, rename #chooseTelemetryKeyToDisplay to getValueMetadata, to reflect what is returned. update tests * change getValueMetadata to chooseValueMetadataToDisplay
This commit is contained in:
parent
5103207a70
commit
39a7f43cd0
@ -373,10 +373,10 @@ define(
|
|||||||
*/
|
*/
|
||||||
FixedController.prototype.updateView = function (telemetryObject, datum) {
|
FixedController.prototype.updateView = function (telemetryObject, datum) {
|
||||||
var metadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
var metadata = this.openmct.telemetry.getMetadata(telemetryObject);
|
||||||
var telemetryKeyToDisplay = this.chooseTelemetryKeyToDisplay(metadata);
|
var valueMetadata = this.chooseValueMetadataToDisplay(metadata);
|
||||||
var formattedTelemetryValue = this.getFormattedTelemetryValueForKey(telemetryKeyToDisplay, datum, metadata);
|
var formattedTelemetryValue = this.getFormattedTelemetryValueForKey(valueMetadata, datum);
|
||||||
var limitEvaluator = this.openmct.telemetry.limitEvaluator(telemetryObject);
|
var limitEvaluator = this.openmct.telemetry.limitEvaluator(telemetryObject);
|
||||||
var alarm = limitEvaluator && limitEvaluator.evaluate(datum, telemetryKeyToDisplay);
|
var alarm = limitEvaluator && limitEvaluator.evaluate(datum, valueMetadata);
|
||||||
|
|
||||||
this.setDisplayedValue(
|
this.setDisplayedValue(
|
||||||
telemetryObject,
|
telemetryObject,
|
||||||
@ -389,29 +389,28 @@ define(
|
|||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
FixedController.prototype.getFormattedTelemetryValueForKey = function (telemetryKeyToDisplay, datum, metadata) {
|
FixedController.prototype.getFormattedTelemetryValueForKey = function (valueMetadata, datum) {
|
||||||
var valueMetadata = metadata.value(telemetryKeyToDisplay);
|
|
||||||
var formatter = this.openmct.telemetry.getValueFormatter(valueMetadata);
|
var formatter = this.openmct.telemetry.getValueFormatter(valueMetadata);
|
||||||
|
|
||||||
return formatter.format(datum[valueMetadata.key]);
|
return formatter.format(datum);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
FixedController.prototype.chooseTelemetryKeyToDisplay = function (metadata) {
|
FixedController.prototype.chooseValueMetadataToDisplay = function (metadata) {
|
||||||
// If there is a range value, show that preferentially
|
// If there is a range value, show that preferentially
|
||||||
var telemetryKeyToDisplay = metadata.valuesForHints(['range'])[0];
|
var valueMetadata = metadata.valuesForHints(['range'])[0];
|
||||||
|
|
||||||
// If no range is defined, default to the highest priority non time-domain data.
|
// If no range is defined, default to the highest priority non time-domain data.
|
||||||
if (telemetryKeyToDisplay === undefined) {
|
if (valueMetadata === undefined) {
|
||||||
var valuesOrderedByPriority = metadata.values();
|
var valuesOrderedByPriority = metadata.values();
|
||||||
telemetryKeyToDisplay = valuesOrderedByPriority.filter(function (valueMetadata) {
|
valueMetadata = valuesOrderedByPriority.filter(function (values) {
|
||||||
return !(valueMetadata.hints.domain);
|
return !(values.hints.domain);
|
||||||
})[0];
|
})[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return telemetryKeyToDisplay.source;
|
return valueMetadata;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,8 +106,8 @@ define(
|
|||||||
'telemetryFormatter',
|
'telemetryFormatter',
|
||||||
['format']
|
['format']
|
||||||
);
|
);
|
||||||
mockFormatter.format.andCallFake(function (value) {
|
mockFormatter.format.andCallFake(function (valueMetadata) {
|
||||||
return "Formatted " + value;
|
return "Formatted " + valueMetadata.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
mockDomainObject = jasmine.createSpyObj(
|
mockDomainObject = jasmine.createSpyObj(
|
||||||
@ -697,7 +697,7 @@ define(
|
|||||||
source: 'range'
|
source: 'range'
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
var key = controller.chooseTelemetryKeyToDisplay(mockMetadata);
|
var key = controller.chooseValueMetadataToDisplay(mockMetadata).source;
|
||||||
expect(key).toEqual('range');
|
expect(key).toEqual('range');
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -719,7 +719,7 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
var key = controller.chooseTelemetryKeyToDisplay(mockMetadata);
|
var key = controller.chooseValueMetadataToDisplay(mockMetadata).source;
|
||||||
expect(key).toEqual('image');
|
expect(key).toEqual('image');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user