Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add offsets up to 0x28F0 #4

Merged
merged 21 commits into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# @fsuipc/api - FSUIPC Node API

Tooling to use FSUIPC external application interface, with nodeJS.

[![Coverage Status](https://coveralls.io/repos/github/fsuipc-node/api/badge.svg?branch=master)](https://coveralls.io/github/fsuipc-node/api?branch=master)
[![npm version](https://badge.fury.io/js/%40fsuipc%2Fapi.svg)](https://badge.fury.io/js/%40fsuipc%2Fapi)
![branch-master](https://github.com/fsuipc-node/api/workflows/branch-master/badge.svg?branch=master)

Tooling to use FSUIPC external application interface, with nodeJS.

## Disclamer

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.
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fsuipc/api",
"version": "0.3.0",
"version": "0.4.0",
"author": {
"name": "FSUIPC-Node Opensource Team",
"url": "https://github.com/fsuipc-node"
Expand Down Expand Up @@ -39,16 +39,16 @@
},
"devDependencies": {
"@exalif/tscpaths": "0.1.3",
"@types/jest": "24.0.25",
"@types/node": "13.1.6",
"@types/jest": "25.1.1",
"@types/node": "13.5.3",
"conventional-changelog-cli": "2.0.31",
"cross-env": "6.0.3",
"jest": "24.9.0",
"cross-env": "7.0.0",
"jest": "25.1.0",
"nodemon": "2.0.2",
"ts-jest": "24.3.0",
"ts-node": "8.6.1",
"ts-jest": "25.1.0",
"ts-node": "8.6.2",
"tsconfig-paths": "3.9.0",
"tslint": "5.20.1",
"typescript": "3.7.4"
"tslint": "6.0.0",
"typescript": "3.7.5"
}
}
14 changes: 14 additions & 0 deletions src/lib/convert/mappings/cloud-type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { CloudType } from '@shared/weather/cloud-type';

export const cloudType = (value: number): CloudType => {
switch (value) {
case 1:
return CloudType.CIRRUS;
case 8:
return CloudType.STRATUS;
case 9:
return CloudType.CUMULUS;
default:
return CloudType.USER;
}
};
2 changes: 2 additions & 0 deletions src/lib/convert/mappings/engine-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,7 @@ export const engineType = (value: number): EngineType => {
return EngineType.ROCKET;
case 5:
return EngineType.TURBOPROP;
default:
return null;
}
};
50 changes: 50 additions & 0 deletions src/lib/convert/mappings/fuel-tank.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { FuelTank } from '@shared/plane/fuel-tank';

export const fuelTank = (value: number): FuelTank => {
switch (value) {
case 0:
return FuelTank.NONE;
case 1:
return FuelTank.ALL;
case 2:
return FuelTank.LEFT;
case 3:
return FuelTank.RIGHT;
case 4:
return FuelTank.LEFT_AUX;
case 5:
return FuelTank.RIGHT_AUX;
case 6:
return FuelTank.CENTER;
case 7:
return FuelTank.CENTER2;
case 8:
return FuelTank.CENTER3;
case 9:
return FuelTank.EXT1;
case 10:
return FuelTank.EXT2;
case 11:
return FuelTank.RIGHT_TIP;
case 12:
return FuelTank.LEFT_TIP;
case 13:
return FuelTank.CROSS_FEED;
case 14:
return FuelTank.CROSS_FEED_LTR;
case 15:
return FuelTank.CROSS_FEED_RTL;
case 16:
return FuelTank.CROSS_FEED_BOTH;
case 17:
return FuelTank.EXTERNAL;
case 18:
return FuelTank.ISOLATE;
case 19:
return FuelTank.LEFT_MAIN;
case 20:
return FuelTank.RIGHT_MAIN;
default:
return null;
}
};
5 changes: 5 additions & 0 deletions src/lib/convert/mappings/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { lightsMapping } from './lights';
import { runwaySurfaceCondition } from './runway-surface-condition';
import { precipitationType } from './precipitation-type';
import { cloudType } from './cloud-type';
import { seasons } from './seasons';
import { ftsecToKt, ktToFtsec } from './units';
import { engineType } from './engine-type';
Expand All @@ -10,6 +11,7 @@ import { spoilersControl } from './spoilers-control';
import { vorToFrom } from './vor-to-from';
import { navBackCourseFlags } from './nav-back-course-flags';
import { navCapabilities } from './nav-capabilities';
import { fuelTank } from './fuel-tank';

export const MAPPINGS: { [key: string]: (_: any) => any } = {
lightsMapping,
Expand All @@ -18,6 +20,7 @@ export const MAPPINGS: { [key: string]: (_: any) => any } = {
// weather
precipitationType,
seasons,
cloudType,

// units
ftsecToKt,
Expand All @@ -27,6 +30,7 @@ export const MAPPINGS: { [key: string]: (_: any) => any } = {
engineType,
appliedBrakes,
spoilersControl,
fuelTank,

// environment
nearestAirportsIds,
Expand All @@ -48,3 +52,4 @@ export * from './spoilers-control';
export * from './vor-to-from';
export * from './nav-back-course-flags';
export * from './nav-capabilities';
export * from './fuel-tank';
2 changes: 2 additions & 0 deletions src/lib/convert/mappings/precipitation-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ export const precipitationType = (value: number): PrecipitationType => {
return PrecipitationType.RAIN;
case 2:
return PrecipitationType.SNOW;
default:
return null;
}
};
2 changes: 2 additions & 0 deletions src/lib/convert/mappings/runway-surface-condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ export const runwaySurfaceCondition = (value: number): SurfaceCondition => {
return SurfaceCondition.ICY;
case 3:
return SurfaceCondition.SNOW;
default:
return null;
}
};
2 changes: 2 additions & 0 deletions src/lib/convert/mappings/seasons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ export const seasons = (value: number): Season => {
return Season.SUMMER;
case 3:
return Season.AUTUMN;
default:
return null;
}
};
14 changes: 14 additions & 0 deletions src/lib/convert/mappings/time-of-day.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { TimeOfDay } from '@shared/environment/time-of-day';

export const timeOfDay = (value: number): TimeOfDay => {
switch (value) {
case 1:
return TimeOfDay.DAY;
case 2:
return TimeOfDay.DUSK_DAWN;
case 3:
return TimeOfDay.NIGHT;
default:
return null;
}
blackholegalaxy marked this conversation as resolved.
Show resolved Hide resolved
};
2 changes: 2 additions & 0 deletions src/lib/convert/mappings/vor-to-from.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@ export const vorToFrom = (value: number): VorToFrom => {
return VorToFrom.TO;
case 2:
return VorToFrom.FROM;
default:
return null;
}
};
8 changes: 8 additions & 0 deletions src/lib/offsets/environment/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,12 @@ export const environment: OffsetList = {
length: 4,
permission: 'r',
}),
timeOfDay: new Offset({
value: 0x115E,
name: 'timeOfDay',
category: OffsetCategory.ENVIRONMENT,
description: 'time of day',
type: Type.Byte,
permission: 'r',
}),
};
38 changes: 38 additions & 0 deletions src/lib/offsets/environment/weather.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { Type } from 'fsuipc';
import { OffsetCategory } from '@shared/offset-category';
import { OffsetList } from '@shared/offset-list';
import { Offset } from '@shared/offset';
import { weatherAtAircraft } from './weather/at-aircraft';
import { weatherSettings } from './weather/settings';

