WSF
ATG_LAR_And_LC_Generator.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 ATG_LAR_AND_LC_GENERATOR_HPP
13#define ATG_LAR_AND_LC_GENERATOR_HPP
14
15#include <array>
16#include <fstream>
17#include <string>
18#include <vector>
19
20#include "Tool.hpp"
21#include "WeaponToolsExport.hpp"
22
35
37{
38public:
42 ~ATG_LAR_And_LC_Generator() override = default;
43 Tool* Clone() const override;
44 bool Initialize(WsfSimulation& aSimulation) override;
45 bool ProcessInput(UtInput& aInput) override;
46 void Update(double aSimTime) override;
47
48protected:
49 void LARGenUpdate(double aSimTime);
50 void SensitivityUpdate(double aSimTime);
51 bool FireNewWeapon(double aSimTime) override;
52 void ErrorBailout() override;
53
54 void WriteOutputFile();
55
56private:
58 double Range(int aRangeIndex) const;
59 double Offset(int aOffsetIndex) const;
60
61 double CurrentRange() const;
62 double CurrentOffset() const;
63
64 void SetCurrentResult(bool aValue);
65
66 void SetHitResult(int aRangeIndex, int aOffsetIndex, bool aValue);
67 bool HitResult(int aRangeIndex, int aOffsetIndex) const;
68
69 void CreateZoneFromBools();
70
72 enum StateType
73 {
74 cLAR_GEN,
75 cTRANSITION,
76 cBASELINE,
77 cALT_DELTA,
78 cSPD_DELTA,
79 cLOFT_DELTA,
80 cDONE
81 };
82
83 class AltAndSpeed
84 {
85 public:
86 AltAndSpeed(double aAlt, double aSpd, const std::string& aInputAltUnits, const std::string& aInputSpdUnits)
87 : mAlt(aAlt)
88 , mSpd(aSpd)
89 , mInputAltUnits(aInputAltUnits)
90 , mInputSpdUnits(aInputSpdUnits)
91 {
92 }
93
94 double mAlt;
95 double mSpd;
96 std::string mInputAltUnits;
97 std::string mInputSpdUnits;
98 };
99
100 class LocationPoint
101 {
102 public:
103 LocationPoint(double aX, double aY)
104 : mX(aX)
105 , mY(aY)
106 {
107 }
108
109 double mX;
110 double mY;
111 };
112
113 struct LAR_Condition
114 {
115 std::string mLarName;
116 std::string mZoneName;
117 double mAlt;
118 double mSpeed;
119 double mBaselineRange;
120 double mPlusAltRange;
121 double mPlusSpeedRange;
122 double mPlusLoftRange;
123 };
124
125 using LaunchConditions = std::vector<AltAndSpeed>;
126 using LocationPoints = std::vector<LocationPoint>;
127 using LAR_Conditions = std::vector<LAR_Condition>;
128
129 void BeginNewLAR();
130 bool PlaceNewTarget(double aSimTime, WsfTrack& aTrack);
131 void AdjustLAR();
132 void WriteZone();
133 void KillGuidance();
134
135 using ClockwisePath = std::array<std::pair<int, int>, 8>;
136
137 bool CreateLARBoundary();
138 ClockwisePath GetClockwisePath(const std::pair<int, int>& aBacktrack) const;
139 bool AddPoint(int aRange, int aOffset);
140
141 // Attributes:
142 int mNumTgtLateralOffsets; // Offsets always start at Y=0.0
143 double mTgtLateralOffset;
144
145 int mNumRanges;
146 double mMinRange;
147 double mTgtFwdOffset;
148
149 LaunchConditions mLaunchCond;
150 int mLaunchCondIndex;
151
152 // Varying State Values
153 int mQuantityLaunched;
154 StateType mState;
155 bool mFirstTime;
156 bool mFirstPass;
157 bool mWithinLAR;
158 bool mWeaponTimedOut;
159 bool mHitAtShortestRange;
160 bool mHitAtLongestRange;
161 bool mHitAtLargestOffset;
162 bool mSwitchSides;
163 double mCurrentAlt;
164 double mCurrentSpd;
165 int mTargetCount;
166 size_t mTgtIndex;
167 int mIRange;
168 int mIOffset;
169
170 std::vector<bool> mResults;
171
172 double mCentroidX;
173 double mShrinkFactor;
174
175 // Sensitivity Values
176 double mBaselineRange;
177 double mPlusAltRange;
178 double mPlusSpeedRange;
179 double mPlusLoftRange;
180
181 std::ofstream mOutFile;
182
183 LAR_Conditions mConditions;
184 LocationPoints mPoints;
185 std::string mGenTime;
186};
187
188#endif
#define WT_EXPORT
Definition WeaponToolsExport.hpp:26
ATG_LAR_And_LC_Generator(WsfScenario &aScenario)
Definition ATG_LAR_And_LC_Generator.cpp:42
void SensitivityUpdate(double aSimTime)
Definition ATG_LAR_And_LC_Generator.cpp:276
void WriteOutputFile()
Definition ATG_LAR_And_LC_Generator.cpp:628
~ATG_LAR_And_LC_Generator() override=default
ATG_LAR_And_LC_Generator & operator=(const ATG_LAR_And_LC_Generator &)=delete
void LARGenUpdate(double aSimTime)
Definition ATG_LAR_And_LC_Generator.cpp:367
virtual bool Initialize(WsfSimulation &aSimulation)
Definition Tool.cpp:206
bool ProcessInput(UtInput &aInput) override
Definition Tool.cpp:103
Tool(const Tool &aSrc)
Definition Tool.cpp:65
virtual void Update(double aSimTime)
Definition Tool.cpp:336
virtual void ErrorBailout()
Definition Tool.hpp:84
Tool * Clone() const override=0
virtual bool FireNewWeapon(double aSimTime)=0
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
The main controller for a simulation.
Definition WsfSimulation.hpp:109
Copyrights Multiple, All Rights Reserved