From 54e58678852fa518c9b1b4646b5a77b91cb84d89 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Thu, 20 Feb 2025 10:45:25 -0600 Subject: [PATCH] Added MsFs20 and MsFs24 as sim types --- .gitignore | 1 + README.md | 65 +++++++++++--------- src/aircraft/{TBM930.ts => TBM930_MSFS20.ts} | 8 +-- src/aircraft/TBM930_MSFS24.ts | 51 +++++++++++++++ src/defs.ts | 5 ++ 5 files changed, 97 insertions(+), 33 deletions(-) rename src/aircraft/{TBM930.ts => TBM930_MSFS20.ts} (82%) create mode 100644 src/aircraft/TBM930_MSFS24.ts diff --git a/.gitignore b/.gitignore index a0fd693..0caf274 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,4 @@ TEST-results.xml package.g.props *v8.log /lib/ +packages.lock.json diff --git a/README.md b/README.md index 93f20d1..c044c4c 100644 --- a/README.md +++ b/README.md @@ -75,11 +75,28 @@ This will setup a watch, and then automatically transpile and then copy the cont npm run dev ``` -It's recommended to run this *after* you've started ACARS, or, in the ACARS configuration, disable the -remote-download of configs: +### Disable Downloading Latest Defaults -> TODO: Guide on how to disable remote config downloading +Sometimes, it's just useful to disable downloading of the latest defaults, and just edit the scripts that are included +to see how they work. To do that, create a file in your `Documents/vmsacars` directory, called `appsettings.local.json`, +and place the following: + +```json filename="appsettings.local.json" +{ + "Config": { + "App": { + "DownloadConfig": false + } + }, + "Serilog": { + "MinimumLevel": { + "Default": "Verbose" + } + } +} +``` +You can also adjust the log level to "Information", "Debug" or "Verbose" ("Debug" is recommended) --- @@ -104,31 +121,6 @@ It also includes other detailed type information, for example `Length`, so you c --- -## Disable Downloading Latest Defaults - -Sometimes, it's just useful to disable downloading of the latest defaults, and just edit the scripts that are included -to see how they work. To do that, create a file in your `Documents/vmsacars` directory, called `appsettings.local.json`, -and place the following: - -```json filename="appsettings.local.json" -{ - "Config": { - "App": { - "DownloadConfig": false - } - }, - "Serilog": { - "MinimumLevel": { - "Default": "Verbose" - } - } -} -``` - -You can also adjust the log level to "Information", "Debug" or "Verbose" ("Debug" is recommended) - ---- - ## Aircraft Configuration: Aircraft rules are required to inherit the `AircraftConfig` abstract class. An example class would look like: @@ -180,6 +172,8 @@ The configuration is a class which has a few different components. - `AircraftConfigSimType.XPlane` - `AircraftConfigSimType.Fsuipc` - `AircraftConfigSimType.MsFs` + - `AircraftConfigSimType.MsFs20` + - `AircraftConfigSimType.MsFs24` - `enabled` - `priority` - from 1 (lowest) to 10 (highest). If there are multiple rules which match this, then which one takes priority. All the built-in rules are at a priority 1, and aircraft specifics rules are priority 2. I recommend @@ -202,6 +196,14 @@ The configuration is a class which has a few different components. In the above example, for the Fenix A320, the landing lights are controlled by two datarefs, both of which the values need to be 1 or 2 for the landing lights to be considered "on". +#### Targeting MSFS + +There are 3 possible values for targetting MSFS in the configs: + + - `AircraftConfigSimType.MsFs` - This will apply the configuration to both 2020 and 2024 + - `AircraftConfigSimType.MsFs20` - This will be for 2020 ONLY + - `AircraftConfigSimType.MsFs24` - This will be for 2024 ONLY + ### Features Features are essentially stored in a dictionary of dictionaries, of type `FeatureAddresses`: @@ -266,6 +268,11 @@ export default class Example extends AircraftConfig { } ``` +### Equality Checking + +I recommend using `==` instead of `===` for equality comparisons, since the types coming from the sim +may not always match up or be casted properly (e.g, `1` being returned instead of `true`) + ### Ignoring Features To ignore a feature in the rules (for example, if a feature doesn't work properly), set the feature to false: @@ -391,7 +398,7 @@ export default class BatteryOnDuringPushback implements Rule { // First check that the battery is declared as part of the aircraft's feature set if (AircraftFeature.Battery in data.features // And then check its value to see if it's on or off - && data.features[AircraftFeature.Battery] === false) { + && data.features[AircraftFeature.Battery] == false) { return ['The battery must be on during pushback'] } } diff --git a/src/aircraft/TBM930.ts b/src/aircraft/TBM930_MSFS20.ts similarity index 82% rename from src/aircraft/TBM930.ts rename to src/aircraft/TBM930_MSFS20.ts index 3cd375d..613e18a 100644 --- a/src/aircraft/TBM930.ts +++ b/src/aircraft/TBM930_MSFS20.ts @@ -7,11 +7,11 @@ import { Meta, } from '../interface/aircraft' -export default class FlyByWireA320N extends AircraftConfig { +export default class TBM930_MSFS20 extends AircraftConfig { meta: Meta = { - id: 'tbm_930', - name: 'TBM 930', - sim: AircraftConfigSimType.MsFs, + id: 'tbm_930_2020', + name: 'TBM 930 2020', + sim: AircraftConfigSimType.MsFs20, enabled: true, priority: 2, } diff --git a/src/aircraft/TBM930_MSFS24.ts b/src/aircraft/TBM930_MSFS24.ts new file mode 100644 index 0000000..26e211d --- /dev/null +++ b/src/aircraft/TBM930_MSFS24.ts @@ -0,0 +1,51 @@ +import { AircraftConfigSimType, AircraftFeature, FeatureType } from '../defs' +import { + AircraftConfig, + FeatureAddresses, + FeatureState, + FlapNames, + Meta, +} from '../interface/aircraft' + +export default class TBM930_MSFS24 extends AircraftConfig { + meta: Meta = { + id: 'tbm_930_2024', + name: 'TBM 930 2024', + sim: AircraftConfigSimType.MsFs24, + enabled: true, + priority: 2, + } + + features: FeatureAddresses = { + [AircraftFeature.BeaconLights]: false, + [AircraftFeature.TaxiLights]: { + 'A:LIGHT TAXI,bool': FeatureType.Int, + }, + [AircraftFeature.LandingLights]: { + 'A:LIGHT LANDING,bool': FeatureType.Int, + }, + [AircraftFeature.LogoLights]: false, + } + + flapNames: FlapNames = { + 0: 'UP', + 1: 'TO', + 2: 'LDG', + } + + match(title: string, icao: string, config_path: string): boolean { + return title.includes('tbm') && title.includes('930') + } + + beaconLights(value: number): FeatureState { + return value == 1 + } + + landingLights(value: number): FeatureState { + return value == 1 + } + + taxiLights(value: number): FeatureState { + return value == 1 + } +} diff --git a/src/defs.ts b/src/defs.ts index 991e7bc..c659edf 100644 --- a/src/defs.ts +++ b/src/defs.ts @@ -124,9 +124,14 @@ export enum PirepState { } /** The simtype for the rule file */ export enum AircraftConfigSimType { + /** This configuration can be for either MSFS 2020 or 2024 */ MsFs = 0, XPlane = 1, Fsuipc = 2, + /** Configuration for MSFS 2020 *only* */ + MsFs20 = 3, + /** Configuration for MSFS 2024 *only* */ + MsFs24 = 4, } /** Features of an aircraft. They are binary on or off */ export enum AircraftFeature {