mirror of
https://github.com/nasa/openmct.git
synced 2025-01-29 23:53: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
|
// so it's not checked for here, just formatted for display
|
||||||
// differently.
|
// differently.
|
||||||
return (i + offset) * 1000 + firstTime * 1000 -
|
return (i + offset) * 1000 + firstTime * 1000 -
|
||||||
(domain === 'yesterday' ? ONE_DAY : 0);
|
(domain === 'yesterday' ? (ONE_DAY * 1000) : 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
generatorData.getRangeValue = function (i, range) {
|
generatorData.getRangeValue = function (i, range) {
|
||||||
|
@ -78,6 +78,8 @@ define(
|
|||||||
cachedObjects = [],
|
cachedObjects = [],
|
||||||
updater,
|
updater,
|
||||||
lastBounds,
|
lastBounds,
|
||||||
|
lastRange,
|
||||||
|
lastDomain,
|
||||||
handle;
|
handle;
|
||||||
|
|
||||||
// Populate the scope with axis information (specifically, options
|
// Populate the scope with axis information (specifically, options
|
||||||
@ -120,16 +122,16 @@ define(
|
|||||||
// Reinstantiate the plot updater (e.g. because we have a
|
// Reinstantiate the plot updater (e.g. because we have a
|
||||||
// new subscription.) This will clear the plot.
|
// new subscription.) This will clear the plot.
|
||||||
function recreateUpdater() {
|
function recreateUpdater() {
|
||||||
updater = new PlotUpdater(
|
var domain = $scope.axes[0].active.key,
|
||||||
handle,
|
range = $scope.axes[1].active.key,
|
||||||
($scope.axes[0].active || {}).key,
|
duration = PLOT_FIXED_DURATION;
|
||||||
($scope.axes[1].active || {}).key,
|
|
||||||
PLOT_FIXED_DURATION
|
updater = new PlotUpdater(handle, domain, range, duration);
|
||||||
);
|
lastDomain = domain;
|
||||||
self.limitTracker = new PlotLimitTracker(
|
lastRange = range;
|
||||||
handle,
|
|
||||||
($scope.axes[1].active || {}).key
|
self.limitTracker = new PlotLimitTracker(handle, range);
|
||||||
);
|
|
||||||
// Keep any externally-provided bounds
|
// Keep any externally-provided bounds
|
||||||
if (lastBounds) {
|
if (lastBounds) {
|
||||||
setBasePanZoom(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)
|
// Respond to a display bounds change (requery for data)
|
||||||
function changeDisplayBounds(event, bounds) {
|
function changeDisplayBounds(event, bounds) {
|
||||||
var domainAxis = $scope.axes[0];
|
var domainAxis = $scope.axes[0];
|
||||||
|
|
||||||
domainAxis.chooseOption(bounds.domain);
|
domainAxis.chooseOption(bounds.domain);
|
||||||
plotTelemetryFormatter
|
updateDomainFormat();
|
||||||
.setDomainFormat(domainAxis.active.format);
|
|
||||||
|
|
||||||
self.pending = true;
|
|
||||||
releaseSubscription();
|
|
||||||
subscribe($scope.domainObject);
|
|
||||||
setBasePanZoom(bounds);
|
setBasePanZoom(bounds);
|
||||||
}
|
requery();
|
||||||
|
|
||||||
function updateDomainFormat(format) {
|
|
||||||
plotTelemetryFormatter.setDomainFormat(format);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.modeOptions = new PlotModeOptions([], subPlotFactory);
|
this.modeOptions = new PlotModeOptions([], subPlotFactory);
|
||||||
@ -237,6 +256,10 @@ define(
|
|||||||
new PlotAxis("ranges", [], AXIS_DEFAULTS[1])
|
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
|
// Subscribe to telemetry when a domain object becomes available
|
||||||
$scope.$watch('domainObject', subscribe);
|
$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 () {
|
beforeEach(function () {
|
||||||
mockScope = jasmine.createSpyObj(
|
mockScope = jasmine.createSpyObj(
|
||||||
@ -263,6 +271,20 @@ define(
|
|||||||
]);
|
]);
|
||||||
expect(mockHandle.request.calls.length).toEqual(2);
|
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()`.
|
* domain objects returned by `getTelemetryObjects()`.
|
||||||
*
|
*
|
||||||
* @param {DomainObject} domainObject the object of interest
|
* @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
|
* @returns the most recent domain value observed
|
||||||
*/
|
*/
|
||||||
TelemetrySubscription.prototype.getDomainValue = function (domainObject) {
|
TelemetrySubscription.prototype.getDomainValue = function (domainObject, key) {
|
||||||
var id = domainObject.getId();
|
var id = domainObject.getId(),
|
||||||
return (this.latestValues[id] || {}).domain;
|
latestValue = this.latestValues[id];
|
||||||
|
return latestValue && (key ?
|
||||||
|
latestValue.datum[key] :
|
||||||
|
latestValue.domain);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -302,11 +308,17 @@ define(
|
|||||||
* domain objects returned by `getTelemetryObjects()`.
|
* domain objects returned by `getTelemetryObjects()`.
|
||||||
*
|
*
|
||||||
* @param {DomainObject} domainObject the object of interest
|
* @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
|
* @returns the most recent range value observed
|
||||||
*/
|
*/
|
||||||
TelemetrySubscription.prototype.getRangeValue = function (domainObject) {
|
TelemetrySubscription.prototype.getRangeValue = function (domainObject, key) {
|
||||||
var id = domainObject.getId();
|
var id = domainObject.getId(),
|
||||||
return (this.latestValues[id] || {}).range;
|
latestValue = this.latestValues[id];
|
||||||
|
return latestValue && (key ?
|
||||||
|
latestValue.datum[key] :
|
||||||
|
latestValue.range);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user