Debian Codegraph @

src/AIModel/AITanker.cxx

raw symbols SCIP
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 - [email protected]
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
8
9 #include "AITanker.hxx"
10
11
12 FGAITanker::FGAITanker(FGAISchedule* ref) : FGAIAircraft(ref)
13 {
14 }
15
16 void FGAITanker::readFromScenario(SGPropertyNode* scFileNode)
17 {
18 if (!scFileNode)
19 return;
20
21 FGAIAircraft::readFromScenario(scFileNode);
22 setTACANChannelID(scFileNode->getStringValue("TACAN-channel-ID", ""));
23 setName(scFileNode->getStringValue("name", "Tanker"));
24 }
25
26 void FGAITanker::bind()
27 {
28 FGAIAircraft::bind();
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
38 void FGAITanker::setTACANChannelID(const std::string& id)
39 {
40 TACAN_channel_id = id;
41 }
42
43 void FGAITanker::Run(double dt)
44 {
45 double start = pos.getElevationFt() + 1000.0;
46 altitude_agl_ft = _getAltitudeAGL(pos, start);
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
61 void FGAITanker::update(double dt)
62 {
63 FGAIAircraft::update(dt);
64 Run(dt);
65 Transform();
66 }