mirror of
https://github.com/nasa/openmct.git
synced 2025-06-10 03:11:39 +00:00
[Time Conductor] Remove telemetry series wrapper
WTD-1515
This commit is contained in:
parent
669b434c36
commit
146e948097
@ -22,8 +22,7 @@
|
|||||||
/*global define*/
|
/*global define*/
|
||||||
|
|
||||||
define(
|
define(
|
||||||
['./ConductorTelemetrySeries'],
|
function () {
|
||||||
function (ConductorTelemetrySeries) {
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,32 +41,6 @@ define(
|
|||||||
this.telemetryService = telemetryService;
|
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) {
|
ConductorTelemetryDecorator.prototype.amendRequests = function (requests) {
|
||||||
var conductor = this.conductorService.getConductor(),
|
var conductor = this.conductorService.getConductor(),
|
||||||
start = conductor.displayStart(),
|
start = conductor.displayStart(),
|
||||||
@ -86,21 +59,14 @@ define(
|
|||||||
ConductorTelemetryDecorator.prototype.requestTelemetry = function (requests) {
|
ConductorTelemetryDecorator.prototype.requestTelemetry = function (requests) {
|
||||||
var self = this;
|
var self = this;
|
||||||
return this.telemetryService
|
return this.telemetryService
|
||||||
.requestTelemetry(this.amendRequests(requests))
|
.requestTelemetry(this.amendRequests(requests));
|
||||||
.then(function (packaged) {
|
|
||||||
return self.pruneNonDisplayable(packaged);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
ConductorTelemetryDecorator.prototype.subscribe = function (callback, requests) {
|
ConductorTelemetryDecorator.prototype.subscribe = function (callback, requests) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
function internalCallback(packagedSeries) {
|
|
||||||
return callback(self.pruneNonDisplayable(packagedSeries));
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.telemetryService
|
return this.telemetryService
|
||||||
.subscribe(internalCallback, this.amendRequests(requests));
|
.subscribe(callback, this.amendRequests(requests));
|
||||||
};
|
};
|
||||||
|
|
||||||
return ConductorTelemetryDecorator;
|
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;
|
|
||||||
}
|
|
||||||
);
|
|
@ -110,27 +110,6 @@ define(
|
|||||||
}]);
|
}]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("prunes historical values to the displayable range", function () {
|
|
||||||
var packagedTelemetry;
|
|
||||||
decorator.requestTelemetry([{ source: "abc", key: "xyz" }]);
|
|
||||||
packagedTelemetry = mockPromise.then.mostRecentCall.args[0]({
|
|
||||||
"abc": { "xyz": mockSeries }
|
|
||||||
});
|
|
||||||
expect(seriesIsInWindow(packagedTelemetry.abc.xyz))
|
|
||||||
.toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("prunes subscribed values to the displayable range", function () {
|
|
||||||
var mockCallback = jasmine.createSpy('callback'),
|
|
||||||
packagedTelemetry;
|
|
||||||
decorator.subscribe(mockCallback, [{ source: "abc", key: "xyz" }]);
|
|
||||||
mockTelemetryService.subscribe.mostRecentCall.args[0]({
|
|
||||||
"abc": { "xyz": mockSeries }
|
|
||||||
});
|
|
||||||
packagedTelemetry = mockCallback.mostRecentCall.args[0];
|
|
||||||
expect(seriesIsInWindow(packagedTelemetry.abc.xyz))
|
|
||||||
.toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -1,86 +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,describe,it,expect,beforeEach,waitsFor,jasmine*/
|
|
||||||
|
|
||||||
define(
|
|
||||||
["../src/ConductorTelemetrySeries"],
|
|
||||||
function (ConductorTelemetrySeries) {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
describe("ConductorTelemetrySeries", function () {
|
|
||||||
var mockSeries,
|
|
||||||
mockConductor,
|
|
||||||
testArray,
|
|
||||||
series;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
testArray = [ -10, 0, 42, 1977, 12321 ];
|
|
||||||
|
|
||||||
mockSeries = jasmine.createSpyObj(
|
|
||||||
'series',
|
|
||||||
[ 'getPointCount', 'getDomainValue', 'getRangeValue' ]
|
|
||||||
);
|
|
||||||
mockConductor = jasmine.createSpyObj(
|
|
||||||
'conductor',
|
|
||||||
[ 'queryStart', 'queryEnd', 'displayStart', 'displayEnd' ]
|
|
||||||
);
|
|
||||||
|
|
||||||
mockSeries.getPointCount.andCallFake(function () {
|
|
||||||
return testArray.length;
|
|
||||||
});
|
|
||||||
mockSeries.getDomainValue.andCallFake(function (i) {
|
|
||||||
return testArray[i];
|
|
||||||
});
|
|
||||||
mockSeries.getRangeValue.andCallFake(function (i) {
|
|
||||||
return testArray[i] * 2;
|
|
||||||
});
|
|
||||||
|
|
||||||
mockConductor.displayStart.andReturn(0);
|
|
||||||
mockConductor.displayEnd.andReturn(2000);
|
|
||||||
|
|
||||||
series = new ConductorTelemetrySeries(
|
|
||||||
mockSeries,
|
|
||||||
mockConductor
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("reduces the apparent size of a series", function () {
|
|
||||||
expect(series.getPointCount()).toEqual(3);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("maps domain value indexes to the displayable range", function () {
|
|
||||||
[0, 1, 2].forEach(function (i) {
|
|
||||||
expect(series.getDomainValue(i))
|
|
||||||
.toEqual(mockSeries.getDomainValue(i + 1));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
it("maps range value indexes to the displayable range", function () {
|
|
||||||
[0, 1, 2].forEach(function (i) {
|
|
||||||
expect(series.getRangeValue(i))
|
|
||||||
.toEqual(mockSeries.getRangeValue(i + 1));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
@ -2,6 +2,5 @@
|
|||||||
"ConductorRepresenter",
|
"ConductorRepresenter",
|
||||||
"ConductorService",
|
"ConductorService",
|
||||||
"ConductorTelemetryDecorator",
|
"ConductorTelemetryDecorator",
|
||||||
"ConductorTelemetrySeries",
|
|
||||||
"TimeConductor"
|
"TimeConductor"
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user