Skip to content

Commit fca7134

Browse files
committed
Update README
1 parent a3b9904 commit fca7134

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

README.md

+31
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,37 @@ A rule also has several components:
334334
- A `violated()` method, which returns a `RuleValue`
335335
- Passed the `pirep` and the `data` (`Telemetry` type)
336336

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+
337368
### Returning a `RuleValue`
338369

339370
The return value has multiple possible values, sending on

0 commit comments

Comments
 (0)