mirror of
https://github.com/nasa/openmct.git
synced 2025-01-18 02:39:56 +00:00
Merge pull request #288 from nasa/open218
[Plot] Support domain/range switching
This commit is contained in:
commit
4de7b7dfb5
@ -62,7 +62,7 @@ define(
|
||||
// so it's not checked for here, just formatted for display
|
||||
// differently.
|
||||
return (i + offset) * 1000 + firstTime * 1000 -
|
||||
(domain === 'yesterday' ? ONE_DAY : 0);
|
||||
(domain === 'yesterday' ? (ONE_DAY * 1000) : 0);
|
||||
};
|
||||
|
||||
generatorData.getRangeValue = function (i, range) {
|
||||
|
@ -78,6 +78,8 @@ define(
|
||||
cachedObjects = [],
|
||||
updater,
|
||||
lastBounds,
|
||||
lastRange,
|
||||
lastDomain,
|
||||
handle;
|
||||
|
||||
// Populate the scope with axis information (specifically, options
|
||||
@ -120,16 +122,16 @@ define(
|
||||
// Reinstantiate the plot updater (e.g. because we have a
|
||||
// new subscription.) This will clear the plot.
|
||||
function recreateUpdater() {
|
||||
updater = new PlotUpdater(
|
||||
handle,
|
||||
($scope.axes[0].active || {}).key,
|
||||
($scope.axes[1].active || {}).key,
|
||||
PLOT_FIXED_DURATION
|
||||
);
|
||||
self.limitTracker = new PlotLimitTracker(
|
||||
handle,
|
||||
($scope.axes[1].active || {}).key
|
||||
);
|
||||
var domain = $scope.axes[0].active.key,
|
||||
range = $scope.axes[1].active.key,
|
||||
duration = PLOT_FIXED_DURATION;
|
||||
|
||||
updater = new PlotUpdater(handle, domain, range, duration);
|
||||
lastDomain = domain;
|
||||
lastRange = range;
|
||||
|
||||
self.limitTracker = new PlotLimitTracker(handle, range);
|
||||
|
||||
// Keep any externally-provided bounds
|
||||
if (lastBounds) {
|
||||
setBasePanZoom(lastBounds);
|
||||
@ -201,22 +203,39 @@ define(
|
||||
}
|
||||
}
|
||||
|
||||
function requery() {
|
||||
self.pending = true;
|
||||
releaseSubscription();
|
||||
subscribe($scope.domainObject);
|
||||
}
|
||||
|
||||
function updateDomainFormat() {
|
||||
var domainAxis = $scope.axes[0];
|
||||
plotTelemetryFormatter
|
||||
.setDomainFormat(domainAxis.active.format);
|
||||
}
|
||||
|
||||
function domainRequery(newDomain) {
|
||||
if (newDomain !== lastDomain) {
|
||||
updateDomainFormat();
|
||||
requery();
|
||||
}
|
||||
}
|
||||
|
||||
function rangeRequery(newRange) {
|
||||
if (newRange !== lastRange) {
|
||||
requery();
|
||||
}
|
||||
}
|
||||
|
||||
// Respond to a display bounds change (requery for data)
|
||||
function changeDisplayBounds(event, bounds) {
|
||||
var domainAxis = $scope.axes[0];
|
||||
|
||||
domainAxis.chooseOption(bounds.domain);
|
||||
plotTelemetryFormatter
|
||||
.setDomainFormat(domainAxis.active.format);
|
||||
|
||||
self.pending = true;
|
||||
releaseSubscription();
|
||||
subscribe($scope.domainObject);
|
||||
updateDomainFormat();
|
||||
setBasePanZoom(bounds);
|
||||
}
|
||||
|
||||
function updateDomainFormat(format) {
|
||||
plotTelemetryFormatter.setDomainFormat(format);
|
||||
requery();
|
||||
}
|
||||
|
||||
this.modeOptions = new PlotModeOptions([], subPlotFactory);
|
||||
@ -237,6 +256,10 @@ define(
|
||||
new PlotAxis("ranges", [], AXIS_DEFAULTS[1])
|
||||
];
|
||||
|
||||
// Watch for changes to the selected axis
|
||||
$scope.$watch("axes[0].active.key", domainRequery);
|
||||
$scope.$watch("axes[1].active.key", rangeRequery);
|
||||
|
||||
// Subscribe to telemetry when a domain object becomes available
|
||||
$scope.$watch('domainObject', subscribe);
|
||||
|
||||
|
@ -53,6 +53,14 @@ define(
|
||||
});
|
||||
}
|
||||
|
||||
function fireWatch(expr, value) {
|
||||
mockScope.$watch.calls.forEach(function (call) {
|
||||
if (call.args[0] === expr) {
|
||||
call.args[1].apply(null, [value]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
beforeEach(function () {
|
||||
mockScope = jasmine.createSpyObj(
|
||||
@ -263,6 +271,20 @@ define(
|
||||
]);
|
||||
expect(mockHandle.request.calls.length).toEqual(2);
|
||||
});
|
||||
|
||||
it("requeries when user changes domain selection", function () {
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
expect(mockHandle.request.calls.length).toEqual(1);
|
||||
fireWatch("axes[0].active.key", 'someNewKey');
|
||||
expect(mockHandle.request.calls.length).toEqual(2);
|
||||
});
|
||||
|
||||
it("requeries when user changes range selection", function () {
|
||||
mockScope.$watch.mostRecentCall.args[1](mockDomainObject);
|
||||
expect(mockHandle.request.calls.length).toEqual(1);
|
||||
fireWatch("axes[1].active.key", 'someNewKey');
|
||||
expect(mockHandle.request.calls.length).toEqual(2);
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
@ -285,11 +285,17 @@ define(
|
||||
* domain objects returned by `getTelemetryObjects()`.
|
||||
*
|
||||
* @param {DomainObject} domainObject the object of interest
|
||||
* @param {string} [key] the symbolic identifier of the domain
|
||||
* to look up; if omitted, the value for this object's
|
||||
* default domain will be used
|
||||
* @returns the most recent domain value observed
|
||||
*/
|
||||
TelemetrySubscription.prototype.getDomainValue = function (domainObject) {
|
||||
var id = domainObject.getId();
|
||||
return (this.latestValues[id] || {}).domain;
|
||||
TelemetrySubscription.prototype.getDomainValue = function (domainObject, key) {
|
||||
var id = domainObject.getId(),
|
||||
latestValue = this.latestValues[id];
|
||||
return latestValue && (key ?
|
||||
latestValue.datum[key] :
|
||||
latestValue.domain);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -302,11 +308,17 @@ define(
|
||||
* domain objects returned by `getTelemetryObjects()`.
|
||||
*
|
||||
* @param {DomainObject} domainObject the object of interest
|
||||
* @param {string} [key] the symbolic identifier of the range
|
||||
* to look up; if omitted, the value for this object's
|
||||
* default range will be used
|
||||
* @returns the most recent range value observed
|
||||
*/
|
||||
TelemetrySubscription.prototype.getRangeValue = function (domainObject) {
|
||||
var id = domainObject.getId();
|
||||
return (this.latestValues[id] || {}).range;
|
||||
TelemetrySubscription.prototype.getRangeValue = function (domainObject, key) {
|
||||
var id = domainObject.getId(),
|
||||
latestValue = this.latestValues[id];
|
||||
return latestValue && (key ?
|
||||
latestValue.datum[key] :
|
||||
latestValue.range);
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user