Hier mal ein Áuszug aus dem Script:
PHP-Code:
//---------------------------------------------------------------------------
// MODULE: Navigation.ABL
//
// Version: 1.0
// Author: Michael Garbers
//
// Beschreibung:
//
// Dies ist das ABL Script zu einer Navigationsaufgabe in der Schweiz.
//
//---------------------------------------------------------------------------
module sample;
//#debug_on
//#print_on
const
#include "script\lib\STDKonstants.abl";
#include "messages\lib\tolerances.msg";
CheckPointCount = 9;
SPTimeEstimated = 100; // Sec from start until pass SP (always the same)
Speed70 = 0;
Speed75 = 1;
Speed80 = 2;
Speed85 = 3;
Speed90 = 4;
Speed95 = 5;
Speed100 = 6;
var
static number choosenSpeed;
static number [CheckPointCount] aLat;
static number [CheckPointCount] aLng;
static number [CheckPointCount] aLat2;
static number [CheckPointCount] aLng2;
static number [CheckPointCount] aHeading;
static number [7,CheckPointCount] aTimes;
static number [CheckPointCount] dtTimeRecord;
//Current Checkpoint to fly to
static number nCurrentCheckpoint;
static number dtStartZeit;
static number nCountTooLow;
static number nCountHeadingError;
// temp vars
static number nEntfernung;
static number nRichtung;
string strTemp; //Temp-String for Printing Messages
static number bTooLow;
static number bBackcourse;
#include "script\lib\STDVars.abl";
#include "script\lib\StringFns.abl";
#include "script\lib\Math.abl";
#include "script\lib\Messages.abl";
#include "script\lib\Throttle.abl";
#include "script\lib\SimQueue.abl";
#include "script\lib\STDChkTolerances.abl";
#include "script\lib\fnUserEvents.abl";
//---------------------------------------------------------------------------
// FUNCTION : init - One-time per-script init.
//
// SYNOPSIS : initializes variables
//---------------------------------------------------------------------------
function init;
var
code
#include "script\lib\STDInit";
fnNormalMsg("So, gleich geht es los. Nach dem Start müssen Sie genau nach 100 Sekunden den SP überquert haben.");
//Set the target speed;
choosenSpeed = aton(fltThisFlight.getScriptState("Speed"));
AP.Master = FALSE;
nDoneFlag = 1; //set flag to indicate did not successfully complete lesson
bCrashCheck = FALSE;
nCountHeadingError = 0;
nCountTooLow = 0;
//SP
aLat[0] = 47.17216667;
aLng[0] = 7.42116667;
aLat2[0] = 47.17186667;
aLng2[0] = 7.42136667;
:
:
:
:
// Setze maximale Strafpunktzahl bevor es max gibt
dtTimeRecord[0] = 100;
dtTimeRecord[1] = aTimes[choosenSpeed,1] + 152;
dtTimeRecord[2] = aTimes[choosenSpeed,2] + 152;
dtTimeRecord[3] = aTimes[choosenSpeed,3] + 152;
dtTimeRecord[4] = aTimes[choosenSpeed,4] + 152;
dtTimeRecord[5] = aTimes[choosenSpeed,5] + 152;
dtTimeRecord[6] = aTimes[choosenSpeed,6] + 152;
dtTimeRecord[7] = aTimes[choosenSpeed,7] + 152;
dtTimeRecord[8] = aTimes[choosenSpeed,8] + 152;
Writeln ("Finished with Init");
endfunction;
function checkGround(): NUMBER;
var
number nRet;
code
nRet = 0;
if (nAltAGL < 500) then
if (bTooLow == FALSE) then
nCountTooLow = nCountTooLow + 1;
nRet = 1;
endif;
bTooLow = TRUE;
else
bTooLow = FALSE;
endif;
return(nRet);
endfunction;
function checkHeadingSoll(number nHeadingSoll): NUMBER;
var
number nRet;
code
nRet = 0;
if ((diff360(nYaw,nHeadingSoll)) > 90) then
if (bBackcourse == FALSE) then
nCountHeadingError = nCountHeadingError + 1;
nRet = 1;
endif;
bBackcourse = TRUE;
else
bBackcourse = FALSE;
endif;
return(nRet);
endfunction;
:
:
:
//================================================================
code
#include "script\lib\STDHousekeeping.abl";
//strTemp = "Heading nach CP6: ";
//Concat (strTemp,ntoa(posHere.BearingTo(aLat[6], aLng[6])));
//print(strTemp);
//strTemp = "Entfernung nach CP6: ";
//Concat (strTemp,ntoa(posHere.DistanceTo(aLat[6], aLng[6])));
//print(strTemp);
switch (nState)
#include "script\lib\STDCases.abl";
case CaseTalk1:
fnSQ_NormalMsg("Jetzt aber! Wir haben Startfreigabe.",0);
fnSQ_ChangeState(100);
fnSQ_Synchronize;
endcase;
case 100: //Abflug, Abhebezeit
if (bWOW == FALSE) then
nCountTooLow = 0;
nCountHeadingError = 0;
dtStartZeit = nElapsedTime; // Merke Startzeit
nEntfernung = 0.464; //Setze Messradius
bCrashCheck = TRUE; //Turn Crash Check on
nCurrentCheckpoint = 0;
fnSQ_NormalMsg("Ab jetzt zählts, drück auf die Stoppuhr!",0);
fnSQ_ChangeState(110);
fnSQ_Synchronize;
endif;
endcase;
case 110: //Test bis SP
if (navTest(nCurrentCheckpoint) == 1) then
strTemp = "Wir haben den ";
if (nCurrentCheckpoint == 0) then
Concat (strTemp,"SP");
else
Concat (strTemp,"CP");
Concat (strTemp,ntoa(nCurrentCheckpoint));
endif;
Concat (strTemp," erreicht, ich habe ");
Concat (strTemp,ntoa(round(dtTimeRecord[nCurrentCheckpoint])));
Concat (strTemp," Sekunden gemessen.");
fnSQ_NormalMsg(strTemp,5);
nCurrentCheckpoint = nCurrentCheckpoint + 1;
nEntfernung = 0.464; //Setze Messradius
if (CheckPointCount == nCurrentCheckpoint) then
fnSQ_ChangeState(500);
endif;
fnSQ_Synchronize;
endif;
endcase;
case 500: //End it all
bCrashCheck = FALSE; //Turn Crash Check off
strTemp = calculateReport;
fnSQ_NormalMsg(strTemp,30);
fnSQ_ChangeState(510);
fnSQ_Synchronize;
endcase;
endswitch;
fnMsgDisplay;
endmodule.