]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AITanker.cxx
clear two gcc warnings
[flightgear.git] / src / AIModel / AITanker.cxx
1 // AITanker.cxx  Based on David Culp's AIModel code
2 // - Tanker specific code isolated from AI Aircraft code
3 // by Thomas Foerster, started June 2007
4 //
5 // 
6 // Original code written by David Culp, started October 2003.
7 // - davidculp2@comcast.net/
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 #ifdef HAVE_CONFIG_H
23 #  include <config.h>
24 #endif
25
26 #include "AITanker.hxx"
27
28 FGAITanker::FGAITanker(FGAISchedule* ref): FGAIAircraft(ref){
29 }
30
31 FGAITanker::~FGAITanker() {}
32
33 void FGAITanker::readFromScenario(SGPropertyNode* scFileNode) {
34     if (!scFileNode)
35         return;
36
37     FGAIAircraft::readFromScenario(scFileNode);
38     setTACANChannelID(scFileNode->getStringValue("TACAN-channel-ID",""));
39     setName(scFileNode->getStringValue("name", "Tanker"));
40
41 }
42
43 void FGAITanker::bind() {
44     FGAIAircraft::bind();
45
46     props->tie("refuel/contact", SGRawValuePointer<bool>(&contact));
47     props->tie("position/altitude-agl-ft",SGRawValuePointer<double>(&altitude_agl_ft));
48     props->setStringValue("navaids/tacan/channel-ID", TACAN_channel_id.c_str());
49     props->setStringValue("name", _name.c_str());
50     props->setBoolValue("tanker", true);
51 }
52
53 void FGAITanker::unbind() {
54     FGAIAircraft::unbind();
55     props->untie("refuel/contact");
56     props->untie("position/altitude-agl-ft");
57
58 }
59
60 void FGAITanker::setTACANChannelID(const string& id) {
61     TACAN_channel_id = id;
62 }
63
64 void FGAITanker::Run(double dt) {
65     //FGAIAircraft::Run(dt);
66
67     double start = pos.getElevationFt() + 1000;
68     altitude_agl_ft = _getAltitudeAGL(pos, start);
69
70     //###########################//
71     // do calculations for radar //
72     //###########################//
73     double range_ft2 = UpdateRadar(manager);
74
75     // check if radar contact
76     if ( (range_ft2 < 250.0 * 250.0) && (y_shift > 0.0)
77               && (elevation > 0.0) ) {
78         //refuel_node->setBoolValue(true);
79         contact = true;
80     } else {
81         //refuel_node->setBoolValue(false);
82         contact = false;
83     }
84 }
85
86
87 void FGAITanker::update(double dt) {
88      FGAIAircraft::update(dt);
89      Run(dt);
90      Transform();
91 }