]> git.mxchange.org Git - flightgear.git/blob - src/Cockpit/radiostack.cxx
Set the format default to float instead of int.
[flightgear.git] / src / Cockpit / radiostack.cxx
1 // radiostack.cxx -- class to manage an instance of the radio stack
2 //
3 // Written by Curtis Olson, started April 2000.
4 //
5 // Copyright (C) 2000  Curtis L. Olson - curt@flightgear.org
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #ifdef HAVE_CONFIG_H
25 #  include <config.h>
26 #endif
27
28 #include <stdio.h>      // snprintf
29
30 #include <simgear/compiler.h>
31 #include <simgear/math/sg_random.h>
32
33 #include <Aircraft/aircraft.hxx>
34 #include <Navaids/navlist.hxx>
35
36 #include "radiostack.hxx"
37
38 #include <string>
39 SG_USING_STD(string);
40
41
42 FGRadioStack *current_radiostack;
43
44
45 // Constructor
46 FGRadioStack::FGRadioStack() {
47 }
48
49
50 // Destructor
51 FGRadioStack::~FGRadioStack() 
52 {
53     //adf.unbind();
54     beacon.unbind();
55     navcom1.unbind();
56     navcom2.unbind();
57     xponder.unbind();
58 }
59
60
61 void
62 FGRadioStack::init ()
63 {
64     navcom1.set_bind_index( 0 );
65     navcom1.init();
66
67     navcom2.set_bind_index( 1 );
68     navcom2.init();
69
70     //adf.init();
71     beacon.init();
72     xponder.init();
73
74     search();
75     update(0);                  // FIXME: use dt
76
77     // Search radio database once per second
78     globals->get_event_mgr()->addTask( "fgRadioSearch()", current_radiostack,
79                                        &FGRadioStack::search, 1 );
80 }
81
82
83 void
84 FGRadioStack::bind ()
85 {
86     //adf.bind();
87     beacon.bind();
88     dme.bind();
89     navcom1.set_bind_index( 0 );
90     navcom1.bind();
91     navcom2.set_bind_index( 1 );
92     navcom2.bind();
93     xponder.bind();
94 }
95
96
97 void
98 FGRadioStack::unbind ()
99 {
100     //adf.unbind();
101     beacon.unbind();
102     dme.unbind();
103     navcom1.unbind();
104     navcom2.unbind();
105     xponder.unbind();
106 }
107
108
109 // Update the various nav values based on position and valid tuned in navs
110 void 
111 FGRadioStack::update(double dt) 
112 {
113     //adf.update( dt );
114     beacon.update( dt );
115     navcom1.update( dt );
116     navcom2.update( dt );
117     dme.update( dt );           // dme is updated after the navcom's
118     xponder.update( dt );
119 }
120
121
122 // Update current nav/adf radio stations based on current postition
123 void FGRadioStack::search() 
124 {
125     //adf.search();
126     beacon.search();
127     navcom1.search();
128     navcom2.search();
129     dme.search();
130     xponder.search();
131 }