0% found this document useful (0 votes)
98 views

AirFASE - Scripting Language Manual

Uploaded by

hddhll.liang
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
98 views

AirFASE - Scripting Language Manual

Uploaded by

hddhll.liang
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 26

A Scripting Language

FAP Editor Overview:


The FAP Editor lets you tailor the AirFASE software to the specific needs of the customer. The FAP Editor is
used to create Flight Application Programs (FAPs). An FAP is comprised of the following elements:
¾ Acquired Parameters – values that are sampled and recorded by the onboard avionics systems.
¾ Derived Parameters – parameters that are calculated based upon the Acquired Parameters.
¾ Standard Parameters – a specific set of Derived Parameters used by the AirFASE system software.
¾ Key Values – constant values that are used in the derivation process and are modifiable to tailor the
process to a specific aircraft or data frame.
¾ Events – flags that are generated when predetermined specific combination of parameters occurs.

Since AirFASE is 100% programmable application, we want our customers to take a full advantage of this
powerful feature. This manual looks at ways to eliminate time consumption and provide you with answers that
you need by manipulating and tailoring the date to your specific needs by writing scripts that perform a specific
task. AirFASE is easily programmable by the user to add or change the Events or data being monitored, so it
can also be used to run a maintenance monitoring program, for example, providing the results of the analysis to
the airline Maintenance Department. But before we go ahead and start to write scripts, we want to first define
what a script is, and the purpose that it serves.

A scripting language differentiates itself from other typical languages in that they are usually simpler to learn
and use, as well as not needing to be compiled. The language is interpreted at run-time so you can execute
instructions immediately. You just need to identify a task that you need an answer for and write a script.

You might be asking yourself what the difference might be between programming and scripting. Well, the basic
difference between "programming" and "scripting" is better defined by usage, or application, as well as scope
and purpose. A programming language is used for building standalone projects, or "applications"; a scripting
language is used to write "scripts" that interact with other data or systems to perform parts of a task rather than
an entire workflow.

Scripting languages are designed for "gluing" applications; they use typeless approaches to achieve a higher
level of programming and more rapid application development than system programming languages.
Scripting languages are designed for gluing: they assume the existence of a set of powerful components and are
intended primarily for connecting components together. On the other hand, programming languages are strongly
typed to help manage complexity, while scripting languages are typeless to simplify connections between
components and provide rapid application development.

An example might make this clearer. Programming languages are used to write programs, which can run for a
while and do multiple things. Scripting languages are used to write scripts, which run for a short duration to
perform a single, simple task. That little snippet of local, customized programming would be a script, written in
a scripting language. The script would be started, perform its one task, and stop.

To summarize, scripting languages are designed for gluing applications. They provide a higher level of
programming than assembly or system programming languages, much weaker typing than system programming
languages, and an interpreted development environment. Scripting languages sacrifice execution speed to
improve development speed.

Before we start to write a script, we need to first learn the fundamentals of a scripting language.
Scripting in FAP’s is performed using a basic scripting language based on the C programming languages.
FAP Script Syntax

THIS IS CONFIDENTIAL AND PROPRIETARY INFORMATION OF TELEDYNE CONTROLS AND MAY NOT BE USED OR DISCLOSED BY THE RECIPIENT WITHOUT THE
PRIOR WRITTEN CONSENT OF TELEDYNE CONTROLS AND THEN ONLY IN ACCORDANCE WITH SPECIFIC WRITTEN INSTRUCTIONS OF TELEDYNE CONTROLS. BY
RECEIPT HEREOF, IN ADDITION TO ANY OBLIGATION THE RECIPIENT HAS UNDER ANY CONFIDENTIALITY AGREEMENT, CONTRACT, OR LICENSE WITH
TELEDYNE CONTROLS, NEITHER RECIPIENT NOR ITS AGENTS, REPRESENTATIVES OR EMPLOYEES WILL COPY, REPRODUCE OR DISTRIBUTE THIS

FAP Script Syntax Summary


Lexical Grammar

Tokens:
Keyword Numbers
Identifier
Number Number:
String-literal Integer-constant
Operator Integer-constant . Integer-constant
Punctuator . Integer-constant

Keyword: Integer-constant
break Digit
case Integer-constant Digit
continue
default String-Literals
do String-literal:
else ""
for "s-char-sequence"
if
return s-char-sequence:
switch s-char
while s-char-sequence s-char
and
or s-char:
div Digit
mod Non-digit
persist SPACE
Operators
Identifiers Punctuators
Identifier:
Non-digit Operators
Identifier Non-digit
Identifier Digit Operator:
% $ [ ] ( ) + - * / ^ ! > < == >= <= != && || =
Non-digit: one of
_abcdefghijklmnopqrstuvwxyz Punctuators
ABCDEFGHIJKLMNOPQRSTUV
Punctuator:
aaaaaa W X Y Z
{},:;
Digit: one of
0123456789
Phrase Structure Grammar

