WSF
WsfSAM_LaunchComputer.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 WSFSAM_LAUNCHCOMPUTER_HPP
13#define WSFSAM_LAUNCHCOMPUTER_HPP
14
15#include "wsf_mil_export.h"
16
17#include <memory>
18#include <utility>
19#include <vector>
20
21#include "TblLookup.hpp"
22class UtInput;
23class UtInputBlock;
24#include "WsfLaunchComputer.hpp"
25
29
30class WSF_MIL_EXPORT WsfSAM_LaunchComputer : public WsfLaunchComputer
31{
32public:
34 static std::string BaseTypeName() { return "WSF_SAM_LAUNCH_COMPUTER"; }
35
39 ~WsfSAM_LaunchComputer() override = default;
40
41 WsfLaunchComputer* Clone() const override;
42 bool ProcessInput(UtInput& aInput) override;
43
44 bool Initialize(double aSimTime, WsfWeapon* aWeaponPtr) override;
45
46 double EstimatedTimeToIntercept(double aSimTime, const WsfTrack& aTrack, double aLaunchDelayTime) override;
47
49 double InterpolatedTimeToIntercept(double aOffset, double aAltitude, double aRange, double aSpeed);
50
51 class WSF_MIL_EXPORT Interpolator
52 {
53 public:
55 : mOffsetLU()
56 , mAltLU()
57 , mRangeLU()
58 , mSpeedLU()
59 , mOffsetsPtr(nullptr)
60 , mAltitudesPtr(nullptr)
61 , mRangesPtr(nullptr)
62 , mSpeedsPtr(nullptr)
63 , mTOFsPtr(nullptr)
64 {
65 }
66 double TimeOfFlightFor(double aOffset, double aAltitude, double aRange, double aSpeed);
67 TblLookupLU<double> mOffsetLU;
68 TblLookupLU<double> mAltLU;
69 TblLookupLU<double> mRangeLU;
70 TblLookupLU<double> mSpeedLU;
71
72 // These must be set before use:
73 const TblIndVarU<double>* mOffsetsPtr;
74 const TblIndVarU<double>* mAltitudesPtr;
75 const TblIndVarU<double>* mRangesPtr;
76 const TblIndVarU<double>* mSpeedsPtr;
77 const TblDepVar4<double>* mTOFsPtr;
78 };
79
80 class WSF_MIL_EXPORT InterceptEnvelope
81 {
82 public:
84 void Resize(const std::vector<double>& aOffsets,
85 const std::vector<double>& aAltitudes,
86 const std::vector<double>& aRanges,
87 const std::vector<double>& aSpeeds);
88 bool Initialize(bool aIgnoreTOFs);
89 void ProcessInterceptEnvBlock(UtInputBlock& aInputBlock);
90 bool ProcessInput(UtInput& aInput);
92 bool ResolveDeprecatedInput();
93 void ResizeTOFsAndSetDefaults();
94 unsigned int CountValidTOFs();
95
96 void SetTOF_Value(unsigned int aOffsetIndex,
97 unsigned int aAltitudeIndex,
98 unsigned int aRangeIndex,
99 unsigned int aSpeedIndex,
100 double aTOF_Value);
101
102 size_t NumOffsets() const { return mOffsets.GetSize(); }
103 size_t NumAltitudes() const { return mAltitudes.GetSize(); }
104 size_t NumRanges() const { return mRanges.GetSize(); }
105 size_t NumSpeeds() const { return mSpeeds.GetSize(); }
106
107 double Offset(unsigned int aIndex) const { return mOffsets.Get(aIndex); }
108 double Altitude(unsigned int aIndex) const { return mAltitudes.Get(aIndex); }
109 double GroundRange(unsigned int aIndex) const { return mRanges.Get(aIndex); }
110 double Speed(unsigned int aIndex) const { return mSpeeds.Get(aIndex); }
111
112 // Only needed for deprecated input style.
113 struct AltSet
114 {
115 double alt{0.0};
116 std::vector<std::pair<double, double>> mRangeAndTOFs;
117 };
118 bool ReadRngAndTOF(UtInput& aInput, double& aRange, double& aTOF);
119
120 double TimeOfFlight(unsigned int aOffsetIndex,
121 unsigned int aAltitudeIndex,
122 unsigned int aRangeIndex,
123 unsigned int aSpeedIndex) const
124 {
125 return mTOFs.Get(aOffsetIndex, aAltitudeIndex, aRangeIndex, aSpeedIndex);
126 }
127
129 TblIndVarU<double> mOffsets;
130 TblIndVarU<double> mAltitudes;
131 TblIndVarU<double> mRanges;
132 TblIndVarU<double> mSpeeds;
133 TblDepVar4<double> mTOFs;
134
135 std::vector<AltSet> mObsoleteInput;
136 };
137
140
141 static bool ValidateEnvelope(InterceptEnvelope* aEnvelopePtr, bool aIgnoreTOFs);
142
143protected:
145 {
147 : latOffset(0)
148 , altitude(0)
149 , groundRange(0)
150 , speed(0.0){};
151 double latOffset;
152 double altitude;
154 double speed;
155 };
157
158 bool ProcessArray(UtInput& aInput,
159 const std::string& aBlockTerminator,
160 UtInput::ValueType aUnitType,
161 std::vector<double>& aValues);
162
163 bool InitializeTTIData() override;
164
165 std::vector<double> mInputOffsets;
166 std::vector<double> mInputAltitudes;
167 std::vector<double> mInputRanges;
168 std::vector<double> mInputSpeeds;
169
170 std::vector<TestPoint> mTestPoints;
171 std::shared_ptr<InterceptEnvelope> mEnvelopePtr;
173};
174
175#endif
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
Definition WsfSAM_LaunchComputer.hpp:81
void ProcessInterceptEnvBlock(UtInputBlock &aInputBlock)
Definition WsfSAM_LaunchComputer.cpp:355
double TimeOfFlight(unsigned int aOffsetIndex, unsigned int aAltitudeIndex, unsigned int aRangeIndex, unsigned int aSpeedIndex) const
Definition WsfSAM_LaunchComputer.hpp:120
double GroundRange(unsigned int aIndex) const
Definition WsfSAM_LaunchComputer.hpp:109
void Resize(const std::vector< double > &aOffsets, const std::vector< double > &aAltitudes, const std::vector< double > &aRanges, const std::vector< double > &aSpeeds)
Definition WsfSAM_LaunchComputer.cpp:499
std::vector< AltSet > mObsoleteInput
Definition WsfSAM_LaunchComputer.hpp:135
bool mLaterallySymmetric
Definition WsfSAM_LaunchComputer.hpp:128
bool AssumeLateralSymmetry() const
Definition WsfSAM_LaunchComputer.hpp:91
TblDepVar4< double > mTOFs
Definition WsfSAM_LaunchComputer.hpp:133
size_t NumAltitudes() const
Definition WsfSAM_LaunchComputer.hpp:103
TblIndVarU< double > mRanges
Definition WsfSAM_LaunchComputer.hpp:131
size_t NumRanges() const
Definition WsfSAM_LaunchComputer.hpp:104
TblIndVarU< double > mOffsets
Definition WsfSAM_LaunchComputer.hpp:129
double Speed(unsigned int aIndex) const
Definition WsfSAM_LaunchComputer.hpp:110
bool ReadRngAndTOF(UtInput &aInput, double &aRange, double &aTOF)
Definition WsfSAM_LaunchComputer.cpp:720
InterceptEnvelope()
Definition WsfSAM_LaunchComputer.cpp:736
TblIndVarU< double > mSpeeds
Definition WsfSAM_LaunchComputer.hpp:132
double Offset(unsigned int aIndex) const
Definition WsfSAM_LaunchComputer.hpp:107
TblIndVarU< double > mAltitudes
Definition WsfSAM_LaunchComputer.hpp:130
size_t NumSpeeds() const
Definition WsfSAM_LaunchComputer.hpp:105
double Altitude(unsigned int aIndex) const
Definition WsfSAM_LaunchComputer.hpp:108
size_t NumOffsets() const
Definition WsfSAM_LaunchComputer.hpp:102
Definition WsfSAM_LaunchComputer.hpp:52
const TblIndVarU< double > * mAltitudesPtr
Definition WsfSAM_LaunchComputer.hpp:74
Interpolator()
Definition WsfSAM_LaunchComputer.hpp:54
const TblIndVarU< double > * mSpeedsPtr
Definition WsfSAM_LaunchComputer.hpp:76
const TblIndVarU< double > * mOffsetsPtr
Definition WsfSAM_LaunchComputer.hpp:73
const TblDepVar4< double > * mTOFsPtr
Definition WsfSAM_LaunchComputer.hpp:77
const TblIndVarU< double > * mRangesPtr
Definition WsfSAM_LaunchComputer.hpp:75
TblLookupLU< double > mAltLU
Definition WsfSAM_LaunchComputer.hpp:68
TblLookupLU< double > mSpeedLU
Definition WsfSAM_LaunchComputer.hpp:70
TblLookupLU< double > mOffsetLU
Definition WsfSAM_LaunchComputer.hpp:67
TblLookupLU< double > mRangeLU
Definition WsfSAM_LaunchComputer.hpp:69
Definition WsfSAM_LaunchComputer.hpp:31
std::vector< double > mInputRanges
Definition WsfSAM_LaunchComputer.hpp:167
WsfSAM_LaunchComputer & operator=(const WsfSAM_LaunchComputer &)=delete
Interpolator mInterpolator
Definition WsfSAM_LaunchComputer.hpp:172
static bool ValidateEnvelope(InterceptEnvelope *aEnvelopePtr, bool aIgnoreTOFs)
Definition WsfSAM_LaunchComputer.cpp:132
std::vector< TestPoint > mTestPoints
Definition WsfSAM_LaunchComputer.hpp:170
std::vector< double > mInputAltitudes
Definition WsfSAM_LaunchComputer.hpp:166
WsfSAM_LaunchComputer()
Definition WsfSAM_LaunchComputer.cpp:90
InterceptEnvelope * GetEnvPtr()
Return a pointer to the intercept envelope.
Definition WsfSAM_LaunchComputer.cpp:116
std::shared_ptr< InterceptEnvelope > mEnvelopePtr
Definition WsfSAM_LaunchComputer.hpp:171
double InterpolatedTimeToIntercept(double aOffset, double aAltitude, double aRange, double aSpeed)
This method is for testing of the internal interpolation routines only.
Definition WsfSAM_LaunchComputer.cpp:883
std::vector< double > mInputSpeeds
Definition WsfSAM_LaunchComputer.hpp:168
std::vector< double > mInputOffsets
Definition WsfSAM_LaunchComputer.hpp:165
~WsfSAM_LaunchComputer() override=default
bool ProcessArray(UtInput &aInput, const std::string &aBlockTerminator, UtInput::ValueType aUnitType, std::vector< double > &aValues)
Definition WsfSAM_LaunchComputer.cpp:809
void TestInterpolationPoints()
Definition WsfSAM_LaunchComputer.cpp:163
static std::string BaseTypeName()
The basic type name (needed by weapon_tools and launch computer processor).
Definition WsfSAM_LaunchComputer.hpp:34
An object that represents an 'track' (perception) of something.
Definition WsfTrack.hpp:120
Definition WsfWeapon.hpp:63
Definition WsfSAM_LaunchComputer.hpp:114
double alt
Definition WsfSAM_LaunchComputer.hpp:115
std::vector< std::pair< double, double > > mRangeAndTOFs
Definition WsfSAM_LaunchComputer.hpp:116
double groundRange
Definition WsfSAM_LaunchComputer.hpp:153
TestPoint()
Definition WsfSAM_LaunchComputer.hpp:146
double speed
Definition WsfSAM_LaunchComputer.hpp:154
double altitude
Definition WsfSAM_LaunchComputer.hpp:152
double latOffset
Definition WsfSAM_LaunchComputer.hpp:151
Copyrights Multiple, All Rights Reserved