Skip to content

WIP: feat: add offsets from 0x2A00 #5

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fsuipc/api",
"version": "0.4.0",
"version": "0.5.0",
"author": {
"name": "FSUIPC-Node Opensource Team",
"url": "https://github.com/fsuipc-node"
Expand Down
20 changes: 20 additions & 0 deletions src/lib/convert/mappings/autobrake.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { AutoBrake } from '@shared/plane/autobrake';

export const autoBrake = (value: number): AutoBrake => {
switch (value) {
case 0:
return AutoBrake.RTO;
case 1:
return AutoBrake.OFF;
case 2:
return AutoBrake.BRAKE1;
case 3:
return AutoBrake.BRAKE2;
case 4:
return AutoBrake.BRAKE3;
case 5:
return AutoBrake.BRAKE3;
default:
return null;
}
};
3 changes: 3 additions & 0 deletions src/lib/convert/mappings/double-percent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const doublePercentRound = (value: number): number => {
return Math.round(value * 100);
};
16 changes: 16 additions & 0 deletions src/lib/convert/mappings/fuel-transfer-mode.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { FuelTransferMode } from '@shared/plane/fuel-transfer-mode';

export const fuelTransferMode = (value: number): FuelTransferMode => {
switch (value) {
case 0:
return FuelTransferMode.NONE;
case 1:
return FuelTransferMode.AUTO;
case 2:
return FuelTransferMode.FWD;
case 3:
return FuelTransferMode.AFT;
default:
return null;
}
};
6 changes: 6 additions & 0 deletions src/lib/convert/mappings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { vorToFrom } from './vor-to-from';
import { navBackCourseFlags } from './nav-back-course-flags';
import { navCapabilities } from './nav-capabilities';
import { fuelTank } from './fuel-tank';
import { fuelTransferMode } from './fuel-transfer-mode';
import { autoBrake } from './autobrake';

export const MAPPINGS: { [key: string]: (_: any) => any } = {
lightsMapping,
Expand All @@ -31,6 +33,8 @@ export const MAPPINGS: { [key: string]: (_: any) => any } = {
appliedBrakes,
spoilersControl,
fuelTank,
fuelTransferMode,
autoBrake,

// environment
nearestAirportsIds,
Expand All @@ -53,3 +57,5 @@ export * from './vor-to-from';
export * from './nav-back-course-flags';
export * from './nav-capabilities';
export * from './fuel-tank';
export * from './fuel-transfer-mode';
export * from './autobrake';
38 changes: 38 additions & 0 deletions src/lib/offsets/environment/weather/at-aircraft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,4 +540,42 @@ export const weatherAtAircraft: OffsetList = {
type: Type.Double,
permission: 'r',
}),
crossWind: new Offset({
value: 0x2DC8,
name: 'crossWind',
category: OffsetCategory.WEATHER,
description: 'cross wind - -ve left +ve right - kt',
convert: 'ftsecToKt',
mapping: true,
type: Type.Double,
permission: 'r',
}),
upWind: new Offset({
value: 0x2DD0,
name: 'upWind',
category: OffsetCategory.WEATHER,
description: 'vertical wind - -ve under +ve over - kt',
convert: 'ftsecToKt',
mapping: true,
type: Type.Double,
permission: 'r',
}),
headWind: new Offset({
value: 0x2DD8,
name: 'headWind',
category: OffsetCategory.WEATHER,
description: 'head/tail wind - -ve head +ve tail - kt',
convert: 'ftsecToKt',
mapping: true,
type: Type.Double,
permission: 'r',
}),
visibilityAtAircraft: new Offset({
value: 0x2DF0,
name: 'visibilityAtAircraft',
category: OffsetCategory.WEATHER,
description: 'visibility at aircraft',
type: Type.Double,
permission: 'r',
}),
};
3 changes: 3 additions & 0 deletions src/lib/offsets/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { controls } from './plane/controls';
import { fuel } from './plane/fuel';
import { cockpit } from './plane/cockpit';
import { radios } from './plane/radios';
import { seaplane } from './plane/seaplane';
import { pressurisation } from './plane/pressurisation';
import { icing } from './plane/icing';
import { engines } from './plane/engines';
Expand Down Expand Up @@ -49,6 +50,7 @@ export const OFFSETS: OffsetList = {
...engines,
...autopilot,
...electric,
...seaplane,
};

export * from './airport/runway';
Expand All @@ -62,6 +64,7 @@ export * from './plane/controls';
export * from './plane/cockpit';
export * from './plane/fuel';
export * from './plane/radios';
export * from './plane/seaplane';
export * from './plane/pressurisation';
export * from './plane/icing';
export * from './plane/engines';
Expand Down
16 changes: 16 additions & 0 deletions src/lib/offsets/plane/aerodynamics.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Type } from 'fsuipc';

