Commit fca7134 1 parent a3b9904 commit fca7134 Copy full SHA for fca7134
File tree 1 file changed +31
-0
lines changed
1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -334,6 +334,37 @@ A rule also has several components:
334
334
- A ` violated() ` method, which returns a ` RuleValue `
335
335
- Passed the ` pirep ` and the ` data ` (` Telemetry ` type)
336
336
337
+ ### Looking at aircraft feature states
338
+
339
+ To lookup the state of an aircraft feature, look at the ` data.Features ` dictionary. The following
340
+ rule is evaluated during pushback, and checks that the battery is on:
341
+
342
+ ``` typescript
343
+ import { AircraftFeature , PirepState } from ' ./defs'
344
+
345
+ export default class BatteryOnDuringPushback implements Rule {
346
+ meta: Meta = {
347
+ id: ' ExampleRule' ,
348
+ name: ' An Example Rule' ,
349
+ enabled: true ,
350
+ message: ' A example rule!' ,
351
+ states: [PirepState .Pushback ],
352
+ repeatable: false ,
353
+ cooldown: 60 ,
354
+ max_count: 3 ,
355
+ }
356
+
357
+ violated(pirep : Pirep , data : Telemetry , previousData ? : Telemetry ): RuleValue {
358
+ // First check that the battery is declared as part of the aircraft's feature set
359
+ if (AircraftFeature .Battery in data .features
360
+ // And then check its value to see if it's on or off
361
+ && data .features [AircraftFeature .Battery ] === false ) {
362
+ return [' The battery must be on during pushback' ]
363
+ }
364
+ }
365
+ }
366
+ ```
367
+
337
368
### Returning a ` RuleValue `
338
369
339
370
The return value has multiple possible values, sending on
You can’t perform that action at this time.
0 commit comments