4 # print "Parsing time @_\n";
7 @timeArray = split(":", $timeStr);
8 # print STDERR "TimeArray: @timeArray\n";
9 return ($timeArray[0] + $timeArray[1]/60.0);
13 print XMLFILE " <flight>\n";
14 print XMLFILE " <callsign>$_[0]</callsign>\n";
15 print XMLFILE " <required-aircraft>$_[1]</required-aircraft>\n";
16 print XMLFILE " <fltrules>$_[2]</fltrules>\n";
17 print XMLFILE " <departure>\n";
18 print XMLFILE " <port>$_[3]</port>\n";
19 if ($_[4] =~ /[0-6]/) { print XMLFILE " <time>$_[4]/$_[5]:00</time>\n" }
20 else { print XMLFILE " <time>$_[5]:00</time>\n" };
21 print XMLFILE " </departure>\n";
22 print XMLFILE " <cruise-alt>$_[6]</cruise-alt>\n";
23 print XMLFILE " <arrival>\n";
24 print XMLFILE " <port>$_[7]</port>\n";
25 if ($_[8] =~ /[0-6]/) { print XMLFILE " <time>$_[8]/$_[9]:00</time>\n" }
26 else { print XMLFILE " <time>$_[9]:00</time>\n" };
27 print XMLFILE " </arrival>\n";
28 if (($_[4] =~ /[0-6]/) && ($_[8] =~ /[0-6]/)) { print XMLFILE " <repeat>WEEK</repeat>\n" }
29 else { print XMLFILE " <repeat>24Hr</repeat>\n" };
30 print XMLFILE " </flight>\n";
34 @inputfiles = glob("???.conf");
35 while ($infile = shift(@inputfiles)) {
36 open (CONF, $infile) or die "Unable to open input configuration file";
37 ($outname = $infile) =~ s/conf/xml/;
38 print "Opening $outname\n";
39 open XMLFILE, ">$outname";
40 while ($buf = readline(CONF)) {
44 print XMLFILE "<?xml version=\"1.0\"?>\n";
45 print XMLFILE "<trafficlist>\n";
46 while ($dataline = shift(@DataList)) {
47 # print STDERR "Dataline: $dataline\n";
48 @token = split(" ", $dataline);
49 if (scalar(@token) > 0) {
50 # print STDERR "Token: @token\n";
51 if ($token[0] eq "AC")
53 print XMLFILE " <aircraft>\n";
54 print XMLFILE " <model>$token[12]</model>\n";
55 print XMLFILE " <livery>$token[6]</livery>\n";
56 print XMLFILE " <airline>$token[5]</airline>\n";
57 print XMLFILE " <home-port>$token[1]</home-port>\n";
58 print XMLFILE " <required-aircraft>$token[3]$token[5]</required-aircraft>\n";
59 print XMLFILE " <actype>$token[4]</actype>\n";
60 print XMLFILE " <offset>$token[7]</offset>\n";
61 print XMLFILE " <radius>$token[8]</radius>\n";
62 print XMLFILE " <flighttype>$token[9]</flighttype>\n";
63 print XMLFILE " <performance-class>$token[10]</performance-class>\n";
64 print XMLFILE " <registration>$token[2]</registration>\n";
65 print XMLFILE " <heavy>$token[11]</heavy>\n";
66 print XMLFILE " </aircraft>\n";
68 if ($token[0] eq "FLIGHT") {
69 $weekdays = $token[3];
70 if (!(($weekdays =~ /^(0|\.)?(1|\.)?(2|\.)?(3|\.)?(4|\.)?(5|\.)?(6|\.)?$/) || ($weekdays eq "DAILY"))) {
71 die "Syntax Error! Check days $weekdays for flight no. $token[1]!\n";
73 if ($token[4] !~ /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])$/) {
74 die "Syntax Error! Check departure time $token[4] for flight no. $token[1]!\n"
76 if ($token[6] !~ /^(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])$/) {
77 die "Syntax Error! Check arrival time $token[6] for flight no. $token[1]!\n"
79 # print STDERR "Weekdays: $weekdays\n";
80 if ($weekdays =~ /^(0|\.)?(1|\.)?(2|\.)?(3|\.)?(4|\.)?(5|\.)?(6|\.)?$/) {
81 # print STDERR "Weekly for flight no. $token[1]\n";
82 # print STDERR "Day: $_\n";
83 @day = split(//, $weekdays);
88 $depTime = parseTime($token[4]);
89 # print STDERR "depTime: $depTime\n";
90 $arrTime = parseTime($token[6]);
91 # print STDERR "arrTime: $arrTime\n";
93 if ($depDay > 6) { $depDay = 0 };
95 if ($depTime > $arrTime) { $arrDay++ };
96 if ($arrDay > 6) { $arrDay = 0 };
97 # print STDERR "depDay: $depDay, arrDay: $arrDay\n";
98 writeFlight ($token[1], $token[9], $token[2], $token[5], $depDay, $token[4], $token[8], $token[7], $arrDay, $token[6]);
102 elsif ($weekdays eq "DAILY") {
103 # print STDERR "Daily flights for flight no. $token[1]\n";
104 $depTime = parseTime($token[4]);
105 $arrTime = parseTime($token[6]);
106 writeFlight ($token[1], $token[9], $token[2], $token[5], 7, $token[4], $token[8], $token[7], 7, $token[6]);
109 die "System Error! Can't find days to place a flight!\n";
114 print XMLFILE "</trafficlist>\n";
116 # print "Closing $outname\n";