aboutsummaryrefslogtreecommitdiff
path: root/Source/PltParser.c
diff options
context:
space:
mode:
authorXaviDCR92 <xavi.dcr@gmail.com>2017-06-06 07:13:16 +0200
committerXaviDCR92 <xavi.dcr@gmail.com>2017-06-06 07:13:16 +0200
commitfaf31975556ceb5be674eb89b0ec5b2d2836e42a (patch)
treed904b589e2e967fae4ec29456c51300b58cad49d /Source/PltParser.c
parent1244505327009142c80140e44c86138f4fd6ae07 (diff)
downloadairport-faf31975556ceb5be674eb89b0ec5b2d2836e42a.tar.gz
* Some more work on Plt file generator.
Diffstat (limited to 'Source/PltParser.c')
-rw-r--r--Source/PltParser.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/Source/PltParser.c b/Source/PltParser.c
index 61f066d..41e2da0 100644
--- a/Source/PltParser.c
+++ b/Source/PltParser.c
@@ -297,9 +297,10 @@ uint8_t* PltParserGenerateFile(TYPE_PLT_CONFIG* ptrPltConfig)
uint8_t maxAircraftTime;
uint8_t nAircraft;
uint8_t i;
+ uint8_t j;
TYPE_HOUR InitialHour;
TYPE_MINUTE InitialMinutes;
- char auxBuffer[32] = {0};
+ char auxBuffer[32] = {'\0'};
switch(ptrPltConfig->Level)
{
@@ -320,6 +321,10 @@ uint8_t* PltParserGenerateFile(TYPE_PLT_CONFIG* ptrPltConfig)
maxAircraftTime = MIN_AIRCRAFT_TIMELAPSE_MAX_SECONDS_HARD;
nAircraft = SystemRand(MIN_AIRCRAFT_HARD, MAX_AIRCRAFT_HARD);
break;
+
+ default:
+ dprintf("PltParserGenerateFile(): Undefined level!\n");
+ return NULL;
}
SystemClearBuffer();
@@ -332,5 +337,36 @@ uint8_t* PltParserGenerateFile(TYPE_PLT_CONFIG* ptrPltConfig)
snprintf(auxBuffer, 32, "%d:%d\n", InitialHour, InitialMinutes);
+ for(i = 0; auxBuffer[i] != '\0'; i++)
+ {
+ // Transfer contents generated from snprintf to main buffer.
+ PltBuffer[i] = auxBuffer[i];
+ }
+
+ dprintf("%s\n", PltBuffer);
+ DEBUG_PRINT_VAR(ptrPltConfig->Level);
+ DEBUG_PRINT_VAR(nAircraft);
+ DEBUG_PRINT_VAR(minAircraftTime);
+ DEBUG_PRINT_VAR(maxAircraftTime);
+
+ for(j = 0; j < nAircraft; j++)
+ {
+ uint8_t dep_arr_rand = SystemRand(0,100);
+
+ if(dep_arr_rand < 50)
+ {
+ // Set departure flight
+
+ memcpy(&PltBuffer[i], "DEPARTURE", sizeof("DEPARTURE") * sizeof(uint8_t) );
+ i += strlen("DEPARTURE");
+ }
+ else
+ {
+ // Set arrival flight
+ memcpy(&PltBuffer[i], "ARRIVAL", sizeof("ARRIVAL") * sizeof(uint8_t) );
+ i += strlen("ARRIVAL");
+ }
+ }
+
return PltBuffer;
}