mirror of
https://github.com/nasa/openmct.git
synced 2025-06-14 13:18:15 +00:00
[Limits] Display limit state in legend of plot
WTD-1223.
This commit is contained in:
@ -10,6 +10,12 @@
|
|||||||
"depends": [ "$q", "$timeout" ]
|
"depends": [ "$q", "$timeout" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"capabilities": [
|
||||||
|
{
|
||||||
|
"key": "limit",
|
||||||
|
"implementation": "SinewaveLimitCapability.js"
|
||||||
|
}
|
||||||
|
],
|
||||||
"types": [
|
"types": [
|
||||||
{
|
{
|
||||||
"key": "generator",
|
"key": "generator",
|
||||||
|
@ -27,12 +27,8 @@ define(
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var RED = 0.9,
|
var RED = 0.9,
|
||||||
YELLOW = 0.5;
|
YELLOW = 0.5,
|
||||||
|
LIMITS = {
|
||||||
function SinewaveLimitCapability(domainObject) {
|
|
||||||
return {
|
|
||||||
limits: function (range) {
|
|
||||||
return {
|
|
||||||
rh: {
|
rh: {
|
||||||
cssClass: "s-limit-upr-red",
|
cssClass: "s-limit-upr-red",
|
||||||
low: RED,
|
low: RED,
|
||||||
@ -46,39 +42,43 @@ define(
|
|||||||
name: "Red Low"
|
name: "Red Low"
|
||||||
},
|
},
|
||||||
yh: {
|
yh: {
|
||||||
cssClass: "s-limit-upr-ylw",
|
cssClass: "s-limit-upr-yellow",
|
||||||
low: YELLOW,
|
low: YELLOW,
|
||||||
high: RED,
|
high: RED,
|
||||||
name: "Yellow High"
|
name: "Yellow High"
|
||||||
},
|
},
|
||||||
yl: {
|
yl: {
|
||||||
cssClass: "s-limit-lwer-ylw",
|
cssClass: "s-limit-lwr-yellow",
|
||||||
low: -RED,
|
low: -RED,
|
||||||
high: -YELLOW,
|
high: -YELLOW,
|
||||||
name: "Yellow Low"
|
name: "Yellow Low"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function SinewaveLimitCapability(domainObject) {
|
||||||
|
return {
|
||||||
|
limits: function (range) {
|
||||||
|
return LIMITS;
|
||||||
},
|
},
|
||||||
evaluate: function (series, index, range) {
|
evaluate: function (value, range) {
|
||||||
var value = series.getRangeValue(index, range);
|
|
||||||
if (value > RED) {
|
if (value > RED) {
|
||||||
return 'rh';
|
return LIMITS.rh;
|
||||||
}
|
}
|
||||||
if (value < -RED) {
|
if (value < -RED) {
|
||||||
return 'rl';
|
return LIMITS.rl;
|
||||||
}
|
}
|
||||||
if (value > YELLOW) {
|
if (value > YELLOW) {
|
||||||
return 'yh';
|
return LIMITS.yh;
|
||||||
}
|
}
|
||||||
if (value < -YELLOW) {
|
if (value < -YELLOW) {
|
||||||
return 'yl';
|
return LIMITS.yl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
SinewaveLimitCapability.appliesTo = function (model) {
|
SinewaveLimitCapability.appliesTo = function (model) {
|
||||||
return model.type === 'example.generator';
|
return model.type === 'generator';
|
||||||
};
|
};
|
||||||
|
|
||||||
return SinewaveLimitCapability;
|
return SinewaveLimitCapability;
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
<span
|
<span
|
||||||
class='plot-legend-item'
|
class='plot-legend-item'
|
||||||
ng-repeat="telemetryObject in subplot.getTelemetryObjects()"
|
ng-repeat="telemetryObject in subplot.getTelemetryObjects()"
|
||||||
ng-class="{ 's-limit-upr-red': $index < 1, 's-stale': $index%2==0 }"
|
ng-class="plot.getLegendClass(telemetryObject)"
|
||||||
>
|
>
|
||||||
<span class='plot-color-swatch'
|
<span class='plot-color-swatch'
|
||||||
ng-style="{ 'background-color': plot.getColor($index) }">
|
ng-style="{ 'background-color': plot.getColor($index) }">
|
||||||
|
@ -29,10 +29,11 @@ define(
|
|||||||
"./elements/PlotUpdater",
|
"./elements/PlotUpdater",
|
||||||
"./elements/PlotPalette",
|
"./elements/PlotPalette",
|
||||||
"./elements/PlotAxis",
|
"./elements/PlotAxis",
|
||||||
|
"./elements/PlotLimitTracker",
|
||||||
"./modes/PlotModeOptions",
|
"./modes/PlotModeOptions",
|
||||||
"./SubPlotFactory"
|
"./SubPlotFactory"
|
||||||
],
|
],
|
||||||
function (PlotUpdater, PlotPalette, PlotAxis, PlotModeOptions, SubPlotFactory) {
|
function (PlotUpdater, PlotPalette, PlotAxis, PlotLimitTracker, PlotModeOptions, SubPlotFactory) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var AXIS_DEFAULTS = [
|
var AXIS_DEFAULTS = [
|
||||||
@ -56,6 +57,7 @@ define(
|
|||||||
modeOptions = new PlotModeOptions([], subPlotFactory),
|
modeOptions = new PlotModeOptions([], subPlotFactory),
|
||||||
subplots = [],
|
subplots = [],
|
||||||
cachedObjects = [],
|
cachedObjects = [],
|
||||||
|
limitTracker,
|
||||||
updater,
|
updater,
|
||||||
handle,
|
handle,
|
||||||
domainOffset;
|
domainOffset;
|
||||||
@ -102,6 +104,10 @@ define(
|
|||||||
($scope.axes[0].active || {}).key,
|
($scope.axes[0].active || {}).key,
|
||||||
($scope.axes[1].active || {}).key
|
($scope.axes[1].active || {}).key
|
||||||
);
|
);
|
||||||
|
limitTracker = new PlotLimitTracker(
|
||||||
|
handle,
|
||||||
|
($scope.axes[1].active || {}).key
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle new telemetry data in this plot
|
// Handle new telemetry data in this plot
|
||||||
@ -113,6 +119,9 @@ define(
|
|||||||
updater.update();
|
updater.update();
|
||||||
modeOptions.getModeHandler().plotTelemetry(updater);
|
modeOptions.getModeHandler().plotTelemetry(updater);
|
||||||
}
|
}
|
||||||
|
if (limitTracker) {
|
||||||
|
limitTracker.update();
|
||||||
|
}
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -226,6 +235,15 @@ define(
|
|||||||
getSubPlots: function () {
|
getSubPlots: function () {
|
||||||
return modeOptions.getModeHandler().getSubPlots();
|
return modeOptions.getModeHandler().getSubPlots();
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Get the CSS class to apply to the legend for this domain
|
||||||
|
* object; this will reflect limit state.
|
||||||
|
* @returns {string} the CSS class
|
||||||
|
*/
|
||||||
|
getLegendClass: function (telemetryObject) {
|
||||||
|
return limitTracker &&
|
||||||
|
limitTracker.getLegendClass(telemetryObject);
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Explicitly update all plots.
|
* Explicitly update all plots.
|
||||||
*/
|
*/
|
||||||
|
69
platform/features/plot/src/elements/PlotLimitTracker.js
Normal file
69
platform/features/plot/src/elements/PlotLimitTracker.js
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/*****************************************************************************
|
||||||
|
* 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,Float32Array*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepares data to be rendered in a GL Plot. Handles
|
||||||
|
* the conversion from data API to displayable buffers.
|
||||||
|
*/
|
||||||
|
define(
|
||||||
|
[],
|
||||||
|
function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var MAX_POINTS = 86400,
|
||||||
|
INITIAL_SIZE = 675; // 1/128 of MAX_POINTS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @constructor
|
||||||
|
* @param {TelemetryHandle} handle the handle to telemetry access
|
||||||
|
* @param {string} range the key to use when looking up range values
|
||||||
|
*/
|
||||||
|
function PlotLimitTracker(handle, range) {
|
||||||
|
var legendClasses = {};
|
||||||
|
|
||||||
|
function updateLimit(telemetryObject) {
|
||||||
|
var limit = telemetryObject.getCapability('limit'),
|
||||||
|
value = handle.getRangeValue(telemetryObject, range);
|
||||||
|
|
||||||
|
if (limit && (value !== undefined)) {
|
||||||
|
legendClasses[telemetryObject.getId()] =
|
||||||
|
(limit.evaluate(value, range) || {}).cssClass;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
update: function () {
|
||||||
|
legendClasses = {};
|
||||||
|
handle.getTelemetryObjects().forEach(updateLimit);
|
||||||
|
},
|
||||||
|
getLegendClass: function (domainObject) {
|
||||||
|
var id = domainObject && domainObject.getId();
|
||||||
|
return id && legendClasses[id];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return PlotLimitTracker;
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
Reference in New Issue
Block a user