-Expression
Expressions
Compound-expression:
Expression: ( Expression )
Atom
Numeric-array-ref Sequence-expression:
Negative-expression Expression , Expression
Logical-expression
Arithmetic-expression Function-call-expression:
Compound-expression Function-name ( )
Relational-expression Function-name ( Argument-list )
Sequence-expression
Function-call-expression String-function-call:
Assignment-expression Function-name $ ( )
Function-name $ ( Argument-list )
String-expression:
String Argument-list:
String-expression + String Expression
String-function-call String-expression
Argument-list, expression
Logical-expression: Argument-list, String-expression
! Expression
Expression and Expression Function-name:
Expression or Expression Build-in-system-primitive-function
Expression && Expression => identifier
Expression || Expression Other-defined-condition-logic-function
=> identifier
Arithmetic-expression:
Expression ^ Expression Atom:
Expression * Expression Number
Expression / Expression Numeric-variable
Expression + Expression Numeric-parameter-from-DB
Expression - Expression => identifier
Expression div Expression Numeric-constant-from-DB
Expression mod Expression => identifier

Relational-expression: String:
Expression > Expression (greater than) String-literal
Expression == Expression (equal to) String-variable
Expression < Expression (less than) String-array-ref
Expression != Expression (not equal to) String-parameter-from-DB
Expression >= Expression (greater than or equal to) => identifier $
Expression <= Expression (less than or equal to)
String == String String-variable:
String != String Identifier $

Assignment-expression: Numeric-variable:
Numeric-L-value = Expression Real-variable
Integer-variable
String-assignment-expression:
String-L-value = String-expression Real-variable:
Identifier

Negative-expression: Integer-variable:
Identifier %
Expression-statement:
Numeric-L-value: Expression ;
Numeric-variable String-assignment ;
Numeric-parameter Numeric-initializer ;
Numeric-array-ref String-initializer ;
Static-declaration ;
Numeric-array-ref:
Numeric-variable [ Expression ] Statement-list:
Numeric-parameter-from-DB [ Expression ] Statement Statement
=> identifier [ Expression ] Statement-list Statement

String-L-value: Break-statement:
String-variable break ;
String-array-ref
Continue-statement:
String-array-ref: continue ;
String-variable [ Expression ]
String-parameter-from-DB [ Expression ] Return-statement:
=> identifier $ [ Expression ] return ;
return Expression ;
Numeric-initializer:
Numeric-variable [ ] = { Numeric-init-list } Compound-statement:
{ Statement }
Numeric-init-list: { Statement-list }
Expression
Numeric-init-list, Expression While-statement:
while Compound-expression Statement
String-initializer:
String-variable [ ] = { String-init-list } If-statement:
if Compound-expression Statement
String-init-list: if Compound-expression Statement else
String-expression Statement
String-init-list, String-expression
Switch-statement:
Static-declaration: switch Compound-expression Statement
persist Assignment-expression
persist String-assignment-expression Default-statement:
persist Numeric-initializer default : Statement
persist String-initializer
Case-statement:
case Expression : Statement
Statements
Statement: Do-statement:
Compound-statement do Statement while Compound-expression ;
Expression-statement
Break-statement For-statement:
Return-statement for ( Statement Statement ) Statement
Continue-statement for ( ; ; ) Statement
If-statement for ( Statement ; ) Statement
Switch-statement for ( ; Statement ) Statement
Case-statement for ( Statement Statement Expression )Statement
Default-statement for ( ; ; Expression ) Statement
While-statement for ( ; Statement Expression ) Statement
Do-statement for ( Statement ; Expression ) Statement
For-statement
Precedence and order of evaluation

Symbol Type of Operation Associativity


$% Type modifier Left to right
[] () Expression Left to right
-! Unary Right to left
^ Power Left to right
* / div mod Multiplicative Left to right
+- Additive Left to right
> < == >= != <= Relational Left to right
&& || and or Logical Left to right
= Assignment Right to left
, Sequential evaluation Left to right

The basics of if-else statements


This section will introduce the logic of if-else statements in general for scripting. After reading this section you
will have knowledge of the basics of if-else statements.

The basics

When programming you often want to control the order in which the statements will be executed. This is done
by using Control Flow Statements, and some of those are the if-else statements.

The if-else statements enable your script program to selectively execute other statements, based on some criteria.
The simplest version, the if statement, is shown below. The block governed by if (delimited with '{' and '}') is
executed if the expression is true, otherwise the execution continues after the last '}'.

if (expressions)
{
statement(s)
}

If you want to execute other statements when the expression is false, you use the else statement.

if (expression)
{
statement(s) executed if expression is true
}
else
{
statement(s) executed if expression is false
}

For example: the following test decides whether a flight is in the initial climb phase or not.

If we define the Initial Climb to be inside of the following conditions:


¾ Radio altitude is greater than 35 feet and less then 1500 feet.
The script for this would be:

if (Radio_ALT_GT > 35 and Radio_Alt_GT < 1500)


