FlightGear next
AITanker.cxx
Go to the documentation of this file.
1/*
2 * SPDX-FileName: AITanker.cxx
3 * SPDX-FileComment: Tanker specific code isolated from AI Aircraft code, based on David Culp's AIModel code
4 * SPDX-FileCopyrightText: by Thomas Foerster, started June 2007
5 * SPDX-FileContributor: Original code written by David Culp, started October 2003 - davidculp2@comcast.net
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9#include "AITanker.hxx"
10
11
15
16void FGAITanker::readFromScenario(SGPropertyNode* scFileNode)
17{
18 if (!scFileNode)
19 return;
20
22 setTACANChannelID(scFileNode->getStringValue("TACAN-channel-ID", ""));
23 setName(scFileNode->getStringValue("name", "Tanker"));
24}
25
27{
29
30 tie("refuel/contact", SGRawValuePointer<bool>(&contact));
31 tie("position/altitude-agl-ft", SGRawValuePointer<double>(&altitude_agl_ft));
32
33 props->setStringValue("navaids/tacan/channel-ID", TACAN_channel_id.c_str());
34 props->setStringValue("name", _name.c_str());
35 props->setBoolValue("tanker", true);
36}
37
38void FGAITanker::setTACANChannelID(const std::string& id)
39{
40 TACAN_channel_id = id;
41}
42
43void FGAITanker::Run(double dt)
44{
45 double start = pos.getElevationFt() + 1000.0;
47
48 //###########################//
49 // do calculations for radar //
50 //###########################//
51 double range_ft2 = UpdateRadar(manager);
52
53 // check if radar contact
54 if ((range_ft2 < 250.0 * 250.0) && (y_shift > 0.0) && (elevation > 0.0)) {
55 contact = true;
56 } else {
57 contact = false;
58 }
59}
60
61void FGAITanker::update(double dt)
62{
64 Run(dt);
65 Transform();
66}
FGAIAircraft(FGAISchedule *ref=0)
void update(double dt) override
void bind() override
void readFromScenario(SGPropertyNode *scFileNode) override
double _getAltitudeAGL(SGGeod inpos, double start)
Definition AIBase.cxx:1030
void setName(const std::string &n)
Definition AIBase.hxx:491
SGGeod pos
Definition AIBase.hxx:212
std::string _name
Definition AIBase.hxx:190
double altitude_agl_ft
Definition AIBase.hxx:223
double UpdateRadar(FGAIManager *manager)
Definition AIBase.cxx:819
double elevation
Definition AIBase.hxx:240
void Transform()
Definition AIBase.cxx:518
double y_shift
Definition AIBase.hxx:246
void tie(const char *aRelPath, const SGRawValue< T > &aRawValue)
Tied-properties helper, record nodes which are tied for easy un-tie-ing.
Definition AIBase.hxx:198
SGPropertyNode_ptr props
Definition AIBase.hxx:205
FGAIManager * manager
Definition AIBase.hxx:209
void bind() override
Definition AITanker.cxx:26
void setTACANChannelID(const std::string &id)
Definition AITanker.cxx:38
void readFromScenario(SGPropertyNode *scFileNode) override
Definition AITanker.cxx:16
FGAITanker(FGAISchedule *ref=0)
Definition AITanker.cxx:12