import { OffsetCategory } from '@shared/offset-category';
import { OffsetList } from '@shared/offset-list';
import { Offset } from '@shared/offset';

export const APU: OffsetList = {
incidenceAlpha: new Offset({
value: 0x2ED0,
name: 'incidenceAlpha',
description: 'incidence alpha (body AoA) - radians',
category: OffsetCategory.AERODYNAMICS,
type: Type.Double,
permission: 'r',
}),
};
24 changes: 24 additions & 0 deletions src/lib/offsets/plane/autopilot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,28 @@ export const autopilot: OffsetList = {
type: Type.UInt32,
permission: 'rw',
}),
apMaxBank: new Offset({
value: 0x2E04,
name: 'apMaxBank',
category: OffsetCategory.AUTOPILOT,
description: 'AP max bank - degrees',
type: Type.UInt32,
permission: 'r',
}),
apMaxSpeed: new Offset({
value: 0x2F40,
name: 'apMaxSpeed',
category: OffsetCategory.AUTOPILOT,
description: 'AP max speed',
type: Type.Double,
permission: 'r',
}),
apCruiseSpeed: new Offset({
value: 0x2F48,
name: 'apCruiseSpeed',
category: OffsetCategory.AUTOPILOT,
description: 'AP cruise speed',
type: Type.Double,
permission: 'r',
}),
};
69 changes: 69 additions & 0 deletions src/lib/offsets/plane/cockpit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,4 +287,73 @@ export const cockpit: OffsetList = {
type: Type.Int32,
permission: 'r',
}),
gyroCompassHeading: new Offset({
value: 0x2B00,
name: 'gyroCompassHeading',
category: OffsetCategory.COCKPIT,
description: 'gyro compass heading (MAG) including drift',
convert: 'Math.round({VAL})',
type: Type.Double,
permission: 'r',
}),
panelAutoFeatherArmSwitch: new Offset({
value: 0x2E88,
name: 'panelAutoFeatherArmSwitch',
category: OffsetCategory.COCKPIT,
description: 'panel auto-feather arm switch',
convert: '!!{VAL}',
type: Type.UInt32,
permission: 'rw',
}),
standbyVacuumCircuitActive: new Offset({
value: 0x2E90,
name: 'standbyVacuumCircuitActive',
category: OffsetCategory.COCKPIT,
description: 'standby vacuum circuit active',
convert: '!!{VAL}',
type: Type.UInt32,
permission: 'rw',
}),
propSyncActive: new Offset({
value: 0x2EC8,
name: 'propSyncActive',
category: OffsetCategory.COCKPIT,
description: 'prop sync active',
convert: '!!{VAL}',
type: Type.UInt32,
permission: 'rw',
}),
barberPoleMach: new Offset({
value: 0x2F50,
name: 'barberPoleMach',
category: OffsetCategory.COCKPIT,
description: 'barber pole mach',
type: Type.Double,
permission: 'r',
}),
attitudeCageButton: new Offset({
value: 0x2F68,
name: 'attitudeCageButton',
category: OffsetCategory.COCKPIT,
description: 'attitude cage button',
convert: '!!{VAL}',
type: Type.UInt32,
permission: 'rw',
}),
attitudeIndicatorPitch: new Offset({
value: 0x2F70,
name: 'attitudeIndicatorPitch',
category: OffsetCategory.COCKPIT,
description: 'attitude indicator pitch - degrees',
type: Type.Double,
permission: 'r',
}),
attitudeIndicatorBank: new Offset({
value: 0x2F78,
name: 'attitudeIndicatorBank',
category: OffsetCategory.COCKPIT,
description: 'attitude indicator bank - degrees',
type: Type.Double,
permission: 'r',
}),
};
Loading