From 9562851d76fb1da548e725a6d6fe3ba377724cdd Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Tue, 6 Aug 2024 16:15:57 -0500 Subject: [PATCH] Add default/base items --- .gitignore | 130 +++++++++++ aircraft/AerosoftA333.js | 64 ++++++ aircraft/Felis742.js | 86 ++++++++ aircraft/FenixA320.js | 70 ++++++ aircraft/FlightFactor757.js | 84 ++++++++ aircraft/FlightFactorA320.js | 79 +++++++ aircraft/FlyByWireA320N.js | 41 ++++ aircraft/FlyJSim727.js | 87 ++++++++ aircraft/FlyJSim732.js | 87 ++++++++ aircraft/FsLabsAirbus.js | 50 +++++ aircraft/IXEG733.js | 85 ++++++++ aircraft/JarDesignA330.js | 70 ++++++ aircraft/PMDG_737_FSUIPC.js | 72 +++++++ aircraft/PMDG_737_MSFS.js | 85 ++++++++ aircraft/PMDG_747_FSUIPC.js | 72 +++++++ aircraft/PMDG_777_FSUIPC.js | 72 +++++++ aircraft/PMDG_777_MSFS.js | 86 ++++++++ aircraft/ProSim737.js | 39 ++++ aircraft/ProjectAirbus.js | 41 ++++ aircraft/QualityWings.js | 42 ++++ aircraft/RotateMD11.js | 86 ++++++++ aircraft/RotateMD80.js | 85 ++++++++ aircraft/Toliss.js | 68 ++++++ aircraft/Zibo738.js | 55 +++++ aircraft/_default_flaps.js | 348 ++++++++++++++++++++++++++++++ aircraft/_default_fsuipc.js | 144 +++++++++++++ aircraft/_default_msfs.js | 104 +++++++++ aircraft/_default_xplane.js | 139 ++++++++++++ aircraft/empty | 0 aircraft/iniBuildsA300.js | 84 ++++++++ aircraft/tests/detections.test.js | 48 +++++ package.json | 47 ++-- 32 files changed, 2634 insertions(+), 16 deletions(-) create mode 100644 aircraft/AerosoftA333.js create mode 100644 aircraft/Felis742.js create mode 100644 aircraft/FenixA320.js create mode 100644 aircraft/FlightFactor757.js create mode 100644 aircraft/FlightFactorA320.js create mode 100644 aircraft/FlyByWireA320N.js create mode 100644 aircraft/FlyJSim727.js create mode 100644 aircraft/FlyJSim732.js create mode 100644 aircraft/FsLabsAirbus.js create mode 100644 aircraft/IXEG733.js create mode 100644 aircraft/JarDesignA330.js create mode 100644 aircraft/PMDG_737_FSUIPC.js create mode 100644 aircraft/PMDG_737_MSFS.js create mode 100644 aircraft/PMDG_747_FSUIPC.js create mode 100644 aircraft/PMDG_777_FSUIPC.js create mode 100644 aircraft/PMDG_777_MSFS.js create mode 100644 aircraft/ProSim737.js create mode 100644 aircraft/ProjectAirbus.js create mode 100644 aircraft/QualityWings.js create mode 100644 aircraft/RotateMD11.js create mode 100644 aircraft/RotateMD80.js create mode 100644 aircraft/Toliss.js create mode 100644 aircraft/Zibo738.js create mode 100644 aircraft/_default_flaps.js create mode 100644 aircraft/_default_fsuipc.js create mode 100644 aircraft/_default_msfs.js create mode 100644 aircraft/_default_xplane.js delete mode 100644 aircraft/empty create mode 100644 aircraft/iniBuildsA300.js create mode 100644 aircraft/tests/detections.test.js diff --git a/.gitignore b/.gitignore index 0d4e5d1..0301cf9 100644 --- a/.gitignore +++ b/.gitignore @@ -93,3 +93,133 @@ fabric.properties # Built Visual Studio Code Extensions *.vsix + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.development.local +.env.test.local +.env.production.local +.env.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp + +# Docusaurus cache and generated files +.docusaurus + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* diff --git a/aircraft/AerosoftA333.js b/aircraft/AerosoftA333.js new file mode 100644 index 0000000..24925d6 --- /dev/null +++ b/aircraft/AerosoftA333.js @@ -0,0 +1,64 @@ +export default class AerosoftA333Airbus { + meta = { + name: 'aerosoft a333', + priority: 2, + sim: 'fsuipc', + } + + features = { + beaconLights: false, + landingLights: false, + navigationLights: false, + strobeLights: false, + taxiLights: false, + flaps: { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 1+F', + 3: 'CONF 2', + 4: 'CONF 3', + 5: 'FULL', + }, + } + + /** + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + // Should match aerosfot + a333/a3 + return ['aerosoft', 'a3'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return null + } + + landingLights(value) { + return null + } + + navigationLights(value) { + return null + } + + strobeLights(value) { + return null + } + + taxiLights(value) { + return null + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/Felis742.js b/aircraft/Felis742.js new file mode 100644 index 0000000..d46b544 --- /dev/null +++ b/aircraft/Felis742.js @@ -0,0 +1,86 @@ +export default class Felis742 { + meta = { + name: 'Felis 742', + priority: 5, + sim: 'xplane', + } + + features = { + beaconLights: false, + landingLights: { + 'B742/ext_light/landing_inbd_L_sw': 'int', + 'B742/ext_light/landing_inbd_R_sw': 'int', + 'B742/ext_light/landing_outbd_L_sw': 'int', + 'B742/ext_light/landing_outbd_R_sw': 'int', + }, + logoLights: { + 'B742/ext_light/logo_sw': 'int', + }, + navigationLights: false, + strobeLights: false, + taxiLights: { + 'B742/ext_light/runway_turnoff_L_sw': 'int', + 'B742/ext_light/runway_turnoff_R_sw': 'int', + }, + wingLights: { + 'B742/ext_light/wing_sw': 'int', + }, + flaps: { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 1+F', + 3: 'CONF 2', + 4: 'CONF 3', + 5: 'FULL', + }, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + return ['boeing', '747-200'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return null + } + + landingLights(inbd_l, inbd_r, outb_l, outb_r) { + return inbd_l === 1 && inbd_r === 1 && outb_l === 1 && outb_r === 1 + } + + logoLights(value) { + return value === 1 + } + + navigationLights(value) { + return null + } + + strobeLights(value) { + return null + } + + taxiLights(turnoff_l, turnoff_r) { + return turnoff_l === 1 && turnoff_r === 1 + } + + wingLights(value) { + return value === 1 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/FenixA320.js b/aircraft/FenixA320.js new file mode 100644 index 0000000..7e27c6a --- /dev/null +++ b/aircraft/FenixA320.js @@ -0,0 +1,70 @@ +export default class FenixA320 { + meta = { + name: 'Fenix A320', + priority: 4, + sim: 'msfs', + author: 'B.Fatih KOZ ', + } + + features = { + landingLights: { + S_OH_EXT_LT_LANDING_L: 'int', + S_OH_EXT_LT_LANDING_R: 'int', + }, + beaconLights: { + S_OH_EXT_LT_BEACON: 'int', + }, + navigationLights: { + S_OH_EXT_LT_NAV_LOGO: 'int', + }, + strobeLights: { + S_OH_EXT_LT_STROBE: 'int', + }, + taxiLights: { + S_OH_EXT_LT_NOSE: 'int', + }, + flaps: { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 1+F', + 3: 'CONF 2', + 4: 'CONF 3', + 5: 'FULL', + }, + } + + match(title, icao, config_path) { + return ( + ['Fenix', 'A320'].every((w) => title.includes(w.toLowerCase())) || + ['FenixA320'].every((w) => title.includes(w.toLowerCase())) + ) + } + + beaconLights(value) { + return value === 1 + } + + landingLights(left, right) { + return left === 2 && right === 2 + } + + navigationLights(value) { + return value === 1 || value === 2 + } + + strobeLights(value) { + if (value === 1) { + return null + } + + return value === 2 + } + + taxiLights(value) { + return value === 1 || value === 2 + } + + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/FlightFactor757.js b/aircraft/FlightFactor757.js new file mode 100644 index 0000000..53357e3 --- /dev/null +++ b/aircraft/FlightFactor757.js @@ -0,0 +1,84 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class FlightFactor757 { + meta = { + name: 'FlightFactor 757', + priority: 2, + sim: 'xplane', + } + + features = { + beaconLights: { + 'sim/cockpit2/switches/beacon_on': 'int', + }, + landingLights: { + 'sim/cockpit2/switches/landing_lights_switch': 'float_array', + }, + logoLights: { + 'sim/cockpit2/switches/generic_lights_switch': 'float_array', + }, + navigationLights: { + 'sim/cockpit2/switches/navigation_lights_on': 'int', + }, + strobeLights: { + 'sim/cockpit2/switches/strobe_lights_on': 'int', + }, + taxiLights: { + 'sim/cockpit2/switches/landing_lights_switch': 'float_array', + }, + wingLights: { + 'sim/cockpit2/switches/generic_lights_switch': 'float_array', + }, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'B757', '') + return ['boeing', '757'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return null + } + + landingLights(value) { + return value[0] === 1 && value[1] === 1 + } + + logoLights(value) { + return value[3] === 1 + } + + navigationLights(value) { + return null + } + + strobeLights(value) { + return null + } + + taxiLights(value) { + return value[2] === 1 + } + + wingLights(value) { + return value[0] === 1 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/FlightFactorA320.js b/aircraft/FlightFactorA320.js new file mode 100644 index 0000000..1c68495 --- /dev/null +++ b/aircraft/FlightFactorA320.js @@ -0,0 +1,79 @@ +export default class FlightFactorA320 { + meta = { + name: 'FlightFactor A320', + priority: 4, + sim: 'xplane', + author: 'B.Fatih KOZ ', + } + + features = { + beaconLights: { + 'model/controls/light_beacon': 'int', + }, + landingLights: { + 'model/controls/light_land1': 'float', + 'model/controls/light_land2': 'float', + }, + navigationLights: { + 'model/controls/light_logo': 'float', + }, + strobeLights: { + 'model/controls/light_strobe': 'float', + }, + taxiLights: { + 'model/controls/light_nose': 'float', + }, + wingLights: { + 'model/controls/light_wing': 'int', + }, + flaps: { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + }, + } + + match(title, icao, config_path) { + return ['flightfactor', 'a320'].every((w) => + title.includes(w.toLowerCase()), + ) + } + + beaconLights(value) { + return value === 1 + } + + landingLights(left, right) { + // Dataref returns 0.5 or 1 when enabled, 0.5 is landing lights extended but off + return Math.floor(left * 10) === 10 && Math.floor(right * 10) === 10 + } + + navigationLights(value) { + // Dataref returns 0.5 or 1 when enabled + return value > 0 + } + + strobeLights(value) { + if (value > 0 && value < 1) { + // Ignore if switch is set to AUTO, dataref returns 0.5 + return null + } + + return value === 1 + } + + taxiLights(value) { + // Dataref returns 0.5 or 1 when enabled + return value > 0 + } + + wingLights(value) { + return value === 1 + } + + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/FlyByWireA320N.js b/aircraft/FlyByWireA320N.js new file mode 100644 index 0000000..d0b43fa --- /dev/null +++ b/aircraft/FlyByWireA320N.js @@ -0,0 +1,41 @@ +export default class FlyByWireA320N { + meta = { + name: 'FlyByWire A320N', + priority: 2, + sim: 'msfs', + } + + features = { + flaps: { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 1+F', + 3: 'CONF 2', + 4: 'CONF 3', + 5: 'FULL', + }, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + return ['a320', 'neo', 'flybywire'].every((w) => + title.includes(w.toLowerCase()), + ) + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/FlyJSim727.js b/aircraft/FlyJSim727.js new file mode 100644 index 0000000..8fb4b67 --- /dev/null +++ b/aircraft/FlyJSim727.js @@ -0,0 +1,87 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class FlyJSim727 { + meta = { + name: 'FlyJSim 727', + priority: 2, + sim: 'xplane', + } + + features = { + beaconLights: { + 'FJS/727/lights/BeaconLightSwitch': 'int', + }, + landingLights: { + 'FJS/727/lights/InboundLLSwitch_L': 'int', + 'FJS/727/lights/InboundLLSwitch_R': 'int', + 'FJS/727/lights/OutboundLLSwitch_L': 'int', + 'FJS/727/lights/OutboundLLSwitch_R': 'int', + }, + logoLights: { + 'FJS/727/lights/LogoLightSwitch': 'int', + }, + navigationLights: { + 'FJS/727/lights/NavLightSwitch': 'int', + }, + strobeLights: { + 'FJS/727/lights/StrobeLightSwitch': 'int', + }, + taxiLights: { + 'FJS/727/lights/TaxiLightSwitch': 'int', + }, + wingLights: { + 'FJS/727/lights/WingLightSwitch': 'int', + }, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'B727', '') + return ['fjs', '722'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return value === true + } + + landingLights(inbd_l, inbd_r, outb_l, outb_r) { + return inbd_l === 1 && inbd_r === 1 && outb_l === 1 && outb_r === 1 + } + + logoLights(value) { + return value === 1 + } + + navigationLights(value) { + return value === 1 + } + + strobeLights(value) { + return value === 1 + } + + taxiLights(value) { + return value === 1 + } + + wingLights(value) { + return value === 1 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/FlyJSim732.js b/aircraft/FlyJSim732.js new file mode 100644 index 0000000..6ea12d5 --- /dev/null +++ b/aircraft/FlyJSim732.js @@ -0,0 +1,87 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class FlyJSim732 { + meta = { + name: 'FlyJSim 732', + priority: 2, + sim: 'xplane', + } + + features = { + beaconLights: { + 'FJS/732/lights/AntiColLightSwitch': 'int', + }, + landingLights: { + 'FJS/732/lights/InBoundLLightSwitch1': 'int', + 'FJS/732/lights/InBoundLLightSwitch2': 'int', + 'FJS/732/lights/OutBoundLLightSwitch1': 'int', + 'FJS/732/lights/OutBoundLLightSwitch2': 'int', + }, + logoLights: { + 'FJS/732/lights/LogoLightSwitch': 'int', + }, + navigationLights: { + 'FJS/732/lights/PositionLightSwitch': 'int', + }, + strobeLights: { + 'FJS/732/lights/StrobeLightSwitch': 'int', + }, + taxiLights: { + 'FJS/732/lights/TaxiLightSwitch': 'int', + }, + wingLights: { + 'FJS/732/lights/WingLightSwitch': 'int', + }, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'B732', '') + return ['fjs', '722'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return value === true + } + + landingLights(inbd_l, inbd_r, outb_l, outb_r) { + return inbd_l === 1 && inbd_r === 1 && outb_l === 2 && outb_r === 2 + } + + logoLights(value) { + return value === 1 + } + + navigationLights(value) { + return value === 1 + } + + strobeLights(value) { + return value === 1 + } + + taxiLights(value) { + return value === 1 + } + + wingLights(value) { + return value === 1 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/FsLabsAirbus.js b/aircraft/FsLabsAirbus.js new file mode 100644 index 0000000..d2ae3b9 --- /dev/null +++ b/aircraft/FsLabsAirbus.js @@ -0,0 +1,50 @@ +export default class FsLabsAirbus { + meta = { + name: 'FsLabs Airbus', + priority: 2, + sim: 'fsuipc', + } + + features = { + beaconLights: false, + landingLights: false, + logoLights: false, + navigationLights: false, + strobeLights: false, + taxiLights: false, + wingLights: false, + flaps: { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF CHG', + 3: 'CONF CHG', + 4: 'CONF CHG', + 5: 'CONF CHG', + 6: 'CONF 1+F', + 7: 'CONF 2', + 8: 'CONF 3', + 9: 'FULL', + }, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + return ['fslabs'].every((w) => title.includes(w.toLowerCase())) + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/IXEG733.js b/aircraft/IXEG733.js new file mode 100644 index 0000000..8d8ea6d --- /dev/null +++ b/aircraft/IXEG733.js @@ -0,0 +1,85 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class IXEG733 { + meta = { + name: 'IXEG 733', + priority: 2, + sim: 'xplane', + } + + features = { + beaconLights: { + 'ixeg/733/lighting/anti_col_lt_act': 'int', + }, + landingLights: { + 'ixeg/733/lighting/l_inboard_ll_act': 'int', + 'ixeg/733/lighting/r_inboard_ll_act': 'int', + 'ixeg/733/lighting/l_outboard_ll_act': 'int', + 'ixeg/733/lighting/r_outboard_ll_act': 'int', + }, + logoLights: { + 'ixeg/733/lighting/logo_lt_act': 'int', + }, + navigationLights: { + 'ixeg/733/lighting/position_lt_act': 'int', + }, + strobeLights: { + 'ixeg/733/lighting/strobe_lt_act': 'int', + }, + taxiLights: { + 'ixeg/733/lighting/taxi_lt_act': 'int', + }, + wingLights: { + 'ixeg/733/lighting/wing_lt_act': 'int', + }, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'b733', '') + return ['boeing', '737-300', 'x-aviation'].every((w) => + title.includes(w.toLowerCase()), + ) + } + + beaconLights(value) { + return value === 1 + } + + landingLights(inbd_l, inbd_r, outb_l, outb_r) { + return inbd_l === 1 && inbd_r === 1 && outb_l === 2 && outb_r === 3 + } + + navigationLights(value) { + return value === 1 + } + + strobeLights(value) { + return value === 1 + } + + taxiLights(value) { + return value === 1 + } + + wingLights(value) { + return value === 1 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/JarDesignA330.js b/aircraft/JarDesignA330.js new file mode 100644 index 0000000..9cd71c9 --- /dev/null +++ b/aircraft/JarDesignA330.js @@ -0,0 +1,70 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class JarDesignA330 { + meta = { + name: 'JARDesign A330', + priority: 2, + sim: 'xplane', + } + + features = { + beaconLights: { + 'sim/custom/xap/extlight/beacon_sw': 'int', + }, + landingLights: { + 'sim/custom/xap/extlight/land_sw': 'int', + }, + navigationLights: { + 'sim/custom/xap/extlight/navlogo_sw': 'int', + }, + strobeLights: { + 'sim/custom/xap/extlight/strobe_sw': 'int', + }, + taxiLights: { + 'sim/custom/xap/extlight/nose_sw': 'int', + }, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'a330', '') + return ['jardesign', 'a330'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return value === 1 + } + + landingLights(value) { + return value === 1 + } + + navigationLights(value) { + return value === 1 || value === 2 + } + + strobeLights(value) { + return value === 2 + } + + taxiLights(value) { + return value === 1 || value === 2 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/PMDG_737_FSUIPC.js b/aircraft/PMDG_737_FSUIPC.js new file mode 100644 index 0000000..12329fc --- /dev/null +++ b/aircraft/PMDG_737_FSUIPC.js @@ -0,0 +1,72 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class PMDG_737_FSUIPC { + meta = { + name: 'PMDG 737', + priority: 2, + sim: 'fsuipc', + } + + features = { + beaconLights: { + '0x6501': 'int', + }, + landingLights: { + '0x64F6': 'int', + }, + logoLights: false, + navigationLights: { + '0x6500': 'int', + }, + strobeLights: { + '0x6500': 'int', + }, + taxiLights: { + '0x64FA': 'int', + }, + wingLights: false, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'b737', '') + return ['pmdg', '737'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return value === 1 + } + + landingLights(value) { + return value === 1 + } + + navigationLights(value) { + return value === 0 || value === 2 + } + + strobeLights(value) { + return value === 2 + } + + taxiLights(value) { + return value === 1 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/PMDG_737_MSFS.js b/aircraft/PMDG_737_MSFS.js new file mode 100644 index 0000000..6b3f1b1 --- /dev/null +++ b/aircraft/PMDG_737_MSFS.js @@ -0,0 +1,85 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class PMDG_737_MSFS { + meta = { + name: 'PMDG 737', + priority: 5, + sim: 'msfs', + } + + features = { + beaconLights: { + switch_124_73X: 'int', + }, + landingLights: { + switch_113_73X: 'int', + switch_114_73X: 'int', + }, + logoLights: { + switch_122_73X: 'int', + }, + navigationLights: { + switch_123_73X: 'int', + }, + strobeLights: { + switch_123_73X: 'int', + }, + taxiLights: { + switch_117_73X: 'int', + }, + wingLights: { + switch_125_73X: 'int', + }, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'b737', '') + return ['pmdg', '737'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return value === 100 + } + + landingLights(v1, v2) { + return v1 === 100 && v2 === 100 + } + + logoLights(value) { + return value === 100 + } + + navigationLights(value) { + return value === 0 || value === 100 + } + + strobeLights(value) { + return value === 0 + } + + taxiLights(value) { + return value === 100 + } + + wingLights(value) { + return value === 100 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/PMDG_747_FSUIPC.js b/aircraft/PMDG_747_FSUIPC.js new file mode 100644 index 0000000..a2b0c19 --- /dev/null +++ b/aircraft/PMDG_747_FSUIPC.js @@ -0,0 +1,72 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class PMDG_747_FSUIPC { + meta = { + name: 'PMDG 747', + priority: 2, + sim: 'fsuipc', + } + + features = { + beaconLights: { + '0x650A': 'int', + }, + landingLights: { + '0x6506': 'int', + }, + logoLights: false, + navigationLights: { + '0x650B': 'int', + }, + strobeLights: { + '0x6511': 'int', + }, + taxiLights: { + '0x6510': 'int', + }, + wingLights: false, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'b747', '') + return ['pmdg', '747'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return value === 0 || value === 2 + } + + landingLights(value) { + return value === 1 + } + + navigationLights(value) { + return value === 0 || value === 2 + } + + strobeLights(value) { + return value === 1 + } + + taxiLights(value) { + return value === 1 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/PMDG_777_FSUIPC.js b/aircraft/PMDG_777_FSUIPC.js new file mode 100644 index 0000000..db11f3d --- /dev/null +++ b/aircraft/PMDG_777_FSUIPC.js @@ -0,0 +1,72 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class PMDG_777_FSUIPC { + meta = { + name: 'PMDG 777', + priority: 2, + sim: 'fsuipc', + } + + features = { + beaconLights: { + '0x6488': 'int', + }, + landingLights: { + '0x6485': 'int', + }, + logoLights: false, + navigationLights: { + '0x650B': '0x6489', + }, + strobeLights: { + '0x648F': 'int', + }, + taxiLights: { + '0x648E': 'int', + }, + wingLights: false, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'b777', '') + return ['pmdg', '777'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return value === 1 + } + + landingLights(value) { + return value === 1 + } + + navigationLights(value) { + return value === 1 + } + + strobeLights(value) { + return value === 1 + } + + taxiLights(value) { + return value === 1 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/PMDG_777_MSFS.js b/aircraft/PMDG_777_MSFS.js new file mode 100644 index 0000000..2730675 --- /dev/null +++ b/aircraft/PMDG_777_MSFS.js @@ -0,0 +1,86 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class PMDG_777_MSFS { + meta = { + name: 'PMDG 777', + priority: 5, + sim: 'msfs', + } + + features = { + beaconLights: { + switch_114_a: 'int', + }, + landingLights: { + switch_22_a: 'int', + switch_23_a: 'int', + switch_24_a: 'int', + }, + logoLights: { + switch_116_a: 'int', + }, + navigationLights: { + switch_115_a: 'int', + }, + strobeLights: { + switch_122_a: 'int', + }, + taxiLights: { + switch_121_a: 'int', + }, + wingLights: { + switch_117_a: 'int', + }, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'b777', '') + return ['pmdg', '777'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return value === 100 + } + + landingLights(s1, s2, s3) { + return s1 === 100 && s2 === 100 && s3 === 100 + } + + logoLights(value) { + return value === 100 + } + + navigationLights(value) { + return value === 100 + } + + strobeLights(value) { + return value === 100 + } + + taxiLights(value) { + return value === 100 + } + + wingLights(value) { + return value === 100 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/ProSim737.js b/aircraft/ProSim737.js new file mode 100644 index 0000000..7741ece --- /dev/null +++ b/aircraft/ProSim737.js @@ -0,0 +1,39 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class ProSim737 { + meta = { + name: 'Prosim 737', + priority: 2, + sim: 'msfs', + } + + features = { + beaconLights: false, + landingLights: false, + navigationLights: false, + strobeLights: false, + taxiLights: false, + flaps: {}, + } + + /** + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'b737', '') + return title.includes('prosim') + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/ProjectAirbus.js b/aircraft/ProjectAirbus.js new file mode 100644 index 0000000..a95efc7 --- /dev/null +++ b/aircraft/ProjectAirbus.js @@ -0,0 +1,41 @@ +export default class ProjectAirbus { + meta = { + name: 'Project Airbus', + priority: 2, + sim: 'xplane', + } + + features = { + flaps: { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 1+F', + 3: 'CONF 2', + 4: 'CONF 3', + 5: 'FULL', + }, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + return ['project', 'airbus', 'a3'].every((w) => + title.includes(w.toLowerCase()), + ) + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/QualityWings.js b/aircraft/QualityWings.js new file mode 100644 index 0000000..1dc232f --- /dev/null +++ b/aircraft/QualityWings.js @@ -0,0 +1,42 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class QualityWings { + meta = { + name: 'QualityWings', + priority: 2, + sim: 'msfs', + } + + features = { + beaconLights: false, + landingLights: false, + navigationLights: false, + strobeLights: false, + taxiLights: false, + flaps: {}, + } + + /** + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'b787', '') + return ( + title.includes('qualitywings') || + (title.includes('quality') && title.includes('wings')) + ) + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/RotateMD11.js b/aircraft/RotateMD11.js new file mode 100644 index 0000000..555fa9f --- /dev/null +++ b/aircraft/RotateMD11.js @@ -0,0 +1,86 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class RotateMD11 { + meta = { + name: 'Rotate MD-11', + priority: 2, + sim: 'xplane', + } + + features = { + beaconLights: { + 'Rotate/aircraft/controls/beacon_lts': 'int', + }, + landingLights: { + 'Rotate/aircraft/controls/ldg_l_lts': 'int', + 'Rotate/aircraft/controls/ldg_r_lts': 'int', + }, + logolights: { + 'Rotate/aircraft/controls/logo_lts': 'int', + }, + navigationLights: { + 'Rotate/aircraft/controls/nav_lts': 'int', + }, + strobeLights: { + 'Rotate/aircraft/controls/strobe_lts': 'int', + }, + taxiLights: { + 'Rotate/aircraft/controls/nose_lts': 'int', + }, + wingLights: { + 'Rotate/aircraft/controls/wing_l_lts': 'int', + 'Rotate/aircraft/controls/wing_r_lts': 'int', + }, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'md11', '') + return ['rotate', 'md-11'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return value === 1 + } + + landingLights(v1, v2) { + return v1 === 2 && v2 === 2 + } + + logoLights(value) { + return value === 1 + } + + navigationLights(value) { + return value === 1 + } + + strobeLights(value) { + return value === 1 + } + + taxiLights(value) { + return value === 1 || value === 2 + } + + wingLights(v1, v2) { + return v1 === 2 && v2 === 2 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/RotateMD80.js b/aircraft/RotateMD80.js new file mode 100644 index 0000000..854d2bc --- /dev/null +++ b/aircraft/RotateMD80.js @@ -0,0 +1,85 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class RotateMD80 { + meta = { + name: 'Rotate MD-80', + priority: 2, + sim: 'xplane', + } + + features = { + beaconLights: { + 'Rotate/md80/lights/anticollision_light_switch': 'int', + }, + landingLights: { + 'Rotate/md80/lights/wing_ldg_light_switch_r': 'int', + 'Rotate/md80/lights/wing_ldg_light_switch_l': 'int', + }, + logolights: { + 'Rotate/md80/lights/logo_light_switch': 'int', + }, + navigationLights: { + 'Rotate/md80/lights/pos_strobe_light_switch': 'int', + }, + strobeLights: { + 'Rotate/md80/lights/pos_strobe_light_switch': 'int', + }, + taxiLights: { + 'Rotate/md80/lights/nose_light_switch': 'int', + }, + wingLights: { + 'Rotate/md80/lights/wing_light_switch': 'int', + }, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'md80', '') + return ['rotate', 'md-80'].every((w) => title.includes(w.toLowerCase())) + } + + beaconLights(value) { + return value === 1 + } + + landingLights(v1, v2) { + return v1 === 2 && v2 === 2 + } + + logoLights(value) { + return value === 1 + } + + navigationLights(value) { + return value === 1 || value === 2 + } + + strobeLights(value) { + return value === 2 + } + + taxiLights(value) { + return value === 1 || value === 2 + } + + wingLights(value) { + return value === 1 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/Toliss.js b/aircraft/Toliss.js new file mode 100644 index 0000000..568f702 --- /dev/null +++ b/aircraft/Toliss.js @@ -0,0 +1,68 @@ +export default class Toliss { + meta = { + name: 'ToLiss Airbus', + sim: 'xplane', + priority: 4, + author: 'B.Fatih KOZ ', + } + + features = { + landingLights: { + 'AirbusFBW/OHPLightSwitches': 'int_array', + }, + beaconLights: { + 'AirbusFBW/OHPLightSwitches': 'int_array', + }, + navigationLights: { + 'AirbusFBW/OHPLightSwitches': 'int_array', + }, + strobeLights: { + 'AirbusFBW/OHPLightSwitches': 'int_array', + }, + taxiLights: { + 'AirbusFBW/OHPLightSwitches': 'int_array', + }, + flaps: { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + }, + } + + match(title, icao, config_path) { + return ['high', 'fidelity', 'system'].every((w) => + title.includes(w.toLowerCase()), + ) + } + + beaconLights(value) { + return value[0] === 1 + } + + landingLights(value) { + return value[4] === 2 && value[5] === 2 + } + + navigationLights(value) { + return value[2] === 1 || value[2] === 2 + } + + strobeLights(value) { + if (value[7] === 1) { + // Ignore if the switch is on AUTO position + return null + } + + return value[7] === 2 + } + + taxiLights(value) { + return value[3] === 1 || value[3] === 2 + } + + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/Zibo738.js b/aircraft/Zibo738.js new file mode 100644 index 0000000..976627e --- /dev/null +++ b/aircraft/Zibo738.js @@ -0,0 +1,55 @@ +import GetDefaultFlaps from './_default_flaps.js' + +export default class Zibo738 { + meta = { + name: 'Zibo 738', + priority: 2, + sim: 'xplane', + } + + features = { + logoLights: { + 'laminar/B738/toggle_switch/logo_light': 'int', + }, + taxiLights: { + 'laminar/B738/toggle_switch/taxi_light_brightness_pos': 'int', + }, + flaps: {}, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps('', 'b738', '') + + const match = ['boeing', '737-800x'].every((w) => + title.includes(w.toLowerCase()), + ) + console.log('match', match) + + return match + } + + logoLights(value) { + return value === 1 + } + + taxiLights(value) { + return value === 2 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/_default_flaps.js b/aircraft/_default_flaps.js new file mode 100644 index 0000000..811ffdc --- /dev/null +++ b/aircraft/_default_flaps.js @@ -0,0 +1,348 @@ +/** + * See if the title, icao or config_path match with what the simulator + * is saying. All of the values are passed in already lower-cased. + * Return true or false + * + * The ICAO and config_path may not be available in some sims. + * + * @param {string} title The title of the aircraft + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {Object.} + */ +export default function GetDefaultFlaps(title, icao, config_path) { + if (/^B712/i.test(icao)) { + return { + 0: 'UP', + 1: '0', + 2: 'DIAL TO', + 3: '11', + 4: '15', + 5: '28', + 6: '40', + } + } + + if (/^B73./i.test(icao)) { + return { + 0: 'UP', + 1: '1', + 2: '2', + 3: '5', + 4: '10', + 5: '15', + 6: '25', + 7: '30', + 8: '40', + } + } + + if (/^B74./i.test(icao)) { + return { + 0: 'UP', + 1: '1', + 2: '5', + 3: '10', + 4: '20', + 5: '25', + 6: '30', + } + } + + if (/^B75./i.test(icao)) { + return { + 0: 'UP', + 1: '1', + 2: '5', + 3: '15', + 4: '20', + 5: '25', + 6: '30', + } + } + + if (/^B76./i.test(icao)) { + return { + 0: 'UP', + 1: '1', + 2: '5', + 3: '15', + 4: '20', + 5: '25', + 6: '30', + } + } + + if (/^B77./i.test(icao)) { + return { + 0: 'UP', + 1: '1', + 2: '5', + 3: '15', + 4: '20', + 5: '25', + 6: '30', + } + } + + if (/^B78./i.test(icao)) { + return { + 0: 'UP', + 1: '1', + 2: '5', + 3: '10', + 4: '15', + 5: '17', + 6: '19', + 7: '20', + 8: '25', + 9: '30', + } + } + + if (/^B72./i.test(icao)) { + return { + 0: 'UP', + 1: '2', + 2: '5', + 3: '15', + 4: '20', + 5: '25', + 6: '30', + 7: '40', + } + } + + if (/^B3.M/i.test(icao)) { + return { + 0: 'UP', + 1: '1', + 2: '2', + 3: '5', + 4: '10', + 5: '15', + 6: '25', + 7: '30', + 8: '40', + } + } + + // Airbus Group + if (/^A30./i.test(icao)) { + return { + 0: 'UP', + 1: '15/0', + 2: '15/15', + 3: '15/20', + 4: '30/40', + } + } + + if (/^A3ST./i.test(icao)) { + return { + 0: 'UP', + 1: '15/0', + 2: '15/15', + 3: '15/20', + 4: '30/40', + } + } + + if (/^A310/i.test(icao)) { + return { + 0: 'UP', + 1: '15/0', + 2: '15/15', + 3: '20/20', + 4: '30/40', + } + } + + if (/^A318/i.test(icao)) { + return { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + } + } + + if (/^A319/i.test(icao)) { + return { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + } + } + + if (/^A32./i.test(icao)) { + return { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + } + } + + if (/^A33./i.test(icao)) { + return { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + } + } + + if (/^A34./i.test(icao)) { + return { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + } + } + + if (/^A35./i.test(icao)) { + return { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + } + } + + if (/^A38./i.test(icao)) { + return { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + } + } + + if (/^A19N/i.test(icao)) { + return { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + } + } + + if (/^A20N/i.test(icao)) { + return { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + } + } + + if (/^A21N/i.test(icao)) { + return { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + } + } + + if (/^BCS/i.test(icao)) { + return { + 0: 'UP', + 1: 'CONF 1', + 2: 'CONF 2', + 3: 'CONF 3', + 4: 'FULL', + } + } + + // McDonnell Douglas Group + if (/^MD11/i.test(icao)) { + return { + 0: 'UP', + 1: '0', + 2: 'DIAL TO', + 3: '28', + 4: '35', + 5: '50', + } + } + + if (/^MD8/i.test(icao)) { + return { + 0: 'UP', + 1: '0', + 2: 'DIAL TO', + 3: '11', + 4: '15', + 5: '28', + 6: '40', + } + } + + if (/^MD90/i.test(icao)) { + return { + 0: 'UP', + 1: '0', + 2: 'DIAL TO', + 3: '11', + 4: '15', + 5: '28', + 6: '40', + } + } + + // Canadair Regional Jet(CRJ) Group + if (/^CRJ/i.test(icao)) { + return { + 0: 'UP', + 1: '1', + 2: '8', + 3: '20', + 4: '30', + 5: '45', + } + } + + // Cessna Group + if (/^C172/i.test(icao)) { + return { + 0: 'UP', + 1: '10', + 2: '20', + 3: 'FULL', + } + } + + if (/^C182/i.test(icao)) { + return { + 0: 'UP', + 1: '10', + 2: '20', + 3: 'FULL', + } + } + + if (/^C82R/i.test(icao)) { + return { + 0: 'UP', + 1: '10', + 2: '20', + 3: 'FULL', + } + } + + return {} +} diff --git a/aircraft/_default_fsuipc.js b/aircraft/_default_fsuipc.js new file mode 100644 index 0000000..0831c36 --- /dev/null +++ b/aircraft/_default_fsuipc.js @@ -0,0 +1,144 @@ +import GetDefaultFlaps from './_default_flaps.js' + +/** + * The default configmap + */ +export default class DefaultFsuipc { + /** + * Data about this config map + * + */ + meta = { + /** + * Name of the rule + */ + name: 'fsuipc default', + + /** + * Enabled or not + */ + enabled: true, + + /** + * The priority of this mapping, with 1 being the lowest + * and 10 being the highest + */ + priority: 1, + + /** + * Sim name - xplane, msfs, or fsuipc + */ + sim: 'fsuipc', + } + + /** + * Individual mappings go here. + * + * FSUIPC is an offset + * X-Plane is a dataref + * MSFS is an LVar + * + * Set to "false" for the feature being disabled/not detected + * Don't add an entry, or set it to null, to use the default + */ + features = { + beaconLights: { '0x0D0C': 'int' }, + landingLights: { '0x0D0C': 'int' }, + logoLights: { '0x0D0C': 'int' }, + navigationLights: { '0x0D0C': 'int' }, + strobeLights: { '0x0D0C': 'int' }, + taxiLights: { '0x0D0C': 'int' }, + wingLights: { '0x0D0C': 'int' }, + flaps: {}, + } + + /** + * See if the title, icao or config_path match with what the simulator + * is saying. All of the values are passed in already lower-cased. + * Return true or false + * + * The ICAO and config_path may not be available in some sims. + * + * @param {string} title The title of the aircraft + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps(title, icao, config_path) + return true + } + + /** + * Parse the value that's returned by the sim. Return null if disabled + * @param value + * @return {boolean|null} + */ + beaconLights(value) { + return (2 & value) === 2 + } + + /** + * Parse the value that's returned by the sim. Return null if disabled + * @param value + * @return {boolean|null} + */ + landingLights(value) { + return (4 & value) === 4 + } + + /** + * Parse the value that's returned by the sim. Return null if disabled + * @param value + * @return {boolean|null} + */ + logoLights(value) { + return null + } + + /** + * Parse the value that's returned by the sim. Return null if disabled + * @param value + * @return {boolean|null} + */ + navigationLights(value) { + return (1 & value) === 1 + } + + /** + * Parse the value that's returned by the sim. Return null if disabled + * @param value + * @return {boolean|null} + */ + strobeLights(value) { + return (16 & value) === 16 + } + + /** + * Parse the value that's returned by the sim. Return null if disabled + * @param value + * @return {boolean|null} + */ + taxiLights(value) { + return (8 & value) === 8 + } + + /** + * Parse the value that's returned by the sim. Return null if disabled + * @param value + * @return {boolean|null} + */ + wingLights(value) { + return null + } + + /** + * Get the right text for the flaps. For the default, the flaps + * meta is set when the match method is called + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/_default_msfs.js b/aircraft/_default_msfs.js new file mode 100644 index 0000000..c4b31c8 --- /dev/null +++ b/aircraft/_default_msfs.js @@ -0,0 +1,104 @@ +import GetDefaultFlaps from './_default_flaps.js' + +/** + * The default configmap + */ +export default class DefaultMsFs { + meta = { + /** + * Name of the rule + */ + name: 'msfs default', + + /** + * Enabled or not + */ + enabled: true, + + /** + * The priority of this mapping, with 1 being the lowest + * and 10 being the highest + */ + priority: 1, + + /** + * Sim name - xplane, msfs, or fsuipc + */ + sim: 'msfs', + } + + /** + * Individual mappings go here. + * + * FSUIPC is an offset + * X-Plane is a dataref + * MSFS is an LVar + * + * Set to null to ignore the feature + */ + features = { + beaconLights: { LIGHTING_BEACON_1: 'bool' }, + landingLights: { LIGHTING_LANDING_1: 'bool' }, + navigationLights: { LIGHTING_NAV_1: 'bool' }, + strobeLights: { LIGHTING_STROBE_1: 'bool' }, + taxiLights: { LIGHTING_TAXI_1: 'bool' }, + wingLights: { LIGHTING_RECOGNITION_1: 'bool' }, + logoLights: { LIGHTING_BEACON_1: 'bool' }, + flaps: {}, + } + + /** + * See if the title, icao or config_path match with what the simulator + * is saying. All of the values are passed in already lower-cased. + * Return true or false + * + * The ICAO and config_path may not be available in some sims. + * + * @param {string} title The title of the aircraft + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps(title, icao, config_path) + return true + } + + beaconLights(value) { + return value === true + } + + landingLights(value) { + return value === true + } + + navigationLights(value) { + return value === true + } + + strobeLights(value) { + return value === true + } + + taxiLights(value) { + return value === true + } + + wingLights(value) { + return value === true + } + + logoLights(value) { + return value === true + } + + /** + * Get the right text for the flaps. For the default, the flaps + * meta is set when the match method is called + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/_default_xplane.js b/aircraft/_default_xplane.js new file mode 100644 index 0000000..0f48944 --- /dev/null +++ b/aircraft/_default_xplane.js @@ -0,0 +1,139 @@ +import GetDefaultFlaps from './_default_flaps.js' + +/** + * The default configmap + */ +export default class DefaultXPlane { + meta = { + /** + * Name of the rule + */ + name: 'xplane default', + + /** + * Enabled or not + */ + enabled: true, + + /** + * The priority of this mapping, with 1 being the lowest + * and 10 being the highest + */ + priority: 1, + + /** + * Sim name - xplane, msfs, or fsuipc + */ + sim: 'xplane', + } + + /** + * Individual mappings go here. + * + * FSUIPC is an offset + * X-Plane is a dataref + * MSFS is an LVar + * + * Set to null to ignore the feature + */ + features = { + beaconLights: { 'sim/cockpit2/switches/beacon_on': 'bool' }, + landingLights: { 'sim/cockpit2/switches/landing_lights_on': 'bool' }, + logoLights: { 'sim/cockpit2/switches/logo_lights_on': 'bool' }, + navigationLights: { 'sim/cockpit2/switches/navigation_lights_on': 'bool' }, + strobeLights: { 'sim/cockpit2/switches/strobe_lights_on': 'bool' }, + taxiLights: { 'sim/cockpit2/switches/taxi_light_on': 'bool' }, + wingLights: { 'sim/cockpit2/switches/wing_lights_on': 'bool' }, + flaps: {}, + } + + /** + * See if the title, icao or config_path match with what the simulator + * is saying. All of the values are passed in already lower-cased. + * Return true or false + * + * The ICAO and config_path may not be available in some sims. + * + * @param {string} title The title of the aircraft + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + this.features.flaps = GetDefaultFlaps(title, icao, config_path) + return true + } + + /** + * Parse the value that's returned by the sim + * @param value + * @return {boolean|null} + */ + beaconLights(value) { + return value === true + } + + /** + * Parse the value that's returned by the sim + * @param value + * @return {boolean|null} + */ + landingLights(value) { + return value === true + } + + /** + * Parse the value that's returned by the sim + * @param value + * @return {boolean|null} + */ + navigationLights(value) { + return value === true + } + + /** + * Parse the value that's returned by the sim + * @param value + * @return {boolean|null} + */ + strobeLights(value) { + return value === true + } + + /** + * Parse the value that's returned by the sim + * @param value + * @return {boolean|null} + */ + taxiLights(value) { + return value === true + } + + /** + * Parse the value that's returned by the sim + * @param value + * @return {boolean|null} + */ + wingLights(value) { + return value === true + } + + /** + * Parse the value that's returned by the sim + * @param value + * @return {boolean|null} + */ + logoLights(value) { + return value === true + } + + /** + * Get the right text for the flaps. For the default, the flaps + * meta is set when the match method is called + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/empty b/aircraft/empty deleted file mode 100644 index e69de29..0000000 diff --git a/aircraft/iniBuildsA300.js b/aircraft/iniBuildsA300.js new file mode 100644 index 0000000..c395635 --- /dev/null +++ b/aircraft/iniBuildsA300.js @@ -0,0 +1,84 @@ +export default class IniBuildsA3N { + meta = { + name: 'IniBuilds A300', + priority: 2, + sim: 'xplane', + } + + features = { + beaconLights: { + 'A300/switches/animations_current': 'float_array', + }, + landingLights: { + 'A300/switches/animations_current': 'float_array', + }, + logoLights: false, + navigationLights: { + 'A300/switches/animations_current': 'float_array', + }, + strobeLights: { + 'A300/switches/animations_current': 'float_array', + }, + taxiLights: { + 'A300/switches/animations_current': 'float_array', + }, + wingLights: { + 'A300/switches/animations_current': 'float_array', + }, + flaps: { + 0: 'UP', + 1: '15/0', + 2: '15/15', + 3: '15/20', + 4: '30/40', + }, + } + + /** + * Determine if this config map should be used for the given aircraft + * + * @param {string} title The title of the aircraft, lowercased + * @param {string=} icao The ICAO of the aircraft. Might not be available + * @param {string=} config_path Path to the aircraft config. Might not be there + * @return {boolean} + */ + match(title, icao, config_path) { + return ( + ['airbus', 'a300'].every((w) => title.includes(w.toLowerCase())) || + ['airbus', 'a310'].every((w) => title.includes(w.toLowerCase())) + ) + } + + beaconLights(value) { + return value[4] === 1 + } + + landingLights(inbd_l, inbd_r, outb_l, outb_r) { + return value[7] === 1 && value[8] === 1 + } + + navigationLights(value) { + return value[1] === 1 || value[1] === 2 + } + + strobeLights(value) { + return value[3] === 1 + } + + taxiLights(value) { + return value[0] === 1 || value[0] === 2 + } + + wingLights(value) { + return value[2] === 1 + } + + /** + * Get the right text for the flaps + * @param {int} value + * @returns {string} + */ + flaps(value) { + return this.features.flaps[value] || value + } +} diff --git a/aircraft/tests/detections.test.js b/aircraft/tests/detections.test.js new file mode 100644 index 0000000..403d81d --- /dev/null +++ b/aircraft/tests/detections.test.js @@ -0,0 +1,48 @@ +/** + * These tests use tap; install it locally using npm install, or + * globally with `npm install -g tap` + */ +import t from 'tap' +import { createMocks } from '../../mocks.js' + +import DefaultFsuipc from '../_default_fsuipc.js' +import GetDefaultFlaps from '../_default_flaps.js' +import AerosoftA333Airbus from '../AerosoftA333.js' + +t.before(createMocks) + +/** + * Check that the expressions for the different default flaps + * based on ICAO work properly + */ +t.test('Default Flaps', (t) => { + let flaps = '' + flaps = GetDefaultFlaps('Boeing 747', 'b748') + t.equal(flaps[6], '30') + + flaps = GetDefaultFlaps('Airbus A3280', 'A389') + t.equal(flaps[3], 'CONF 3') + + flaps = GetDefaultFlaps('Boeing 737 Max8', 'B38M') + t.equal(flaps[8], '40') + + t.end() +}) + +/** + * + */ +t.test('IntMask tests', (t) => { + const c = new DefaultFsuipc() + t.ok(c.match('anything')) + t.ok(c.landingLights(70)) + t.end() +}) + +t.test('Aerosoft A333', (t) => { + const c = new AerosoftA333Airbus() + t.ok(c.match('aerosoft a333')) + t.notOk(c.match('default a333')) + t.notOk(c.match('a333')) + t.end() +}) diff --git a/package.json b/package.json index ac7d213..f5ea106 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,34 @@ { - "name": "default", - "version": "1.0.0", - "config": { - "aircraft": { - "path": "aircraft" - }, - "rules": { - "path": "rules" - }, - "scripts": { - "path": "sounds" - }, - "sounds": { - "path": "sounds" - } + "name": "configs", + "version": "1.0.0", + "author": "Nabeel Shahzad", + "license": "restricted", + "type": "module", + "config": { + "aircraft": { + "path": "aircraft" }, - "private": true + "rules": { + "path": "rules" + }, + "scripts": { + "path": "scripts" + }, + "sounds": { + "path": "sounds" + } + }, + "scripts": { + "test": "tap **/tests/*.test.js", + "tests": "npm run test" + }, + "devDependencies": { + "tap": "^18.7.1" + }, + "prettier": { + "trailingComma": "all", + "tabWidth": 2, + "semi": false, + "singleQuote": true + } }