{
FLIGHT_PHASE% = 4; //4 for Initial Climb
}
else
{
FLIGHT_PHASE% = 3; //3 for Take OFF
}

This is used to decide whether to do something at a special point, or to decide between two courses of action.
Each version consists of a test, (this is the bracketed statement following the “if”). If the test is true, then the
next statement is obeyed. If it is false then the statement following the else is obeyed. After this, the rest of the
program continues as normal.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Loops in Scripting
Loops allow script programs to repeat one or more statements a bunch of times. There are three main kinds of
loops: for loops, while loops, and do loops.

FOR LOOPS
for (<initialization>; <stopping condition>; <expression)
{
<one or more statements>
} //end for

The <initialization> portion is often used to set the value of a counter variable. The <expression> is typically
used to increment the counter variable. The “for” loop continues executing the statements it contains until the
<stopping condition> is met.

The <stopping condition> may be a boolean expression which evaluates to true or false, or it actually may be an
expression which produces any value. In the latter case, this value is converted to an integer. If this integer is 0,
then the <stopping condition> is considered to be false. If this integer is not 0, the <stopping condition> is
considered to be true.

For example, lets create a for loop condition where it will continue to compare certain engine parameters as
long as it’s in a certain
// conditions over multiple samples number of seconds.
for (i% = 0; i% < NumOfSec%; i% = i% + 1)
{
N1_LT_11% = N1_LT_11% and ((_N1_1(i%) < 11.0) or (_N1_2(i%) < 11.0));
N2_LT_11% = N2_LT_11% and ((_N2_1(i%) < 11.0) or (_N2_2(i%) < 11.0));
N1_GT_60% = N1_GT_60% and ((_N1_1(i%) > 60.0) and (_N1_2(i%) > 60.0));
}
//end for

Note: The "++" operator adds one to a number, so count++ would be equivalent to count = count + 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WHILE LOOPS
while (<stopping condition>)
{
<one or more statements>
} //end while

The while loop checks to see if the <stopping condition> is true (or not -). If so, the statements inside the while
loop are executed, then the <stopping condition> is checked again, and so on. When the <stopping condition> is
found to be false (or -), execution continues with whatever statements follow at the end of the while loop.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DO LOOP
do {
<one or more statements>
} while (<stopping condition>)

The do loop is similar to the while loop, except that it checks the <stopping condition> after the statements that
it contains. This means that the statements inside a do loop are always executed at least once, whereas the
statements inside a while loop may never be executed.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Case Statements
Case statement can be used instead of if statement suitably when one condition could have multiple possibilities.

Following example illustrates the use of case statement in flight phase transition logic:

case 0: // PREFLIGHT
if (ALL_N1_AND_N2_GT_11%) {
l_FLIGHT_PHASE% = 1; // ENGINE START
break;
// return 1; // ENGINE START
}
break;
case 1: // ENGINE START
if (ANY_N1_OR_N2_LT_11%) {
l_FLIGHT_PHASE% = 0; // PREFLIGHT
break;
// return 0; // PREFLIGHT
}
if (GS_GT_10KT% and N2_GT_50%) {
l_FLIGHT_PHASE% = 2; // TAXI OUT
break;
// return 2; // TAXI OUT
}
// break;
case 2: // TAXI OUT
if (N1_GT_60% and GS_INCREASING% and GS_GT_50KT%)
{
l_FLIGHT_PHASE% = 3; // TAKE OFF
break;
// return 3; // TAKE OFF
}
break;
Functions/Primitives
Now that you have learned about if-else statements, loops, and case statements it is time to learn about functions.
In general, functions/primitives are blocks of code that perform a number of pre-defined commands to
accomplish something productive.
Functions that a programmer writes will generally require a prototype. Just like a blueprint, the prototype tells
the interpreter what the function will return, what the function will be called, as well as what arguments the
function can be passed. When I say that the function returns a value, I mean that the function can be used in the
same manner as a variable would be. For example, a variable can be set equal to a function that returns a value
between zero and four.
The general format for a prototype is simple: return-type function_name ( arg_type arg1, ..., arg_type argN );
“arg”_type just means the type for each argument -- for instance, an int, a float, or a char. It's exactly the same
thing as what you would put if you were declaring a variable.
There can be more than one argument passed to a function or none at all (where the parentheses are empty), and
it does not have to return a value. Functions that do not return values have a return type of void.
Lets look at a function prototype: int mult ( int x, int y );
This prototype specifies that the function “mult” will accept two arguments, both integers, and that it will return
an integer. Do not forget the trailing semi-colon. Without it, the interpreter will probably think that you are
trying to write the actual definition of the function.
Example:
To simplify usage of this primitive for a user in FAP Script, it will be written something like the following:
myResult = MAX(CAS, 5); // assume CAS is the acquired parameter;
return maximum CAS over 5 second period

So the function prototype for script has changed in FAP Script to the following:
MAX(ParamName, Duration)

FAPScript Primitive will look like the following:


<Param> MAX(<Param Name> Param, <Param> Duration);

Prototype for AVERAGE primitive


