-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMCWSDataProductStreamProvider.js
More file actions
55 lines (46 loc) · 1.84 KB
/
MCWSDataProductStreamProvider.js
File metadata and controls
55 lines (46 loc) · 1.84 KB
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
46
47
48
49
50
51
52
53
54
55
import MCWSStreamProvider from './MCWSStreamProvider';
/**
* Provides real-time streaming DataProduct data.
* @memberof {vista/telemetry}
*/
class MCWSDataProductStreamProvider extends MCWSStreamProvider {
getUrl(domainObject) {
return domainObject.telemetry?.dataProductStreamUrl;
}
getKey() {
// We return undefined so that we can match on undefined properties.
return undefined;
}
getProperty() {
// We just want something that returns undefined so it matches the
// key above. Hacky.
return 'some_undefined_property';
}
subscribe(domainObject, callback, options) {
function wrappedCallback(datum) {
let sessionId = datum.session_id;
if (datum.unique_name !== undefined) {
let uniqueName = datum.unique_name.replace(/\.dat$/, "");
let filter = "(session_id=" + sessionId + ",unique_name=" + uniqueName + ")";
let params = "?filter=" + filter + "&filetype=";
let base_url = domainObject.telemetry.dataProductContentUrl + params;
datum.emd_url = base_url + '.emd';
datum.emd_preview = base_url + '.emd';
datum.dat_url = base_url + '.dat';
datum.txt_url = base_url.replace('DataProductContent', 'DataProductView') + '.dat';
}
callback(datum);
}
return super.subscribe(domainObject, wrappedCallback, options);
}
notifyWorker(key, value) {
if (key === 'subscribe' && this.options.realtimeProductAPIDs
&& value.mcwsVersion === 3.2) {
value.extraFilterTerms = {
apid: '(' + this.options.realtimeProductAPIDs.join(',') + ')'
};
}
super.notifyWorker(key, value);
}
}
export default MCWSDataProductStreamProvider;