Merge remote-tracking branch 'github/master' into open117b
This commit is contained in:
@@ -31,6 +31,7 @@ define(
|
||||
"<mct-include key=\"'time-controller'\" ng-model='conductor'>",
|
||||
"</mct-include>"
|
||||
].join(''),
|
||||
THROTTLE_MS = 200,
|
||||
GLOBAL_SHOWING = false;
|
||||
|
||||
/**
|
||||
@@ -40,6 +41,8 @@ define(
|
||||
* @implements {Representer}
|
||||
* @constructor
|
||||
* @memberof platform/features/conductor
|
||||
* @param {Function} throttle a function used to reduce the frequency
|
||||
* of function invocations
|
||||
* @param {platform/features/conductor.ConductorService} conductorService
|
||||
* service which provides the active time conductor
|
||||
* @param $compile Angular's $compile
|
||||
@@ -47,7 +50,15 @@ define(
|
||||
* @param {Scope} the scope of the representation
|
||||
* @param element the jqLite-wrapped representation element
|
||||
*/
|
||||
function ConductorRepresenter(conductorService, $compile, views, scope, element) {
|
||||
function ConductorRepresenter(
|
||||
throttle,
|
||||
conductorService,
|
||||
$compile,
|
||||
views,
|
||||
scope,
|
||||
element
|
||||
) {
|
||||
this.throttle = throttle;
|
||||
this.scope = scope;
|
||||
this.conductorService = conductorService;
|
||||
this.element = element;
|
||||
@@ -55,51 +66,59 @@ define(
|
||||
this.$compile = $compile;
|
||||
}
|
||||
|
||||
// Combine start/end times into a single object
|
||||
function bounds(start, end) {
|
||||
return { start: start, end: end };
|
||||
}
|
||||
|
||||
// Update the time conductor from the scope
|
||||
function wireScope(conductor, conductorScope, repScope) {
|
||||
function updateConductorOuter() {
|
||||
conductor.queryStart(conductorScope.conductor.outer.start);
|
||||
conductor.queryEnd(conductorScope.conductor.outer.end);
|
||||
repScope.$broadcast(
|
||||
'telemetry:query:bounds',
|
||||
bounds(conductor.queryStart(), conductor.queryEnd())
|
||||
);
|
||||
ConductorRepresenter.prototype.wireScope = function () {
|
||||
var conductor = this.conductorService.getConductor(),
|
||||
conductorScope = this.conductorScope(),
|
||||
repScope = this.scope,
|
||||
lastObservedBounds,
|
||||
broadcastBounds;
|
||||
|
||||
// Combine start/end times into a single object
|
||||
function bounds(start, end) {
|
||||
return {
|
||||
start: conductor.displayStart(),
|
||||
end: conductor.displayEnd()
|
||||
};
|
||||
}
|
||||
|
||||
function boundsAreStable(newlyObservedBounds) {
|
||||
return !lastObservedBounds ||
|
||||
(lastObservedBounds.start === newlyObservedBounds.start &&
|
||||
lastObservedBounds.end === newlyObservedBounds.end);
|
||||
}
|
||||
|
||||
function updateConductorInner() {
|
||||
conductor.displayStart(conductorScope.conductor.inner.start);
|
||||
conductor.displayEnd(conductorScope.conductor.inner.end);
|
||||
repScope.$broadcast(
|
||||
'telemetry:display:bounds',
|
||||
bounds(conductor.displayStart(), conductor.displayEnd())
|
||||
);
|
||||
lastObservedBounds = lastObservedBounds || bounds();
|
||||
broadcastBounds();
|
||||
}
|
||||
|
||||
conductorScope.conductor = {
|
||||
outer: bounds(conductor.queryStart(), conductor.queryEnd()),
|
||||
inner: bounds(conductor.displayStart(), conductor.displayEnd())
|
||||
};
|
||||
broadcastBounds = this.throttle(function () {
|
||||
var newlyObservedBounds = bounds();
|
||||
|
||||
if (boundsAreStable(newlyObservedBounds)) {
|
||||
repScope.$broadcast('telemetry:display:bounds', bounds());
|
||||
lastObservedBounds = undefined;
|
||||
} else {
|
||||
lastObservedBounds = newlyObservedBounds;
|
||||
broadcastBounds();
|
||||
}
|
||||
}, THROTTLE_MS);
|
||||
|
||||
conductorScope.conductor = { outer: bounds(), inner: bounds() };
|
||||
|
||||
conductorScope
|
||||
.$watch('conductor.outer.start', updateConductorOuter);
|
||||
conductorScope
|
||||
.$watch('conductor.outer.end', updateConductorOuter);
|
||||
conductorScope
|
||||
.$watch('conductor.inner.start', updateConductorInner);
|
||||
conductorScope
|
||||
.$watch('conductor.inner.end', updateConductorInner);
|
||||
|
||||
repScope.$on('telemetry:view', updateConductorInner);
|
||||
}
|
||||
};
|
||||
|
||||
ConductorRepresenter.prototype.conductorScope = function (s) {
|
||||
return (this.cScope = arguments.length > 0 ?
|
||||
s : this.cScope);
|
||||
return (this.cScope = arguments.length > 0 ? s : this.cScope);
|
||||
};
|
||||
|
||||
// Handle a specific representation of a specific domain object
|
||||
@@ -113,11 +132,7 @@ define(
|
||||
|
||||
// Create a new scope for the conductor
|
||||
this.conductorScope(this.scope.$new());
|
||||
wireScope(
|
||||
this.conductorService.getConductor(),
|
||||
this.conductorScope(),
|
||||
this.scope
|
||||
);
|
||||
this.wireScope();
|
||||
this.conductorElement =
|
||||
this.$compile(TEMPLATE)(this.conductorScope());
|
||||
this.element.after(this.conductorElement[0]);
|
||||
|
||||
@@ -22,8 +22,7 @@
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
['./ConductorTelemetrySeries'],
|
||||
function (ConductorTelemetrySeries) {
|
||||
function () {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
@@ -42,32 +41,6 @@ define(
|
||||
this.telemetryService = telemetryService;
|
||||
}
|
||||
|
||||
// Strip out any realtime data series that is outside of the conductor's
|
||||
// bounds.
|
||||
ConductorTelemetryDecorator.prototype.pruneNonDisplayable = function (packaged) {
|
||||
var conductor = this.conductorService.getConductor(),
|
||||
repackaged = {};
|
||||
|
||||
function filterSource(packagedBySource) {
|
||||
var repackagedBySource = {};
|
||||
|
||||
Object.keys(packagedBySource).forEach(function (k) {
|
||||
repackagedBySource[k] = new ConductorTelemetrySeries(
|
||||
packagedBySource[k],
|
||||
conductor
|
||||
);
|
||||
});
|
||||
|
||||
return repackagedBySource;
|
||||
}
|
||||
|
||||
Object.keys(packaged).forEach(function (source) {
|
||||
repackaged[source] = filterSource(packaged[source]);
|
||||
});
|
||||
|
||||
return repackaged;
|
||||
};
|
||||
|
||||
ConductorTelemetryDecorator.prototype.amendRequests = function (requests) {
|
||||
var conductor = this.conductorService.getConductor(),
|
||||
start = conductor.displayStart(),
|
||||
@@ -86,21 +59,14 @@ define(
|
||||
ConductorTelemetryDecorator.prototype.requestTelemetry = function (requests) {
|
||||
var self = this;
|
||||
return this.telemetryService
|
||||
.requestTelemetry(this.amendRequests(requests))
|
||||
.then(function (packaged) {
|
||||
return self.pruneNonDisplayable(packaged);
|
||||
});
|
||||
.requestTelemetry(this.amendRequests(requests));
|
||||
};
|
||||
|
||||
ConductorTelemetryDecorator.prototype.subscribe = function (callback, requests) {
|
||||
var self = this;
|
||||
|
||||
function internalCallback(packagedSeries) {
|
||||
return callback(self.pruneNonDisplayable(packagedSeries));
|
||||
}
|
||||
|
||||
return this.telemetryService
|
||||
.subscribe(internalCallback, this.amendRequests(requests));
|
||||
.subscribe(callback, this.amendRequests(requests));
|
||||
};
|
||||
|
||||
return ConductorTelemetryDecorator;
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*****************************************************************************
|
||||
* Open MCT Web, Copyright (c) 2014-2015, United States Government
|
||||
* as represented by the Administrator of the National Aeronautics and Space
|
||||
* Administration. All rights reserved.
|
||||
*
|
||||
* Open MCT Web is licensed under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0.
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
* Open MCT Web includes source code licensed under additional open source
|
||||
* licenses. See the Open Source Licenses file (LICENSES.md) included with
|
||||
* this source code distribution or the Licensing information page available
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
|
||||
/*global define*/
|
||||
|
||||
define(
|
||||
function () {
|
||||
'use strict';
|
||||
|
||||
|
||||
/**
|
||||
* Bound a series of telemetry such that it only includes
|
||||
* points from within the time conductor's displayable window.
|
||||
*
|
||||
* @param {TelemetrySeries} series the telemetry series
|
||||
* @param {platform/features/conductor.TimeConductor} the
|
||||
* time conductor instance which bounds this series
|
||||
* @constructor
|
||||
* @implements {TelemetrySeries}
|
||||
*/
|
||||
function ConductorTelemetrySeries(series, conductor) {
|
||||
var max = series.getPointCount() - 1;
|
||||
|
||||
function binSearch(min, max, value) {
|
||||
var mid = Math.floor((min + max) / 2);
|
||||
|
||||
return min > max ? min :
|
||||
series.getDomainValue(mid) < value ?
|
||||
binSearch(mid + 1, max, value) :
|
||||
binSearch(min, mid - 1, value);
|
||||
}
|
||||
|
||||
this.startIndex = binSearch(0, max, conductor.displayStart());
|
||||
this.endIndex = binSearch(0, max, conductor.displayEnd());
|
||||
this.series = series;
|
||||
}
|
||||
|
||||
ConductorTelemetrySeries.prototype.getPointCount = function () {
|
||||
return Math.max(0, this.endIndex - this.startIndex);
|
||||
};
|
||||
|
||||
ConductorTelemetrySeries.prototype.getDomainValue = function (i, d) {
|
||||
return this.series.getDomainValue(i + this.startIndex, d);
|
||||
};
|
||||
|
||||
ConductorTelemetrySeries.prototype.getRangeValue = function (i, r) {
|
||||
return this.series.getRangeValue(i + this.startIndex, r);
|
||||
};
|
||||
|
||||
return ConductorTelemetrySeries;
|
||||
}
|
||||
);
|
||||
@@ -41,35 +41,9 @@ define(
|
||||
* @param {number} end the initial end time
|
||||
*/
|
||||
function TimeConductor(start, end) {
|
||||
this.inner = { start: start, end: end };
|
||||
this.outer = { start: start, end: end };
|
||||
this.range = { start: start, end: end };
|
||||
}
|
||||
|
||||
/**
|
||||
* Get or set (if called with an argument) the start time for queries.
|
||||
* @param {number} [value] the start time to set
|
||||
* @returns {number} the start time
|
||||
*/
|
||||
TimeConductor.prototype.queryStart = function (value) {
|
||||
if (arguments.length > 0) {
|
||||
this.outer.start = value;
|
||||
}
|
||||
return this.outer.start;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get or set (if called with an argument) the end time for queries.
|
||||
* @param {number} [value] the end time to set
|
||||
* @returns {number} the end time
|
||||
*/
|
||||
TimeConductor.prototype.queryEnd = function (value) {
|
||||
if (arguments.length > 0) {
|
||||
this.outer.end = value;
|
||||
}
|
||||
return this.outer.end;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get or set (if called with an argument) the start time for displays.
|
||||
* @param {number} [value] the start time to set
|
||||
@@ -77,9 +51,9 @@ define(
|
||||
*/
|
||||
TimeConductor.prototype.displayStart = function (value) {
|
||||
if (arguments.length > 0) {
|
||||
this.inner.start = value;
|
||||
this.range.start = value;
|
||||
}
|
||||
return this.inner.start;
|
||||
return this.range.start;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -89,9 +63,9 @@ define(
|
||||
*/
|
||||
TimeConductor.prototype.displayEnd = function (value) {
|
||||
if (arguments.length > 0) {
|
||||
this.inner.end = value;
|
||||
this.range.end = value;
|
||||
}
|
||||
return this.inner.end;
|
||||
return this.range.end;
|
||||
};
|
||||
|
||||
return TimeConductor;
|
||||
|
||||
Reference in New Issue
Block a user