Skip to content

Commit

Permalink
feat: add engine offsets (#1)
Browse files Browse the repository at this point in the history
* feat: add engine offsets
* refact: move helicopter specific engine data to proper offset
  • Loading branch information
blackholegalaxy authored Jan 24, 2020
1 parent 22b5071 commit 546e8e1
Show file tree
Hide file tree
Showing 34 changed files with 5,266 additions and 16 deletions.
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.1.0",
"version": "0.2.0",
"author": {
"name": "FSUIPC-Node Opensource Team",
"url": "https://github.com/fsuipc-node"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/convert/apply-conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const applyConversion = (offset: Offset, rawOffsetValue: RawOffsetValue):
}

const convertExpression: string = offset.convert.replace(
'{VAL}',
new RegExp(/{VAL}/g),
Array.isArray(rawOffsetValue)
? `${JSON.stringify(rawOffsetValue)}`
: rawOffsetValue.toString()
Expand Down
9 changes: 9 additions & 0 deletions src/lib/offsets/plane/engines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ import { OffsetCategory } from '@shared/offset-category';
import { OffsetList } from '@shared/offset-list';
import { Offset } from '@shared/offset';

import { engine1 } from './engines/engine1';
import { engine2 } from './engines/engine2';
import { engine3 } from './engines/engine3';
import { engine4 } from './engines/engine4';

export const engines: OffsetList = {
engineType: new Offset({
value: 0x609,
Expand Down Expand Up @@ -42,4 +47,8 @@ export const engines: OffsetList = {
length: 1,
permission: 'rw',
}),
...engine1,
...engine2,
...engine3,
...engine4,
};
261 changes: 261 additions & 0 deletions src/lib/offsets/plane/engines/engine1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
import { Type } from 'fsuipc';

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

export const engine1: OffsetList = {
engine1ThrottleLever: new Offset({
value: 0x88C,
name: 'engine1ThrottleLever',
category: OffsetCategory.ENGINE,
description: 'engine 1 throttle lever - percent - negative = reverse',
convert: 'Math.round({VAL} < 0 ? {VAL} / 4096 * 100 : {VAL} / 16384 * 100)',
type: Type.Int16,
permission: 'r',
}),
engine1PropLever: new Offset({
value: 0x88E,
name: 'engine1PropLever',
category: OffsetCategory.ENGINE,
description: 'engine 1 prop lever - percent - negative = reverse',
convert: 'Math.round({VAL} < 0 ? {VAL} / 4096 * 100 : {VAL} / 16384 * 100)',
type: Type.Int16,
permission: 'rw',
}),
engine1MixtureLever: new Offset({
value: 0x890,
name: 'engine1MixtureLever',
category: OffsetCategory.ENGINE,
description: 'engine 1 prop lever - percent',
convert: '{VAL} / 16384 * 100',
type: Type.UInt16,
permission: 'rw',
}),
engine1StarterSwitchPosition: new Offset({
value: 0x892,
name: 'engine1StarterSwitchPosition',
category: OffsetCategory.ENGINE,
description: 'engine1 start switch position - JET: 0=off 1=start 2=gen/alt - PROP: 0=off 1=right 2=left 3=both 4=start',
type: Type.UInt16,
permission: 'rw',
}),
engine1Firing: new Offset({
value: 0x894,
name: 'engine1Firing',
category: OffsetCategory.ENGINE,
description: 'engine 1 combustion',
convert: '!!{VAL}',
type: Type.UInt16,
permission: 'r',
}),
engine1N2: new Offset({
value: 0x896,
name: 'engine1N2',
category: OffsetCategory.ENGINE,
description: 'engine 1 N2 - also helo RPM %',
convert: '{VAL} / 16384 * 100',
type: Type.UInt16,
permission: 'rw',
}),
engine1N1: new Offset({
value: 0x898,
name: 'engine1N1',
category: OffsetCategory.ENGINE,
description: 'engine 1 N1 - also helo RPM %',
convert: '{VAL} / 16384 * 100',
type: Type.Int16,
permission: 'rw',
}),
engine1PropRPM: new Offset({
value: 0x898,
name: 'engine1PropRPM',
category: OffsetCategory.ENGINE,
description: 'derive RPM by multiplying by - negative = counter-rotating propeller',
convert: '{VAL} / 16384 / 65536',
type: Type.Int16,
permission: 'rw',
}),
engine1ThrottleLeverControl: new Offset({
value: 0x89A,
name: 'engine1ThrottleLeverControl',
category: OffsetCategory.ENGINE,
description: 'engine1 throttle lever control - -4096 to +16384',
type: Type.Int16,
permission: 'rw',
}),
engine1FuelFlowLbHourSSL: new Offset({
value: 0x8A0,
name: 'engine1FuelFlowLbHourSSL',
category: OffsetCategory.ENGINE,
description: 'engine1 fuel flow (lb per hour, sea level)',
convert: '{VAL} / 128',
type: Type.UInt16,
permission: 'r',
}),
engine1AntiIce: new Offset({
value: 0x8B2,
name: 'engine1AntiIce',
category: OffsetCategory.ENGINE,
description: 'engine1 anti-ice/carb heat active',
convert: '!!{VAL}',
type: Type.UInt16,
permission: 'r',
}),
engine1OilTemp: new Offset({
value: 0x8B8,
name: 'engine1OilTemp',
category: OffsetCategory.ENGINE,
description: 'engine1 oil temp - celsius',
convert: 'Math.round({VAL} * 140 / 16384)',
type: Type.UInt16,
permission: 'r',
}),
engine1OilPres: new Offset({
value: 0x8BA,
name: 'engine1OilPres',
category: OffsetCategory.ENGINE,
description: 'engine1 oil pressure - PSI',
convert: 'Math.round({VAL} * 55 / 16384)',
type: Type.UInt16,
permission: 'r',
}),
engine1PressureRatio: new Offset({
value: 0x8BC,
name: 'engine1PressureRatio',
category: OffsetCategory.ENGINE,
description: 'engine1 pressure ratio',
convert: '{VAL} * 1.6 / 16384',
type: Type.UInt16,
permission: 'r',
}),
engine1EGT: new Offset({
value: 0x8BE,
name: 'engine1EGT',
category: OffsetCategory.ENGINE,
description: 'engine1 exhaust gas temperature - Trust only on jet engine - celsius',
convert: 'Math.round({VAL} * 860 / 16384)',
type: Type.UInt16,
permission: 'r',
}),
engine1MP: new Offset({
value: 0x8C0,
name: 'engine1MP',
category: OffsetCategory.ENGINE,
description: 'engine1 manifold pressure - inHg',
convert: '{VAL} / 1024',
type: Type.UInt16,
permission: 'r',
}),
engine1RPMScaler: new Offset({
value: 0x8C8,
name: 'engine1RPMScaler',
category: OffsetCategory.ENGINE,
description: 'engine1 RPM Scaler - props: used to calculate RPM',
type: Type.UInt16,
permission: 'r',
}),
engine1OilQuantity: new Offset({
value: 0x8D0,
name: 'engine1OilQuantity',
category: OffsetCategory.ENGINE,
description: 'engine1 oil quantity - percent',
convert: 'Math.round({VAL} / 16384 * 100)',
type: Type.UInt32,
permission: 'r',
}),
engine1Vibration: new Offset({
value: 0x8D4,
name: 'engine1Vibration',
category: OffsetCategory.ENGINE,
description: 'engine1 vibration',
convert: 'Math.round({VAL} * 5 / 16384)',
type: Type.UInt32,
permission: 'r',
}),
engine1HydPres: new Offset({
value: 0x8D8,
name: 'engine1HydPres',
category: OffsetCategory.ENGINE,
description: 'engine1 hydraulic pressure - PSI',
convert: '{VAL} / 4',
type: Type.UInt32,
permission: 'r',
}),
engine1HydQuantity: new Offset({
value: 0x8DC,
name: 'engine1HydQuantity',
category: OffsetCategory.ENGINE,
description: 'engine1 hydraulic quantity - PSI',
convert: '{VAL} / 16384 * 100',
type: Type.UInt32,
permission: 'r',
}),
engine1CHT: new Offset({
value: 0x8E8,
name: 'engine1CHT',
category: OffsetCategory.ENGINE,
description: 'engine1 cylinder head temperature - F',
type: Type.Double,
permission: 'r',
}),
engine1ITT: new Offset({
value: 0x8F0,
name: 'engine1ITT',
category: OffsetCategory.ENGINE,
description: 'engine1 turbine temperature - C',
convert: '{VAL} / 16384',
type: Type.UInt32,
permission: 'r',
}),
engine1Torque: new Offset({
value: 0x8F4,
name: 'engine1Torque',
category: OffsetCategory.ENGINE,
description: 'engine1 torque - trust only for helo - percent',
convert: '{VAL} / 16384 * 100',
type: Type.UInt32,
permission: 'r',
}),
engine1FuelPres: new Offset({
value: 0x8F8,
name: 'engine1FuelPres',
category: OffsetCategory.ENGINE,
description: 'engine1 fuel pressure - PSI',
convert: '{VAL} / 144',
type: Type.UInt32,
permission: 'r',
}),
engine1FuelUsedSinceStart: new Offset({
value: 0x90C,
name: 'engine1FuelUsedSinceStart',
category: OffsetCategory.ENGINE,
description: 'engine1 used fuel since start - lb',
type: Type.Single,
permission: 'r',
}),
engine1FuelElapsedTime: new Offset({
value: 0x910,
name: 'engine1FuelElapsedTime',
category: OffsetCategory.ENGINE,
description: 'engine1 fuel elapsed time - h',
type: Type.Single,
permission: 'r',
}),
engine1FuelFlowLbHour: new Offset({
value: 0x918,
name: 'engine1FuelFlowLbHour',
category: OffsetCategory.ENGINE,
description: 'engine1 fuel elapsed time - lb/h',
type: Type.Double,
permission: 'r',
}),
engine1TorqueFtLb: new Offset({
value: 0x920,
name: 'engine1TorqueFtLb',
category: OffsetCategory.ENGINE,
description: 'engine1 fuel elapsed time - ft lb',
type: Type.Single,
permission: 'r',
}),
};
Loading

0 comments on commit 546e8e1

Please sign in to comment.