-
Notifications
You must be signed in to change notification settings - Fork 104
/
dictionary-plugin.js
45 lines (42 loc) · 1.32 KB
/
dictionary-plugin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function getDictionary() {
return http.get('/dictionary.json')
.then(function (result) {
return result.data;
});
}
var objectProvider = {
get: function (identifier) {
return getDictionary().then(function (dictionary) {
if (identifier.key === 'spacecraft') {
return {
identifier: identifier,
name: dictionary.name,
type: 'folder',
location: 'ROOT'
};
} else {
var measurement = dictionary.measurements.filter(function (m) {
return m.key === identifier.key;
})[0];
return {
identifier: identifier,
name: measurement.name,
type: 'example.telemetry',
telemetry: {
values: measurement.values
},
location: 'example.taxonomy:spacecraft'
};
}
});
}
};
function DictionaryPlugin() {
return function install(openmct) {
openmct.objects.addRoot({
namespace: 'example.taxonomy',
key: 'spacecraft'
});
openmct.objects.addProvider('example.taxonomy', objectProvider);
}
};