]> git.mxchange.org Git - flightgear.git/blob - src/Instrumentation/KLN89/kln89_page_cal.cxx
Add missing include files needed by the new math code under windows
[flightgear.git] / src / Instrumentation / KLN89 / kln89_page_cal.cxx
1 // kln89_page_*.[ch]xx - this file is one of the "pages" that
2 //                       are used in the KLN89 GPS unit simulation. 
3 //
4 // Written by David Luff, started 2005.
5 //
6 // Copyright (C) 2005 - 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., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 // $Id$
23
24 #ifdef HAVE_CONFIG_H
25 #  include "config.h"
26 #endif
27
28 #include "kln89_page_cal.hxx"
29
30 KLN89CalPage::KLN89CalPage(KLN89* parent)
31 : KLN89Page(parent) {
32         _nSubPages = 8;
33         _subPage = 0;
34         _name = "CAL";
35         _nFp0 = 0;
36         _ground_speed_ms = 110 * 0.514444444444;
37 }
38
39 KLN89CalPage::~KLN89CalPage() {
40 }
41
42 void KLN89CalPage::Update(double dt) {
43         if(_subPage == 0) {
44                 if(1) { // TODO - fix this hardwiring!
45                         // Flightplan calc
46                         _kln89->DrawText(">Fpl:", 2, 0, 3);
47                         _kln89->DrawText("0", 2, 6, 3);// TODO - fix this hardwiring!
48                         GPSFlightPlan* fp = _kln89->_flightPlans[_nFp0];
49                         if(fp) {
50                                 unsigned int n = fp->waypoints.size();
51                                 if(n < 2) {
52                                         // TODO - check that this is what really happens
53                                         _kln89->DrawText("----", 2, 9, 3);
54                                         _kln89->DrawText("----", 2, 9, 2);
55                                 } else {
56                                         _kln89->DrawText(fp->waypoints[0]->id, 2, 9, 3);
57                                         _kln89->DrawText(fp->waypoints[n-1]->id, 2, 9, 2);
58                                         double cum_tot_m = 0.0;
59                                         for(unsigned int i = 1; i < fp->waypoints.size(); ++i) {
60                                                 cum_tot_m += _kln89->GetGreatCircleDistance(fp->waypoints[i-1]->lat, fp->waypoints[i-1]->lon,
61                                                                                     fp->waypoints[i]->lat, fp->waypoints[i]->lon);
62                                         }
63                                         double ete = (cum_tot_m * SG_NM_TO_METER) / _ground_speed_ms;
64                                         _kln89->DrawDist(cum_tot_m, 2, 5, 1);
65                                         _kln89->DrawSpeed(_ground_speed_ms / 0.5144444444, 2, 5, 0);
66                                         _kln89->DrawTime(ete, 2, 14, 0);
67                                 }
68                         } else {
69                                 _kln89->DrawText("----", 2, 9, 3);
70                                 _kln89->DrawText("----", 2, 9, 2);
71                         }
72                 } else {
73                         _kln89->DrawText(">Wpt:", 2, 0, 3);
74                 }
75                 _kln89->DrawText("To", 2, 6, 2);
76                 _kln89->DrawText("ESA ----'", 2, 7, 1); // TODO - implement an ESA calc
77                 _kln89->DrawText("ETE", 2, 7, 0);
78         } else if(_subPage == 1) {
79                 _kln89->DrawText(">Fpl: 0", 2, 0, 3);   // TODO - fix this hardwiring!
80                 _kln89->DrawText("FF:", 2, 0, 2);
81                 _kln89->DrawText("Res:", 2, 7, 1);
82                 _kln89->DrawText("Fuel Req", 2, 0, 0);
83         } else if(_subPage == 2) {
84                 _kln89->DrawText("Time:", 2, 0, 3);
85                 _kln89->DrawText("Alarm at:", 2, 0, 2);
86                 _kln89->DrawText("in:", 2, 6, 1);
87                 _kln89->DrawText("Elapsed", 2, 0, 0);
88         } else if(_subPage == 3) {
89                 _kln89->DrawText("PRESSURE ALT", 2, 1, 3);
90                 _kln89->DrawText("Ind:", 2, 0, 2);
91                 _kln89->DrawText("Baro:", 2, 0, 1);
92                 _kln89->DrawText("Prs", 2, 0, 0);
93         } else if(_subPage == 4) {
94                 _kln89->DrawText("DENSITY ALT", 2, 1, 3);
95                 _kln89->DrawText("Prs:", 2, 0, 2);
96                 _kln89->DrawText("Temp:", 2, 0, 1);
97                 _kln89->DrawText("Den", 2, 0, 0);
98         } else if(_subPage == 5) {
99                 _kln89->DrawText("CAS:", 2, 0, 3);
100                 _kln89->DrawText("Prs:", 2, 0, 2);
101                 _kln89->DrawText("Temp:", 2, 0, 1);
102                 _kln89->DrawText("TAS", 2, 0, 0);
103         } else if(_subPage == 6) {
104                 _kln89->DrawText("TAS:", 2, 0, 3);
105                 _kln89->DrawText("Hdg:", 2, 0, 2);
106                 _kln89->DrawText("Headwind:", 2, 0, 1);
107                 _kln89->DrawText("True", 2, 4, 0);
108         } else {
109                 _kln89->DrawText("SUNRISE", 2, 0, 1);
110                 _kln89->DrawText("SUNSET", 2, 0, 0);
111         }
112
113         KLN89Page::Update(dt);
114 }