// ------------------------------------------------------------------------------------------------------------
// Name: AVERAGE
// Description: Get the average value of a Real Parameter over a N-second period
// Return: a parameter containing the average value
// Exceptions: CFapException* if error
// ------------------------------------------------------------------------------------------------------------
CParam AVERAGE ( // C/C++ prototype
const int32 iParamId, // IN: parameter Ident
const bool bAcq, // IN: true for acquired parameters, false for derived
const CParam &ParamDuration // IN: duration (seconds)
) const;
is changed to

<CParam> AVERAGE ( // FAP Script prototype


<CParam Name> ParamName, // Name of Parameter without (AgeIndex)
<CParan> ParamDuration // IN: duration (seconds)
);
Example:
return AVERAGE(_CAS, 60); // return average _CAS value over a 60 second period

So the function prototype for script has changed in FAP Script to the following:
AVERAGE(ParamName, Duration)

Prototype for KeyValue primitive


// -----------------------------------------------------------------------------
// Name: KeyValue
// Description: obtain key value given key value name
// Return: key value
// Exceptions: None
// -----------------------------------------------------------------------------
<real> KeyValue (
<str> KeyValueName; // string contain name of key value
);

Example:
l_MyKeyValue = KeyValue("#kMyKeyValue"); // get key value "#kMyKeyValue"

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

OPERATORS IN FAPSCRIPT AND FAPENGINE


Almost all operators are overloaded in FAPEngine, so there is no special handler in FAPScript for them. FAPScript exepts them as is.

• ARITHMETIC OPERATOR between a parameter and a variable


o operator ‘+’
ƒ in FAPScript ‘+’ or ‘ADD’
ƒ in Form-Base defined in a Primitive List as: ‘ADD’
o operator ‘-’ Æ in Form-Base defined in a Primitive List as: ‘SUBSTRACT’
o operator ‘*’ Æ in Form-Base defined in a Primitive List as: ‘MULTIPLY’
o operator ‘/’ Æ in Form-Base defined in a Primitive List as: ‘DIVIED’
o operator ‘%’ Æ in Form-Base defined in a Primitive List as: ‘MODULO’

• LOGICAL OPERATOR between a parameter and a variable


o operator ‘&&’
ƒ in FAPScript ‘&&’ or ‘AND’
ƒ in Form-Base defined in a Primitive List as: ‘AND’
o operator ‘||’
ƒ in FAPScript ‘||’ or OR’
ƒ in Form-Base defined in a Primitive List as: ‘OR’
• ASSIGNMENT OPERATOR between a parameter and a variable
o operator ‘=’ Æ in Form-Base defined in a Primitive List as: ‘ASSIGN’
• COMPARISON OPERATOR between a parameter and a variable
o operator ‘==’ Æ in Form-Base defined in a Primitive List as: ‘EQ’
o operator ‘!=’ Æ in Form-Base defined in a Primitive List as: ‘NE’
o operator ‘>’ Æ in Form-Base defined in a Primitive List as: ‘GT’
o operator ‘>=’ Æ in Form-Base defined in a Primitive List as: ‘GE’
o operator ‘<’ Æ in Form-Base defined in a Primitive List as: ‘LT’
o operator ‘<=’ Æ in Form-Base defined in a Primitive List as: ‘LE’

NOTE: For a List of Primitives please look at the table in Appendix I at the end of the manual.
Lets now look at some real examples that combine all of the scripting methods that was discussed:

Example I: - Event 3005 Logic


In Approach or Final Approach - If the FLAPS(at the current time) is less than the FLAPS(one second ago) then
add 1 to the time over limit counter (l_value).
If Flaps retracted 2 seconds severity equals low.
If Flaps retracted 4 seconds severity equals medium.
If Flaps retracted 6 seconds or greater severity equals high.
Standard Parameter _FLAPS values are:
FLAPS0 = 0
FLAPS1 = 0
FLAPS1pF = 10
FLAPS2 = 15
FLAPS3 = 20
FLAPSF = 40

Event Logic:
– In Approach or Final Approach - If the FLAPS(at the current time) is less than the FLAPS(one second ago)
then add 1 to the time over limit counter (l_value).
New Event

Event Script Logic


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//Event - Flaps are retracted on Approach
//RFC 31 MAR 2006
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
l_severity = 4; // Return no severity (i.e. No event detected)

persist l_event_flag = 0;
persist l_value = 0;

if( CurrentTime() == 0)
{
l_event_flag = 0;
l_value = 0;
}
// Flight Modes
// Preflight - 0, Engine Start - 1, Take Out - 2, Take Off - 3, Inital Climb - 4,
// Climb - 5, Cruise - 6, Descent - 7, Approach - 8, Final Approach - 9, Go Around - 10,
// Landing - 11, Touch and Go - 12, Taxi In - 13, Engine Stop - 14, Unknown - 99

// Check in Flight modes Approach and Final Approach


