Skip to main content

Defining CAS Alerts Using panel.xml

Introduction

When using the CAS System API, you may choose to support defining CAS alerts and their activation criteria in panel.xml using the Annunciation syntax. However, keep in mind that this panel.xml API has several limitations:

  • Activation criteria are limited to what can be evaluated using the sim's standard <Condition> tag syntax.
  • Only one priority level is supported for each alert.
  • Debounce is not supported.
  • Inhibit states are not supported.
  • The ID of the alert is generated automatically and is not retrievable, meaning you cannot interact with the alert using Typescript.

The panel.xml Syntax

To define panel.xml CAS alerts, include the <Annunciations> tag in the global scope (as a direct child of <PlaneHTMLConfig>). Each <Annunciation> tag that is a child of <Annunciations> then defines a single alert:

<Annunciations>
<!--
Defines an alert with message text 'PARKING BRAKE' that will be activated at advisory priority
when the parking brake is engaged.
-->
<Annunciation>
<Type>Advisory</Type>
<Text>PARKING BRAKE</Text>
<Condition>
<Simvar name="BRAKE PARKING POSITION" unit="Bool" />
</Condition>
</Annunciation>

<!--
Defines an alert with message text 'FUEL LOW' that will be activated at caution priority
with suffixes 'L' and 'R' when the fuel in the left and right tanks, respectively,
drops below 10 gallons.
-->
<Annunciation>
<Type>Caution</Type>
<Text>FUEL LOW</Text>
<Condition Suffix="L">
<Lower>
<Simvar name="FUEL TANK LEFT MAIN QUANTITY" unit="gallon"/>
<Constant>10</Constant>
</Lower>
</Condition>
<Condition Suffix="R">
<Lower>
<Simvar name="FUEL TANK RIGHT MAIN QUANTITY" unit="gallon"/>
<Constant>10</Constant>
</Lower>
</Condition>
</Annunciation>
</Annunciations>

Parsing panel.xml Alert Definitions

To parse and use CAS alert definitions from panel.xml, you can use the XMLAnnunciationFactory and CasSystemLegacyAdapter classes. XMLAnnunciationFactory is used to parse the panel.xml document and generate an array of Annunciation definitions. This array is then provided to CasSystemLegacyAdapter, which will automatically register the appropriate alerts and generate the logic required to activate/deactivate them.

The following is an example of how to configure an instrument to support panel.xml-defined CAS alerts (it is assumed that CasSystem is already set up and initialized):

import { EventBus, CasSystemLegacyAdapter, CompositeLogicXMLHost, XMLAnnunciationFactory } from '@microsoft/msfs-sdk';

class MyInstrument extends BaseInstrument {

private readonly bus = new EventBus();

private readonly logicHost = new CompositeLogicXMLHost();

// ...

public connectedCallback(): void {
super.connectedCallback();

const annunciations = new XMLAnnunciationFactory(this).parseConfig(this.xmlConfig);
const adapter = new CasSystemLegacyAdapter(this.bus, this.logicHost, annunciations);
adapter.start();
}
}