2018-03-21 21:18:08 +00:00
|
|
|
/*****************************************************************************
|
2021-03-29 16:56:52 +00:00
|
|
|
* Open MCT, Copyright (c) 2014-2021, United States Government
|
2018-03-21 21:18:08 +00:00
|
|
|
* as represented by the Administrator of the National Aeronautics and Space
|
|
|
|
* Administration. All rights reserved.
|
|
|
|
*
|
|
|
|
* Open MCT 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 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.
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
define([
|
|
|
|
|
|
|
|
], function (
|
|
|
|
|
|
|
|
) {
|
|
|
|
|
2021-06-21 23:22:28 +00:00
|
|
|
var PURPLE = {
|
|
|
|
sin: 2.2,
|
|
|
|
cos: 2.2
|
|
|
|
},
|
|
|
|
RED = {
|
2019-11-28 00:04:52 +00:00
|
|
|
sin: 0.9,
|
2018-08-31 18:54:46 +00:00
|
|
|
cos: 0.9
|
|
|
|
},
|
2021-06-21 23:22:28 +00:00
|
|
|
ORANGE = {
|
|
|
|
sin: 0.7,
|
|
|
|
cos: 0.7
|
|
|
|
},
|
2018-08-31 18:54:46 +00:00
|
|
|
YELLOW = {
|
|
|
|
sin: 0.5,
|
|
|
|
cos: 0.5
|
|
|
|
},
|
2021-06-21 23:22:28 +00:00
|
|
|
CYAN = {
|
|
|
|
sin: 0.45,
|
|
|
|
cos: 0.45
|
|
|
|
},
|
2018-03-21 21:18:08 +00:00
|
|
|
LIMITS = {
|
|
|
|
rh: {
|
2018-12-20 21:17:44 +00:00
|
|
|
cssClass: "is-limit--upr is-limit--red",
|
2018-03-21 21:18:08 +00:00
|
|
|
low: RED,
|
|
|
|
high: Number.POSITIVE_INFINITY,
|
|
|
|
name: "Red High"
|
|
|
|
},
|
|
|
|
rl: {
|
2018-12-20 21:17:44 +00:00
|
|
|
cssClass: "is-limit--lwr is-limit--red",
|
2018-03-21 21:18:08 +00:00
|
|
|
high: -RED,
|
|
|
|
low: Number.NEGATIVE_INFINITY,
|
|
|
|
name: "Red Low"
|
|
|
|
},
|
|
|
|
yh: {
|
2018-12-20 21:17:44 +00:00
|
|
|
cssClass: "is-limit--upr is-limit--yellow",
|
2018-03-21 21:18:08 +00:00
|
|
|
low: YELLOW,
|
|
|
|
high: RED,
|
|
|
|
name: "Yellow High"
|
|
|
|
},
|
|
|
|
yl: {
|
2018-12-20 21:17:44 +00:00
|
|
|
cssClass: "is-limit--lwr is-limit--yellow",
|
2018-03-21 21:18:08 +00:00
|
|
|
low: -RED,
|
|
|
|
high: -YELLOW,
|
|
|
|
name: "Yellow Low"
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
function SinewaveLimitProvider() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SinewaveLimitProvider.prototype.supportsLimits = function (domainObject) {
|
|
|
|
return domainObject.type === 'generator';
|
|
|
|
};
|
|
|
|
|
|
|
|
SinewaveLimitProvider.prototype.getLimitEvaluator = function (domainObject) {
|
|
|
|
return {
|
|
|
|
evaluate: function (datum, valueMetadata) {
|
2018-08-31 18:54:46 +00:00
|
|
|
var range = valueMetadata && valueMetadata.key;
|
2019-11-28 00:04:52 +00:00
|
|
|
|
2018-08-31 18:54:46 +00:00
|
|
|
if (datum[range] > RED[range]) {
|
2018-03-21 21:18:08 +00:00
|
|
|
return LIMITS.rh;
|
|
|
|
}
|
2020-07-31 19:11:03 +00:00
|
|
|
|
2018-08-31 18:54:46 +00:00
|
|
|
if (datum[range] < -RED[range]) {
|
2018-03-21 21:18:08 +00:00
|
|
|
return LIMITS.rl;
|
|
|
|
}
|
2020-07-31 19:11:03 +00:00
|
|
|
|
2018-08-31 18:54:46 +00:00
|
|
|
if (datum[range] > YELLOW[range]) {
|
2018-03-21 21:18:08 +00:00
|
|
|
return LIMITS.yh;
|
|
|
|
}
|
2020-07-31 19:11:03 +00:00
|
|
|
|
2018-08-31 18:54:46 +00:00
|
|
|
if (datum[range] < -YELLOW[range]) {
|
2018-03-21 21:18:08 +00:00
|
|
|
return LIMITS.yl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-05-28 21:51:29 +00:00
|
|
|
SinewaveLimitProvider.prototype.getLimits = function (domainObject) {
|
2021-06-21 23:22:28 +00:00
|
|
|
|
2021-05-28 21:51:29 +00:00
|
|
|
return {
|
|
|
|
limits: function () {
|
2021-06-21 23:22:28 +00:00
|
|
|
return Promise.resolve({
|
|
|
|
WATCH: {
|
|
|
|
low: {
|
|
|
|
color: "cyan",
|
|
|
|
sin: -CYAN.sin,
|
|
|
|
cos: -CYAN.cos
|
|
|
|
},
|
|
|
|
high: {
|
|
|
|
color: "cyan",
|
|
|
|
...CYAN
|
|
|
|
}
|
|
|
|
},
|
2021-05-28 21:51:29 +00:00
|
|
|
WARNING: {
|
|
|
|
low: {
|
2021-06-21 23:22:28 +00:00
|
|
|
color: "yellow",
|
2021-05-28 21:51:29 +00:00
|
|
|
sin: -YELLOW.sin,
|
|
|
|
cos: -YELLOW.cos
|
|
|
|
},
|
|
|
|
high: {
|
2021-06-21 23:22:28 +00:00
|
|
|
color: "yellow",
|
2021-05-28 21:51:29 +00:00
|
|
|
...YELLOW
|
|
|
|
}
|
|
|
|
},
|
|
|
|
DISTRESS: {
|
|
|
|
low: {
|
2021-06-21 23:22:28 +00:00
|
|
|
color: "orange",
|
|
|
|
sin: -ORANGE.sin,
|
|
|
|
cos: -ORANGE.cos
|
|
|
|
},
|
|
|
|
high: {
|
|
|
|
color: "orange",
|
|
|
|
...ORANGE
|
|
|
|
}
|
|
|
|
},
|
|
|
|
CRITICAL: {
|
|
|
|
low: {
|
|
|
|
color: "red",
|
2021-05-28 21:51:29 +00:00
|
|
|
sin: -RED.sin,
|
|
|
|
cos: -RED.cos
|
|
|
|
},
|
|
|
|
high: {
|
2021-06-21 23:22:28 +00:00
|
|
|
color: "red",
|
2021-05-28 21:51:29 +00:00
|
|
|
...RED
|
|
|
|
}
|
2021-06-21 23:22:28 +00:00
|
|
|
},
|
|
|
|
SEVERE: {
|
|
|
|
low: {
|
|
|
|
color: "purple",
|
|
|
|
sin: -PURPLE.sin,
|
|
|
|
cos: -PURPLE.cos
|
|
|
|
},
|
|
|
|
high: {
|
|
|
|
color: "purple",
|
|
|
|
...PURPLE
|
|
|
|
}
|
2021-05-28 21:51:29 +00:00
|
|
|
}
|
2021-06-21 23:22:28 +00:00
|
|
|
});
|
2021-05-28 21:51:29 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-03-21 21:18:08 +00:00
|
|
|
return SinewaveLimitProvider;
|
|
|
|
});
|