forked from Ponjimon/extplane-ts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.js
32 lines (30 loc) · 930 Bytes
/
example.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
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { ExtPlane } = require('./dist');
const extPlane = new ExtPlane({
host: '192.168.1.100',
port: 51000,
broadcast: true,
debug: true,
});
extPlane
.interval(1000)
.observe([
'sim/flightmodel/position/latitude',
'sim/flightmodel/position/longitude',
'sim/time/framerate_period',
])
.subscribe({
next: ([dataRef, value]) => {
switch (dataRef) {
case 'sim/flightmodel/position/latitude':
console.warn('Lat', value);
break;
case 'sim/flightmodel/position/longitude':
console.warn('Long', value);
break;
case 'sim/time/framerate_period':
console.warn('FPS', Math.floor(1 / value));
break;
}
},
});