Compare commits

...

1 Commits

Author SHA1 Message Date
98200b1dba adding large values to swg for testing 2023-09-19 12:16:19 -07:00
3 changed files with 47 additions and 12 deletions

View File

@ -29,7 +29,8 @@ define(['./WorkerInterface'], function (WorkerInterface) {
randomness: 0,
phase: 0,
loadDelay: 0,
infinityValues: false
infinityValues: false,
veryLargeValues: false
};
function GeneratorProvider(openmct, StalenessProvider) {
@ -53,7 +54,8 @@ define(['./WorkerInterface'], function (WorkerInterface) {
'randomness',
'phase',
'loadDelay',
'infinityValues'
'infinityValues',
'veryLargeValues'
];
request = request || {};

View File

@ -85,7 +85,8 @@
data.offset,
data.phase,
data.randomness,
data.infinityValues
data.infinityValues,
data.veryLargeValues
),
wavelengths: wavelengths(),
intensities: intensities(),
@ -96,7 +97,8 @@
data.offset,
data.phase,
data.randomness,
data.infinityValues
data.infinityValues,
data.veryLargeValues
)
}
});
@ -136,6 +138,7 @@
var randomness = request.randomness;
var loadDelay = Math.max(request.loadDelay, 0);
var infinityValues = request.infinityValues;
var veryLargeValues = request.veryLargeValues;
var step = 1000 / dataRateInHz;
var nextStep = start - (start % step) + step;
@ -146,10 +149,10 @@
data.push({
utc: nextStep,
yesterday: nextStep - 60 * 60 * 24 * 1000,
sin: sin(nextStep, period, amplitude, offset, phase, randomness, infinityValues),
sin: sin(nextStep, period, amplitude, offset, phase, randomness, infinityValues, veryLargeValues),
wavelengths: wavelengths(),
intensities: intensities(),
cos: cos(nextStep, period, amplitude, offset, phase, randomness, infinityValues)
cos: cos(nextStep, period, amplitude, offset, phase, randomness, infinityValues, veryLargeValues)
});
}
@ -176,9 +179,20 @@
});
}
function cos(timestamp, period, amplitude, offset, phase, randomness, infinityValues) {
if (infinityValues && Math.random() > 0.5) {
return Number.POSITIVE_INFINITY;
function cos(timestamp, period, amplitude, offset, phase, randomness, infinityValues, veryLargeValues) {
const randomValue = Math.random();
if (infinityValues && veryLargeValues) {
if (randomValue < 0.33) return Number.POSITIVE_INFINITY;
if (randomValue < 0.66) return (randomValue > 0.5 ? -1 : 1) * 1e+177;
// if neither condition is met, it just proceeds to the normal return value
} else {
if (infinityValues && randomValue > 0.5) {
return Number.POSITIVE_INFINITY;
}
if (veryLargeValues && randomValue > 0.5) {
return (randomValue > 0.5 ? -1 : 1) * 1e+177;
}
}
return (
@ -188,9 +202,20 @@
);
}
function sin(timestamp, period, amplitude, offset, phase, randomness, infinityValues) {
if (infinityValues && Math.random() > 0.5) {
return Number.POSITIVE_INFINITY;
function sin(timestamp, period, amplitude, offset, phase, randomness, infinityValues, veryLargeValues) {
const randomValue = Math.random();
if (infinityValues && veryLargeValues) {
if (randomValue < 0.33) return Number.POSITIVE_INFINITY;
if (randomValue < 0.66) return (randomValue > 0.5 ? -1 : 1) * 1e+177;
// if neither condition is met, it just proceeds to the normal return value
} else {
if (infinityValues && randomValue > 0.5) {
return Number.POSITIVE_INFINITY;
}
if (veryLargeValues && randomValue > 0.5) {
return (randomValue > 0.5 ? -1 : 1) * 1e+177;
}
}
return (

View File

@ -122,6 +122,13 @@ export default function (openmct) {
key: 'infinityValues',
property: ['telemetry', 'infinityValues']
},
{
name: 'Include Very Large Values',
control: 'toggleSwitch',
cssClass: 'l-input',
key: 'veryLargeValues',
property: ['telemetry', 'veryLargeValues']
},
{
name: 'Provide Staleness Updates',
control: 'toggleSwitch',
@ -140,6 +147,7 @@ export default function (openmct) {
randomness: 0,
loadDelay: 0,
infinityValues: false,
veryLargeValues: false,
staleness: false
};
}