mirror of
https://github.com/nasa/openmct.git
synced 2025-06-21 16:49:42 +00:00
chore: add prettier
(2/3): apply formatting, re-enable lint ci step (#6682)
* style: apply prettier formatting * fix: re-enable lint ci check
This commit is contained in:
@ -21,44 +21,40 @@
|
||||
*****************************************************************************/
|
||||
|
||||
class EventMetadataProvider {
|
||||
constructor() {
|
||||
this.METADATA_BY_TYPE = {
|
||||
'eventGenerator': {
|
||||
values: [
|
||||
{
|
||||
key: "name",
|
||||
name: "Name",
|
||||
format: "string"
|
||||
},
|
||||
{
|
||||
key: "utc",
|
||||
name: "Time",
|
||||
format: "utc",
|
||||
hints: {
|
||||
domain: 1
|
||||
}
|
||||
},
|
||||
{
|
||||
key: "message",
|
||||
name: "Message",
|
||||
format: "string"
|
||||
}
|
||||
]
|
||||
constructor() {
|
||||
this.METADATA_BY_TYPE = {
|
||||
eventGenerator: {
|
||||
values: [
|
||||
{
|
||||
key: 'name',
|
||||
name: 'Name',
|
||||
format: 'string'
|
||||
},
|
||||
{
|
||||
key: 'utc',
|
||||
name: 'Time',
|
||||
format: 'utc',
|
||||
hints: {
|
||||
domain: 1
|
||||
}
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
key: 'message',
|
||||
name: 'Message',
|
||||
format: 'string'
|
||||
}
|
||||
]
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
supportsMetadata(domainObject) {
|
||||
return Object.prototype.hasOwnProperty.call(this.METADATA_BY_TYPE, domainObject.type);
|
||||
}
|
||||
supportsMetadata(domainObject) {
|
||||
return Object.prototype.hasOwnProperty.call(this.METADATA_BY_TYPE, domainObject.type);
|
||||
}
|
||||
|
||||
getMetadata(domainObject) {
|
||||
return Object.assign(
|
||||
{},
|
||||
domainObject.telemetry,
|
||||
this.METADATA_BY_TYPE[domainObject.type]
|
||||
);
|
||||
}
|
||||
getMetadata(domainObject) {
|
||||
return Object.assign({}, domainObject.telemetry, this.METADATA_BY_TYPE[domainObject.type]);
|
||||
}
|
||||
}
|
||||
|
||||
export default EventMetadataProvider;
|
||||
|
@ -27,70 +27,78 @@
|
||||
import messages from './transcript.json';
|
||||
|
||||
class EventTelemetryProvider {
|
||||
constructor() {
|
||||
this.defaultSize = 25;
|
||||
constructor() {
|
||||
this.defaultSize = 25;
|
||||
}
|
||||
|
||||
generateData(firstObservedTime, count, startTime, duration, name) {
|
||||
const millisecondsSinceStart = startTime - firstObservedTime;
|
||||
const utc = startTime + count * duration;
|
||||
const ind = count % messages.length;
|
||||
const message = messages[ind] + ' - [' + millisecondsSinceStart + ']';
|
||||
|
||||
return {
|
||||
name,
|
||||
utc,
|
||||
message
|
||||
};
|
||||
}
|
||||
|
||||
supportsRequest(domainObject) {
|
||||
return domainObject.type === 'eventGenerator';
|
||||
}
|
||||
|
||||
supportsSubscribe(domainObject) {
|
||||
return domainObject.type === 'eventGenerator';
|
||||
}
|
||||
|
||||
subscribe(domainObject, callback) {
|
||||
const duration = domainObject.telemetry.duration * 1000;
|
||||
const firstObservedTime = Date.now();
|
||||
let count = 0;
|
||||
|
||||
const interval = setInterval(() => {
|
||||
const startTime = Date.now();
|
||||
const datum = this.generateData(
|
||||
firstObservedTime,
|
||||
count,
|
||||
startTime,
|
||||
duration,
|
||||
domainObject.name
|
||||
);
|
||||
count += 1;
|
||||
callback(datum);
|
||||
}, duration);
|
||||
|
||||
return function () {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}
|
||||
|
||||
request(domainObject, options) {
|
||||
let start = options.start;
|
||||
const end = Math.min(Date.now(), options.end); // no future values
|
||||
const duration = domainObject.telemetry.duration * 1000;
|
||||
const size = options.size ? options.size : this.defaultSize;
|
||||
const data = [];
|
||||
const firstObservedTime = options.start;
|
||||
let count = 0;
|
||||
|
||||
if (options.strategy === 'latest' || options.size === 1) {
|
||||
start = end;
|
||||
}
|
||||
|
||||
generateData(firstObservedTime, count, startTime, duration, name) {
|
||||
const millisecondsSinceStart = startTime - firstObservedTime;
|
||||
const utc = startTime + (count * duration);
|
||||
const ind = count % messages.length;
|
||||
const message = messages[ind] + " - [" + millisecondsSinceStart + "]";
|
||||
|
||||
return {
|
||||
name,
|
||||
utc,
|
||||
message
|
||||
};
|
||||
while (start <= end && data.length < size) {
|
||||
const startTime = options.start + count;
|
||||
data.push(
|
||||
this.generateData(firstObservedTime, count, startTime, duration, domainObject.name)
|
||||
);
|
||||
start += duration;
|
||||
count += 1;
|
||||
}
|
||||
|
||||
supportsRequest(domainObject) {
|
||||
return domainObject.type === 'eventGenerator';
|
||||
}
|
||||
|
||||
supportsSubscribe(domainObject) {
|
||||
return domainObject.type === 'eventGenerator';
|
||||
}
|
||||
|
||||
subscribe(domainObject, callback) {
|
||||
const duration = domainObject.telemetry.duration * 1000;
|
||||
const firstObservedTime = Date.now();
|
||||
let count = 0;
|
||||
|
||||
const interval = setInterval(() => {
|
||||
const startTime = Date.now();
|
||||
const datum = this.generateData(firstObservedTime, count, startTime, duration, domainObject.name);
|
||||
count += 1;
|
||||
callback(datum);
|
||||
}, duration);
|
||||
|
||||
return function () {
|
||||
clearInterval(interval);
|
||||
};
|
||||
}
|
||||
|
||||
request(domainObject, options) {
|
||||
let start = options.start;
|
||||
const end = Math.min(Date.now(), options.end); // no future values
|
||||
const duration = domainObject.telemetry.duration * 1000;
|
||||
const size = options.size ? options.size : this.defaultSize;
|
||||
const data = [];
|
||||
const firstObservedTime = options.start;
|
||||
let count = 0;
|
||||
|
||||
if (options.strategy === 'latest' || options.size === 1) {
|
||||
start = end;
|
||||
}
|
||||
|
||||
while (start <= end && data.length < size) {
|
||||
const startTime = options.start + count;
|
||||
data.push(this.generateData(firstObservedTime, count, startTime, duration, domainObject.name));
|
||||
start += duration;
|
||||
count += 1;
|
||||
}
|
||||
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
return Promise.resolve(data);
|
||||
}
|
||||
}
|
||||
|
||||
export default EventTelemetryProvider;
|
||||
|
@ -23,20 +23,20 @@ import EventTelmetryProvider from './EventTelemetryProvider';
|
||||
import EventMetadataProvider from './EventMetadataProvider';
|
||||
|
||||
export default function EventGeneratorPlugin(options) {
|
||||
return function install(openmct) {
|
||||
openmct.types.addType("eventGenerator", {
|
||||
name: "Event Message Generator",
|
||||
description: "For development use. Creates sample event message data that mimics a live data stream.",
|
||||
cssClass: "icon-generator-events",
|
||||
creatable: true,
|
||||
initialize: function (object) {
|
||||
object.telemetry = {
|
||||
duration: 5
|
||||
};
|
||||
}
|
||||
});
|
||||
openmct.telemetry.addProvider(new EventTelmetryProvider());
|
||||
openmct.telemetry.addProvider(new EventMetadataProvider());
|
||||
|
||||
};
|
||||
return function install(openmct) {
|
||||
openmct.types.addType('eventGenerator', {
|
||||
name: 'Event Message Generator',
|
||||
description:
|
||||
'For development use. Creates sample event message data that mimics a live data stream.',
|
||||
cssClass: 'icon-generator-events',
|
||||
creatable: true,
|
||||
initialize: function (object) {
|
||||
object.telemetry = {
|
||||
duration: 5
|
||||
};
|
||||
}
|
||||
});
|
||||
openmct.telemetry.addProvider(new EventTelmetryProvider());
|
||||
openmct.telemetry.addProvider(new EventMetadataProvider());
|
||||
};
|
||||
}
|
||||
|
@ -20,57 +20,54 @@
|
||||
* at runtime from the About dialog for additional information.
|
||||
*****************************************************************************/
|
||||
import EventMessageGeneratorPlugin from './plugin.js';
|
||||
import {
|
||||
createOpenMct,
|
||||
resetApplicationState
|
||||
} from '../../src/utils/testing';
|
||||
import { createOpenMct, resetApplicationState } from '../../src/utils/testing';
|
||||
|
||||
describe('the plugin', () => {
|
||||
let openmct;
|
||||
const mockDomainObject = {
|
||||
identifier: {
|
||||
namespace: '',
|
||||
key: 'some-value'
|
||||
},
|
||||
telemetry: {
|
||||
duration: 0
|
||||
},
|
||||
options: {},
|
||||
type: 'eventGenerator'
|
||||
};
|
||||
let openmct;
|
||||
const mockDomainObject = {
|
||||
identifier: {
|
||||
namespace: '',
|
||||
key: 'some-value'
|
||||
},
|
||||
telemetry: {
|
||||
duration: 0
|
||||
},
|
||||
options: {},
|
||||
type: 'eventGenerator'
|
||||
};
|
||||
|
||||
beforeEach((done) => {
|
||||
const options = {};
|
||||
openmct = createOpenMct();
|
||||
openmct.install(new EventMessageGeneratorPlugin(options));
|
||||
openmct.on('start', done);
|
||||
openmct.startHeadless();
|
||||
beforeEach((done) => {
|
||||
const options = {};
|
||||
openmct = createOpenMct();
|
||||
openmct.install(new EventMessageGeneratorPlugin(options));
|
||||
openmct.on('start', done);
|
||||
openmct.startHeadless();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await resetApplicationState(openmct);
|
||||
});
|
||||
|
||||
describe('the plugin', () => {
|
||||
it('supports subscription', (done) => {
|
||||
const unsubscribe = openmct.telemetry.subscribe(mockDomainObject, (telemetry) => {
|
||||
expect(telemetry).not.toEqual(null);
|
||||
expect(telemetry.message).toContain('CC: Eagle, Houston');
|
||||
expect(unsubscribe).not.toEqual(null);
|
||||
unsubscribe();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await resetApplicationState(openmct);
|
||||
it('supports requests without start/end defined', async () => {
|
||||
const telemetry = await openmct.telemetry.request(mockDomainObject);
|
||||
expect(telemetry[0].message).toContain('CC: Eagle, Houston');
|
||||
});
|
||||
|
||||
describe('the plugin', () => {
|
||||
it("supports subscription", (done) => {
|
||||
const unsubscribe = openmct.telemetry.subscribe(mockDomainObject, (telemetry) => {
|
||||
expect(telemetry).not.toEqual(null);
|
||||
expect(telemetry.message).toContain('CC: Eagle, Houston');
|
||||
expect(unsubscribe).not.toEqual(null);
|
||||
unsubscribe();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it("supports requests without start/end defined", async () => {
|
||||
const telemetry = await openmct.telemetry.request(mockDomainObject);
|
||||
expect(telemetry[0].message).toContain('CC: Eagle, Houston');
|
||||
});
|
||||
|
||||
it("supports requests with arbitrary start time in the past", async () => {
|
||||
mockDomainObject.options.start = 100000000000; // Mar 03 1973
|
||||
const telemetry = await openmct.telemetry.request(mockDomainObject);
|
||||
expect(telemetry[0].message).toContain('CC: Eagle, Houston');
|
||||
});
|
||||
it('supports requests with arbitrary start time in the past', async () => {
|
||||
mockDomainObject.options.start = 100000000000; // Mar 03 1973
|
||||
const telemetry = await openmct.telemetry.request(mockDomainObject);
|
||||
expect(telemetry[0].message).toContain('CC: Eagle, Houston');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,58 +1,58 @@
|
||||
[
|
||||
"CC: Eagle, Houston. You're GO for landing. Over.",
|
||||
"LMP: Roger. Understand. GO for landing. 3000 feet. PROGRAM ALARM.",
|
||||
"CC: Copy.",
|
||||
"LMP: 1201",
|
||||
"CDR: 1201.",
|
||||
"CC: Roger. 1201 alarm. We're GO. Same type. We're GO.",
|
||||
"LMP: 2000 feet. 2000 feet, Into the AGS, 47 degrees.",
|
||||
"CC: Roger.",
|
||||
"LMP: 47 degrees.",
|
||||
"CC: Eagle, looking great. You're GO.",
|
||||
"CC: Roger. 1202. We copy it.",
|
||||
"O1: LMP 35 degrees. 35 degrees. 750. Coming down to 23.fl",
|
||||
"LMP: 700 feet, 21 down, 33 degrees.",
|
||||
"LMP: 600 feet, down at 19.",
|
||||
"LMP: 540 feet, down at - 30. Down at 15.",
|
||||
"LMP: At 400 feet, down at 9.",
|
||||
"LMP: ...forward.",
|
||||
"LMP: 350 feet, down at 4.",
|
||||
"LMP: 30, ... one-half down.",
|
||||
"LMP: We're pegged on horizontal velocity.",
|
||||
"LMP: 300 feet, down 3 1/2, 47 forward.",
|
||||
"LMP: ... up.",
|
||||
"LMP: On 1 a minute, 1 1/2 down.",
|
||||
"CDR: 70.",
|
||||
"LMP: Watch your shadow out there.",
|
||||
"LMP: 50, down at 2 1/2, 19 forward.",
|
||||
"LMP: Altitude-velocity light.",
|
||||
"LMP: 3 1/2 down s 220 feet, 13 forward.",
|
||||
"LMP: 1t forward. Coming down nicely.",
|
||||
"LMP: 200 feet, 4 1/2 down.",
|
||||
"LMP: 5 1/2 down.",
|
||||
"LMP: 160, 6 - 6 1/2 down.",
|
||||
"LMP: 5 1/2 down, 9 forward. That's good.",
|
||||
"LMP: 120 feet.",
|
||||
"LMP: 100 feet, 3 1/2 down, 9 forward. Five percent.",
|
||||
"LMP: ...",
|
||||
"LMP: Okay. 75 feet. There's looking good. Down a half, 6 forward.",
|
||||
"CC: 60 seconds.",
|
||||
"LMP: Lights on. ...",
|
||||
"LMP: Down 2 1/2. Forward. Forward. Good.",
|
||||
"LMP: 40 feet, down 2 1/2. Kicking up some dust.",
|
||||
"LMP: 30 feet, 2 1/2 down. Faint shadow.",
|
||||
"LMP: 4 forward. 4 forward. Drifting to the right a little. Okay. Down a half.",
|
||||
"CC: 30 seconds.",
|
||||
"CDR: Forward drift?",
|
||||
"LMP: Yes.",
|
||||
"LMP: Okay.",
|
||||
"LMP: CONTACT LIGHT.",
|
||||
"LMP: Okay. ENGINE STOP.",
|
||||
"LMP: ACA - out of DETENT.",
|
||||
"CDR: Out of DETENT.",
|
||||
"LMP: MODE CONTROL - both AUTO. DESCENT ENGINE COMMAND OVERRIDE - OFF. ENGINE ARM - OFF.",
|
||||
"LMP: 413 is in.",
|
||||
"CC: We copy you down, Eagle.",
|
||||
"CDR: Houston, Tranquility Base here.",
|
||||
"CDR: THE EAGLE HAS LANDED."
|
||||
]
|
||||
"CC: Eagle, Houston. You're GO for landing. Over.",
|
||||
"LMP: Roger. Understand. GO for landing. 3000 feet. PROGRAM ALARM.",
|
||||
"CC: Copy.",
|
||||
"LMP: 1201",
|
||||
"CDR: 1201.",
|
||||
"CC: Roger. 1201 alarm. We're GO. Same type. We're GO.",
|
||||
"LMP: 2000 feet. 2000 feet, Into the AGS, 47 degrees.",
|
||||
"CC: Roger.",
|
||||
"LMP: 47 degrees.",
|
||||
"CC: Eagle, looking great. You're GO.",
|
||||
"CC: Roger. 1202. We copy it.",
|
||||
"O1: LMP 35 degrees. 35 degrees. 750. Coming down to 23.fl",
|
||||
"LMP: 700 feet, 21 down, 33 degrees.",
|
||||
"LMP: 600 feet, down at 19.",
|
||||
"LMP: 540 feet, down at - 30. Down at 15.",
|
||||
"LMP: At 400 feet, down at 9.",
|
||||
"LMP: ...forward.",
|
||||
"LMP: 350 feet, down at 4.",
|
||||
"LMP: 30, ... one-half down.",
|
||||
"LMP: We're pegged on horizontal velocity.",
|
||||
"LMP: 300 feet, down 3 1/2, 47 forward.",
|
||||
"LMP: ... up.",
|
||||
"LMP: On 1 a minute, 1 1/2 down.",
|
||||
"CDR: 70.",
|
||||
"LMP: Watch your shadow out there.",
|
||||
"LMP: 50, down at 2 1/2, 19 forward.",
|
||||
"LMP: Altitude-velocity light.",
|
||||
"LMP: 3 1/2 down s 220 feet, 13 forward.",
|
||||
"LMP: 1t forward. Coming down nicely.",
|
||||
"LMP: 200 feet, 4 1/2 down.",
|
||||
"LMP: 5 1/2 down.",
|
||||
"LMP: 160, 6 - 6 1/2 down.",
|
||||
"LMP: 5 1/2 down, 9 forward. That's good.",
|
||||
"LMP: 120 feet.",
|
||||
"LMP: 100 feet, 3 1/2 down, 9 forward. Five percent.",
|
||||
"LMP: ...",
|
||||
"LMP: Okay. 75 feet. There's looking good. Down a half, 6 forward.",
|
||||
"CC: 60 seconds.",
|
||||
"LMP: Lights on. ...",
|
||||
"LMP: Down 2 1/2. Forward. Forward. Good.",
|
||||
"LMP: 40 feet, down 2 1/2. Kicking up some dust.",
|
||||
"LMP: 30 feet, 2 1/2 down. Faint shadow.",
|
||||
"LMP: 4 forward. 4 forward. Drifting to the right a little. Okay. Down a half.",
|
||||
"CC: 30 seconds.",
|
||||
"CDR: Forward drift?",
|
||||
"LMP: Yes.",
|
||||
"LMP: Okay.",
|
||||
"LMP: CONTACT LIGHT.",
|
||||
"LMP: Okay. ENGINE STOP.",
|
||||
"LMP: ACA - out of DETENT.",
|
||||
"CDR: Out of DETENT.",
|
||||
"LMP: MODE CONTROL - both AUTO. DESCENT ENGINE COMMAND OVERRIDE - OFF. ENGINE ARM - OFF.",
|
||||
"LMP: 413 is in.",
|
||||
"CC: We copy you down, Eagle.",
|
||||
"CDR: Houston, Tranquility Base here.",
|
||||
"CDR: THE EAGLE HAS LANDED."
|
||||
]
|
||||
|
Reference in New Issue
Block a user