Skip to content

Commit ab64932

Browse files
committed
New features and reading of SimVars
1 parent 7a97419 commit ab64932

File tree

6 files changed

+161
-21
lines changed

6 files changed

+161
-21
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Features are essentially stored in a dictionary of dictionaries, of type `Featur
185185
features: FeatureAddresses = {
186186
// Aircraft feature
187187
[AircraftFeature.BeaconLights]: {
188-
'lvar name': FeatureType.Int,
188+
'Lookup Address': FeatureType.Int,
189189
},
190190
}
191191
```
@@ -194,6 +194,7 @@ In the above example:
194194

195195
- `AircraftFeature.BeaconLights` is an enum value of the feature type. It's put in `[]` because it's a variable name
196196
- It's set to an object, where the keys are the lookup address or lvar.
197+
- `Lookup Address` is where to find this data:
197198
- `FeatureType.Int` - is the type of value that's returned.
198199

199200
The different features available are:
@@ -211,6 +212,13 @@ The different features contain how to look up the value, and the type. You can h
211212
read and looked at for a feature. Each feature then corresponds to a method which is called to return if
212213
that feature is on or off. That method will have the equivalent number of arguments for each data reference
213214

215+
### Lookup Locations
216+
217+
- For FSUIPC, the lookup location is the offset
218+
- For X-Plane, it's the DRef
219+
- For MSFS, it's either the LVar name, or a Simvar:
220+
- Simvar has to be prefixed with `A:`, e.g, `A:LIGHT LOGO,bool`, and then the type
221+
214222
Example:
215223

