Skip to content

Commit

Permalink
Added MsFs20 and MsFs24 as sim types
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio committed Feb 20, 2025
1 parent 0c7f557 commit 54e5867
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,4 @@ TEST-results.xml
package.g.props
*v8.log
/lib/
packages.lock.json
65 changes: 36 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

---

Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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`:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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']
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/aircraft/TBM930.ts → src/aircraft/TBM930_MSFS20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down
51 changes: 51 additions & 0 deletions src/aircraft/TBM930_MSFS24.ts
Original file line number Diff line number Diff line change
@@ -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
}
}
5 changes: 5 additions & 0 deletions src/defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 54e5867

Please # to comment.