Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
nabeelio committed Nov 7, 2024
1 parent 176b09f commit 5160099
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,37 @@ A rule also has several components:
- A `violated()` method, which returns a `RuleValue`
- Passed the `pirep` and the `data` (`Telemetry` type)

### Looking at aircraft feature states

To lookup the state of an aircraft feature, look at the `data.Features` dictionary. The following
rule is evaluated during pushback, and checks that the battery is on:

```typescript
import { AircraftFeature, PirepState } from './defs'

export default class BatteryOnDuringPushback implements Rule {
meta: Meta = {
id: 'ExampleRule',
name: 'An Example Rule',
enabled: true,
message: 'A example rule!',
states: [PirepState.Pushback],
repeatable: false,
cooldown: 60,
max_count: 3,
}

violated(pirep: Pirep, data: Telemetry, previousData?: Telemetry): RuleValue {
// 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) {
return ['The battery must be on during pushback']
}
}
}
```

### Returning a `RuleValue`

The return value has multiple possible values, sending on
Expand Down

0 comments on commit 5160099

Please sign in to comment.