export const weather: OffsetList = {
metarStationAltitude: new Offset({
Expand Down Expand Up @@ -237,4 +239,40 @@ export const weather: OffsetList = {
type: Type.UInt16,
permission: 'r',
}),
windGust: new Offset({
value: 0xE94,
name: 'windGust',
category: OffsetCategory.WEATHER,
description: 'wind gust at aircraft - kt',
type: Type.UInt16,
permission: 'r',
}),
windDirectionalVariation: new Offset({
value: 0xE96,
name: 'windDirectionalVariation',
category: OffsetCategory.WEATHER,
description: 'wind directional variation at aircraft - TRUE degrees',
convert: '+({VAL} * 360 / 65536).toFixed(2)',
type: Type.UInt16,
permission: 'r',
}),
windTurbulence: new Offset({
value: 0xE98,
name: 'windTurbulence',
category: OffsetCategory.WEATHER,
description: 'wind turbulence at aircraft atltitude - 0-255',
type: Type.UInt16,
permission: 'r',
}),
totalAirTemperature: new Offset({
value: 0x11D0,
name: 'totalAirTemperature',
category: OffsetCategory.WEATHER,
description: 'total air temperature',
convert: 'Math.round({VAL} / 256)',
type: Type.Int16,
permission: 'r',
}),
...weatherAtAircraft,
blackholegalaxy marked this conversation as resolved.
Show resolved Hide resolved
...weatherSettings,
};
Loading