From 4efa323c5588cd70648769df210ed338f68747fa Mon Sep 17 00:00:00 2001 From: blackholegalaxy Date: Sat, 8 Feb 2020 12:06:38 -0500 Subject: [PATCH 1/8] add offsets for seaplane --- package.json | 2 +- src/lib/convert/mappings/double-percent.ts | 3 + src/lib/offsets/index.ts | 3 + src/lib/offsets/plane/controls.ts | 101 +++++++++++ src/lib/offsets/plane/plane.ts | 18 -- src/lib/offsets/plane/seaplane.ts | 51 ++++++ src/shared/offset-category.ts | 1 + .../offsets/__snapshots__/offset.spec.ts.snap | 169 +++++++++++++++++- .../plane/__snapshots__/controls.spec.ts.snap | 132 ++++++++++++++ .../plane/__snapshots__/plane.spec.ts.snap | 22 --- .../plane/__snapshots__/seaplane.spec.ts.snap | 61 +++++++ tests/offsets/plane/controls.spec.ts | 2 + tests/offsets/plane/plane.spec.ts | 2 - tests/offsets/plane/seaplane.spec.ts | 27 +++ 14 files changed, 549 insertions(+), 45 deletions(-) create mode 100644 src/lib/convert/mappings/double-percent.ts create mode 100644 src/lib/offsets/plane/seaplane.ts create mode 100644 tests/offsets/plane/__snapshots__/seaplane.spec.ts.snap create mode 100644 tests/offsets/plane/seaplane.spec.ts diff --git a/package.json b/package.json index c2bea55..54a2b50 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/lib/convert/mappings/double-percent.ts b/src/lib/convert/mappings/double-percent.ts new file mode 100644 index 0000000..2e111e7 --- /dev/null +++ b/src/lib/convert/mappings/double-percent.ts @@ -0,0 +1,3 @@ +export const doublePercentRound = (value: number): number => { + return Math.round(value * 100); +}; diff --git a/src/lib/offsets/index.ts b/src/lib/offsets/index.ts index c7d786a..5a95439 100644 --- a/src/lib/offsets/index.ts +++ b/src/lib/offsets/index.ts @@ -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'; @@ -49,6 +50,7 @@ export const OFFSETS: OffsetList = { ...engines, ...autopilot, ...electric, + ...seaplane, }; export * from './airport/runway'; @@ -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'; diff --git a/src/lib/offsets/plane/controls.ts b/src/lib/offsets/plane/controls.ts index 856c124..fc2ba66 100644 --- a/src/lib/offsets/plane/controls.ts +++ b/src/lib/offsets/plane/controls.ts @@ -314,4 +314,105 @@ export const controls: OffsetList = { type: Type.Int16, permission: 'r', }), + elevon1Deflection: new Offset({ + value: 0x2A00, + name: 'elevon1Deflection', + description: 'elevon 1 deflection', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'r', + }), + elevon2Deflection: new Offset({ + value: 0x2A08, + name: 'elevon2Deflection', + description: 'elevon 2 deflection', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'r', + }), + elevon3Deflection: new Offset({ + value: 0x2A10, + name: 'elevon3Deflection', + description: 'elevon 3 deflection', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'r', + }), + elevon4Deflection: new Offset({ + value: 0x2A18, + name: 'elevon4Deflection', + description: 'elevon 4 deflection', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'r', + }), + elevon5Deflection: new Offset({ + value: 0x2A20, + name: 'elevon5Deflection', + description: 'elevon 5 deflection', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'r', + }), + elevon6Deflection: new Offset({ + value: 0x2A28, + name: 'elevon6Deflection', + description: 'elevon 6 deflection', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'r', + }), + elevon7Deflection: new Offset({ + value: 0x2A30, + name: 'elevon7Deflection', + description: 'elevon 7 deflection', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'r', + }), + elevon8Deflection: new Offset({ + value: 0x2A30, + name: 'elevon8Deflection', + description: 'elevon 8 deflection', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'r', + }), + foldingWingLeft: new Offset({ + value: 0x2A48, + name: 'foldingWingLeft', + description: 'folding right left - percent', + category: OffsetCategory.CONTROLS, + convert: 'doublePercentRound', + mapping: true, + type: Type.Double, + permission: 'r', + }), + foldingWingRight: new Offset({ + value: 0x2A50, + name: 'foldingWingRight', + description: 'folding right right - percent', + category: OffsetCategory.CONTROLS, + convert: 'doublePercentRound', + mapping: true, + type: Type.Double, + permission: 'r', + }), + canopyOpen: new Offset({ + value: 0x2A50, + name: 'canopyOpen', + description: 'canopy open', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'r', + }), + tailWheelLocked: new Offset({ + value: 0x2A90, + name: 'tailWheelLocked', + description: 'tail wheel locked', + category: OffsetCategory.CONTROLS, + convert: '!!{VAL}', + type: Type.UInt32, + permission: 'rw', + }), }; diff --git a/src/lib/offsets/plane/plane.ts b/src/lib/offsets/plane/plane.ts index 46d9138..4b1177e 100644 --- a/src/lib/offsets/plane/plane.ts +++ b/src/lib/offsets/plane/plane.ts @@ -63,24 +63,6 @@ export const plane: OffsetList = { type: Type.Byte, permission: 'r', }), - retractableLeftFloatExtension: new Offset({ - value: 0x614, - name: 'retractableLeftFloatExtension', - category: OffsetCategory.PLANE, - description: 'retractable left float extension - percent', - convert: 'Math.floor({VAL} / 16384 * 100)', - type: Type.UInt16, - permission: 'r', - }), - retractableRightFloatExtension: new Offset({ - value: 0x616, - name: 'retractableRightFloatExtension', - category: OffsetCategory.PLANE, - description: 'retractable right float extension - percent', - convert: 'Math.floor({VAL} / 16384 * 100)', - type: Type.UInt16, - permission: 'r', - }), hasFlaps: new Offset({ value: 0x778, name: 'hasFlaps', diff --git a/src/lib/offsets/plane/seaplane.ts b/src/lib/offsets/plane/seaplane.ts new file mode 100644 index 0000000..3d6babd --- /dev/null +++ b/src/lib/offsets/plane/seaplane.ts @@ -0,0 +1,51 @@ +import { Type } from 'fsuipc'; + +import { OffsetCategory } from '@shared/offset-category'; +import { OffsetList } from '@shared/offset-list'; +import { Offset } from '@shared/offset'; + +export const seaplane: OffsetList = { + retractableLeftFloatExtension: new Offset({ + value: 0x614, + name: 'retractableLeftFloatExtension', + category: OffsetCategory.SEAPLANE, + description: 'retractable left float extension - percent', + convert: 'Math.floor({VAL} / 16384 * 100)', + type: Type.UInt16, + permission: 'r', + }), + retractableRightFloatExtension: new Offset({ + value: 0x616, + name: 'retractableRightFloatExtension', + category: OffsetCategory.SEAPLANE, + description: 'retractable right float extension - percent', + convert: 'Math.floor({VAL} / 16384 * 100)', + type: Type.UInt16, + permission: 'r', + }), + waterLeftRudderExtended: new Offset({ + value: 0x2A78, + name: 'waterLeftRudderExtended', + category: OffsetCategory.SEAPLANE, + description: 'water left rudder extended', + type: Type.Double, + permission: 'r', + }), + waterRightRudderExtended: new Offset({ + value: 0x2A80, + name: 'waterRightRudderExtended', + category: OffsetCategory.SEAPLANE, + description: 'water right rudder extended', + type: Type.Double, + permission: 'r', + }), + waterRudderHandlePosition: new Offset({ + value: 0x2A88, + name: 'waterRudderHandlePosition', + category: OffsetCategory.SEAPLANE, + description: 'water rudder handle position', + convert: 'Math.floor({VAL} / 16384 * 100)', + type: Type.UInt32, + permission: 'rw', + }), +}; diff --git a/src/shared/offset-category.ts b/src/shared/offset-category.ts index 9e76d9c..c657a6d 100644 --- a/src/shared/offset-category.ts +++ b/src/shared/offset-category.ts @@ -16,6 +16,7 @@ export enum OffsetCategory { PUSHBACK = 'pushback', RADIOS = 'radios', RUNWAY = 'runway', + SEAPLANE = 'seaplane', SIMULATION = 'simulation', WEATHER = 'weather', } diff --git a/tests/offsets/__snapshots__/offset.spec.ts.snap b/tests/offsets/__snapshots__/offset.spec.ts.snap index 7740aab..70a8d9e 100644 --- a/tests/offsets/__snapshots__/offset.spec.ts.snap +++ b/tests/offsets/__snapshots__/offset.spec.ts.snap @@ -871,6 +871,17 @@ Object { "type": 2, "value": 3018, }, + "canopyOpen": Offset { + "category": "controls", + "convert": undefined, + "description": "canopy open", + "length": undefined, + "mapping": undefined, + "name": "canopyOpen", + "permission": "r", + "type": 8, + "value": 10832, + }, "clockHour": Offset { "category": "environment", "convert": undefined, @@ -1256,6 +1267,94 @@ Object { "type": 2, "value": 3008, }, + "elevon1Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 1 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon1Deflection", + "permission": "r", + "type": 8, + "value": 10752, + }, + "elevon2Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 2 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon2Deflection", + "permission": "r", + "type": 8, + "value": 10760, + }, + "elevon3Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 3 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon3Deflection", + "permission": "r", + "type": 8, + "value": 10768, + }, + "elevon4Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 4 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon4Deflection", + "permission": "r", + "type": 8, + "value": 10776, + }, + "elevon5Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 5 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon5Deflection", + "permission": "r", + "type": 8, + "value": 10784, + }, + "elevon6Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 6 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon6Deflection", + "permission": "r", + "type": 8, + "value": 10792, + }, + "elevon7Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 7 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon7Deflection", + "permission": "r", + "type": 8, + "value": 10800, + }, + "elevon8Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 8 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon8Deflection", + "permission": "r", + "type": 8, + "value": 10800, + }, "engine1AntiIce": Offset { "category": "engine", "convert": "!!{VAL}", @@ -3544,6 +3643,28 @@ Object { "type": 0, "value": 1978, }, + "foldingWingLeft": Offset { + "category": "controls", + "convert": "doublePercentRound", + "description": "folding right left - percent", + "length": undefined, + "mapping": true, + "name": "foldingWingLeft", + "permission": "r", + "type": 8, + "value": 10824, + }, + "foldingWingRight": Offset { + "category": "controls", + "convert": "doublePercentRound", + "description": "folding right right - percent", + "length": undefined, + "mapping": true, + "name": "foldingWingRight", + "permission": "r", + "type": 8, + "value": 10832, + }, "framerate": Offset { "category": "simulation", "convert": "Math.floor(32768/{VAL})", @@ -5767,7 +5888,7 @@ Object { "value": 1548, }, "retractableLeftFloatExtension": Offset { - "category": "plane", + "category": "seaplane", "convert": "Math.floor({VAL} / 16384 * 100)", "description": "retractable left float extension - percent", "length": undefined, @@ -5778,7 +5899,7 @@ Object { "value": 1556, }, "retractableRightFloatExtension": Offset { - "category": "plane", + "category": "seaplane", "convert": "Math.floor({VAL} / 16384 * 100)", "description": "retractable right float extension - percent", "length": undefined, @@ -6591,6 +6712,17 @@ Object { "type": 5, "value": 3958, }, + "tailWheelLocked": Offset { + "category": "controls", + "convert": "!!{VAL}", + "description": "tail wheel locked", + "length": undefined, + "mapping": undefined, + "name": "tailWheelLocked", + "permission": "rw", + "type": 6, + "value": 10896, + }, "tas": Offset { "category": "position_attitude", "convert": "Math.floor({VAL} / 128)", @@ -7405,6 +7537,39 @@ Object { "type": 3, "value": 780, }, + "waterLeftRudderExtended": Offset { + "category": "seaplane", + "convert": undefined, + "description": "water left rudder extended", + "length": undefined, + "mapping": undefined, + "name": "waterLeftRudderExtended", + "permission": "r", + "type": 8, + "value": 10872, + }, + "waterRightRudderExtended": Offset { + "category": "seaplane", + "convert": undefined, + "description": "water right rudder extended", + "length": undefined, + "mapping": undefined, + "name": "waterRightRudderExtended", + "permission": "r", + "type": 8, + "value": 10880, + }, + "waterRudderHandlePosition": Offset { + "category": "seaplane", + "convert": "Math.floor({VAL} / 16384 * 100)", + "description": "water rudder handle position", + "length": undefined, + "mapping": undefined, + "name": "waterRudderHandlePosition", + "permission": "rw", + "type": 6, + "value": 10888, + }, "whiskeyCompass": Offset { "category": "position_attitude", "convert": undefined, diff --git a/tests/offsets/plane/__snapshots__/controls.spec.ts.snap b/tests/offsets/plane/__snapshots__/controls.spec.ts.snap index bf967a5..e4513cd 100644 --- a/tests/offsets/plane/__snapshots__/controls.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/controls.spec.ts.snap @@ -57,6 +57,17 @@ Object { "type": 2, "value": 3018, }, + "canopyOpen": Offset { + "category": "controls", + "convert": undefined, + "description": "canopy open", + "length": undefined, + "mapping": undefined, + "name": "canopyOpen", + "permission": "r", + "type": 8, + "value": 10832, + }, "elevatorIndicator": Offset { "category": "controls", "convert": undefined, @@ -101,6 +112,94 @@ Object { "type": 2, "value": 3008, }, + "elevon1Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 1 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon1Deflection", + "permission": "r", + "type": 8, + "value": 10752, + }, + "elevon2Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 2 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon2Deflection", + "permission": "r", + "type": 8, + "value": 10760, + }, + "elevon3Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 3 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon3Deflection", + "permission": "r", + "type": 8, + "value": 10768, + }, + "elevon4Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 4 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon4Deflection", + "permission": "r", + "type": 8, + "value": 10776, + }, + "elevon5Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 5 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon5Deflection", + "permission": "r", + "type": 8, + "value": 10784, + }, + "elevon6Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 6 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon6Deflection", + "permission": "r", + "type": 8, + "value": 10792, + }, + "elevon7Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 7 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon7Deflection", + "permission": "r", + "type": 8, + "value": 10800, + }, + "elevon8Deflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevon 8 deflection", + "length": undefined, + "mapping": undefined, + "name": "elevon8Deflection", + "permission": "r", + "type": 8, + "value": 10800, + }, "flapsControl": Offset { "category": "controls", "convert": "Math.round({VAL} / 16383 * 100)", @@ -145,6 +244,28 @@ Object { "type": 3, "value": 3040, }, + "foldingWingLeft": Offset { + "category": "controls", + "convert": "doublePercentRound", + "description": "folding right left - percent", + "length": undefined, + "mapping": true, + "name": "foldingWingLeft", + "permission": "r", + "type": 8, + "value": 10824, + }, + "foldingWingRight": Offset { + "category": "controls", + "convert": "doublePercentRound", + "description": "folding right right - percent", + "length": undefined, + "mapping": true, + "name": "foldingWingRight", + "permission": "r", + "type": 8, + "value": 10832, + }, "gearControl": Offset { "category": "controls", "convert": "Math.round({VAL} / 16383 * 100)", @@ -387,5 +508,16 @@ Object { "type": 2, "value": 3080, }, + "tailWheelLocked": Offset { + "category": "controls", + "convert": "!!{VAL}", + "description": "tail wheel locked", + "length": undefined, + "mapping": undefined, + "name": "tailWheelLocked", + "permission": "rw", + "type": 6, + "value": 10896, + }, } `; diff --git a/tests/offsets/plane/__snapshots__/plane.spec.ts.snap b/tests/offsets/plane/__snapshots__/plane.spec.ts.snap index 0d7374b..5318483 100644 --- a/tests/offsets/plane/__snapshots__/plane.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/plane.spec.ts.snap @@ -145,28 +145,6 @@ Object { "type": 0, "value": 1548, }, - "retractableLeftFloatExtension": Offset { - "category": "plane", - "convert": "Math.floor({VAL} / 16384 * 100)", - "description": "retractable left float extension - percent", - "length": undefined, - "mapping": undefined, - "name": "retractableLeftFloatExtension", - "permission": "r", - "type": 5, - "value": 1556, - }, - "retractableRightFloatExtension": Offset { - "category": "plane", - "convert": "Math.floor({VAL} / 16384 * 100)", - "description": "retractable right float extension - percent", - "length": undefined, - "mapping": undefined, - "name": "retractableRightFloatExtension", - "permission": "r", - "type": 5, - "value": 1558, - }, "smokeSystemControl": Offset { "category": "plane", "convert": "!!{VAL}", diff --git a/tests/offsets/plane/__snapshots__/seaplane.spec.ts.snap b/tests/offsets/plane/__snapshots__/seaplane.spec.ts.snap new file mode 100644 index 0000000..972fef3 --- /dev/null +++ b/tests/offsets/plane/__snapshots__/seaplane.spec.ts.snap @@ -0,0 +1,61 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`offset - plane/seaplane offsets list should have required properties 1`] = ` +Object { + "retractableLeftFloatExtension": Offset { + "category": "seaplane", + "convert": "Math.floor({VAL} / 16384 * 100)", + "description": "retractable left float extension - percent", + "length": undefined, + "mapping": undefined, + "name": "retractableLeftFloatExtension", + "permission": "r", + "type": 5, + "value": 1556, + }, + "retractableRightFloatExtension": Offset { + "category": "seaplane", + "convert": "Math.floor({VAL} / 16384 * 100)", + "description": "retractable right float extension - percent", + "length": undefined, + "mapping": undefined, + "name": "retractableRightFloatExtension", + "permission": "r", + "type": 5, + "value": 1558, + }, + "waterLeftRudderExtended": Offset { + "category": "seaplane", + "convert": undefined, + "description": "water left rudder extended", + "length": undefined, + "mapping": undefined, + "name": "waterLeftRudderExtended", + "permission": "r", + "type": 8, + "value": 10872, + }, + "waterRightRudderExtended": Offset { + "category": "seaplane", + "convert": undefined, + "description": "water right rudder extended", + "length": undefined, + "mapping": undefined, + "name": "waterRightRudderExtended", + "permission": "r", + "type": 8, + "value": 10880, + }, + "waterRudderHandlePosition": Offset { + "category": "seaplane", + "convert": "Math.floor({VAL} / 16384 * 100)", + "description": "water rudder handle position", + "length": undefined, + "mapping": undefined, + "name": "waterRudderHandlePosition", + "permission": "rw", + "type": 6, + "value": 10888, + }, +} +`; diff --git a/tests/offsets/plane/controls.spec.ts b/tests/offsets/plane/controls.spec.ts index 0ae89e0..20d7f33 100644 --- a/tests/offsets/plane/controls.spec.ts +++ b/tests/offsets/plane/controls.spec.ts @@ -39,6 +39,8 @@ describe('offset - plane/controls', () => { { name: 'steeringTillerCalibratedValue', value: -16383, expectedResult: -100 }, { name: 'rudderCalibratedvalue', value: 16383, expectedResult: 100 }, { name: 'rudderCalibratedvalue', value: -16383, expectedResult: -100 }, + { name: 'tailWheelLocked', value: 0, expectedResult: false }, + { name: 'tailWheelLocked', value: 1, expectedResult: true }, ]; describe('offsets list', () => { diff --git a/tests/offsets/plane/plane.spec.ts b/tests/offsets/plane/plane.spec.ts index 749b29c..34f20cd 100644 --- a/tests/offsets/plane/plane.spec.ts +++ b/tests/offsets/plane/plane.spec.ts @@ -7,8 +7,6 @@ describe('offset - plane/plane', () => { { name: 'smokeSystemControl', value: 1, expectedResult: true }, { name: 'retractableGear', value: 0, expectedResult: false }, { name: 'retractableGear', value: 1, expectedResult: true }, - { name: 'retractableLeftFloatExtension', value: 13200, expectedResult: 80 }, - { name: 'retractableRightFloatExtension', value: 13200, expectedResult: 80 }, { name: 'hasFlaps', value: 0, expectedResult: false }, { name: 'hasFlaps', value: 1, expectedResult: true }, { name: 'hasStallHorn', value: 0, expectedResult: false }, diff --git a/tests/offsets/plane/seaplane.spec.ts b/tests/offsets/plane/seaplane.spec.ts new file mode 100644 index 0000000..5a8d617 --- /dev/null +++ b/tests/offsets/plane/seaplane.spec.ts @@ -0,0 +1,27 @@ +import { seaplane as offsets } from '@offsets/plane/seaplane'; +import { replaceOffsetExpressionValue } from '@convert/apply-conversion'; + +describe('offset - plane/seaplane', () => { + const offsetsTestCases = [ + { name: 'retractableLeftFloatExtension', value: 13200, expectedResult: 80 }, + { name: 'retractableRightFloatExtension', value: 13200, expectedResult: 80 }, + { name: 'waterRudderHandlePosition', value: 13200, expectedResult: 80 }, + ]; + + describe('offsets list', () => { + it('should have required properties', () => { + expect(offsets).toMatchSnapshot(); + }); + }); + + offsetsTestCases.forEach(testedOffset => { + describe(testedOffset.name, () => { + it('should convert data properly', () => { + const convertExpression = replaceOffsetExpressionValue(offsets[testedOffset.name], testedOffset.value); + + // tslint:disable-next-line:no-eval + expect(eval(convertExpression)).toEqual(testedOffset.expectedResult); + }); + }); + }); +}); From 36feb768db18de34ee768ef0f1ffac8afd104ebc Mon Sep 17 00:00:00 2001 From: blackholegalaxy Date: Sat, 8 Feb 2020 12:12:18 -0500 Subject: [PATCH 2/8] add CDI and GSI offsets --- src/lib/offsets/plane/radios/nav1.ts | 18 +++++++++++++++ src/lib/offsets/plane/radios/nav2.ts | 18 +++++++++++++++ .../radios/__snapshots__/nav1.spec.ts.snap | 22 +++++++++++++++++++ .../radios/__snapshots__/nav2.spec.ts.snap | 22 +++++++++++++++++++ tests/offsets/plane/radios/nav1.spec.ts | 2 ++ tests/offsets/plane/radios/nav2.spec.ts | 2 ++ 6 files changed, 84 insertions(+) diff --git a/src/lib/offsets/plane/radios/nav1.ts b/src/lib/offsets/plane/radios/nav1.ts index d6baa81..950f853 100644 --- a/src/lib/offsets/plane/radios/nav1.ts +++ b/src/lib/offsets/plane/radios/nav1.ts @@ -270,4 +270,22 @@ export const NAV1: OffsetList = { type: Type.UInt16, permission: 'r', }), + nav1CDI: new Offset({ + value: 0x2AAC, + name: 'nav1CDI', + category: OffsetCategory.RADIOS, + description: 'NAV1 course deviation needle - percent - -ve left +ve right', + convert: 'Math.round({VAL} * 100 / 127)', + type: Type.Single, + permission: 'r', + }), + nav1GSI: new Offset({ + value: 0x2AB0, + name: 'nav1GSI', + category: OffsetCategory.RADIOS, + description: 'NAV1 glideslope indicator - percent - -ve left +ve right', + convert: 'Math.round({VAL} * 100 / 127)', + type: Type.Single, + permission: 'r', + }), }; diff --git a/src/lib/offsets/plane/radios/nav2.ts b/src/lib/offsets/plane/radios/nav2.ts index 196b3f2..972be74 100644 --- a/src/lib/offsets/plane/radios/nav2.ts +++ b/src/lib/offsets/plane/radios/nav2.ts @@ -270,4 +270,22 @@ export const NAV2: OffsetList = { length: 8, permission: 'r', }), + nav2CDI: new Offset({ + value: 0x2AB4, + name: 'nav2CDI', + category: OffsetCategory.RADIOS, + description: 'NAV2 course deviation needle - percent - -ve left +ve right', + convert: 'Math.round({VAL} * 100 / 127)', + type: Type.Single, + permission: 'r', + }), + nav2GSI: new Offset({ + value: 0x2AB8, + name: 'nav2GSI', + category: OffsetCategory.RADIOS, + description: 'NAV2 glideslope indicator - percent - -ve left +ve right', + convert: 'Math.round({VAL} * 100 / 127)', + type: Type.Single, + permission: 'r', + }), }; diff --git a/tests/offsets/plane/radios/__snapshots__/nav1.spec.ts.snap b/tests/offsets/plane/radios/__snapshots__/nav1.spec.ts.snap index 8a2628e..2d169d9 100644 --- a/tests/offsets/plane/radios/__snapshots__/nav1.spec.ts.snap +++ b/tests/offsets/plane/radios/__snapshots__/nav1.spec.ts.snap @@ -57,6 +57,17 @@ Object { "type": 5, "value": 3158, }, + "nav1CDI": Offset { + "category": "radios", + "convert": "Math.round({VAL} * 100 / 127)", + "description": "NAV1 course deviation needle - percent - -ve left +ve right", + "length": undefined, + "mapping": undefined, + "name": "nav1CDI", + "permission": "r", + "type": 9, + "value": 10924, + }, "nav1Capabilities": Offset { "category": "radios", "convert": "navCapabilities", @@ -79,6 +90,17 @@ Object { "type": 5, "value": 848, }, + "nav1GSI": Offset { + "category": "radios", + "convert": "Math.round({VAL} * 100 / 127)", + "description": "NAV1 glideslope indicator - percent - -ve left +ve right", + "length": undefined, + "mapping": undefined, + "name": "nav1GSI", + "permission": "r", + "type": 9, + "value": 10928, + }, "nav1GlideslopeActive": Offset { "category": "radios", "convert": "!!{VAL}", diff --git a/tests/offsets/plane/radios/__snapshots__/nav2.spec.ts.snap b/tests/offsets/plane/radios/__snapshots__/nav2.spec.ts.snap index ac0c33f..f0d12bb 100644 --- a/tests/offsets/plane/radios/__snapshots__/nav2.spec.ts.snap +++ b/tests/offsets/plane/radios/__snapshots__/nav2.spec.ts.snap @@ -57,6 +57,17 @@ Object { "type": 5, "value": 3164, }, + "nav2CDI": Offset { + "category": "radios", + "convert": "Math.round({VAL} * 100 / 127)", + "description": "NAV2 course deviation needle - percent - -ve left +ve right", + "length": undefined, + "mapping": undefined, + "name": "nav2CDI", + "permission": "r", + "type": 9, + "value": 10932, + }, "nav2Capabilities": Offset { "category": "radios", "convert": "navCapabilities", @@ -79,6 +90,17 @@ Object { "type": 5, "value": 850, }, + "nav2GSI": Offset { + "category": "radios", + "convert": "Math.round({VAL} * 100 / 127)", + "description": "NAV2 glideslope indicator - percent - -ve left +ve right", + "length": undefined, + "mapping": undefined, + "name": "nav2GSI", + "permission": "r", + "type": 9, + "value": 10936, + }, "nav2GlideslopeActive": Offset { "category": "radios", "convert": "!!{VAL}", diff --git a/tests/offsets/plane/radios/nav1.spec.ts b/tests/offsets/plane/radios/nav1.spec.ts index ae6c293..52a62b8 100644 --- a/tests/offsets/plane/radios/nav1.spec.ts +++ b/tests/offsets/plane/radios/nav1.spec.ts @@ -40,6 +40,8 @@ describe('offset - plane/radios/nav1', () => { { name: 'nav1GlideslopeActive', value: 0, expectedResult: false }, { name: 'nav1GlideslopeActive', value: 1, expectedResult: true }, { name: 'nav1Radial', value: 9102, expectedResult: 50 }, + { name: 'nav1CDI', value: 102.786, expectedResult: 81 }, + { name: 'nav1GSI', value: 102.786, expectedResult: 81 }, ]; describe('offsets list', () => { diff --git a/tests/offsets/plane/radios/nav2.spec.ts b/tests/offsets/plane/radios/nav2.spec.ts index 379ba07..3fb428b 100644 --- a/tests/offsets/plane/radios/nav2.spec.ts +++ b/tests/offsets/plane/radios/nav2.spec.ts @@ -40,6 +40,8 @@ describe('offset - plane/radios/nav2', () => { { name: 'nav2GlideslopeNeedlePosition', value: -127, expectedResult: -100 }, { name: 'nav2GlideslopeActive', value: 0, expectedResult: false }, { name: 'nav2GlideslopeActive', value: 1, expectedResult: true }, + { name: 'nav2CDI', value: 102.786, expectedResult: 81 }, + { name: 'nav2GSI', value: 102.786, expectedResult: 81 }, ]; describe('offsets list', () => { From 90006490984fe58df174f381255be80b408701ce Mon Sep 17 00:00:00 2001 From: blackholegalaxy Date: Sat, 8 Feb 2020 12:21:36 -0500 Subject: [PATCH 3/8] add offsets for hydraulic --- src/lib/offsets/plane/cockpit.ts | 9 +++ src/lib/offsets/plane/helicopter.ts | 9 +++ src/lib/offsets/plane/hydraulic.ts | 62 +++++++++++++++++++ src/shared/offset-category.ts | 1 + .../offsets/__snapshots__/offset.spec.ts.snap | 11 ++++ .../plane/__snapshots__/cockpit.spec.ts.snap | 11 ++++ .../__snapshots__/helicopter.spec.ts.snap | 11 ++++ tests/offsets/plane/cockpit.spec.ts | 1 + tests/offsets/plane/helicopter.spec.ts | 3 + 9 files changed, 118 insertions(+) create mode 100644 src/lib/offsets/plane/hydraulic.ts diff --git a/src/lib/offsets/plane/cockpit.ts b/src/lib/offsets/plane/cockpit.ts index 85154e5..0d16320 100644 --- a/src/lib/offsets/plane/cockpit.ts +++ b/src/lib/offsets/plane/cockpit.ts @@ -287,4 +287,13 @@ 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', + }), }; diff --git a/src/lib/offsets/plane/helicopter.ts b/src/lib/offsets/plane/helicopter.ts index 3e7eb53..22b9c9c 100644 --- a/src/lib/offsets/plane/helicopter.ts +++ b/src/lib/offsets/plane/helicopter.ts @@ -146,4 +146,13 @@ export const helicopter: OffsetList = { type: Type.Int16, permission: 'rw', }), + helicopterBeep: new Offset({ + value: 0x2DC6, + name: 'helicopterBeep', + description: 'helicopter beep', + category: OffsetCategory.HELICOPTER, + convert: '!!{VAL}', + type: Type.UInt16, + permission: 'r', + }), }; diff --git a/src/lib/offsets/plane/hydraulic.ts b/src/lib/offsets/plane/hydraulic.ts new file mode 100644 index 0000000..41074aa --- /dev/null +++ b/src/lib/offsets/plane/hydraulic.ts @@ -0,0 +1,62 @@ +import { Type } from 'fsuipc'; + +import { OffsetCategory } from '@shared/offset-category'; +import { OffsetList } from '@shared/offset-list'; +import { Offset } from '@shared/offset'; + +export const hydraulic: OffsetList = { + hyd1Pressure: new Offset({ + value: 0x2B08, + name: 'hyd1Pressure', + category: OffsetCategory.HYDRAULIC, + description: 'hyd1 pressure', + type: Type.Double, + permission: 'r', + }), + hyd1Reservoir: new Offset({ + value: 0x2B1C, + name: 'hyd1Reservoir', + category: OffsetCategory.HYDRAULIC, + description: 'hyd1 reservoir percent', + convert: 'doublePercentRound', + mapping: true, + type: Type.Double, + permission: 'r', + }), + hyd2Pressure: new Offset({ + value: 0x2C08, + name: 'hyd2Pressure', + category: OffsetCategory.HYDRAULIC, + description: 'hyd2 pressure', + type: Type.Double, + permission: 'r', + }), + hyd2Reservoir: new Offset({ + value: 0x2C1C, + name: 'hyd2Reservoir', + category: OffsetCategory.HYDRAULIC, + description: 'hyd2 reservoir percent', + convert: 'doublePercentRound', + mapping: true, + type: Type.Double, + permission: 'r', + }), + hyd3Pressure: new Offset({ + value: 0x2D08, + name: 'hyd3Pressure', + category: OffsetCategory.HYDRAULIC, + description: 'hyd3 pressure', + type: Type.Double, + permission: 'r', + }), + hyd3Reservoir: new Offset({ + value: 0x2D1C, + name: 'hyd3Reservoir', + category: OffsetCategory.HYDRAULIC, + description: 'hyd3 reservoir percent', + convert: 'doublePercentRound', + mapping: true, + type: Type.Double, + permission: 'r', + }), +}; diff --git a/src/shared/offset-category.ts b/src/shared/offset-category.ts index c657a6d..ac6d3c5 100644 --- a/src/shared/offset-category.ts +++ b/src/shared/offset-category.ts @@ -9,6 +9,7 @@ export enum OffsetCategory { FAILURE = 'failure', FUEL = 'fuel', HELICOPTER = 'helicopter', + HYDRAULIC = 'hydraulic', ICING = 'icing', PLANE = 'plane', POSITION_ATTITUDE = 'position_attitude', diff --git a/tests/offsets/__snapshots__/offset.spec.ts.snap b/tests/offsets/__snapshots__/offset.spec.ts.snap index 70a8d9e..c40416b 100644 --- a/tests/offsets/__snapshots__/offset.spec.ts.snap +++ b/tests/offsets/__snapshots__/offset.spec.ts.snap @@ -4215,6 +4215,17 @@ Object { "type": 3, "value": 692, }, + "gyroCompassHeading": Offset { + "category": "cockpit", + "convert": "Math.round({VAL})", + "description": "gyro compass heading (MAG) including drift", + "length": undefined, + "mapping": undefined, + "name": "gyroCompassHeading", + "permission": "r", + "type": 8, + "value": 11008, + }, "gyroDrift": Offset { "category": "cockpit", "convert": "Math.round({VAL} * 360 / 65536)", diff --git a/tests/offsets/plane/__snapshots__/cockpit.spec.ts.snap b/tests/offsets/plane/__snapshots__/cockpit.spec.ts.snap index b19f535..c53b534 100644 --- a/tests/offsets/plane/__snapshots__/cockpit.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/cockpit.spec.ts.snap @@ -222,6 +222,17 @@ Object { "type": 3, "value": 4720, }, + "gyroCompassHeading": Offset { + "category": "cockpit", + "convert": "Math.round({VAL})", + "description": "gyro compass heading (MAG) including drift", + "length": undefined, + "mapping": undefined, + "name": "gyroCompassHeading", + "permission": "r", + "type": 8, + "value": 11008, + }, "gyroDrift": Offset { "category": "cockpit", "convert": "Math.round({VAL} * 360 / 65536)", diff --git a/tests/offsets/plane/__snapshots__/helicopter.spec.ts.snap b/tests/offsets/plane/__snapshots__/helicopter.spec.ts.snap index 155e2db..246f047 100644 --- a/tests/offsets/plane/__snapshots__/helicopter.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/helicopter.spec.ts.snap @@ -24,6 +24,17 @@ Object { "type": 2, "value": 3078, }, + "helicopterBeep": Offset { + "category": "helicopter", + "convert": "!!{VAL}", + "description": "helicopter beep", + "length": undefined, + "mapping": undefined, + "name": "helicopterBeep", + "permission": "r", + "type": 5, + "value": 11718, + }, "helicopterEngine1ElectricalLoad": Offset { "category": "helicopter", "convert": "{VAL} / 16384 * 100", diff --git a/tests/offsets/plane/cockpit.spec.ts b/tests/offsets/plane/cockpit.spec.ts index 03b4b64..0ea1774 100644 --- a/tests/offsets/plane/cockpit.spec.ts +++ b/tests/offsets/plane/cockpit.spec.ts @@ -30,6 +30,7 @@ describe('offset - plane/cockpit', () => { { name: 'autopilotSpeedSwitch321EFIS', value: 1, expectedResult: true }, { name: 'altitudeChangeRate321EFIS', value: 0, expectedResult: 100 }, { name: 'altitudeChangeRate321EFIS', value: 1, expectedResult: 1000 }, + { name: 'gyroCompassHeading', value: 167.54, expectedResult: 168 }, ]; describe('offsets list', () => { diff --git a/tests/offsets/plane/helicopter.spec.ts b/tests/offsets/plane/helicopter.spec.ts index 74abd18..ec5a4a6 100644 --- a/tests/offsets/plane/helicopter.spec.ts +++ b/tests/offsets/plane/helicopter.spec.ts @@ -14,6 +14,9 @@ describe('offset - plane/helicopter', () => { { name: 'helicopterPitchTrim', value: -16000, expectedResult: -98 }, { name: 'helicopterBankTrim', value: 16383, expectedResult: 100 }, { name: 'helicopterBankTrim', value: -16383, expectedResult: -100 }, + { name: 'helicopterBeep', value: 0, expectedResult: false }, + { name: 'helicopterBeep', value: 1, expectedResult: true }, + { name: 'helicopterBeep', value: 16000, expectedResult: true }, ]; describe('offsets list', () => { From 08da7e782065f0daa48641035cbe7238fadc9f40 Mon Sep 17 00:00:00 2001 From: blackholegalaxy Date: Sat, 8 Feb 2020 12:36:58 -0500 Subject: [PATCH 4/8] add offsets --- .../environment/weather/at-aircraft.ts | 38 +++++++++++++ src/lib/offsets/plane/autopilot.ts | 8 +++ src/lib/offsets/plane/hydraulic.ts | 18 ++++++ src/lib/offsets/plane/wb.ts | 18 ++++++ .../offsets/__snapshots__/offset.spec.ts.snap | 55 +++++++++++++++++++ .../__snapshots__/weather.spec.ts.snap | 44 +++++++++++++++ .../__snapshots__/at-aircraft.spec.ts.snap | 44 +++++++++++++++ .../__snapshots__/autopilot.spec.ts.snap | 11 ++++ .../plane/__snapshots__/wb.spec.ts.snap | 17 ++++++ tests/offsets/plane/wb.spec.ts | 24 ++++++++ 10 files changed, 277 insertions(+) create mode 100644 src/lib/offsets/plane/wb.ts create mode 100644 tests/offsets/plane/__snapshots__/wb.spec.ts.snap create mode 100644 tests/offsets/plane/wb.spec.ts diff --git a/src/lib/offsets/environment/weather/at-aircraft.ts b/src/lib/offsets/environment/weather/at-aircraft.ts index 0750e2c..57ebee5 100644 --- a/src/lib/offsets/environment/weather/at-aircraft.ts +++ b/src/lib/offsets/environment/weather/at-aircraft.ts @@ -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', + }), }; diff --git a/src/lib/offsets/plane/autopilot.ts b/src/lib/offsets/plane/autopilot.ts index 0e0df0b..50615cd 100644 --- a/src/lib/offsets/plane/autopilot.ts +++ b/src/lib/offsets/plane/autopilot.ts @@ -264,4 +264,12 @@ 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', + }), }; diff --git a/src/lib/offsets/plane/hydraulic.ts b/src/lib/offsets/plane/hydraulic.ts index 41074aa..b4ca585 100644 --- a/src/lib/offsets/plane/hydraulic.ts +++ b/src/lib/offsets/plane/hydraulic.ts @@ -59,4 +59,22 @@ export const hydraulic: OffsetList = { type: Type.Double, permission: 'r', }), + hyd4Pressure: new Offset({ + value: 0x2E08, + name: 'hyd4Pressure', + category: OffsetCategory.HYDRAULIC, + description: 'hyd4 pressure', + type: Type.Double, + permission: 'r', + }), + hyd4Reservoir: new Offset({ + value: 0x2E1C, + name: 'hyd4Reservoir', + category: OffsetCategory.HYDRAULIC, + description: 'hyd4 reservoir percent', + convert: 'doublePercentRound', + mapping: true, + type: Type.Double, + permission: 'r', + }), }; diff --git a/src/lib/offsets/plane/wb.ts b/src/lib/offsets/plane/wb.ts new file mode 100644 index 0000000..a8748b2 --- /dev/null +++ b/src/lib/offsets/plane/wb.ts @@ -0,0 +1,18 @@ +import { Type } from 'fsuipc'; + +import { OffsetCategory } from '@shared/offset-category'; +import { OffsetList } from '@shared/offset-list'; +import { Offset } from '@shared/offset'; + +export const weightAndBalance: OffsetList = { + lateralCGPercent: new Offset({ + value: 0x2E78, + name: 'lateralCGPercent', + category: OffsetCategory.SEAPLANE, + description: 'lateral CG - percent from chord', + convert: 'doublePercentRound', + mapping: true, + type: Type.Double, + permission: 'r', + }), +}; diff --git a/tests/offsets/__snapshots__/offset.spec.ts.snap b/tests/offsets/__snapshots__/offset.spec.ts.snap index c40416b..84742a1 100644 --- a/tests/offsets/__snapshots__/offset.spec.ts.snap +++ b/tests/offsets/__snapshots__/offset.spec.ts.snap @@ -596,6 +596,17 @@ Object { "type": 6, "value": 1980, }, + "apMaxBank": Offset { + "category": "autopilot", + "convert": undefined, + "description": "AP max bank - degrees", + "length": undefined, + "mapping": undefined, + "name": "apMaxBank", + "permission": "r", + "type": 6, + "value": 11780, + }, "apNav1Hold": Offset { "category": "autopilot", "convert": "!!{VAL}", @@ -1135,6 +1146,17 @@ Object { "type": 2, "value": 2112, }, + "crossWind": Offset { + "category": "weather", + "convert": "ftsecToKt", + "description": "cross wind - -ve left +ve right - kt", + "length": undefined, + "mapping": true, + "name": "crossWind", + "permission": "r", + "type": 8, + "value": 11720, + }, "dayOfYear": Offset { "category": "environment", "convert": undefined, @@ -4325,6 +4347,17 @@ Object { "type": 6, "value": 1948, }, + "headWind": Offset { + "category": "weather", + "convert": "ftsecToKt", + "description": "head/tail wind - -ve head +ve tail - kt", + "length": undefined, + "mapping": true, + "name": "headWind", + "permission": "r", + "type": 8, + "value": 11736, + }, "heading": Offset { "category": "position_attitude", "convert": "+({VAL} * 360 / (65536 * 65536)).toFixed(2)", @@ -7031,6 +7064,17 @@ Object { "type": 3, "value": 3064, }, + "upWind": Offset { + "category": "weather", + "convert": "ftsecToKt", + "description": "vertical wind - -ve under +ve over - kt", + "length": undefined, + "mapping": true, + "name": "upWind", + "permission": "r", + "type": 8, + "value": 11728, + }, "upperCloudBase": Offset { "category": "weather", "convert": "+({VAL} * 3.28084).toFixed(2)", @@ -7482,6 +7526,17 @@ Object { "type": 2, "value": 3722, }, + "visibilityAtAircraft": Offset { + "category": "weather", + "convert": undefined, + "description": "visibility at aircraft", + "length": undefined, + "mapping": undefined, + "name": "visibilityAtAircraft", + "permission": "r", + "type": 8, + "value": 11760, + }, "visibilitySetting": Offset { "category": "weather", "convert": "{VAL} / 100", diff --git a/tests/offsets/environment/__snapshots__/weather.spec.ts.snap b/tests/offsets/environment/__snapshots__/weather.spec.ts.snap index fe0183e..0e6c75f 100644 --- a/tests/offsets/environment/__snapshots__/weather.spec.ts.snap +++ b/tests/offsets/environment/__snapshots__/weather.spec.ts.snap @@ -112,6 +112,17 @@ Object { "type": 0, "value": 3716, }, + "crossWind": Offset { + "category": "weather", + "convert": "ftsecToKt", + "description": "cross wind - -ve left +ve right - kt", + "length": undefined, + "mapping": true, + "name": "crossWind", + "permission": "r", + "type": 8, + "value": 11720, + }, "dewPoint": Offset { "category": "weather", "convert": "{VAL} / 256", @@ -134,6 +145,17 @@ Object { "type": 5, "value": 1236, }, + "headWind": Offset { + "category": "weather", + "convert": "ftsecToKt", + "description": "head/tail wind - -ve head +ve tail - kt", + "length": undefined, + "mapping": true, + "name": "headWind", + "permission": "r", + "type": 8, + "value": 11736, + }, "interpolatedDewPoint": Offset { "category": "weather", "convert": "Math.round({VAL} / 256)", @@ -1223,6 +1245,17 @@ Object { "type": 3, "value": 3064, }, + "upWind": Offset { + "category": "weather", + "convert": "ftsecToKt", + "description": "vertical wind - -ve under +ve over - kt", + "length": undefined, + "mapping": true, + "name": "upWind", + "permission": "r", + "type": 8, + "value": 11728, + }, "upperCloudBase": Offset { "category": "weather", "convert": "+({VAL} * 3.28084).toFixed(2)", @@ -1564,6 +1597,17 @@ Object { "type": 2, "value": 3722, }, + "visibilityAtAircraft": Offset { + "category": "weather", + "convert": undefined, + "description": "visibility at aircraft", + "length": undefined, + "mapping": undefined, + "name": "visibilityAtAircraft", + "permission": "r", + "type": 8, + "value": 11760, + }, "visibilitySetting": Offset { "category": "weather", "convert": "{VAL} / 100", diff --git a/tests/offsets/environment/weather/__snapshots__/at-aircraft.spec.ts.snap b/tests/offsets/environment/weather/__snapshots__/at-aircraft.spec.ts.snap index 2bb770d..714a191 100644 --- a/tests/offsets/environment/weather/__snapshots__/at-aircraft.spec.ts.snap +++ b/tests/offsets/environment/weather/__snapshots__/at-aircraft.spec.ts.snap @@ -24,6 +24,28 @@ Object { "type": 8, "value": 10440, }, + "crossWind": Offset { + "category": "weather", + "convert": "ftsecToKt", + "description": "cross wind - -ve left +ve right - kt", + "length": undefined, + "mapping": true, + "name": "crossWind", + "permission": "r", + "type": 8, + "value": 11720, + }, + "headWind": Offset { + "category": "weather", + "convert": "ftsecToKt", + "description": "head/tail wind - -ve head +ve tail - kt", + "length": undefined, + "mapping": true, + "name": "headWind", + "permission": "r", + "type": 8, + "value": 11736, + }, "lowerCloudBase": Offset { "category": "weather", "convert": "+({VAL} * 3.28084).toFixed(2)", @@ -508,6 +530,17 @@ Object { "type": 2, "value": 3778, }, + "upWind": Offset { + "category": "weather", + "convert": "ftsecToKt", + "description": "vertical wind - -ve under +ve over - kt", + "length": undefined, + "mapping": true, + "name": "upWind", + "permission": "r", + "type": 8, + "value": 11728, + }, "upperCloudBase": Offset { "category": "weather", "convert": "+({VAL} * 3.28084).toFixed(2)", @@ -673,5 +706,16 @@ Object { "type": 5, "value": 3794, }, + "visibilityAtAircraft": Offset { + "category": "weather", + "convert": undefined, + "description": "visibility at aircraft", + "length": undefined, + "mapping": undefined, + "name": "visibilityAtAircraft", + "permission": "r", + "type": 8, + "value": 11760, + }, } `; diff --git a/tests/offsets/plane/__snapshots__/autopilot.spec.ts.snap b/tests/offsets/plane/__snapshots__/autopilot.spec.ts.snap index 2980ea5..057f4ad 100644 --- a/tests/offsets/plane/__snapshots__/autopilot.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/autopilot.spec.ts.snap @@ -156,6 +156,17 @@ Object { "type": 6, "value": 1980, }, + "apMaxBank": Offset { + "category": "autopilot", + "convert": undefined, + "description": "AP max bank - degrees", + "length": undefined, + "mapping": undefined, + "name": "apMaxBank", + "permission": "r", + "type": 6, + "value": 11780, + }, "apNav1Hold": Offset { "category": "autopilot", "convert": "!!{VAL}", diff --git a/tests/offsets/plane/__snapshots__/wb.spec.ts.snap b/tests/offsets/plane/__snapshots__/wb.spec.ts.snap new file mode 100644 index 0000000..520bea0 --- /dev/null +++ b/tests/offsets/plane/__snapshots__/wb.spec.ts.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`offset - plane/weightAndBalance offsets list should have required properties 1`] = ` +Object { + "lateralCGPercent": Offset { + "category": "seaplane", + "convert": "doublePercentRound", + "description": "lateral CG - percent from chord", + "length": undefined, + "mapping": true, + "name": "lateralCGPercent", + "permission": "r", + "type": 8, + "value": 11896, + }, +} +`; diff --git a/tests/offsets/plane/wb.spec.ts b/tests/offsets/plane/wb.spec.ts new file mode 100644 index 0000000..010a6a8 --- /dev/null +++ b/tests/offsets/plane/wb.spec.ts @@ -0,0 +1,24 @@ +import { weightAndBalance as offsets } from '@offsets/plane/wb'; +import { replaceOffsetExpressionValue } from '@convert/apply-conversion'; + +describe('offset - plane/weightAndBalance', () => { + const offsetsTestCases = [ + ]; + + describe('offsets list', () => { + it('should have required properties', () => { + expect(offsets).toMatchSnapshot(); + }); + }); + + offsetsTestCases.forEach(testedOffset => { + describe(testedOffset.name, () => { + it('should convert data properly', () => { + const convertExpression = replaceOffsetExpressionValue(offsets[testedOffset.name], testedOffset.value); + + // tslint:disable-next-line:no-eval + expect(eval(convertExpression)).toEqual(testedOffset.expectedResult); + }); + }); + }); +}); From 1c85291ac39767909cf69ba55230885d52415323 Mon Sep 17 00:00:00 2001 From: blackholegalaxy Date: Sat, 8 Feb 2020 12:45:06 -0500 Subject: [PATCH 5/8] add tests --- tests/convert/mappings/double-percent.spec.ts | 15 +++ .../__snapshots__/hydraulic.spec.ts.snap | 94 +++++++++++++++++++ tests/offsets/plane/hydraulic.spec.ts | 24 +++++ 3 files changed, 133 insertions(+) create mode 100644 tests/convert/mappings/double-percent.spec.ts create mode 100644 tests/offsets/plane/__snapshots__/hydraulic.spec.ts.snap create mode 100644 tests/offsets/plane/hydraulic.spec.ts diff --git a/tests/convert/mappings/double-percent.spec.ts b/tests/convert/mappings/double-percent.spec.ts new file mode 100644 index 0000000..13aab5b --- /dev/null +++ b/tests/convert/mappings/double-percent.spec.ts @@ -0,0 +1,15 @@ +import { doublePercentRound } from '@mappings/double-percent'; +const TESTS = [ + { value: 0, result: 0 }, + { value: 0.0567, result: 6 }, + { value: 0.8927, result: 89 }, + { value: -0.05, result: -5 }, +]; + +describe('double percent round mapping', () => { + TESTS.forEach(test => { + it(`should map value ${test.value} to percent ${test.result}`, () => { + expect(doublePercentRound(test.value)).toEqual(test.result); + }); + }); +}); diff --git a/tests/offsets/plane/__snapshots__/hydraulic.spec.ts.snap b/tests/offsets/plane/__snapshots__/hydraulic.spec.ts.snap new file mode 100644 index 0000000..441c418 --- /dev/null +++ b/tests/offsets/plane/__snapshots__/hydraulic.spec.ts.snap @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`offset - plane/hydraulic offsets list should have required properties 1`] = ` +Object { + "hyd1Pressure": Offset { + "category": "hydraulic", + "convert": undefined, + "description": "hyd1 pressure", + "length": undefined, + "mapping": undefined, + "name": "hyd1Pressure", + "permission": "r", + "type": 8, + "value": 11016, + }, + "hyd1Reservoir": Offset { + "category": "hydraulic", + "convert": "doublePercentRound", + "description": "hyd1 reservoir percent", + "length": undefined, + "mapping": true, + "name": "hyd1Reservoir", + "permission": "r", + "type": 8, + "value": 11036, + }, + "hyd2Pressure": Offset { + "category": "hydraulic", + "convert": undefined, + "description": "hyd2 pressure", + "length": undefined, + "mapping": undefined, + "name": "hyd2Pressure", + "permission": "r", + "type": 8, + "value": 11272, + }, + "hyd2Reservoir": Offset { + "category": "hydraulic", + "convert": "doublePercentRound", + "description": "hyd2 reservoir percent", + "length": undefined, + "mapping": true, + "name": "hyd2Reservoir", + "permission": "r", + "type": 8, + "value": 11292, + }, + "hyd3Pressure": Offset { + "category": "hydraulic", + "convert": undefined, + "description": "hyd3 pressure", + "length": undefined, + "mapping": undefined, + "name": "hyd3Pressure", + "permission": "r", + "type": 8, + "value": 11528, + }, + "hyd3Reservoir": Offset { + "category": "hydraulic", + "convert": "doublePercentRound", + "description": "hyd3 reservoir percent", + "length": undefined, + "mapping": true, + "name": "hyd3Reservoir", + "permission": "r", + "type": 8, + "value": 11548, + }, + "hyd4Pressure": Offset { + "category": "hydraulic", + "convert": undefined, + "description": "hyd4 pressure", + "length": undefined, + "mapping": undefined, + "name": "hyd4Pressure", + "permission": "r", + "type": 8, + "value": 11784, + }, + "hyd4Reservoir": Offset { + "category": "hydraulic", + "convert": "doublePercentRound", + "description": "hyd4 reservoir percent", + "length": undefined, + "mapping": true, + "name": "hyd4Reservoir", + "permission": "r", + "type": 8, + "value": 11804, + }, +} +`; diff --git a/tests/offsets/plane/hydraulic.spec.ts b/tests/offsets/plane/hydraulic.spec.ts new file mode 100644 index 0000000..09d1014 --- /dev/null +++ b/tests/offsets/plane/hydraulic.spec.ts @@ -0,0 +1,24 @@ +import { hydraulic as offsets } from '@offsets/plane/hydraulic'; +import { replaceOffsetExpressionValue } from '@convert/apply-conversion'; + +describe('offset - plane/hydraulic', () => { + const offsetsTestCases = [ + ]; + + describe('offsets list', () => { + it('should have required properties', () => { + expect(offsets).toMatchSnapshot(); + }); + }); + + offsetsTestCases.forEach(testedOffset => { + describe(testedOffset.name, () => { + it('should convert data properly', () => { + const convertExpression = replaceOffsetExpressionValue(offsets[testedOffset.name], testedOffset.value); + + // tslint:disable-next-line:no-eval + expect(eval(convertExpression)).toEqual(testedOffset.expectedResult); + }); + }); + }); +}); From 98d7a789e4149803fe3de040f18ff0fd419ddf46 Mon Sep 17 00:00:00 2001 From: blackholegalaxy Date: Sat, 8 Feb 2020 18:42:31 -0500 Subject: [PATCH 6/8] add offsets --- src/lib/offsets/plane/aerodynamics.ts | 16 ++ src/lib/offsets/plane/cockpit.ts | 27 ++++ src/lib/offsets/plane/controls.ts | 73 +++++++++ src/lib/offsets/plane/electric.ts | 9 ++ src/lib/offsets/plane/wb.ts | 48 +++++- src/shared/offset-category.ts | 2 + .../offsets/__snapshots__/offset.spec.ts.snap | 143 ++++++++++++++++++ .../plane/__snapshots__/cockpit.spec.ts.snap | 33 ++++ .../plane/__snapshots__/controls.spec.ts.snap | 99 ++++++++++++ .../plane/__snapshots__/electric.spec.ts.snap | 11 ++ .../plane/__snapshots__/wb.spec.ts.snap | 57 ++++++- tests/offsets/plane/cockpit.spec.ts | 6 + tests/offsets/plane/electric.spec.ts | 2 + 13 files changed, 524 insertions(+), 2 deletions(-) create mode 100644 src/lib/offsets/plane/aerodynamics.ts diff --git a/src/lib/offsets/plane/aerodynamics.ts b/src/lib/offsets/plane/aerodynamics.ts new file mode 100644 index 0000000..b2739ba --- /dev/null +++ b/src/lib/offsets/plane/aerodynamics.ts @@ -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', + }), +}; diff --git a/src/lib/offsets/plane/cockpit.ts b/src/lib/offsets/plane/cockpit.ts index 0d16320..352a423 100644 --- a/src/lib/offsets/plane/cockpit.ts +++ b/src/lib/offsets/plane/cockpit.ts @@ -296,4 +296,31 @@ export const cockpit: OffsetList = { 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: 'panel auto-feather arm switch', + convert: '!!{VAL}', + type: Type.UInt32, + permission: 'rw', + }), + propSyncActive: new Offset({ + value: 0x2EC8, + name: 'propSyncActive', + category: OffsetCategory.COCKPIT, + description: 'panel auto-feather arm switch', + convert: '!!{VAL}', + type: Type.UInt32, + permission: 'rw', + }), }; diff --git a/src/lib/offsets/plane/controls.ts b/src/lib/offsets/plane/controls.ts index fc2ba66..3420c72 100644 --- a/src/lib/offsets/plane/controls.ts +++ b/src/lib/offsets/plane/controls.ts @@ -415,4 +415,77 @@ export const controls: OffsetList = { type: Type.UInt32, permission: 'rw', }), + elevatorDeflection: new Offset({ + value: 0x2E98, + name: 'elevatorDeflection', + description: 'elevator deflection - radians +ve up -ve down', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'r', + }), + elevatorTrimDeflection: new Offset({ + value: 0x2EA0, + name: 'elevatorTrimDeflection', + description: 'elevator trim deflection - radians +ve up -ve down', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'rw', + }), + aileronDeflection: new Offset({ + value: 0x2EA8, + name: 'aileronDeflection', + description: 'aileron deflection - radians +ve right -ve left', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'r', + }), + aileronTrimDeflection: new Offset({ + value: 0x2EB0, + name: 'aileronTrimDeflection', + description: 'aileron trim deflection - radians +ve right -ve left', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'rw', + }), + rudderDeflection: new Offset({ + value: 0x2EB8, + name: 'rudderDeflection', + description: 'rudder deflection - radians +ve right -ve left', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'r', + }), + rudderTrimDeflection: new Offset({ + value: 0x2EC0, + name: 'rudderTrimDeflection', + description: 'rudder trim deflection - radians +ve right -ve left', + category: OffsetCategory.CONTROLS, + type: Type.Double, + permission: 'rw', + }), + flightDirectorActive: new Offset({ + value: 0x2EE0, + name: 'flightDirectorActive', + category: OffsetCategory.CONTROLS, + description: 'panel auto-feather arm switch', + convert: '!!{VAL}', + type: Type.UInt32, + permission: 'rw', + }), + flightDirectorPitch: new Offset({ + value: 0x2EE8, + name: 'flightDirectorPitch', + category: OffsetCategory.CONTROLS, + description: 'flight director pitch - degrees', + type: Type.Double, + permission: 'rw', + }), + flightDirectorBank: new Offset({ + value: 0x2EF0, + name: 'flightDirectorBank', + category: OffsetCategory.CONTROLS, + description: 'flight director bank - degrees', + type: Type.Double, + permission: 'rw', + }), }; diff --git a/src/lib/offsets/plane/electric.ts b/src/lib/offsets/plane/electric.ts index 8ce0e25..bed33ca 100644 --- a/src/lib/offsets/plane/electric.ts +++ b/src/lib/offsets/plane/electric.ts @@ -166,4 +166,13 @@ export const electric: OffsetList = { type: Type.Double, permission: 'r', }), + masterAvionicsSwitch: new Offset({ + value: 0x2E80, + name: 'masterAvionicsSwitch', + category: OffsetCategory.ELECTRIC, + description: 'master avionics switch', + convert: '!!{VAL}', + type: Type.UInt32, + permission: 'rw', + }), }; diff --git a/src/lib/offsets/plane/wb.ts b/src/lib/offsets/plane/wb.ts index a8748b2..7e2bf65 100644 --- a/src/lib/offsets/plane/wb.ts +++ b/src/lib/offsets/plane/wb.ts @@ -8,11 +8,57 @@ export const weightAndBalance: OffsetList = { lateralCGPercent: new Offset({ value: 0x2E78, name: 'lateralCGPercent', - category: OffsetCategory.SEAPLANE, + category: OffsetCategory.WB, description: 'lateral CG - percent from chord', convert: 'doublePercentRound', mapping: true, type: Type.Double, permission: 'r', }), + CGPercent: new Offset({ + value: 0x2EF8, + name: 'CGPercent', + category: OffsetCategory.WB, + description: 'CG - percent from chord', + convert: 'doublePercentRound', + mapping: true, + type: Type.Double, + permission: 'r', + }), + CGAftLimit: new Offset({ + value: 0x2F00, + name: 'CGAftLimit', + category: OffsetCategory.WB, + description: 'CG aft limit - percent', + convert: 'doublePercentRound', + mapping: true, + type: Type.Double, + permission: 'r', + }), + CGFwdLimit: new Offset({ + value: 0x2F08, + name: 'CGFwdLimit', + category: OffsetCategory.WB, + description: 'CG forward limit - percent', + convert: 'doublePercentRound', + mapping: true, + type: Type.Double, + permission: 'r', + }), + CGMaxMach: new Offset({ + value: 0x2F10, + name: 'CGMaxMach', + category: OffsetCategory.WB, + description: 'CG max mach', + type: Type.Double, + permission: 'r', + }), + CGMinMach: new Offset({ + value: 0x2F18, + name: 'CGMinMach', + category: OffsetCategory.WB, + description: 'CG min mach', + type: Type.Double, + permission: 'r', + }), }; diff --git a/src/shared/offset-category.ts b/src/shared/offset-category.ts index ac6d3c5..875cdae 100644 --- a/src/shared/offset-category.ts +++ b/src/shared/offset-category.ts @@ -1,4 +1,5 @@ export enum OffsetCategory { + AERODYNAMICS = 'aerodynamics', APU = 'APU', AUTOPILOT = 'autopilot', COCKPIT = 'cockpit', @@ -19,5 +20,6 @@ export enum OffsetCategory { RUNWAY = 'runway', SEAPLANE = 'seaplane', SIMULATION = 'simulation', + WB = 'WB', WEATHER = 'weather', } diff --git a/tests/offsets/__snapshots__/offset.spec.ts.snap b/tests/offsets/__snapshots__/offset.spec.ts.snap index 84742a1..a35e64c 100644 --- a/tests/offsets/__snapshots__/offset.spec.ts.snap +++ b/tests/offsets/__snapshots__/offset.spec.ts.snap @@ -266,6 +266,17 @@ Object { "type": 2, "value": 856, }, + "aileronDeflection": Offset { + "category": "controls", + "convert": undefined, + "description": "aileron deflection - radians +ve right -ve left", + "length": undefined, + "mapping": undefined, + "name": "aileronDeflection", + "permission": "r", + "type": 8, + "value": 11944, + }, "aileronIndicator": Offset { "category": "controls", "convert": undefined, @@ -288,6 +299,17 @@ Object { "type": 2, "value": 2998, }, + "aileronTrimDeflection": Offset { + "category": "controls", + "convert": undefined, + "description": "aileron trim deflection - radians +ve right -ve left", + "length": undefined, + "mapping": undefined, + "name": "aileronTrimDeflection", + "permission": "rw", + "type": 8, + "value": 11952, + }, "aileronTrimPosition": Offset { "category": "controls", "convert": "Math.round({VAL} / 16383 * 100)", @@ -1245,6 +1267,17 @@ Object { "type": 0, "value": 2922, }, + "elevatorDeflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevator deflection - radians +ve up -ve down", + "length": undefined, + "mapping": undefined, + "name": "elevatorDeflection", + "permission": "r", + "type": 8, + "value": 11928, + }, "elevatorIndicator": Offset { "category": "controls", "convert": undefined, @@ -1267,6 +1300,17 @@ Object { "type": 2, "value": 2994, }, + "elevatorTrimDeflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevator trim deflection - radians +ve up -ve down", + "length": undefined, + "mapping": undefined, + "name": "elevatorTrimDeflection", + "permission": "rw", + "type": 8, + "value": 11936, + }, "elevatorTrimIndicator": Offset { "category": "controls", "convert": undefined, @@ -3577,6 +3621,39 @@ Object { "type": 6, "value": 2068, }, + "flightDirectorActive": Offset { + "category": "controls", + "convert": "!!{VAL}", + "description": "panel auto-feather arm switch", + "length": undefined, + "mapping": undefined, + "name": "flightDirectorActive", + "permission": "rw", + "type": 6, + "value": 12000, + }, + "flightDirectorBank": Offset { + "category": "controls", + "convert": undefined, + "description": "flight director bank - degrees", + "length": undefined, + "mapping": undefined, + "name": "flightDirectorBank", + "permission": "rw", + "type": 8, + "value": 12016, + }, + "flightDirectorPitch": Offset { + "category": "controls", + "convert": undefined, + "description": "flight director pitch - degrees", + "length": undefined, + "mapping": undefined, + "name": "flightDirectorPitch", + "permission": "rw", + "type": 8, + "value": 12008, + }, "flightModeDisplay": Offset { "category": "simulation", "convert": undefined, @@ -5029,6 +5106,17 @@ Object { "type": 8, "value": 10304, }, + "masterAvionicsSwitch": Offset { + "category": "electric", + "convert": "!!{VAL}", + "description": "master avionics switch", + "length": undefined, + "mapping": undefined, + "name": "masterAvionicsSwitch", + "permission": "rw", + "type": 6, + "value": 11904, + }, "masterBatterySwitch": Offset { "category": "electric", "convert": "!!{VAL}", @@ -5436,6 +5524,17 @@ Object { "type": 0, "value": 877, }, + "panelAutoFeatherArmSwitch": Offset { + "category": "cockpit", + "convert": "!!{VAL}", + "description": "panel auto-feather arm switch", + "length": undefined, + "mapping": undefined, + "name": "panelAutoFeatherArmSwitch", + "permission": "rw", + "type": 6, + "value": 11912, + }, "parkingBrake": Offset { "category": "controls", "convert": "typeof {VAL} === \`boolean\` ? {VAL} ? 32767 : 0 : {VAL} >= 32767", @@ -5678,6 +5777,17 @@ Object { "type": 5, "value": 3912, }, + "propSyncActive": Offset { + "category": "cockpit", + "convert": "!!{VAL}", + "description": "panel auto-feather arm switch", + "length": undefined, + "mapping": undefined, + "name": "propSyncActive", + "permission": "rw", + "type": 6, + "value": 11976, + }, "propeller1AutofeatherArmed": Offset { "category": "engine", "convert": "!!{VAL}", @@ -6008,6 +6118,17 @@ Object { "type": 2, "value": 3082, }, + "rudderDeflection": Offset { + "category": "controls", + "convert": undefined, + "description": "rudder deflection - radians +ve right -ve left", + "length": undefined, + "mapping": undefined, + "name": "rudderDeflection", + "permission": "r", + "type": 8, + "value": 11960, + }, "rudderIndicator": Offset { "category": "controls", "convert": undefined, @@ -6030,6 +6151,17 @@ Object { "type": 2, "value": 3002, }, + "rudderTrimDeflection": Offset { + "category": "controls", + "convert": undefined, + "description": "rudder trim deflection - radians +ve right -ve left", + "length": undefined, + "mapping": undefined, + "name": "rudderTrimDeflection", + "permission": "rw", + "type": 8, + "value": 11968, + }, "rudderTrimPosition": Offset { "category": "controls", "convert": "Math.round({VAL} / 16383 * 100)", @@ -6371,6 +6503,17 @@ Object { "type": 8, "value": 10464, }, + "standbyVacuumCircuitActive": Offset { + "category": "cockpit", + "convert": "!!{VAL}", + "description": "panel auto-feather arm switch", + "length": undefined, + "mapping": undefined, + "name": "standbyVacuumCircuitActive", + "permission": "rw", + "type": 6, + "value": 11920, + }, "startupFlight": Offset { "category": "simulation", "convert": undefined, diff --git a/tests/offsets/plane/__snapshots__/cockpit.spec.ts.snap b/tests/offsets/plane/__snapshots__/cockpit.spec.ts.snap index c53b534..ec7a757 100644 --- a/tests/offsets/plane/__snapshots__/cockpit.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/cockpit.spec.ts.snap @@ -288,6 +288,17 @@ Object { "type": 0, "value": 877, }, + "panelAutoFeatherArmSwitch": Offset { + "category": "cockpit", + "convert": "!!{VAL}", + "description": "panel auto-feather arm switch", + "length": undefined, + "mapping": undefined, + "name": "panelAutoFeatherArmSwitch", + "permission": "rw", + "type": 6, + "value": 11912, + }, "pitotHeat": Offset { "category": "cockpit", "convert": "!!{VAL}", @@ -321,6 +332,17 @@ Object { "type": 9, "value": 900, }, + "propSyncActive": Offset { + "category": "cockpit", + "convert": "!!{VAL}", + "description": "panel auto-feather arm switch", + "length": undefined, + "mapping": undefined, + "name": "propSyncActive", + "permission": "rw", + "type": 6, + "value": 11976, + }, "stallWarning": Offset { "category": "cockpit", "convert": "!!{VAL}", @@ -332,6 +354,17 @@ Object { "type": 0, "value": 876, }, + "standbyVacuumCircuitActive": Offset { + "category": "cockpit", + "convert": "!!{VAL}", + "description": "panel auto-feather arm switch", + "length": undefined, + "mapping": undefined, + "name": "standbyVacuumCircuitActive", + "permission": "rw", + "type": 6, + "value": 11920, + }, "strobeLights": Offset { "category": "cockpit", "convert": "!!{VAL}", diff --git a/tests/offsets/plane/__snapshots__/controls.spec.ts.snap b/tests/offsets/plane/__snapshots__/controls.spec.ts.snap index e4513cd..3d8d587 100644 --- a/tests/offsets/plane/__snapshots__/controls.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/controls.spec.ts.snap @@ -2,6 +2,17 @@ exports[`offset - plane/controls offsets list should have required properties 1`] = ` Object { + "aileronDeflection": Offset { + "category": "controls", + "convert": undefined, + "description": "aileron deflection - radians +ve right -ve left", + "length": undefined, + "mapping": undefined, + "name": "aileronDeflection", + "permission": "r", + "type": 8, + "value": 11944, + }, "aileronIndicator": Offset { "category": "controls", "convert": undefined, @@ -24,6 +35,17 @@ Object { "type": 2, "value": 2998, }, + "aileronTrimDeflection": Offset { + "category": "controls", + "convert": undefined, + "description": "aileron trim deflection - radians +ve right -ve left", + "length": undefined, + "mapping": undefined, + "name": "aileronTrimDeflection", + "permission": "rw", + "type": 8, + "value": 11952, + }, "aileronTrimPosition": Offset { "category": "controls", "convert": "Math.round({VAL} / 16383 * 100)", @@ -68,6 +90,17 @@ Object { "type": 8, "value": 10832, }, + "elevatorDeflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevator deflection - radians +ve up -ve down", + "length": undefined, + "mapping": undefined, + "name": "elevatorDeflection", + "permission": "r", + "type": 8, + "value": 11928, + }, "elevatorIndicator": Offset { "category": "controls", "convert": undefined, @@ -90,6 +123,17 @@ Object { "type": 2, "value": 2994, }, + "elevatorTrimDeflection": Offset { + "category": "controls", + "convert": undefined, + "description": "elevator trim deflection - radians +ve up -ve down", + "length": undefined, + "mapping": undefined, + "name": "elevatorTrimDeflection", + "permission": "rw", + "type": 8, + "value": 11936, + }, "elevatorTrimIndicator": Offset { "category": "controls", "convert": undefined, @@ -244,6 +288,39 @@ Object { "type": 3, "value": 3040, }, + "flightDirectorActive": Offset { + "category": "controls", + "convert": "!!{VAL}", + "description": "panel auto-feather arm switch", + "length": undefined, + "mapping": undefined, + "name": "flightDirectorActive", + "permission": "rw", + "type": 6, + "value": 12000, + }, + "flightDirectorBank": Offset { + "category": "controls", + "convert": undefined, + "description": "flight director bank - degrees", + "length": undefined, + "mapping": undefined, + "name": "flightDirectorBank", + "permission": "rw", + "type": 8, + "value": 12016, + }, + "flightDirectorPitch": Offset { + "category": "controls", + "convert": undefined, + "description": "flight director pitch - degrees", + "length": undefined, + "mapping": undefined, + "name": "flightDirectorPitch", + "permission": "rw", + "type": 8, + "value": 12008, + }, "foldingWingLeft": Offset { "category": "controls", "convert": "doublePercentRound", @@ -420,6 +497,17 @@ Object { "type": 2, "value": 3082, }, + "rudderDeflection": Offset { + "category": "controls", + "convert": undefined, + "description": "rudder deflection - radians +ve right -ve left", + "length": undefined, + "mapping": undefined, + "name": "rudderDeflection", + "permission": "r", + "type": 8, + "value": 11960, + }, "rudderIndicator": Offset { "category": "controls", "convert": undefined, @@ -442,6 +530,17 @@ Object { "type": 2, "value": 3002, }, + "rudderTrimDeflection": Offset { + "category": "controls", + "convert": undefined, + "description": "rudder trim deflection - radians +ve right -ve left", + "length": undefined, + "mapping": undefined, + "name": "rudderTrimDeflection", + "permission": "rw", + "type": 8, + "value": 11968, + }, "rudderTrimPosition": Offset { "category": "controls", "convert": "Math.round({VAL} / 16383 * 100)", diff --git a/tests/offsets/plane/__snapshots__/electric.spec.ts.snap b/tests/offsets/plane/__snapshots__/electric.spec.ts.snap index 1a2a25e..ac06ea1 100644 --- a/tests/offsets/plane/__snapshots__/electric.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/electric.spec.ts.snap @@ -200,6 +200,17 @@ Object { "type": 8, "value": 10304, }, + "masterAvionicsSwitch": Offset { + "category": "electric", + "convert": "!!{VAL}", + "description": "master avionics switch", + "length": undefined, + "mapping": undefined, + "name": "masterAvionicsSwitch", + "permission": "rw", + "type": 6, + "value": 11904, + }, "masterBatterySwitch": Offset { "category": "electric", "convert": "!!{VAL}", diff --git a/tests/offsets/plane/__snapshots__/wb.spec.ts.snap b/tests/offsets/plane/__snapshots__/wb.spec.ts.snap index 520bea0..6fb93b1 100644 --- a/tests/offsets/plane/__snapshots__/wb.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/wb.spec.ts.snap @@ -2,8 +2,63 @@ exports[`offset - plane/weightAndBalance offsets list should have required properties 1`] = ` Object { + "CGAftLimit": Offset { + "category": "WB", + "convert": "doublePercentRound", + "description": "CG aft limit - percent", + "length": undefined, + "mapping": true, + "name": "CGAftLimit", + "permission": "r", + "type": 8, + "value": 12032, + }, + "CGFwdLimit": Offset { + "category": "WB", + "convert": "doublePercentRound", + "description": "CG forward limit - percent", + "length": undefined, + "mapping": true, + "name": "CGFwdLimit", + "permission": "r", + "type": 8, + "value": 12040, + }, + "CGMaxMach": Offset { + "category": "WB", + "convert": undefined, + "description": "CG max mach", + "length": undefined, + "mapping": undefined, + "name": "CGMaxMach", + "permission": "r", + "type": 8, + "value": 12048, + }, + "CGMinMach": Offset { + "category": "WB", + "convert": undefined, + "description": "CG min mach", + "length": undefined, + "mapping": undefined, + "name": "CGMinMach", + "permission": "r", + "type": 8, + "value": 12056, + }, + "CGPercent": Offset { + "category": "WB", + "convert": "doublePercentRound", + "description": "CG - percent from chord", + "length": undefined, + "mapping": true, + "name": "CGPercent", + "permission": "r", + "type": 8, + "value": 12024, + }, "lateralCGPercent": Offset { - "category": "seaplane", + "category": "WB", "convert": "doublePercentRound", "description": "lateral CG - percent from chord", "length": undefined, diff --git a/tests/offsets/plane/cockpit.spec.ts b/tests/offsets/plane/cockpit.spec.ts index 0ea1774..56920ca 100644 --- a/tests/offsets/plane/cockpit.spec.ts +++ b/tests/offsets/plane/cockpit.spec.ts @@ -31,6 +31,12 @@ describe('offset - plane/cockpit', () => { { name: 'altitudeChangeRate321EFIS', value: 0, expectedResult: 100 }, { name: 'altitudeChangeRate321EFIS', value: 1, expectedResult: 1000 }, { name: 'gyroCompassHeading', value: 167.54, expectedResult: 168 }, + { name: 'panelAutoFeatherArmSwitch', value: 0, expectedResult: false }, + { name: 'panelAutoFeatherArmSwitch', value: 1, expectedResult: true }, + { name: 'standbyVacuumCircuitActive', value: 0, expectedResult: false }, + { name: 'standbyVacuumCircuitActive', value: 1, expectedResult: true }, + { name: 'propSyncActive', value: 0, expectedResult: false }, + { name: 'propSyncActive', value: 1, expectedResult: true }, ]; describe('offsets list', () => { diff --git a/tests/offsets/plane/electric.spec.ts b/tests/offsets/plane/electric.spec.ts index 95a550c..bab354b 100644 --- a/tests/offsets/plane/electric.spec.ts +++ b/tests/offsets/plane/electric.spec.ts @@ -5,6 +5,8 @@ describe('offset - plane/electric', () => { const offsetsTestCases = [ { name: 'masterBatterySwitch', value: 0, expectedResult: false }, { name: 'masterBatterySwitch', value: 1, expectedResult: true }, + { name: 'masterAvionicsSwitch', value: 0, expectedResult: false }, + { name: 'masterAvionicsSwitch', value: 1, expectedResult: true }, ]; describe('offsets list', () => { From 72959de3476d71741056a8f2a3e91252de5d35a0 Mon Sep 17 00:00:00 2001 From: blackholegalaxy Date: Sat, 8 Feb 2020 20:38:41 -0500 Subject: [PATCH 7/8] add offset and converts --- src/lib/convert/mappings/autobrake.ts | 20 ++++ .../convert/mappings/fuel-transfer-mode.ts | 16 +++ src/lib/convert/mappings/index.ts | 6 + src/lib/offsets/plane/autopilot.ts | 16 +++ src/lib/offsets/plane/cockpit.ts | 37 +++++- src/lib/offsets/plane/controls.ts | 20 +++- src/lib/offsets/plane/fuel.ts | 10 ++ src/lib/offsets/plane/hydraulic.ts | 10 ++ src/shared/plane/autobrake.ts | 8 ++ src/shared/plane/fuel-transfer-mode.ts | 6 + .../__snapshots__/mappings.spec.ts.snap | 2 + .../mappings/fuel-transfer-mode.spec.ts | 19 ++++ .../offsets/__snapshots__/offset.spec.ts.snap | 107 +++++++++++++++++- .../__snapshots__/autopilot.spec.ts.snap | 22 ++++ .../plane/__snapshots__/cockpit.spec.ts.snap | 48 +++++++- .../plane/__snapshots__/controls.spec.ts.snap | 26 ++++- .../plane/__snapshots__/fuel.spec.ts.snap | 11 ++ .../__snapshots__/hydraulic.spec.ts.snap | 11 ++ tests/offsets/plane/cockpit.spec.ts | 2 + 19 files changed, 386 insertions(+), 11 deletions(-) create mode 100644 src/lib/convert/mappings/autobrake.ts create mode 100644 src/lib/convert/mappings/fuel-transfer-mode.ts create mode 100644 src/shared/plane/autobrake.ts create mode 100644 src/shared/plane/fuel-transfer-mode.ts create mode 100644 tests/convert/mappings/fuel-transfer-mode.spec.ts diff --git a/src/lib/convert/mappings/autobrake.ts b/src/lib/convert/mappings/autobrake.ts new file mode 100644 index 0000000..e7a80e5 --- /dev/null +++ b/src/lib/convert/mappings/autobrake.ts @@ -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; + } +}; diff --git a/src/lib/convert/mappings/fuel-transfer-mode.ts b/src/lib/convert/mappings/fuel-transfer-mode.ts new file mode 100644 index 0000000..a9dc5cb --- /dev/null +++ b/src/lib/convert/mappings/fuel-transfer-mode.ts @@ -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; + } +}; diff --git a/src/lib/convert/mappings/index.ts b/src/lib/convert/mappings/index.ts index 0698802..8bc250f 100644 --- a/src/lib/convert/mappings/index.ts +++ b/src/lib/convert/mappings/index.ts @@ -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, @@ -31,6 +33,8 @@ export const MAPPINGS: { [key: string]: (_: any) => any } = { appliedBrakes, spoilersControl, fuelTank, + fuelTransferMode, + autoBrake, // environment nearestAirportsIds, @@ -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'; diff --git a/src/lib/offsets/plane/autopilot.ts b/src/lib/offsets/plane/autopilot.ts index 50615cd..e0b6427 100644 --- a/src/lib/offsets/plane/autopilot.ts +++ b/src/lib/offsets/plane/autopilot.ts @@ -272,4 +272,20 @@ export const autopilot: OffsetList = { 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', + }), }; diff --git a/src/lib/offsets/plane/cockpit.ts b/src/lib/offsets/plane/cockpit.ts index 352a423..f50651d 100644 --- a/src/lib/offsets/plane/cockpit.ts +++ b/src/lib/offsets/plane/cockpit.ts @@ -309,7 +309,7 @@ export const cockpit: OffsetList = { value: 0x2E90, name: 'standbyVacuumCircuitActive', category: OffsetCategory.COCKPIT, - description: 'panel auto-feather arm switch', + description: 'standby vacuum circuit active', convert: '!!{VAL}', type: Type.UInt32, permission: 'rw', @@ -318,9 +318,42 @@ export const cockpit: OffsetList = { value: 0x2EC8, name: 'propSyncActive', category: OffsetCategory.COCKPIT, - description: 'panel auto-feather arm switch', + 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', + }), }; diff --git a/src/lib/offsets/plane/controls.ts b/src/lib/offsets/plane/controls.ts index 3420c72..cbc9481 100644 --- a/src/lib/offsets/plane/controls.ts +++ b/src/lib/offsets/plane/controls.ts @@ -478,7 +478,7 @@ export const controls: OffsetList = { category: OffsetCategory.CONTROLS, description: 'flight director pitch - degrees', type: Type.Double, - permission: 'rw', + permission: 'r', }), flightDirectorBank: new Offset({ value: 0x2EF0, @@ -486,6 +486,24 @@ export const controls: OffsetList = { category: OffsetCategory.CONTROLS, description: 'flight director bank - degrees', type: Type.Double, + permission: 'r', + }), + gearPosTail: new Offset({ + value: 0x2F38, + name: 'gearPosTail', + category: OffsetCategory.CONTROLS, + description: 'gear pos tail', + type: Type.Double, + permission: 'r', + }), + autoBrakeSwitch: new Offset({ + value: 0x2F80, + name: 'autoBrakeSwitch', + category: OffsetCategory.CONTROLS, + description: 'auto brake switch', + convert: 'autoBrake', + mapping: true, + type: Type.SByte, permission: 'rw', }), }; diff --git a/src/lib/offsets/plane/fuel.ts b/src/lib/offsets/plane/fuel.ts index 4619dba..ff67b2d 100644 --- a/src/lib/offsets/plane/fuel.ts +++ b/src/lib/offsets/plane/fuel.ts @@ -243,4 +243,14 @@ export const fuel: OffsetList = { type: Type.Int32, permission: 'r', }), + selectedFuelTransferMode: new Offset({ + value: 0x2F58, + name: 'selectedFuelTransferMode', + category: OffsetCategory.FUEL, + description: 'selected fuel transfer mode', + convert: 'fuelTransferMode', + mapping: true, + type: Type.UInt32, + permission: 'r', + }), }; diff --git a/src/lib/offsets/plane/hydraulic.ts b/src/lib/offsets/plane/hydraulic.ts index b4ca585..96786be 100644 --- a/src/lib/offsets/plane/hydraulic.ts +++ b/src/lib/offsets/plane/hydraulic.ts @@ -77,4 +77,14 @@ export const hydraulic: OffsetList = { type: Type.Double, permission: 'r', }), + hydSystemIntegrity: new Offset({ + value: 0x2F60, + name: 'hydSystemIntegrity', + category: OffsetCategory.HYDRAULIC, + description: 'hydraulic system integrity - percent', + convert: 'doublePercentRound', + mapping: true, + type: Type.Double, + permission: 'r', + }), }; diff --git a/src/shared/plane/autobrake.ts b/src/shared/plane/autobrake.ts new file mode 100644 index 0000000..79599c4 --- /dev/null +++ b/src/shared/plane/autobrake.ts @@ -0,0 +1,8 @@ +export enum AutoBrake { + RTO = 'rto', + OFF = 'off', + BRAKE1 = 'brake1', + BRAKE2 = 'brake2', + BRAKE3 = 'brake3', + MAX = 'max', +} diff --git a/src/shared/plane/fuel-transfer-mode.ts b/src/shared/plane/fuel-transfer-mode.ts new file mode 100644 index 0000000..9ff2d8c --- /dev/null +++ b/src/shared/plane/fuel-transfer-mode.ts @@ -0,0 +1,6 @@ +export enum FuelTransferMode { + NONE = 'none', + AUTO = 'auto', + FWD = 'fwd', + AFT = 'aft', +} diff --git a/tests/convert/mappings/__snapshots__/mappings.spec.ts.snap b/tests/convert/mappings/__snapshots__/mappings.spec.ts.snap index d923f3a..9dd8901 100644 --- a/tests/convert/mappings/__snapshots__/mappings.spec.ts.snap +++ b/tests/convert/mappings/__snapshots__/mappings.spec.ts.snap @@ -3,10 +3,12 @@ exports[`mappings list should import all mappings 1`] = ` Object { "appliedBrakes": [Function], + "autoBrake": [Function], "cloudType": [Function], "engineType": [Function], "ftsecToKt": [Function], "fuelTank": [Function], + "fuelTransferMode": [Function], "ktToFtsec": [Function], "lightsMapping": [Function], "navBackCourseFlags": [Function], diff --git a/tests/convert/mappings/fuel-transfer-mode.spec.ts b/tests/convert/mappings/fuel-transfer-mode.spec.ts new file mode 100644 index 0000000..4216fe0 --- /dev/null +++ b/tests/convert/mappings/fuel-transfer-mode.spec.ts @@ -0,0 +1,19 @@ + +import { fuelTransferMode } from '@mappings/fuel-transfer-mode'; +import { FuelTransferMode } from '@shared/plane/fuel-transfer-mode'; + +const TESTS = [ + { value: 0, result: FuelTransferMode.NONE }, + { value: 1, result: FuelTransferMode.AUTO }, + { value: 2, result: FuelTransferMode.FWD }, + { value: 3, result: FuelTransferMode.AFT }, + { value: null, result: null }, +]; + +describe('fuel-transfer-mode mapping', () => { + TESTS.forEach(test => { + it(`should map value ${test.value} to fuel-transfer-mode ${test.result}`, () => { + expect(fuelTransferMode(test.value)).toEqual(test.result); + }); + }); +}); diff --git a/tests/offsets/__snapshots__/offset.spec.ts.snap b/tests/offsets/__snapshots__/offset.spec.ts.snap index a35e64c..de0f67c 100644 --- a/tests/offsets/__snapshots__/offset.spec.ts.snap +++ b/tests/offsets/__snapshots__/offset.spec.ts.snap @@ -552,6 +552,17 @@ Object { "type": 6, "value": 2052, }, + "apCruiseSpeed": Offset { + "category": "autopilot", + "convert": undefined, + "description": "AP cruise speed", + "length": undefined, + "mapping": undefined, + "name": "apCruiseSpeed", + "permission": "r", + "type": 8, + "value": 12104, + }, "apGlideSlopeHold": Offset { "category": "autopilot", "convert": "!!{VAL}", @@ -629,6 +640,17 @@ Object { "type": 6, "value": 11780, }, + "apMaxSpeed": Offset { + "category": "autopilot", + "convert": undefined, + "description": "AP max speed", + "length": undefined, + "mapping": undefined, + "name": "apMaxSpeed", + "permission": "r", + "type": 8, + "value": 12096, + }, "apNav1Hold": Offset { "category": "autopilot", "convert": "!!{VAL}", @@ -717,6 +739,28 @@ Object { "type": 6, "value": 2056, }, + "attitudeCageButton": Offset { + "category": "cockpit", + "convert": "!!{VAL}", + "description": "attitude cage button", + "length": undefined, + "mapping": undefined, + "name": "attitudeCageButton", + "permission": "rw", + "type": 6, + "value": 12136, + }, + "attitudeIndicatorBank": Offset { + "category": "cockpit", + "convert": undefined, + "description": "attitude indicator bank - degrees", + "length": undefined, + "mapping": undefined, + "name": "attitudeIndicatorBank", + "permission": "r", + "type": 8, + "value": 12152, + }, "attitudeIndicatorFailure": Offset { "category": "failure", "convert": "typeof {VAL} === \`boolean\` ? {VAL} ? 1 : 0 : !!{VAL}", @@ -728,6 +772,28 @@ Object { "type": 0, "value": 2919, }, + "attitudeIndicatorPitch": Offset { + "category": "cockpit", + "convert": undefined, + "description": "attitude indicator pitch - degrees", + "length": undefined, + "mapping": undefined, + "name": "attitudeIndicatorPitch", + "permission": "r", + "type": 8, + "value": 12144, + }, + "autoBrakeSwitch": Offset { + "category": "controls", + "convert": "autoBrake", + "description": "auto brake switch", + "length": undefined, + "mapping": true, + "name": "autoBrakeSwitch", + "permission": "rw", + "type": 1, + "value": 12160, + }, "autoPilotAvailable": Offset { "category": "autopilot", "convert": "!!{VAL}", @@ -816,6 +882,17 @@ Object { "type": 3, "value": 1404, }, + "barberPoleMach": Offset { + "category": "cockpit", + "convert": undefined, + "description": "barber pole mach", + "length": undefined, + "mapping": undefined, + "name": "barberPoleMach", + "permission": "r", + "type": 8, + "value": 12112, + }, "batteryBusAmps": Offset { "category": "electric", "convert": undefined, @@ -3639,7 +3716,7 @@ Object { "length": undefined, "mapping": undefined, "name": "flightDirectorBank", - "permission": "rw", + "permission": "r", "type": 8, "value": 12016, }, @@ -3650,7 +3727,7 @@ Object { "length": undefined, "mapping": undefined, "name": "flightDirectorPitch", - "permission": "rw", + "permission": "r", "type": 8, "value": 12008, }, @@ -4182,6 +4259,17 @@ Object { "type": 3, "value": 3052, }, + "gearPosTail": Offset { + "category": "controls", + "convert": undefined, + "description": "gear pos tail", + "length": undefined, + "mapping": undefined, + "name": "gearPosTail", + "permission": "r", + "type": 8, + "value": 12088, + }, "gearRightPosition": Offset { "category": "controls", "convert": "Math.round({VAL} / 16383 * 100)", @@ -5780,7 +5868,7 @@ Object { "propSyncActive": Offset { "category": "cockpit", "convert": "!!{VAL}", - "description": "panel auto-feather arm switch", + "description": "prop sync active", "length": undefined, "mapping": undefined, "name": "propSyncActive", @@ -6272,6 +6360,17 @@ Object { "type": 5, "value": 584, }, + "selectedFuelTransferMode": Offset { + "category": "fuel", + "convert": "fuelTransferMode", + "description": "selected fuel transfer mode", + "length": undefined, + "mapping": true, + "name": "selectedFuelTransferMode", + "permission": "r", + "type": 6, + "value": 12120, + }, "simulationRate": Offset { "category": "simulation", "convert": "+({VAL} / 256).toFixed(2)", @@ -6506,7 +6605,7 @@ Object { "standbyVacuumCircuitActive": Offset { "category": "cockpit", "convert": "!!{VAL}", - "description": "panel auto-feather arm switch", + "description": "standby vacuum circuit active", "length": undefined, "mapping": undefined, "name": "standbyVacuumCircuitActive", diff --git a/tests/offsets/plane/__snapshots__/autopilot.spec.ts.snap b/tests/offsets/plane/__snapshots__/autopilot.spec.ts.snap index 057f4ad..de859a1 100644 --- a/tests/offsets/plane/__snapshots__/autopilot.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/autopilot.spec.ts.snap @@ -90,6 +90,17 @@ Object { "type": 6, "value": 2052, }, + "apCruiseSpeed": Offset { + "category": "autopilot", + "convert": undefined, + "description": "AP cruise speed", + "length": undefined, + "mapping": undefined, + "name": "apCruiseSpeed", + "permission": "r", + "type": 8, + "value": 12104, + }, "apGlideSlopeHold": Offset { "category": "autopilot", "convert": "!!{VAL}", @@ -167,6 +178,17 @@ Object { "type": 6, "value": 11780, }, + "apMaxSpeed": Offset { + "category": "autopilot", + "convert": undefined, + "description": "AP max speed", + "length": undefined, + "mapping": undefined, + "name": "apMaxSpeed", + "permission": "r", + "type": 8, + "value": 12096, + }, "apNav1Hold": Offset { "category": "autopilot", "convert": "!!{VAL}", diff --git a/tests/offsets/plane/__snapshots__/cockpit.spec.ts.snap b/tests/offsets/plane/__snapshots__/cockpit.spec.ts.snap index ec7a757..175dd05 100644 --- a/tests/offsets/plane/__snapshots__/cockpit.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/cockpit.spec.ts.snap @@ -167,6 +167,39 @@ Object { "type": 5, "value": 3610, }, + "attitudeCageButton": Offset { + "category": "cockpit", + "convert": "!!{VAL}", + "description": "attitude cage button", + "length": undefined, + "mapping": undefined, + "name": "attitudeCageButton", + "permission": "rw", + "type": 6, + "value": 12136, + }, + "attitudeIndicatorBank": Offset { + "category": "cockpit", + "convert": undefined, + "description": "attitude indicator bank - degrees", + "length": undefined, + "mapping": undefined, + "name": "attitudeIndicatorBank", + "permission": "r", + "type": 8, + "value": 12152, + }, + "attitudeIndicatorPitch": Offset { + "category": "cockpit", + "convert": undefined, + "description": "attitude indicator pitch - degrees", + "length": undefined, + "mapping": undefined, + "name": "attitudeIndicatorPitch", + "permission": "r", + "type": 8, + "value": 12144, + }, "autopilotSpeedSwitch321EFIS": Offset { "category": "cockpit", "convert": "!!{VAL}", @@ -189,6 +222,17 @@ Object { "type": 5, "value": 3596, }, + "barberPoleMach": Offset { + "category": "cockpit", + "convert": undefined, + "description": "barber pole mach", + "length": undefined, + "mapping": undefined, + "name": "barberPoleMach", + "permission": "r", + "type": 8, + "value": 12112, + }, "bleedAirSourceControl": Offset { "category": "cockpit", "convert": undefined, @@ -335,7 +379,7 @@ Object { "propSyncActive": Offset { "category": "cockpit", "convert": "!!{VAL}", - "description": "panel auto-feather arm switch", + "description": "prop sync active", "length": undefined, "mapping": undefined, "name": "propSyncActive", @@ -357,7 +401,7 @@ Object { "standbyVacuumCircuitActive": Offset { "category": "cockpit", "convert": "!!{VAL}", - "description": "panel auto-feather arm switch", + "description": "standby vacuum circuit active", "length": undefined, "mapping": undefined, "name": "standbyVacuumCircuitActive", diff --git a/tests/offsets/plane/__snapshots__/controls.spec.ts.snap b/tests/offsets/plane/__snapshots__/controls.spec.ts.snap index 3d8d587..a9f8cfd 100644 --- a/tests/offsets/plane/__snapshots__/controls.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/controls.spec.ts.snap @@ -57,6 +57,17 @@ Object { "type": 2, "value": 3074, }, + "autoBrakeSwitch": Offset { + "category": "controls", + "convert": "autoBrake", + "description": "auto brake switch", + "length": undefined, + "mapping": true, + "name": "autoBrakeSwitch", + "permission": "rw", + "type": 1, + "value": 12160, + }, "autoRudder": Offset { "category": "controls", "convert": "!!{VAL}", @@ -306,7 +317,7 @@ Object { "length": undefined, "mapping": undefined, "name": "flightDirectorBank", - "permission": "rw", + "permission": "r", "type": 8, "value": 12016, }, @@ -317,7 +328,7 @@ Object { "length": undefined, "mapping": undefined, "name": "flightDirectorPitch", - "permission": "rw", + "permission": "r", "type": 8, "value": 12008, }, @@ -376,6 +387,17 @@ Object { "type": 3, "value": 3052, }, + "gearPosTail": Offset { + "category": "controls", + "convert": undefined, + "description": "gear pos tail", + "length": undefined, + "mapping": undefined, + "name": "gearPosTail", + "permission": "r", + "type": 8, + "value": 12088, + }, "gearRightPosition": Offset { "category": "controls", "convert": "Math.round({VAL} / 16383 * 100)", diff --git a/tests/offsets/plane/__snapshots__/fuel.spec.ts.snap b/tests/offsets/plane/__snapshots__/fuel.spec.ts.snap index 7aa2212..0ca7db6 100644 --- a/tests/offsets/plane/__snapshots__/fuel.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/fuel.spec.ts.snap @@ -299,6 +299,17 @@ Object { "type": 2, "value": 2804, }, + "selectedFuelTransferMode": Offset { + "category": "fuel", + "convert": "fuelTransferMode", + "description": "selected fuel transfer mode", + "length": undefined, + "mapping": true, + "name": "selectedFuelTransferMode", + "permission": "r", + "type": 6, + "value": 12120, + }, "totalFuelCapacity": Offset { "category": "fuel", "convert": undefined, diff --git a/tests/offsets/plane/__snapshots__/hydraulic.spec.ts.snap b/tests/offsets/plane/__snapshots__/hydraulic.spec.ts.snap index 441c418..7f0a53c 100644 --- a/tests/offsets/plane/__snapshots__/hydraulic.spec.ts.snap +++ b/tests/offsets/plane/__snapshots__/hydraulic.spec.ts.snap @@ -90,5 +90,16 @@ Object { "type": 8, "value": 11804, }, + "hydSystemIntegrity": Offset { + "category": "hydraulic", + "convert": "doublePercentRound", + "description": "hydraulic system integrity - percent", + "length": undefined, + "mapping": true, + "name": "hydSystemIntegrity", + "permission": "r", + "type": 8, + "value": 12128, + }, } `; diff --git a/tests/offsets/plane/cockpit.spec.ts b/tests/offsets/plane/cockpit.spec.ts index 56920ca..560548a 100644 --- a/tests/offsets/plane/cockpit.spec.ts +++ b/tests/offsets/plane/cockpit.spec.ts @@ -37,6 +37,8 @@ describe('offset - plane/cockpit', () => { { name: 'standbyVacuumCircuitActive', value: 1, expectedResult: true }, { name: 'propSyncActive', value: 0, expectedResult: false }, { name: 'propSyncActive', value: 1, expectedResult: true }, + { name: 'attitudeCageButton', value: 0, expectedResult: false }, + { name: 'attitudeCageButton', value: 1, expectedResult: true }, ]; describe('offsets list', () => { From 06354726a20e81cb126aca7a2f3a133c11037ad7 Mon Sep 17 00:00:00 2001 From: blackholegalaxy Date: Sat, 8 Feb 2020 21:14:18 -0500 Subject: [PATCH 8/8] add HSI offsets --- src/lib/offsets/plane/radios/hsi.ts | 106 +++++++++++++++ .../radios/__snapshots__/hsi.spec.ts.snap | 127 ++++++++++++++++++ tests/offsets/plane/radios/hsi.spec.ts | 33 +++++ 3 files changed, 266 insertions(+) create mode 100644 src/lib/offsets/plane/radios/hsi.ts create mode 100644 tests/offsets/plane/radios/__snapshots__/hsi.spec.ts.snap create mode 100644 tests/offsets/plane/radios/hsi.spec.ts diff --git a/src/lib/offsets/plane/radios/hsi.ts b/src/lib/offsets/plane/radios/hsi.ts new file mode 100644 index 0000000..70f423b --- /dev/null +++ b/src/lib/offsets/plane/radios/hsi.ts @@ -0,0 +1,106 @@ +import { Type } from 'fsuipc'; + +import { OffsetCategory } from '@shared/offset-category'; +import { OffsetList } from '@shared/offset-list'; +import { Offset } from '@shared/offset'; + +export const HSI: OffsetList = { + HSICDINeedlePosition: new Offset({ + value: 0x2F88, + name: 'HSICDINeedlePosition', + category: OffsetCategory.RADIOS, + description: 'HSI CDI needle position - percent - 10 for VOR - 2.5 for LOC', + type: Type.Double, + convert: 'Math.round({VAL} * 100 / 127)', + permission: 'r', + }), + HSIGSINeedlePosition: new Offset({ + value: 0x2F90, + name: 'HSIGSINeedlePosition', + category: OffsetCategory.RADIOS, + description: 'HSI GSI needle position - percent - represents range from -0.7 to 0.7', + type: Type.Double, + convert: 'Math.round({VAL} * 100 / 119)', + permission: 'r', + }), + HSISpeed: new Offset({ + value: 0x2F98, + name: 'HSISpeed', + category: OffsetCategory.RADIOS, + description: 'HSI speed', + type: Type.Double, + convert: 'Math.round({VAL} * 1.94384)', + permission: 'r', + }), + HSIDistance: new Offset({ + value: 0x2FA0, + name: 'HSIDistance', + category: OffsetCategory.RADIOS, + description: 'HSI distance - meters', + type: Type.Double, + permission: 'r', + }), + HSIBearing: new Offset({ + value: 0x2FA8, + name: 'HSIBearing', + category: OffsetCategory.RADIOS, + description: 'HSI bearing - degrees', + type: Type.UInt16, + permission: 'r', + }), + HSICDIValid: new Offset({ + value: 0x2FAA, + name: 'HSICDIValid', + category: OffsetCategory.RADIOS, + description: 'HSI CDI valid flag', + convert: '!!{VAL}', + type: Type.Byte, + permission: 'r', + }), + HSIGSIValid: new Offset({ + value: 0x2FAB, + name: 'HSIGSIValid', + category: OffsetCategory.RADIOS, + description: 'HSI GSI valid flag', + convert: '!!{VAL}', + type: Type.Byte, + permission: 'r', + }), + HSIBearingValid: new Offset({ + value: 0x2FAC, + name: 'HSIBearingValid', + category: OffsetCategory.RADIOS, + description: 'HSI Bearing valid flag', + convert: '!!{VAL}', + type: Type.Byte, + permission: 'r', + }), + HSIToFrom: new Offset({ + value: 0x2FAD, + name: 'HSIToFrom', + category: OffsetCategory.RADIOS, + description: 'HSI To/From flag', + convert: 'vorToFrom', + mapping: true, + type: Type.Byte, + permission: 'r', + }), + HSIHasLocaliser: new Offset({ + value: 0x2FAE, + name: 'HSIHasLocaliser', + category: OffsetCategory.RADIOS, + description: 'HSI has localiser flag', + convert: '!!{VAL}', + type: Type.Byte, + permission: 'r', + }), + HSIIdent: new Offset({ + value: 0x2FB0, + name: 'HSIIdent', + category: OffsetCategory.RADIOS, + description: 'HSI ident string', + length: 6, + type: Type.String, + permission: 'r', + }), +}; diff --git a/tests/offsets/plane/radios/__snapshots__/hsi.spec.ts.snap b/tests/offsets/plane/radios/__snapshots__/hsi.spec.ts.snap new file mode 100644 index 0000000..d2d60c4 --- /dev/null +++ b/tests/offsets/plane/radios/__snapshots__/hsi.spec.ts.snap @@ -0,0 +1,127 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`offset - plane/radios/hsi offsets list should have required properties 1`] = ` +Object { + "HSIBearing": Offset { + "category": "radios", + "convert": undefined, + "description": "HSI bearing - degrees", + "length": undefined, + "mapping": undefined, + "name": "HSIBearing", + "permission": "r", + "type": 5, + "value": 12200, + }, + "HSIBearingValid": Offset { + "category": "radios", + "convert": "!!{VAL}", + "description": "HSI Bearing valid flag", + "length": undefined, + "mapping": undefined, + "name": "HSIBearingValid", + "permission": "r", + "type": 0, + "value": 12204, + }, + "HSICDINeedlePosition": Offset { + "category": "radios", + "convert": "Math.round({VAL} * 100 / 127)", + "description": "HSI CDI needle position - percent - 10 for VOR - 2.5 for LOC", + "length": undefined, + "mapping": undefined, + "name": "HSICDINeedlePosition", + "permission": "r", + "type": 8, + "value": 12168, + }, + "HSICDIValid": Offset { + "category": "radios", + "convert": "!!{VAL}", + "description": "HSI CDI valid flag", + "length": undefined, + "mapping": undefined, + "name": "HSICDIValid", + "permission": "r", + "type": 0, + "value": 12202, + }, + "HSIDistance": Offset { + "category": "radios", + "convert": undefined, + "description": "HSI distance - meters", + "length": undefined, + "mapping": undefined, + "name": "HSIDistance", + "permission": "r", + "type": 8, + "value": 12192, + }, + "HSIGSINeedlePosition": Offset { + "category": "radios", + "convert": "Math.round({VAL} * 100 / 119)", + "description": "HSI GSI needle position - percent - represents range from -0.7 to 0.7", + "length": undefined, + "mapping": undefined, + "name": "HSIGSINeedlePosition", + "permission": "r", + "type": 8, + "value": 12176, + }, + "HSIGSIValid": Offset { + "category": "radios", + "convert": "!!{VAL}", + "description": "HSI GSI valid flag", + "length": undefined, + "mapping": undefined, + "name": "HSIGSIValid", + "permission": "r", + "type": 0, + "value": 12203, + }, + "HSIHasLocaliser": Offset { + "category": "radios", + "convert": "!!{VAL}", + "description": "HSI has localiser flag", + "length": undefined, + "mapping": undefined, + "name": "HSIHasLocaliser", + "permission": "r", + "type": 0, + "value": 12206, + }, + "HSIIdent": Offset { + "category": "radios", + "convert": undefined, + "description": "HSI ident string", + "length": 6, + "mapping": undefined, + "name": "HSIIdent", + "permission": "r", + "type": 11, + "value": 12208, + }, + "HSISpeed": Offset { + "category": "radios", + "convert": "Math.round({VAL} * 1.94384)", + "description": "HSI speed", + "length": undefined, + "mapping": undefined, + "name": "HSISpeed", + "permission": "r", + "type": 8, + "value": 12184, + }, + "HSIToFrom": Offset { + "category": "radios", + "convert": "vorToFrom", + "description": "HSI To/From flag", + "length": undefined, + "mapping": true, + "name": "HSIToFrom", + "permission": "r", + "type": 0, + "value": 12205, + }, +} +`; diff --git a/tests/offsets/plane/radios/hsi.spec.ts b/tests/offsets/plane/radios/hsi.spec.ts new file mode 100644 index 0000000..6bb5f25 --- /dev/null +++ b/tests/offsets/plane/radios/hsi.spec.ts @@ -0,0 +1,33 @@ +import { HSI as offsets } from '@offsets/plane/radios/hsi'; +import { replaceOffsetExpressionValue } from '@convert/apply-conversion'; + +describe('offset - plane/radios/hsi', () => { + const offsetsTestCases = [ + { name: 'HSICDINeedlePosition', value: 102.786, expectedResult: 81 }, + { name: 'HSIGSINeedlePosition', value: 102.786, expectedResult: 86 }, + { name: 'HSISpeed', value: 100, expectedResult: 194 }, + { name: 'HSICDIValid', value: 0, expectedResult: false }, + { name: 'HSICDIValid', value: 1, expectedResult: true }, + { name: 'HSIGSIValid', value: 0, expectedResult: false }, + { name: 'HSIGSIValid', value: 1, expectedResult: true }, + { name: 'HSIHasLocaliser', value: 0, expectedResult: false }, + { name: 'HSIHasLocaliser', value: 1, expectedResult: true }, + ]; + + describe('offsets list', () => { + it('should have required properties', () => { + expect(offsets).toMatchSnapshot(); + }); + }); + + offsetsTestCases.forEach(testedOffset => { + describe(testedOffset.name, () => { + it('should convert data properly', () => { + const convertExpression = replaceOffsetExpressionValue(offsets[testedOffset.name], testedOffset.value); + + // tslint:disable-next-line:no-eval + expect(eval(convertExpression)).toEqual(testedOffset.expectedResult); + }); + }); + }); +});