if((_FLIGHT_PHASE(0) == 8) and (_FLIGHT_PHASE(-1) != 8))
{
l_value = 0;
}
if((_FLIGHT_PHASE(0) == 8) or (_FLIGHT_PHASE(0) == 9))
{
if( _FLAPS(0) < _FLAPS(-1))
{
l_value = l_value + 1; // count seconds retracted.
}
else
{
if(l_value > 0)
{
l_value = l_value - 1;
}
}
if( (l_value >= KEYVALUE("#K_3005_H")) and (l_event_flag < 3) )
{
l_severity = 3;
l_event_flag = 3;
}
if( (l_value == KEYVALUE("#K_3005_M")) and (l_event_flag < 2) )
{
l_severity = 2;
l_event_flag = 2;
}
if( (l_value == KEYVALUE("#K_3005_L")) and (l_event_flag == 0) )
{
l_severity = 1;
l_event_flag = 1;
}
}
// Reset for redetection
if( (_FLIGHT_PHASE(0) == 12) and (l_event_flag != 0))
// Touch and Go = 12
{
l_event_flag = 0;
}

return l_severity;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Annotations:

Once the event see run the FAP Generator and Build FAP.

You are ready to process data.


EXAMPLE II: Engine shutdown during taxi in EXAMPLE
Note: Backup your SQL Database first
Trigger condition: If N2 less than KeyValue (N2< 20%) for TOL (3 Seconds) and Ground speed > 3
Kts in Landing or Taxi In Engine is shutdown.

In the AirFASE FAP Editor – First select aircraft type. Then under menu item FAP Application select
Event Browser.

Fill in the information in the dialog box –General tab


In the Script Logic tab – cut and paste the following script (Ctrl –V to Paste)
//******************************************************************************
// Event# 3000: Engine shut down in taxi in
//
// Trigger cond: If N2 less than KeyValue in Landing or Taxi In Engine is shutdown
//
// Event Category: Information only - (RFC 03/01/2006)
//
// #K_3000_TOL Time over limit (3 second)
// #K_3000_N2 N2 Trigger (N2 less than 20 percent)
// #K_3000_GS Ground speed (3 Kts)
//******************************************************************************
l_severity%=4;
persist l_count1%=0;
persist l_count2%=0;
persist l_count3%=0;
persist l_count4%=0;
persist l_event_flag%=0;

l_n2_1 = _N2_1(0);
l_n2_2 = _N2_2(0);
// if only 2 engine aircraft
l_n2_3 = 100;
l_n2_4 = 100;
// uncomment if 4 engine aircraft
//l_n2_3 = _N2_3(0);
//l_n2_4 = _N2_4(0);

if(CurrentTime()==0)
{
l_count1% = 0;
l_count2% = 0;
l_count3% = 0;
l_count4% = 0;
l_event_flag% = 0;
}

// if(( _FLIGHT_PHASE(0) == 11) or (_FLIGHT_PHASE(0) == 13))


if(( _FLIGHT_PHASE(0) == 11) or (_FLIGHT_PHASE(0) == 13) or (_FLIGHT_PHASE(0) == 14))
{
l_time%= CurrentTime();

if((l_n2_1 < KEYVALUE("#K_3000_N2")) and (_GS(0) >= KEYVALUE("#K_3000_GS")))


{
l_count1% = l_count1% + 1;
}

if((l_n2_2 < KEYVALUE("#K_3000_N2")) and (_GS(0) >= KEYVALUE("#K_3000_GS")))


{
l_count2% = l_count2% + 1;
}

if((l_n2_3 < KEYVALUE("#K_3000_N2")) and (_GS(0) >= KEYVALUE("#K_3000_GS")))


{
l_count3% = l_count3% + 1;
}

if((l_n2_4 < KEYVALUE("#K_3000_N2")) and (_GS(0) >= KEYVALUE("#K_3000_GS")))


{
l_count4% = l_count4% + 1;
}
// Test for engine shut down
if((l_count1% == KEYVALUE("#K_3000_TOL")))
{
l_severity%= 0;
l_event_flag%= 3;
}
if((l_count2% == KEYVALUE("#K_3000_TOL")))
{
l_severity%= 0;
l_event_flag%= 3;
}
if((l_count3% == KEYVALUE("#K_3000_TOL")))
{
l_severity%= 0;
l_event_flag%= 3;
}
if((l_count4% == KEYVALUE("#K_3000_TOL")))
{
l_severity%= 0;
l_event_flag%= 3;
}
}

return l_severity%;
//****************************************************************************************************************
Set return type
Fill in the Annotations tab as follows

Next we need to create three Key Values

#K_3000_TOL Time over limit (3 Seconds)


#K_3000_N2 Trigger for N2 (20 Percent)
#K_3000_GS Ground Speed (3 Kts)

Then under menu item FAP Application select Key Value Browser.
Now go back to the Event Browser and Edit Event 3000 (right mouse click)

Test script syntax


Then under menu item FAP Application select FAP Configuration Build –
Generate FAP Code and Then Build FAP

