WSF
WsfAirToAirLaunchComputer.hpp
Go to the documentation of this file.
1// ****************************************************************************
2// CUI
3//
4// The Advanced Framework for Simulation, Integration, and Modeling (AFSIM)
5//
6// Copyright 2003-2015 The Boeing Company. All rights reserved.
7//
8// The use, dissemination or disclosure of data in this file is subject to
9// limitation or restriction. See accompanying README and LICENSE for details.
10// ****************************************************************************
11
12#ifndef WSFAIRTOAIRLAUNCHCOMPUTER_HPP
13#define WSFAIRTOAIRLAUNCHCOMPUTER_HPP
14
15#include "wsf_mil_export.h"
16
17#include <memory>
18#include <vector>
19
20#include "UtAtmosphere.hpp"
21class UtInput;
22class UtInputBlock;
23#include "WsfLaunchComputer.hpp"
24
35
36class WSF_MIL_EXPORT WsfAirToAirLaunchComputer : public WsfLaunchComputer
37{
38public:
40 static std::string BaseTypeName() { return "WSF_AIR_TO_AIR_LAUNCH_COMPUTER"; }
41
42 WsfAirToAirLaunchComputer(const UtAtmosphere& aAtmosphere);
44 ~WsfAirToAirLaunchComputer() override = default;
45
46 WsfLaunchComputer* Clone() const override;
47
48 bool ProcessInput(UtInput& aInput) override;
49
50 bool Initialize(double aSimTime, WsfWeapon* aWeaponPtr) override;
51
52 bool ToolOnlyInitialize(double aSimTime);
53
54 double EstimatedTimeToIntercept(double aSimTime, const WsfTrack& aTrack, double aLaunchDelayTime) override;
55
56 bool LookupResult(const WsfTrack& aTrack,
57 double& aRmax,
58 double& aRmaxTOF,
59 double& aRne,
60 double& aRneTOF,
61 double& aRmin,
62 double& aRminTOF);
63
64 bool LookupResult(double aShooterInAlt,
65 double aShooterInMach,
66 double aTargetInAlt,
67 double aTargetInMach,
68 double aTargetInAspect,
69 double aTargetInLead,
70 double& aShooterOutAlt,
71 double& aShooterOutMach,
72 double& aTargetOutAlt,
73 double& aTargetOutMach,
74 double& aTargetOutAspect,
75 double& aTargetOutLead,
76 double& aRmax,
77 double& aRmaxTOF,
78 double& aRne,
79 double& aRneTOF,
80 double& aRmin,
81 double& aRminTOF);
82
83 // =======================================================================
84
85 class WSF_MIL_EXPORT ATA_InterceptTable
86 {
87 public:
88 struct WSF_MIL_EXPORT Result
89 {
90 Result();
91 void Reset();
92 bool ProcessInput(UtInput& aInput);
93 bool IsNull() const;
94 void Stream(std::ostream& aStream) const;
95
96 double mRmax;
97 double mRmaxTOF;
98 double mRne;
99 double mRneTOF;
100 double mRmin;
101 double mRminTOF;
102 };
103
105
106 size_t SizeOfTargetAspectSet() const { return mTargetLeads.size(); }
107 size_t SizeOfTargetMachSet() const { return mTargetAspects.size() * SizeOfTargetAspectSet(); }
108 size_t SizeOfTargetAltSet() const { return mTargetMachs.size() * SizeOfTargetMachSet(); }
109 size_t SizeOfShooterMachSet() const { return mTargetAlts.size() * SizeOfTargetAltSet(); }
110 size_t SizeOfShooterAltSet() const { return mShooterMachs.size() * SizeOfShooterMachSet(); }
111 size_t SizeOfResultsSet() const { return mShooterAlts.size() * SizeOfShooterAltSet(); }
112
113 bool IndexToIndices(size_t aResultIndex,
114 size_t& aShooterAltIndex,
115 size_t& aShooterMachIndex,
116 size_t& aTargetAltIndex,
117 size_t& aTargetMachIndex,
118 size_t& aTargetAspectIndex,
119 size_t& aTargetLeadIndex) const;
120
121 bool IndicesToIndex(size_t aShooterAltIndex,
122 size_t aShooterMachIndex,
123 size_t aTargetAltIndex,
124 size_t aTargetMachIndex,
125 size_t aTargetAspectIndex,
126 size_t aTargetLeadIndex,
127 size_t& aResultIndex) const;
128
129 bool IndexToValues(size_t aResultIndex,
130 double& aShooterAlt,
131 double& aShooterMach,
132 double& aTargetAlt,
133 double& aTargetMach,
134 double& aTargetAspect,
135 double& aTargetLead) const;
136
137 bool ValuesToIndices(double aShooterAlt,
138 double aShooterMach,
139 double aTargetAlt,
140 double aTargetMach,
141 double aTargetAspect,
142 double aTargetLead,
143 size_t& aShooterAltIndex,
144 size_t& aShooterMachIndex,
145 size_t& aTargetAltIndex,
146 size_t& aTargetMachIndex,
147 size_t& aTargetAspectIndex,
148 size_t& aTargetLeadIndex) const;
149
150 bool GetResult(size_t aResultIndex, Result& aResult) const;
151
152 bool SetResult(size_t aResultIndex, const Result& aResult);
153
154 bool FindNearestIndex(double aValue, const std::vector<double>& aArray, size_t& aIndex) const;
155
157
158 bool Load(const std::string& aFileName, bool aDebugEnabled);
159
161 void Stream(std::ostream& aStream, const std::string& aResultsFilename) const;
162 void StreamResults(std::ostream& aStream, const std::string& aResultsFilename) const;
163 bool ProcessInput(UtInput& aInput);
164 void ClearAll();
165
166 const std::vector<double>& ShooterAlts() const { return mShooterAlts; }
167 const std::vector<double>& ShooterMachs() const { return mShooterMachs; }
168 const std::vector<double>& TargetAlts() const { return mTargetAlts; }
169 const std::vector<double>& TargetMachs() const { return mTargetMachs; }
170 const std::vector<double>& TargetAspects() const { return mTargetAspects; }
171 const std::vector<double>& TargetLeads() const { return mTargetLeads; }
172
173 size_t ResultsSize() const { return mResults.size(); }
174
175 protected:
176 void StreamIndependentBlock(std::ostream& aStream) const;
177 bool IVArraysOk(UtInput& aInput);
178 bool ArrayOk(UtInput& aInput, const std::vector<double>& aArray, const std::string& aArrayType, double aMinimumDelta) const;
179 bool ProcessIndependentBlock(UtInputBlock& aInputBlock);
180 void ProcessInterceptResults(UtInputBlock& aInputBlock);
181
183 std::vector<double> mShooterAlts;
184 std::vector<double> mShooterMachs;
185 std::vector<double> mTargetAlts;
186 std::vector<double> mTargetMachs;
187 std::vector<double> mTargetAspects;
188 std::vector<double> mTargetLeads;
189 std::vector<Result> mResults;
190 };
191
192 // =======================================================================
193
194 ATA_InterceptTable& GetTable() { return *mAirToAirTablePtr; }
195
197 bool Test();
198
199protected:
200 static constexpr double cNOT_SET{-1.0};
201
202 bool InitializeTTIData() override;
204
205private:
206 std::shared_ptr<ATA_InterceptTable> mAirToAirTablePtr;
207
208 UtAtmosphere mAtmosphere;
209};
210
211#endif
void Load(PakI &aBuff, WsfXIO_PlatformPartInfo *&aPtr)
Definition WsfXIO_ObjectInfo.cpp:345
Definition WsfAirToAirLaunchComputer.hpp:86
const std::vector< double > & ShooterMachs() const
Definition WsfAirToAirLaunchComputer.hpp:167
size_t SizeOfTargetAspectSet() const
Definition WsfAirToAirLaunchComputer.hpp:106
std::vector< double > mTargetMachs
Definition WsfAirToAirLaunchComputer.hpp:186
size_t SizeOfShooterMachSet() const
Definition WsfAirToAirLaunchComputer.hpp:109
double NoEscapeManeuverAcceleration() const
Definition WsfAirToAirLaunchComputer.hpp:156
ATA_InterceptTable()
Definition WsfAirToAirLaunchComputer.cpp:294
size_t ResultsSize() const
Definition WsfAirToAirLaunchComputer.hpp:173
std::vector< double > mShooterAlts
Definition WsfAirToAirLaunchComputer.hpp:183
std::vector< double > mShooterMachs
Definition WsfAirToAirLaunchComputer.hpp:184
size_t SizeOfShooterAltSet() const
Definition WsfAirToAirLaunchComputer.hpp:110
std::vector< Result > mResults
Definition WsfAirToAirLaunchComputer.hpp:189
const std::vector< double > & TargetLeads() const
Definition WsfAirToAirLaunchComputer.hpp:171
size_t SizeOfResultsSet() const
Definition WsfAirToAirLaunchComputer.hpp:111
const std::vector< double > & TargetAspects() const
Definition WsfAirToAirLaunchComputer.hpp:170
size_t SizeOfTargetAltSet() const
Definition WsfAirToAirLaunchComputer.hpp:108
std::vector< double > mTargetLeads
Definition WsfAirToAirLaunchComputer.hpp:188
const std::vector< double > & TargetAlts() const
Definition WsfAirToAirLaunchComputer.hpp:168
size_t SizeOfTargetMachSet() const
Definition WsfAirToAirLaunchComputer.hpp:107
double mRNE_ManeuverAccel
Definition WsfAirToAirLaunchComputer.hpp:182
const std::vector< double > & TargetMachs() const
Definition WsfAirToAirLaunchComputer.hpp:169
std::vector< double > mTargetAlts
Definition WsfAirToAirLaunchComputer.hpp:185
const std::vector< double > & ShooterAlts() const
Definition WsfAirToAirLaunchComputer.hpp:166
std::vector< double > mTargetAspects
Definition WsfAirToAirLaunchComputer.hpp:187
Definition WsfAirToAirLaunchComputer.hpp:37
~WsfAirToAirLaunchComputer() override=default
bool ToolOnlyInitialize(double aSimTime)
Definition WsfAirToAirLaunchComputer.cpp:881
WsfAirToAirLaunchComputer & operator=(const WsfAirToAirLaunchComputer &)=delete
static constexpr double cNOT_SET
Definition WsfAirToAirLaunchComputer.hpp:200
bool LookupResult(const WsfTrack &aTrack, double &aRmax, double &aRmaxTOF, double &aRne, double &aRneTOF, double &aRmin, double &aRminTOF)
Definition WsfAirToAirLaunchComputer.cpp:73
static std::string BaseTypeName()
The basic type name (needed by weapon_tools and launch computer processor).
Definition WsfAirToAirLaunchComputer.hpp:40
WsfAirToAirLaunchComputer(const UtAtmosphere &aAtmosphere)
Definition WsfAirToAirLaunchComputer.cpp:35
ATA_InterceptTable & GetTable()
Definition WsfAirToAirLaunchComputer.hpp:194
virtual bool InitializeTTIData()
Definition WsfLaunchComputer.cpp:440
WsfLaunchComputer()
Definition WsfLaunchComputer.cpp:44
virtual double EstimatedTimeToIntercept(double aSimTime, const WsfTrack &aTrack, double aLaunchDelayTime)
Definition WsfLaunchComputer.cpp:749
WsfLaunchComputer * Clone() const override
Definition WsfLaunchComputer.cpp:518
bool ProcessInput(UtInput &aInput) override
Definition WsfLaunchComputer.cpp:171
virtual bool Initialize(double aSimTime, WsfWeapon *aWeaponPtr)
Definition WsfLaunchComputer.cpp:393
An object that represents an 'track' (perception) of something.
Definition WsfTrack.hpp:120
Definition WsfWeapon.hpp:63
Result()
Definition WsfAirToAirLaunchComputer.cpp:1061
double mRne
Definition WsfAirToAirLaunchComputer.hpp:98
double mRneTOF
Definition WsfAirToAirLaunchComputer.hpp:99
double mRmaxTOF
Definition WsfAirToAirLaunchComputer.hpp:97
double mRmin
Definition WsfAirToAirLaunchComputer.hpp:100
double mRminTOF
Definition WsfAirToAirLaunchComputer.hpp:101
bool IsNull() const
Definition WsfAirToAirLaunchComputer.cpp:1081
void Stream(std::ostream &aStream) const
Definition WsfAirToAirLaunchComputer.cpp:1086
double mRmax
Definition WsfAirToAirLaunchComputer.hpp:96
void Reset()
Definition WsfAirToAirLaunchComputer.cpp:1071
Copyrights Multiple, All Rights Reserved