Skip to content

Commit 3e0e76a

Browse files
feat: add offsets up to 0x28F0 (#4)
1 parent 43765df commit 3e0e76a

File tree

101 files changed

+15250
-3576
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+15250
-3576
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# @fsuipc/api - FSUIPC Node API
22

3+
Tooling to use FSUIPC external application interface, with nodeJS.
4+
35
[![Coverage Status](https://coveralls.io/repos/github/fsuipc-node/api/badge.svg?branch=master)](https://coveralls.io/github/fsuipc-node/api?branch=master)
6+
[![npm version](https://badge.fury.io/js/%40fsuipc%2Fapi.svg)](https://badge.fury.io/js/%40fsuipc%2Fapi)
47
![branch-master](https://github.com/fsuipc-node/api/workflows/branch-master/badge.svg?branch=master)
58

6-
Tooling to use FSUIPC external application interface, with nodeJS.
7-
89
## Disclamer
910

1011
This API is a wrapper around [fsuipc-node adapter by koesie10](https://github.com/koesie10/fsuipc-node) meant to create a simple API around all available fsuipc offsets.

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@fsuipc/api",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"author": {
55
"name": "FSUIPC-Node Opensource Team",
66
"url": "https://github.com/fsuipc-node"
@@ -39,16 +39,16 @@
3939
},
4040
"devDependencies": {
4141
"@exalif/tscpaths": "0.1.3",
42-
"@types/jest": "24.0.25",
43-
"@types/node": "13.1.6",
42+
"@types/jest": "25.1.1",
43+
"@types/node": "13.5.3",
4444
"conventional-changelog-cli": "2.0.31",
45-
"cross-env": "6.0.3",
46-
"jest": "24.9.0",
45+
"cross-env": "7.0.0",
46+
"jest": "25.1.0",
4747
"nodemon": "2.0.2",
48-
"ts-jest": "24.3.0",
49-
"ts-node": "8.6.1",
48+
"ts-jest": "25.1.0",
49+
"ts-node": "8.6.2",
5050
"tsconfig-paths": "3.9.0",
51-
"tslint": "5.20.1",
52-
"typescript": "3.7.4"
51+
"tslint": "6.0.0",
52+
"typescript": "3.7.5"
5353
}
5454
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { CloudType } from '@shared/weather/cloud-type';
2+
3+
export const cloudType = (value: number): CloudType => {
4+
switch (value) {
5+
case 1:
6+
return CloudType.CIRRUS;
7+
case 8:
8+
return CloudType.STRATUS;
9+
case 9:
10+
return CloudType.CUMULUS;
11+
default:
12+
return CloudType.USER;
13+
}
14+
};

src/lib/convert/mappings/engine-type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,7 @@ export const engineType = (value: number): EngineType => {
1414
return EngineType.ROCKET;
1515
case 5:
1616
return EngineType.TURBOPROP;
17+
default:
18+
return null;
1719
}
1820
};

src/lib/convert/mappings/fuel-tank.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { FuelTank } from '@shared/plane/fuel-tank';
2+
3+
export const fuelTank = (value: number): FuelTank => {
4+
switch (value) {
5+
case 0:
6+
return FuelTank.NONE;
7+
case 1:
8+
return FuelTank.ALL;
9+
case 2:
10+
return FuelTank.LEFT;
11+
case 3:
12+
return FuelTank.RIGHT;
13+
case 4:
14+
return FuelTank.LEFT_AUX;
15+
case 5:
16+
return FuelTank.RIGHT_AUX;
17+
case 6:
18+
return FuelTank.CENTER;
19+
case 7:
20+
return FuelTank.CENTER2;
21+
case 8:
22+
return FuelTank.CENTER3;
23+
case 9:
24+
return FuelTank.EXT1;
25+
case 10:
26+
return FuelTank.EXT2;
27+
case 11:
28+
return FuelTank.RIGHT_TIP;
29+
case 12:
30+
return FuelTank.LEFT_TIP;
31+
case 13:
32+
return FuelTank.CROSS_FEED;
33+
case 14:
34+
return FuelTank.CROSS_FEED_LTR;
35+
case 15:
36+
return FuelTank.CROSS_FEED_RTL;
37+
case 16:
38+
return FuelTank.CROSS_FEED_BOTH;
39+
case 17:
40+
return FuelTank.EXTERNAL;
41+
case 18:
42+
return FuelTank.ISOLATE;
43+
case 19:
44+
return FuelTank.LEFT_MAIN;
45+
case 20:
46+
return FuelTank.RIGHT_MAIN;
47+
default:
48+
return null;
49+
}
50+
};

src/lib/convert/mappings/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { lightsMapping } from './lights';
22
import { runwaySurfaceCondition } from './runway-surface-condition';
33
import { precipitationType } from './precipitation-type';
4+
import { cloudType } from './cloud-type';
45
import { seasons } from './seasons';
56
import { ftsecToKt, ktToFtsec } from './units';
67
import { engineType } from './engine-type';
@@ -10,6 +11,7 @@ import { spoilersControl } from './spoilers-control';
1011
import { vorToFrom } from './vor-to-from';
1112
import { navBackCourseFlags } from './nav-back-course-flags';
1213
import { navCapabilities } from './nav-capabilities';
14+
import { fuelTank } from './fuel-tank';
1315

1416
export const MAPPINGS: { [key: string]: (_: any) => any } = {
1517
lightsMapping,
@@ -18,6 +20,7 @@ export const MAPPINGS: { [key: string]: (_: any) => any } = {
1820
// weather
1921
precipitationType,
2022
seasons,
23+
cloudType,
2124

2225
// units
2326
ftsecToKt,
@@ -27,6 +30,7 @@ export const MAPPINGS: { [key: string]: (_: any) => any } = {
2730
engineType,
2831
appliedBrakes,
2932
spoilersControl,
33+
fuelTank,
3034

3135
// environment
3236
nearestAirportsIds,
@@ -48,3 +52,4 @@ export * from './spoilers-control';
4852
export * from './vor-to-from';
4953
export * from './nav-back-course-flags';
5054
export * from './nav-capabilities';
55+
export * from './fuel-tank';

src/lib/convert/mappings/precipitation-type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ export const precipitationType = (value: number): PrecipitationType => {
88
return PrecipitationType.RAIN;
99
case 2:
1010
return PrecipitationType.SNOW;
11+
default:
12+
return null;
1113
}
1214
};

src/lib/convert/mappings/runway-surface-condition.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ export const runwaySurfaceCondition = (value: number): SurfaceCondition => {
1010
return SurfaceCondition.ICY;
1111
case 3:
1212
return SurfaceCondition.SNOW;
13+
default:
14+
return null;
1315
}
1416
};

src/lib/convert/mappings/seasons.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@ export const seasons = (value: number): Season => {
1010
return Season.SUMMER;
1111
case 3:
1212
return Season.AUTUMN;
13+
default:
14+
return null;
1315
}
1416
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { TimeOfDay } from '@shared/environment/time-of-day';
2+
3+
export const timeOfDay = (value: number): TimeOfDay => {
4+
switch (value) {
5+
case 1:
6+
return TimeOfDay.DAY;
7+
case 2:
8+
return TimeOfDay.DUSK_DAWN;
9+
case 3:
10+
return TimeOfDay.NIGHT;
11+
default:
12+
return null;
13+
}
14+
};

src/lib/convert/mappings/vor-to-from.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@ export const vorToFrom = (value: number): VorToFrom => {
88
return VorToFrom.TO;
99
case 2:
1010
return VorToFrom.FROM;
11+
default:
12+
return null;
1113
}
1214
};

src/lib/offsets/environment/environment.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,12 @@ export const environment: OffsetList = {
206206
length: 4,
207207
permission: 'r',
208208
}),
209+
timeOfDay: new Offset({
210+
value: 0x115E,
211+
name: 'timeOfDay',
212+
category: OffsetCategory.ENVIRONMENT,
213+
description: 'time of day',
214+
type: Type.Byte,
215+
permission: 'r',
216+
}),
209217
};

src/lib/offsets/environment/weather.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { Type } from 'fsuipc';
33
import { OffsetCategory } from '@shared/offset-category';
44
import { OffsetList } from '@shared/offset-list';
55
import { Offset } from '@shared/offset';
6+
import { weatherAtAircraft } from './weather/at-aircraft';
7+
import { weatherSettings } from './weather/settings';
68

79
export const weather: OffsetList = {
810
metarStationAltitude: new Offset({
@@ -237,4 +239,40 @@ export const weather: OffsetList = {
237239
type: Type.UInt16,
238240
permission: 'r',
239241
}),
242+
windGust: new Offset({
243+
value: 0xE94,
244+
name: 'windGust',
245+
category: OffsetCategory.WEATHER,
246+
description: 'wind gust at aircraft - kt',
247+
type: Type.UInt16,
248+
permission: 'r',
249+
}),
250+
windDirectionalVariation: new Offset({
251+
value: 0xE96,
252+
name: 'windDirectionalVariation',
253+
category: OffsetCategory.WEATHER,
254+
description: 'wind directional variation at aircraft - TRUE degrees',
255+
convert: '+({VAL} * 360 / 65536).toFixed(2)',
256+
type: Type.UInt16,
257+
permission: 'r',
258+
}),
259+
windTurbulence: new Offset({
260+
value: 0xE98,
261+
name: 'windTurbulence',
262+
category: OffsetCategory.WEATHER,
263+
description: 'wind turbulence at aircraft atltitude - 0-255',
264+
type: Type.UInt16,
265+
permission: 'r',
266+
}),
267+
totalAirTemperature: new Offset({
268+
value: 0x11D0,
269+
name: 'totalAirTemperature',
270+
category: OffsetCategory.WEATHER,
271+
description: 'total air temperature',
272+
convert: 'Math.round({VAL} / 256)',
273+
type: Type.Int16,
274+
permission: 'r',
275+
}),
276+
...weatherAtAircraft,
277+
...weatherSettings,
240278
};

0 commit comments

Comments
 (0)