You are ready to process new flight data.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Appendix I
Script Primitives
OVERVIEW
This table describes the Derived Parameter Primitives or Functions that are implemented in
AirFASE System and available to a user to develop Flight Analysis Program (FAP) through FAPScript
or Form-Base Editor. Primitives are intended to be used by the logics to compute derived parameter
values, create logic to detect events, define flight detection and time block detection logics.

A Parameter with Parameter Type= FAPDERI are called FAPDerivedParameter.


By default ParameterSampleValue is calculated per second (subframe) for all samples of Source
Parameter, however a parameter Rate can be defined by a use in FAPDeveloper Tool.

SourceParameter is the parameter from where sample value is derived.


TargetParameter is the parameter itself.
StandardParameter is the parameter known by FAPEngine and FlightAnimation.

Function prototype means signature of a function with a given return type and signature of argument list
including number of arguments and their data types.

FAPSCRIPT PRIMITIVES VS. FAPENGINE PRIMITIVES


Some primitive functions in FAPScript has different function prototypes than their implementation in FAPEngine.
These differences are mainly to simplify usage for FAP Development.

¾ Primitives Table used in AirFASE FAP’s


Argument List
ID Name FAP Script Description
FAP Engine
/Form-Base/
Any
Add to Parameter(int,real) to
0 ADD /CParam(Age), Any
Parameter (int, real)
CParam(Age)/
Any
Divide Parameter(int,real) by
1 DIVIDE /CParam(Age), Any
Parameter(int,real)
CParam(Age)/
Any
Multiply Parameter(int,real) by
2 MULTIPLY /CParam(Age), Any
Parameter(int,real)
CParam(Age)/
Any
Subtract Parameter(int,real) by
3 SUBTRACT /CParam(Age), Any
Parameter(int,real)
CParam(Age)/
Any
Modulo Parameter(int,real) by
4 MODULO /CParam(Age), Any
Parameter(int,real)
CParam(Age)/
Any Assign Parameter(int,real) to
5 ASSIGN Any
/CParam(Age)/ Parameter(int,real)
Any
6 LT Any Less Than Parameter(int,real)
/CParam(Age)/
Any
7 GT Any Greater Than Parameter(int,real)
/CParam(Age)/
Any Less Than or Equal to
8 LE Any
/CParam(Age)/ Parameter(int,real)
Any Greater Than or Equal to
9 GE Any
/CParam(Age)/ Parameter(int,real)
Any
10 EQ Any Equal to Parameter(int,real)
/CParam(Age)/
Gets the absolute maximum value (in
CParam(Age), &CParam1,
11 ABSMAXPARM the mathematical sense) of 2
CParam(Age) &CParam2
parameters.
Gets the absolute minimum value (in
CParam(Age), &CParam1,
12 ABSMINPARM the mathematical sense) of 2
CParam(Age) &CParam2
parameters.
13 ASCTONUM CParam(Age) &CParam Convert ASCII tintoa a Real Parameter
CParam, int, boolean, Get the average value of a Real
14 AVERAGE
CParam(Age) &CParam Parameter over a N-second period .
15 CONCAT CParam(Age) &CParam CONCAT Parameter value
The values of latitude and longitude
CParam(Age),
16 DBAIRP &CParam, &CParam are used to search into the
CParam(Age)
APT_AIRPORT Database table.
The function looks for the Flap Placard
17 DBFLAPPL CParam(Age) &CParam Speed corresponding Flap Settings.
The function looks for the Flap
CParam(Age),
18 DBFLAPST &CParam, &CParam setting corresponding to the Flap
CParam(Age)
postion and optionally the Slat po
The values of Magnetic Heading is
CParam(Age),
19 DBRUNW &CParam, &CParam used to search into the RWY_RUNWAY
CParam(Age)
Database table for the airport
20 DMTOYMD CParam(Age) &CParam Convert Date from format DDMM to YYMMDD
21 DMYTOYMD CParam(Age) &CParam Convert Date from format DDMMYY to YYMMDD
22 DTOYMD CParam(Age) &CParam Convert Date from format DD to YYMMDD
Looks in the Database for the IATA
23 ICAOIATA CParam(Age) &CParam airport name corresponding to the
ICAO given name.
CParam, int, boolean, Get the maximum value of a Real
24 MAX
CParam(Age) &CParam Parameter over a N-Second period
CParam(Age),
&Param1,
CParam(Age), Gets the maximum value of two-four
25 MAXPARM &Param2,
CParam(Age), parameters.
&Param3, &Param4
CParam(Age)
26 MDTOYMD CParam(Age) &Param Convert Date from format MMDD to YYMMDD
CParam, int, boolean, Get the minimum value of a Real
27 MIN
CParam(Age) &CParam Parameter over a N-second period.
CParam(Age),
&Param1,
CParam(Age), Gets the minimum value of two-four
28 MINPARM &Param2,
CParam(Age), parameters.
&Param3, &Param4
CParam(Age)
29 NUMTOASC CParam(Age) &CParam Convert number value ASCII string

