]> git.mxchange.org Git - flightgear.git/blob - src/ATCDCL/atis.hxx
Fix ATIS /environment/attention handling
[flightgear.git] / src / ATCDCL / atis.hxx
1 // atis.hxx -- ATIS class
2 //
3 // Written by David Luff, started October 2001.
4 // Based on nav.hxx by Curtis Olson, started April 2000.
5 //
6 // Copyright (C) 2001  David C. Luff - david.luff@nottingham.ac.uk
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21
22
23 #ifndef _FG_ATIS_HXX
24 #define _FG_ATIS_HXX
25
26 #include <string>
27 #include <iosfwd>
28
29 #include <simgear/compiler.h>
30 #include <simgear/timing/sg_time.hxx>
31 #include <simgear/props/props.hxx>
32
33 #include "ATC.hxx"
34
35 typedef std::map<std::string,std::string> MSS;
36
37 class FGATIS : public FGATC {
38
39     std::string        _name;
40     int                _num;
41
42     SGPropertyNode_ptr _root;
43     SGPropertyNode_ptr _volume;
44     SGPropertyNode_ptr _serviceable;
45     SGPropertyNode_ptr _operable;
46     SGPropertyNode_ptr _electrical;
47     SGPropertyNode_ptr _freq;
48     SGPropertyNode_ptr _atis;
49
50     // Pointers to current users position
51     SGPropertyNode_ptr _lon_node;
52     SGPropertyNode_ptr _lat_node;
53     SGPropertyNode_ptr _elev_node;
54
55     SGPropertyChangeCallback<FGATIS> _cb_attention;
56
57     // The actual ATIS transmission
58     // This is generated from the prevailing conditions when required.
59     // This is the version with markup, suitable for voice synthesis:
60     std::string transmission;
61
62     // Same as above, but in a form more readable as text.
63     std::string transmission_readable;
64
65     // for failure modeling
66     std::string trans_ident; // transmitted ident
67     double old_volume;
68     bool atis_failed;        // atis failed?
69     time_t msg_time;         // for moderating error messages
70     time_t cur_time;
71     int msg_OK;
72     bool _attention;
73
74     bool _prev_display;      // Previous value of _display flag
75     MSS _remap;              // abbreviations to be expanded
76
77     // internal periodic station search timer
78     double _time_before_search_sec;
79     int _last_frequency;
80
81 public:
82
83     FGATIS(const std::string& name, int num);
84
85     virtual void init();
86     void attend(SGPropertyNode* node);
87
88     //run the ATIS instance
89     void update(double dt);
90
91     //inline void set_type(const atc_type tp) {type = tp;}
92     inline const std::string& get_trans_ident() { return trans_ident; }
93
94 protected:
95     virtual FGATCVoice* GetVoicePointer();
96
97 private:
98
99     // Generate the ATIS transmission text:
100     int GenTransmission(const int regen, const bool special);
101
102     // Put the text into the property tree
103     // (and in debug mode, print it on the console):
104     void TreeOut(int msgOK);
105
106     // Search the specified radio for stations on the same frequency and in range.
107     void search(void);
108
109     friend std::istream& operator>> ( std::istream&, FGATIS& );
110
111 };
112
113 typedef int (FGATIS::*int_getter)() const;
114
115 #endif // _FG_ATIS_HXX