1 // AITanker.cxx Based on David Culp's AIModel code
\r
2 // - Tanker specific code isolated from AI Aircraft code
\r
3 // by Thomas Foerster, started June 2007
\r
6 // Original code written by David Culp, started October 2003.
\r
7 // - davidculp2@comcast.net/
\r
8 // This program is free software; you can redistribute it and/or
\r
9 // modify it under the terms of the GNU General Public License as
\r
10 // published by the Free Software Foundation; either version 2 of the
\r
11 // License, or (at your option) any later version.
\r
13 // This program is distributed in the hope that it will be useful, but
\r
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
16 // General Public License for more details.
\r
18 // You should have received a copy of the GNU General Public License
\r
19 // along with this program; if not, write to the Free Software
\r
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
22 #ifdef HAVE_CONFIG_H
\r
23 # include <config.h>
\r
26 #include "AITanker.hxx"
\r
28 FGAITanker::FGAITanker(FGAISchedule* ref): FGAIAircraft(ref){
\r
31 FGAITanker::~FGAITanker() {}
\r
33 void FGAITanker::readFromScenario(SGPropertyNode* scFileNode) {
\r
37 FGAIAircraft::readFromScenario(scFileNode);
\r
38 setTACANChannelID(scFileNode->getStringValue("TACAN-channel-ID",""));
\r
39 setName(scFileNode->getStringValue("name", "Tanker"));
43 void FGAITanker::bind() {
\r
44 FGAIAircraft::bind();
\r
46 props->tie("refuel/contact", SGRawValuePointer<bool>(&contact));
\r
47 props->tie("position/altitude-agl-ft",SGRawValuePointer<double>(&altitude_agl_ft));
\r
48 props->setStringValue("navaids/tacan/channel-ID", TACAN_channel_id.c_str());
\r
49 props->setStringValue("name", _name.c_str());
\r
50 props->setBoolValue("tanker", true);
\r
53 void FGAITanker::unbind() {
\r
54 FGAIAircraft::unbind();
\r
55 props->untie("refuel/contact");
\r
56 props->untie("position/altitude-agl-ft");
\r
60 void FGAITanker::setTACANChannelID(const string& id) {
\r
61 TACAN_channel_id = id;
\r
64 void FGAITanker::Run(double dt) {
\r
65 //FGAIAircraft::Run(dt);
\r
67 double start = pos.getElevationFt() + 1000;
\r
68 altitude_agl_ft = _getAltitudeAGL(pos, start);
\r
70 //###########################//
\r
71 // do calculations for radar //
\r
72 //###########################//
\r
73 double range_ft2 = UpdateRadar(manager);
\r
75 // check if radar contact
\r
76 if ( (range_ft2 < 250.0 * 250.0) && (y_shift > 0.0)
\r
77 && (elevation > 0.0) ) {
\r
78 //refuel_node->setBoolValue(true);
\r
81 //refuel_node->setBoolValue(false);
\r
87 void FGAITanker::update(double dt) {
\r
88 FGAIAircraft::update(dt);
\r