30 RATE CParam int, boolean Get the rate of a parameter


Used by logics to signal a transition
31 SET_GATE CParam(Age) &CParam
between 2 Flight Phases
Get a key value from its identifier,
32 KEYVALUE strVal int lookup key value in the Database
Smooth the value of a parameter.The
CParam, iParamId, bAcq, smoothed value for the current time
33 SMOOTH
CParam(Age) &ParamCste is.Smoothed value = (v(0) + v(t-
1)).Constant should be != 0
CParam(Age),
&CParam, int, Detects whether and compute the
34 TIME_OVER_LIMIT CParam,
boolVal, boolean, duration while a parameter value is
refReal, boolean, &float, beyond a threshold.
refReal &float

To write a message into the trace file.


35 TRACE strVal Msg There is one trace file per Flight.
intVal,
36 GET_EVENT int, int To look for a specified event.
intVal
The functions looks for the V1 speed
CParam(Age),
37 DBV1 &CParam, &CParam corresponding to the Flap Setting and
CParam(Age)
the Weight passed as prm
The functions looks for the V2 speed
CParam(Age),
38 DBV2 &CParam, &CParam corresponding to the Flap Setting and
CParam(Age)
the Weight passed as para
The functions looks for the Vr speed
CParam(Age),
39 DBVR &CParam, &CParam corresponding to the Flap Setting and
CParam(Age)
the Weight passed as prm
The functions looks for the Vmin
CParam(Age),
40 DBVMIN &CParam, &CParam speed corresponding to the Flap
CParam(Age)
Setting and the Weight passed as prm
The functions looks for the Vstall
CParam(Age),
41 DBVSTALL &CParam, &CParam speed corresponding to the Flap
CParam(Age)
Setting and the Weight passed as
CParam, int, boolean, Get the absolute maximum value of a Real
42 ABSMAX Parameter over a N-second period
CParam(Age) &CParam
CParam, int, boolean, Get the absolute minimum value of a Real
43 ABSMIN Parameter over a N-second period .
CParam(Age) &CParam
CParam(Age),
&CParam, int,
CParam, Detects whether and compute the
boolean,
44 TIME_UNDER_LIMIT boolVal, duration while a parameter value is
boolean, &float,
refReal, under a threshold.
&float
refReal
CParam(Age),
45 DBVREF &CParam, &CParam The functions looks for the VREF speed
CParam(Age)
Compute the duration while a
46 DURATION CParam int, boolean (boolean) parameter value is true
(e.g all consecutive values are true)
Convert Date format DDMMYY value to
47 YMDTODATE CParam(Age) &CParam
YYMMDD value
48 ABS CParam(Age) &CParam Returns the absolute parameter value
Returns the arc cosine of a parameter
49 ACOS CParam(Age) &CParam
value
Returns in radians the arc sine of a
50 ASIN CParam(Age) &CParam
parameter value
Returns in radians the arc tangent of
51 ATAN CParam(Age) &CParam
a
Returns the cosine of a parameter
52 COS CParam(Age) &CParam
value
Returns the sine of an angle
53 SIN CParam(Age) &CParam
parameter
Returns the tangent of a specified
54 TAN CParam(Age) &CParam
angle parameter
Returns the hyperbolic cosine of a
55 COSH CParam(Age) &CParam
parameter value
Returns the hyperbolic sine of a
56 SINH CParam(Age) &CParam
parameter value
Returns the hyperbolic tangent of a
57 TANH CParam(Age) &CParam
parameter value
CParam(Age), Raises a parameter value to the
58 POW &CParam
CParam(Age) specified power
Returns the square root of a
59 SQRT CParam(Age) &CParam
parameter value
Calculates the absolute value of the
60 FABS CParam(Age) &CParam
floating-point of parameter value
61 LOG CParam(Age) &CParam Calculates logarithms of parameter value
Returns 'e' raised to the power
62 EXP CParam(Age) &CParam
parameter value
63 DeIDDate CParam(Age) (none) Deidentification of Date
64 DeIDFlt CParam(Age) (none) Deidentification of Leg Number
Deidentification of Aircraft
65 DeIDLeg CParam(Age) (none)
Registration
Deidentification of Aircraft
66 DeIDAC CParam(Age) (none)
Registration
CParam(Age), &ParValue,
67 FLTLEVEL Convert Alt Param into a Flight level
CParam(Age) &ParAltitude
Used by logics to signal the end of a
68 START_CRUISE_CUT (none) (none)
Cruise Cut
Used by logics to signal a transition
between 2 Flight Phases. The gate will
69 END_CRUISE_CUT (none) (none) contian the new Flight Phase, the
transition date and the snapshot values
of several parameters at this time
CParam, iParamId, bAcq, Cumulate a parameter value. Invalid
70 INTGRATE
CParam(Age) &ParamIntegCste values are ignored (not cumulated)
CParam(Age),
&ParIn,
CParam(Age),
71 FILTER_MIS_SIGN_BIT &ParamThreshld,f Filter Parameter
realVal,
WordRg, &ParOut
CParam(Age)
realVal, fThreshold,
72 FILTER_INVALID_PARAM CParam, iParamIdent, Filter Parameter
CParam(Age) bAcq, &ParamOut
fThreshold,
realVal,
fLSBPart,
73 FILTER_FINE_COARSE realVal, Filter Parameter
iParamIdent,
CParam
bAcq, &ParamOut
Used by logics to signal that a time gap
74 InsertTimeGap intVal (none) was detected. Cannot be called outside of
the Time Block Detection phase
Used by logics to signal that a flight
75 SetFlightStart (none) (none) start detected. Cannot be called outside
of the Flight Detection phase
Used by logics to signal that a flight
76 SetFlightEnd (none) (none) end was detected. Cannot be called
outside of the Flight Detection phase
77 IsValid refCParam Checks Parameter Validity.
78 IsParamValid refCParam Checks Parameter Validity.
79 SetFlags intVal not available Set Validity Flag for a Parameter
80 GetFlags (none) not available Get Validity Flag for a Parameter
81 GetParamFlags refCParam not available Get Validity Flag for a Parameter
Used by logics to get the current
82 CurrentTime (none) (none)
analysis time.
83 START_APPROACH (none) (none) Insert an Approach to the Approach list.
84 END_APPROACH (none) (none) Terminate an approach
85 GetPar CParam,realVal iParamID, bAcq Used by logics to get a CParam
Used by logics to get a CParam at a
CParam, iParamID, bAcq,
86 GetParBySample Sample Position (relative to the
intVal fTime
current one)
Get date with max field length of 8
87 GET_DATE (none) (none)
for schedule file (YYYYMMDD)
88 GET_FLIGHT_NUMBER (none) (none) Get flight number with max field
length of 5 for schedule file
Get leg number with max field length
89 GET_LEG_NUMBER (none) (none)
of 2 for schedule file
Get tail or registration number with max
90 GET_TAIL_NUMBER (none) (none) field length of 7 for schedule file
Get departure airport with max field
91 GET_DEPART_AIRPORT (none) (none)
length of 5 for schedule file
Get arrival airport with max field
92 GET_ARRIVAL_AIRPORT (none) (none)
length of 5 for schedule file
Get scheduled block out time with max
93 GET_SCH_BLCK_OUT_TIME (none) (none)
field length of 4
Get scheduled actual block out time
94 GET_ACT_BLCK_OUT_TIME (none) (none)
with max field length of 4
Get actual takeoff time with max
95 GET_ACT_TAKEOFF_TIME (none) (none)
field length of 4
Get actual landing time with max
96 GET_ACT_LANDING_TIME (none) (none)
field length of 4
Get actual block in time with max
97 GET_ACT_BLOCK_IN_TIME (none) (none)
field length of 4
Get scheduled block in time with max
98 GET_SCH_BLOCK_IN_TIME (none) (none)
field length of 4
Get actual takeoff gross weight with
99 GET_ACT_TKO_GROSS_WT (none) (none)
max field length of 5 (lbs or kg)
Get actual landing gross weight with
100 GET_ACT_LAND_WT (none) (none)
max field length of 5 (lbs or kg)
Get fuel weight at departure with max
101 GET_DEPART_FUEL_WT (none) (none)
field length of 4 (lbs or kg)
Get fuel weight at arrival with max
102 GET_ARRIVAL_FUEL_WT (none) (none)
field length of 4 (lbs or kg)
Get additional field for a schedule
103 GET_CODE_SCHED (none) (none)
file with arbitrary length(e.g Crew Code)
iParamIdSource,b
AcqSource,
Smooth the value of a parameter that
SMOOTH iParamIdTarget,
MUST BE a Real DATATYPE.
bAcqTarget,
fConstant, iTime
IParamIdTarget,bA
cqTarget,
INTGRATE iParamIdSource,
bAcqSource,
fConstant
AGW (none) To find an aircraft’s actual gross weight
IParamIdTarget,
ALTARW bAcqTarget, To find altitude above run way
fConstant
iParamId1,
bAcq1,iParamId2,
MACH bAcq2, To calculate a MACH
iParamIdTarget,
bAcqTarget
iParamId1, bAcq1, iParamId2, bAcq2, iParamIdTarget,
PALTSYNC
bAcqTarget
&Param, fConstant0, fConstant1, fConstant2,
POLYNOM
fConstant3, iParamIdTarget, bAcqTarget
iParamId1, bAcq1,iParamId2, bAcq2, iParamIdTarget,
RHMSBCOR
bAcqTarget
RWALT IParamIdSource, bAcqSource, iParamIdTarget, bAcqTarget
iParamId1, bAcq1,iParamId2, bAcq2, iParamIdTarget,
TAT bAcqTarget
CREATDAT &ParamDay, &ParamMonth, &ParamYear
<~~~~~~~~~~~~~~~~~~~~~~~End of Manual ~~~~~~~~~~~~~~~~~~~~~>

You might also like