generated from phpvms/acars-pdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
588 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Excess bank angle | ||
*/ | ||
import { AircraftFeature, PirepState } from '../defs' | ||
import { Meta, Rule, RuleValue } from '../types/rule' | ||
import { Pirep, Telemetry } from '../types/types' | ||
|
||
export default class ExcessBank implements Rule { | ||
meta: Meta = { | ||
id: 'EXCESS_BANK', | ||
name: 'Bank angle exceeded limit', | ||
enabled: true, // Default, will change depending on airline config | ||
message: 'Bank angle exceeded limit', | ||
states: [ | ||
PirepState.Takeoff, | ||
PirepState.Enroute, | ||
PirepState.Approach, | ||
PirepState.Final, | ||
], | ||
repeatable: false, | ||
cooldown: 60, | ||
max_count: 3, | ||
points: -1, | ||
delay_time: 5000, | ||
parameter: 30, // default, gets overwritten from remote | ||
} | ||
|
||
violated(pirep: Pirep, data: Telemetry, previousData?: Telemetry): RuleValue { | ||
if (data.onGround) { | ||
return [false] | ||
} | ||
|
||
return Acars.ViolatedAfterDelay(this.meta.id, this.meta.delay_time, () => { | ||
// +Bank is right, -Bank is left | ||
const value = | ||
data.bank < -1 * this.meta.parameter! || | ||
data.bank > this.meta.parameter! | ||
|
||
if (value) { | ||
return [true] | ||
} else { | ||
return [false] | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Detect if there's excess gforces | ||
*/ | ||
import { AircraftFeature, PirepState } from '../defs' | ||
import { Meta, Rule, RuleValue } from '../types/rule' | ||
import { Pirep, Telemetry } from '../types/types' | ||
|
||
export default class ExcessGForce implements Rule { | ||
meta: Meta = { | ||
id: 'EXCESS_GFORCE', | ||
name: 'GForce exceeded limit', | ||
enabled: true, // Default, will change depending on airline config | ||
message: 'GForce exceeded limit', | ||
states: [ | ||
PirepState.Takeoff, | ||
PirepState.Enroute, | ||
PirepState.Approach, | ||
PirepState.Final, | ||
], | ||
repeatable: false, | ||
cooldown: 60, | ||
max_count: 3, | ||
points: -1, | ||
delay_time: 5000, | ||
parameter: 4, | ||
} | ||
|
||
violated(pirep: Pirep, data: Telemetry, previousData?: Telemetry): RuleValue { | ||
if (data.onGround) { | ||
return [false] | ||
} | ||
|
||
return [data.gForce >= this.meta.parameter!] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Detect is the aircraft is pitched up or down excessively | ||
*/ | ||
import { AircraftFeature, PirepState } from '../defs' | ||
import { Meta, Rule, RuleValue } from '../types/rule' | ||
import { Pirep, Telemetry } from '../types/types' | ||
|
||
export default class ExcessPitch implements Rule { | ||
meta: Meta = { | ||
id: 'EXCESS_PITCH', | ||
name: 'Pitch exceeded limit', | ||
enabled: true, | ||
message: 'Pitch exceeded limit', | ||
states: [ | ||
PirepState.Takeoff, | ||
PirepState.Enroute, | ||
PirepState.Approach, | ||
PirepState.Final, | ||
], | ||
repeatable: false, | ||
cooldown: 60, | ||
max_count: 3, | ||
points: -1, | ||
delay_time: 5000, | ||
parameter: 4, | ||
} | ||
|
||
violated(pirep: Pirep, data: Telemetry, previousData?: Telemetry): RuleValue { | ||
if (data.onGround) { | ||
return [false] | ||
} | ||
|
||
return [ | ||
data.pitch < -1 * this.meta.parameter! || | ||
data.pitch > this.meta.parameter!, | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Evaluate if this rule has been violated. If they go overspeed, then start the | ||
* stopwatch. Then mark it as violated if they've gone overspeed for ~ 6 seconds | ||
* 6 seconds to make sure it doesn't interfere with a takeoff roll | ||
*/ | ||
import { PirepState } from '../defs' | ||
import { Meta, Rule, RuleValue } from '../types/rule' | ||
import { Pirep, Telemetry } from '../types/types' | ||
|
||
export default class ExcessTaxiSpeed implements Rule { | ||
meta: Meta = { | ||
id: 'EXCESS_TAXI_SPEED', | ||
name: 'Taxi speed exceeded limit', | ||
enabled: true, | ||
message: 'Taxi speed exceeded limit', | ||
states: [PirepState.TaxiIn, PirepState.TaxiOut], | ||
repeatable: false, | ||
cooldown: 60, | ||
max_count: 3, | ||
points: -1, | ||
delay_time: 5000, | ||
parameter: 4, | ||
} | ||
|
||
violated(pirep: Pirep, data: Telemetry, previousData?: Telemetry): RuleValue { | ||
return Acars.ViolatedAfterDelay( | ||
this.meta.id, | ||
this.meta.delay_time, | ||
(): RuleValue => { | ||
if (!data.onGround) { | ||
return [false] | ||
} | ||
|
||
// If they're on a runway, ignore any taxi speed warnings, might be taking off | ||
if (data.approachingRunway != null || data.runway != null) { | ||
return [false] | ||
} | ||
|
||
return [data.groundSpeed.Knots > this.meta.parameter!] | ||
}, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* If the fuel level is higher at any point | ||
*/ | ||
import { PirepState } from '../defs' | ||
import { Meta, Rule, RuleValue } from '../types/rule' | ||
import { Pirep, Telemetry } from '../types/types' | ||
|
||
export default class FuelRefilled implements Rule { | ||
meta: Meta = { | ||
id: 'EXCESS_TAXI_SPEED', | ||
name: 'Taxi speed exceeded limit', | ||
enabled: true, | ||
message: 'Taxi speed exceeded limit', | ||
states: [], | ||
repeatable: false, | ||
cooldown: 60, | ||
max_count: 3, | ||
points: -1, | ||
delay_time: 5000, | ||
parameter: 4, | ||
} | ||
|
||
violated(pirep: Pirep, data: Telemetry, previousData?: Telemetry): RuleValue { | ||
if (data.onGround || previousData == null) { | ||
return [false] | ||
} | ||
|
||
if (data.fuelQuantity.Pounds > previousData.fuelQuantity.Pounds) { | ||
return [false] | ||
} | ||
|
||
return [ | ||
Acars.NumberOverPercent( | ||
data.fuelQuantity.Pounds, | ||
previousData.fuelQuantity.Pounds, | ||
10, | ||
), | ||
`Fuel Refilled: Current: ${data.fuelQuantity.Pounds}, previous=${previousData.fuelQuantity.Pounds}`, | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { PirepState } from '../defs' | ||
import { Meta, Rule, RuleValue } from '../types/rule' | ||
import { Pirep, Telemetry } from '../types/types' | ||
|
||
export default class HandLandings implements Rule { | ||
meta: Meta = { | ||
id: 'HARD_LANDING', | ||
name: 'Hard Landing', | ||
enabled: true, // Default, will change depending on airline config | ||
message: 'Hard Landing', | ||
states: [PirepState.Final, PirepState.Landed], | ||
repeatable: false, | ||
cooldown: 60, | ||
max_count: 3, | ||
points: -1, | ||
parameter: 300, // default, gets overwritten from remote | ||
} | ||
|
||
violated(pirep: Pirep, data: Telemetry, previousData?: Telemetry): RuleValue { | ||
const absRate = Math.abs(pirep.landingRate.FeetPerMinute) | ||
const absParam = Math.abs(this.meta.parameter!) | ||
if (absRate < absParam) { | ||
return [false] | ||
} | ||
|
||
console.log( | ||
`Hard landing violation, rate=${absRate}, threshold=${absParam}`, | ||
) | ||
|
||
return [true] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Determine if the beacon lights are on while the aircraft is in motio | ||
*/ | ||
import { AircraftFeature, PirepState } from '../defs' | ||
import { Meta, Rule, RuleValue } from '../types/rule' | ||
import { Pirep, Telemetry } from '../types/types' | ||
|
||
export default class LightsOffDuringTaxi implements Rule { | ||
meta: Meta = { | ||
id: 'LAND_LIGHTS_OFF_TAXI', | ||
name: 'Landing lights must be off during pushback or taxi', | ||
enabled: true, | ||
message: 'Landing lights must be off during pushback or taxi', | ||
states: [PirepState.TaxiOut, PirepState.Pushback, PirepState.TaxiIn], | ||
repeatable: false, | ||
cooldown: 60, | ||
max_count: 3, | ||
points: -1, | ||
delay_time: 5000, | ||
} | ||
|
||
violated(pirep: Pirep, data: Telemetry, previousData?: Telemetry): RuleValue { | ||
if (!Acars.IsFeatureEnabled(AircraftFeature.LandingLights)) { | ||
return [false] | ||
} | ||
|
||
return Acars.ViolatedAfterDelay( | ||
this.meta.id, | ||
this.meta.delay_time, | ||
(): RuleValue => { | ||
// Ignore landing lights being turned on | ||
if (data.approachingRunway != null || data.runway != null) { | ||
return [false] | ||
} | ||
|
||
return [data.landingLights] | ||
}, | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Determine if the beacon lights are on while the aircraft is in motio | ||
*/ | ||
import { AircraftFeature, PirepState } from '../defs' | ||
import { Meta, Rule, RuleValue } from '../types/rule' | ||
import { Pirep, Telemetry } from '../types/types' | ||
|
||
export default class LightsOver10K implements Rule { | ||
meta: Meta = { | ||
id: 'LAND_LIGHTS_OVER_10K', | ||
name: 'Landing lights must be off above ', | ||
enabled: true, | ||
message: 'Landing lights must be off above ', | ||
states: [], | ||
repeatable: false, | ||
cooldown: 60, | ||
max_count: 3, | ||
points: -1, | ||
delay_time: 5000, | ||
} | ||
|
||
violated(pirep: Pirep, data: Telemetry, previousData?: Telemetry): RuleValue { | ||
if (!Acars.IsFeatureEnabled(AircraftFeature.LandingLights)) { | ||
return [false] | ||
} | ||
|
||
if (data.onGround) { | ||
return [false] | ||
} | ||
|
||
return Acars.ViolatedAfterDelay( | ||
this.meta.id, | ||
this.meta.delay_time, | ||
(): RuleValue => { | ||
// Ignore landing lights being turned on | ||
const violated = | ||
data.landingLights && | ||
data.planeAltitude.Feet > this.meta.parameter! + 500 | ||
|
||
return [violated, this.meta.message + this.meta.parameter!] | ||
}, | ||
) | ||
} | ||
} |
Oops, something went wrong.