216224
```typescript

src/aircraft/FenixA320.ts

+10-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,16 @@ export default class FenixA320 extends AircraftConfig {
137137
return master_switch === 1 && avail_status === 1
138138
}
139139

140-
packs(left_switch: number, left_message: number, right_switch: number, right_message: number): FeatureState {
141-
return (left_switch === 1 && left_message === 0) || (right_switch === 1 && right_message === 0)
140+
packs(
141+
left_switch: number,
142+
left_message: number,
143+
right_switch: number,
144+
right_message: number,
145+
): FeatureState {
146+
return (
147+
(left_switch === 1 && left_message === 0) ||
148+
(right_switch === 1 && right_message === 0)
149+
)
142150
}
143151

144152
doors(exits_left: number, exits_right: number): FeatureState {

src/aircraft/Toliss_A330.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default class Toliss_A330 extends AircraftConfig {
3434
'AirbusFBW/OHPLightSwitches': FeatureType.IntArray,
3535
},
3636
[AircraftFeature.APU]: {
37-
'AirbusFBW/APUAvail': FeatureType.Int,
37+
'AirbusFBW/APUAvail': FeatureType.Int,
3838
},
3939
}
4040

src/aircraft/_default_msfs.ts

+92-13
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,41 @@ export default class DefaultMsFs extends AircraftConfig {
2929
* Set to null to ignore the feature
3030
*/
3131
features: FeatureAddresses = {
32+
[AircraftFeature.Autopilot]: {
33+
'A:AUTOPILOT MASTER,bool': FeatureType.Bool,
34+
'A:AUTOPILOT DISENGAGED,bool': FeatureType.Bool,
35+
},
36+
[AircraftFeature.APU]: {
37+
'A:APU SWITCH,bool': FeatureType.Bool,
38+
},
39+
[AircraftFeature.Battery]: {
40+
'A:ELECTRICAL MASTER BATTERY:0,bool': FeatureType.Bool,
41+
'A:BATTERY CONNECTION ON:0,bool': FeatureType.Bool,
42+
},
3243
[AircraftFeature.BeaconLights]: {
33-
LIGHTING_BEACON_1: FeatureType.Bool,
44+
'A:LIGHT BEACON,bool': FeatureType.Bool,
45+
},
46+
[AircraftFeature.ExternalPower]: {
47+
'A:EXTERNAL POWER ON,bool': FeatureType.Bool,
3448
},
3549
[AircraftFeature.LandingLights]: {
36-
LIGHTING_LANDING_1: FeatureType.Bool,
50+
'A:LIGHT LANDING,bool': FeatureType.Bool,
51+
},
52+
[AircraftFeature.LogoLights]: {
53+
'A:LIGHT LOGO,bool': FeatureType.Bool,
3754
},
3855
[AircraftFeature.NavigationLights]: {
39-
LIGHTING_NAV_1: FeatureType.Bool,
56+
'A:LIGHT NAV,bool': FeatureType.Bool,
4057
},
4158
[AircraftFeature.StrobeLights]: {
42-
LIGHTING_STROBE_1: FeatureType.Bool,
59+
'A:LIGHT STROBE,bool': FeatureType.Bool,
60+
},
61+
[AircraftFeature.TaxiLights]: {
62+
'A:LIGHT TAXI,bool': FeatureType.Bool,
4363
},
44-
[AircraftFeature.TaxiLights]: { LIGHTING_TAXI_1: FeatureType.Bool },
4564
[AircraftFeature.WingLights]: {
46-
LIGHTING_RECOGNITION_1: FeatureType.Bool,
65+
'A:LIGHT RECOGNITION,bool': FeatureType.Bool,
4766
},
48-
[AircraftFeature.LogoLights]: { LIGHTING_BEACON_1: FeatureType.Bool },
4967
}
5068

5169
/**
@@ -65,15 +83,76 @@ export default class DefaultMsFs extends AircraftConfig {
6583
return true
6684
}
6785

68-
beaconLights = (value: boolean): FeatureState => value
86+
/**
87+
* @param value
88+
*/
89+
apu(value: boolean): FeatureState {
90+
return value
91+
}
92+
93+
/**
94+
* @param master
95+
* @param disengaged "AUTOPILOT DISENGAGED"
96+
*/
97+
autopilot(master: boolean, disengaged: boolean): FeatureState {
98+
return master && !disengaged
99+
}
100+
101+
/**
102+
* @param master "ELECTRICAL MASTER BATTERY"
103+
* @param connection "BATTERY CONNECTION ON"
104+
*/
105+
battery(master: boolean, connection: boolean): FeatureState {
106+
return master && connection
107+
}
108+
109+
/**
110+
* Is the external power connected?
111+
* @param externalOn EXTERNAL POWER ON
112+
*/
113+
externalPower(externalOn: boolean): FeatureState {
114+
return externalOn
115+
}
116+
117+
/**
118+
* @param value
119+
*/
120+
beaconLights(value: boolean): FeatureState {
121+
return value
122+
}
69123

70-
landingLights = (value: boolean): FeatureState => value
124+
/**
125+
* @param value
126+
*/
127+
landingLights(value: boolean): FeatureState {
128+
return value
129+
}
71130

72-
navigationLights = (value: boolean): FeatureState => value
131+
/**
132+
* @param value
133+
*/
134+
navigationLights(value: boolean): FeatureState {
135+
return value
136+
}
73137

74-
strobeLights = (value: boolean): FeatureState => value
138+
/**
139+
* @param value
140+
*/
141+
strobeLights(value: boolean): FeatureState {
142+
return value
143+
}
75144

76-
taxiLights = (value: boolean): FeatureState => value
145+
/**
146+
* @param value
147+
*/
148+
taxiLights(value: boolean): FeatureState {
149+
return value
150+
}
77151

78-
wingLights = (value: boolean): FeatureState => value
152+
/**
153+
* @param value
154+
*/
155+
wingLights(value: boolean): FeatureState {
156+
return value
157+
}
79158
}

src/defs.ts

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export enum GateType {
2121
/** Added for MSFS */
2222
Jetway = 16,
2323
}
24+
/** The runway/taxiway surface */
2425
export enum Surface {
2526
Concrete = 0,
2627
Grass = 1,
@@ -67,10 +68,13 @@ export enum SimType {
6768
None = 0,
6869
Prepar3D = 1,
6970
Xplane = 2,
71+
/** You can use this for ALL FlightSimulator (2020, 2024, and beyond) */
7072
FlightSimulator = 3,
7173
Fsx = 4,
7274
Fs9 = 5,
75+
/** Specifically only for MSFS 2020 */
7376
FlightSimulator2020 = 6,
77+
/** Specifically only for MSFS 2024 */
7478
FlightSimulator2024 = 7,
7579
}
7680
export enum FareType {
@@ -145,6 +149,8 @@ export enum AircraftFeature {
145149
Engines = 16,
146150
Transponder = 17,
147151
LandingGear = 18,
152+
Autopilot = 19,
153+
ExternalPower = 20,
148154
}
149155
/** The type of the dataref */
150156
export enum FeatureType {

src/interface/aircraft.ts

+43-4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ export abstract class AircraftConfig {
104104
return this.flapNames[value] || value
105105
}
106106

107+
apu(...args: any): FeatureState {
108+
return null
109+
}
110+
111+
/**
112+
*
113+
*/
114+
autopilot(...args: any): FeatureState {
115+
return null
116+
}
117+
107118
/**
108119
* Provide an implementation for but, by default, it's null
109120
* @param args
@@ -136,10 +147,6 @@ export abstract class AircraftConfig {
136147
return null
137148
}
138149

139-
apu(...args: any): FeatureState {
140-
return null
141-
}
142-
143150
doors(...args: any): FeatureState {
144151
return null
145152
}
@@ -163,4 +170,36 @@ export abstract class AircraftConfig {
163170
packs(...args: any): FeatureState {
164171
return null
165172
}
173+
174+
externalPower(...args: any): FeatureState {
175+
return null
176+
}
177+
178+
/**
179+
* Not Implemented
180+
*/
181+
parkingBrakes(...args: any): FeatureState {
182+
return null
183+
}
184+
185+
/**
186+
* Not Implemented
187+
*/
188+
engines(...args: any): FeatureState {
189+
return null
190+
}
191+
192+
/**
193+
* Not Implemented
194+
*/
195+
transponder(...args: any): FeatureState {
196+
return null
197+
}
198+
199+
/**
200+
* Not Implemented
201+
*/
202+
landingGear(...args: any): FeatureState {
203+
return null
204+
}
166205
}

0 commit comments

Comments
 (0)