2 Encode an ATIS into spoken words
3 Copyright (C) 2014 Torsten Dreyer
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #ifndef __ATIS_ENCODER_HXX
21 #define __ATIS_ENCODER_HXX
24 #include <Airports/airport.hxx>
25 #include <simgear/props/props.hxx>
30 static const char * getSpokenDigit( int i );
31 static std::string getSpokenNumber( std::string number );
32 static std::string getSpokenNumber( int number, bool leadingZero = false, int digits = 1 );
33 static std::string getSpokenAltitude( int altitude );
36 class ATISInformationProvider {
38 virtual ~ATISInformationProvider() {}
39 virtual bool isValid() = 0;
40 virtual std::string airportId() = 0;
42 static long makeAtisTime( int day, int hour, int minute ) {
43 return 100*100l* day + 100l * hour + minute;
45 inline int getAtisTimeDay( long atisTime ) { return atisTime / (100l*100l); }
46 inline int getAtisTimeHour( long atisTime ) { return (atisTime % (100l*100l)) / 100l; }
47 inline int getAtisTimeMinute( long atisTime ) { return atisTime % 100l; }
48 virtual long getTime() = 0; // see makeAtisTime
50 virtual int getWindDeg() = 0;
51 virtual int getWindMinDeg() = 0;
52 virtual int getWindMaxDeg() = 0;
53 virtual int getWindSpeedKt() = 0;
54 virtual int getGustsKt() = 0;
55 virtual int getQnh() = 0;
56 virtual bool isCavok() = 0;
57 virtual int getVisibilityMeters() = 0;
58 virtual std::string getPhenomena() = 0;
60 typedef std::map<int,std::string> CloudEntries;
61 virtual CloudEntries getClouds() = 0;
62 virtual int getTemperatureDeg() = 0;
63 virtual int getDewpointDeg() = 0;
64 virtual std::string getTrend() = 0;
67 class ATISEncoder : public ATCSpeech {
70 virtual ~ATISEncoder();
71 virtual std::string encodeATIS( ATISInformationProvider * atisInformationProvider );
74 virtual std::string getAtisId( SGPropertyNode_ptr );
75 virtual std::string getAirportName( SGPropertyNode_ptr );
76 virtual std::string getTime( SGPropertyNode_ptr );
77 virtual std::string getApproachType( SGPropertyNode_ptr );
78 virtual std::string getLandingRunway( SGPropertyNode_ptr );
79 virtual std::string getTakeoffRunway( SGPropertyNode_ptr );
80 virtual std::string getTransitionLevel( SGPropertyNode_ptr );
81 virtual std::string getWindDirection( SGPropertyNode_ptr );
82 virtual std::string getWindMinDirection( SGPropertyNode_ptr );
83 virtual std::string getWindMaxDirection( SGPropertyNode_ptr );
84 virtual std::string getWindspeedKnots( SGPropertyNode_ptr );
85 virtual std::string getGustsKnots( SGPropertyNode_ptr );
86 virtual std::string getCavok( SGPropertyNode_ptr );
87 virtual std::string getVisibilityMetric( SGPropertyNode_ptr );
88 virtual std::string getPhenomena( SGPropertyNode_ptr );
89 virtual std::string getClouds( SGPropertyNode_ptr );
90 virtual std::string getTemperatureDeg( SGPropertyNode_ptr );
91 virtual std::string getDewpointDeg( SGPropertyNode_ptr );
92 virtual std::string getQnh( SGPropertyNode_ptr );
93 virtual std::string getInhg( SGPropertyNode_ptr );
94 virtual std::string getTrend( SGPropertyNode_ptr );
96 typedef std::string (ATISEncoder::*handler_t)( SGPropertyNode_ptr baseNode );
97 typedef std::map<std::string, handler_t > HandlerMap;
98 HandlerMap handlerMap;
100 SGPropertyNode_ptr atisSchemaNode;
102 std::string processTokens( SGPropertyNode_ptr baseNode );
103 std::string processToken( SGPropertyNode_ptr baseNode );
105 std::string processTextToken( SGPropertyNode_ptr baseNode );
106 std::string processTokenToken( SGPropertyNode_ptr baseNode );
107 std::string processIfToken( SGPropertyNode_ptr baseNode );
108 bool checkEmptyCondition( SGPropertyNode_ptr node, bool isEmpty );
109 bool checkEqualsCondition( SGPropertyNode_ptr node, bool isEmpty );
111 FGAirportRef airport;
112 ATISInformationProvider * _atis;