WSF
WsfWeaponEngagement.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 WSFWEAPONENGAGEMENT_HPP
13#define WSFWEAPONENGAGEMENT_HPP
14
15#include "wsf_mil_export.h"
16
17#include <memory>
18#include <string>
19
20class UtScriptClass;
21class UtScriptTypes;
22#include "WsfEvent.hpp"
23class WsfPlatform;
24#include "WsfStringId.hpp"
25#include "WsfTrackId.hpp"
26class WsfWeapon;
27#include "WsfWeaponEffects.hpp"
28
41
42class WSF_MIL_EXPORT WsfWeaponEngagement : public UtScriptAccessible
43{
44public:
58
59 static WsfWeaponEngagement* Find(const WsfPlatform& aPlatform);
60
61 static bool Assign(WsfPlatform& aPlatform, WsfWeaponEngagement*& aEngagementPtr);
62
63 static std::unique_ptr<UtScriptClass> CreateScriptClass(const std::string& aClassName, UtScriptTypes* aScriptTypesPtr);
64
65 static bool EnumToString(std::string& aString, GeometryResult aGeometryResult);
66
67 static bool StringToEnum(GeometryResult& aGeometryResult, const std::string& aString);
68
70
71 WsfWeaponEngagement(double aStartTime,
72 WsfSimulation* aSimulationPtr,
73 WsfWeapon* aWeaponSystemPtr,
74 const WsfTrackId& aTargetTrackId,
75 size_t aIntendedTargetIndex,
76 WsfStringId aWeaponEffectsType,
77 WsfStringId aIntendedTargetOffsetName = WsfStringId());
78
79 static void Delete(WsfWeaponEngagement* aEngagementPtr);
80
81 const char* GetScriptClassName() const override { return "WsfWeaponEngagement"; }
82
84 virtual bool Initialize(double aSimTime, WsfPlatform* aWeaponPlatformPtr);
85
86 bool Initialize(WsfPlatform* aWeaponPlatformPtr);
87
88 virtual void Update(double aSimTime);
89
90 // NOTE: This is not virtual for a reason. See the implementation file.
91 void Terminate(double aSimTime, GeometryResult aGeometryResult = cFAR_AWAY_IN_AIR);
92
94 void Defeat()
95 {
96 if (mEffectPtr != nullptr)
97 {
98 mEffectPtr->Defeat();
99 }
100 }
101
104 void SetExtendedResult(const std::string& aExtendedResult) { mExtendedResult = aExtendedResult; }
105
111 void SetIsExternallyControlled(bool aIsExternallyControlled) { mIsExternallyControlled = aIsExternallyControlled; }
112
114 void SetWeaponEffects(WsfStringId aWeaponEffectsType);
115
116 void SetInitialWeaponVelocityWCS(const double aInitialVelWCS[3]);
117
118 void SetInitialTargetLocationWCS(const double aInitialLocWCS[3]);
119
121
123
124
126 WsfWeaponEffects* GetWeaponEffects() const { return mEffectPtr; }
127
130 unsigned int GetSerialNumber() const { return mSerialNumber; }
131
133 double GetStartTime() const { return mStartTime; }
134
138 double GetElapsedTime(double aSimTime) const;
139
143 double GetCompletionTime() const { return mCompletionTime; }
144
146 void SetCompletionTime(double aCompletionTime) { mCompletionTime = aCompletionTime; }
147
149 bool IsComplete() const { return mIsComplete; }
150
152 bool IsExternallyControlled() const { return mIsExternallyControlled; }
153
155
157
158
159 WsfPlatform* GetFiringPlatform() const;
160 void SetFiringPlatform(WsfPlatform* aPlatform);
161
163 size_t GetFiringPlatformIndex() const { return mFiringPlatformIndex; }
164
165 WsfStringId GetFiringPlatformName() const;
166
167 const WsfWeapon* GetWeaponSystem() const;
168
170 WsfStringId GetWeaponSystemName() const { return mWeaponSystemName; }
171
173 WsfStringId GetWeaponSystemType() const { return mWeaponSystemType; }
174
175 WsfPlatform* GetWeaponPlatform() const;
176
179 size_t GetWeaponPlatformIndex() const { return mWeaponPlatformIndex; }
180
181 WsfStringId GetWeaponPlatformName() const;
182
186 const WsfTrackId& GetInitialTargetTrackId() const { return mInitialTargetTrackId; }
187
188 const WsfTrackId& GetTargetTrackId() const;
189
190 size_t GetTargetPlatformIndex() const;
191
192 WsfPlatform* GetTargetPlatform() const;
193
194 WsfStringId GetIntendedTargetName() const;
195
196 WsfStringId GetIntendedTargetOffsetName() const { return mIntendedTargetOffsetName; }
197
199
201
202
206 GeometryResult GetGeometryResult() const { return mGeometryResult; }
207
210 WsfWeaponEffects::Result GetTargetResult() const { return mEffectPtr->GetTargetResult(); }
211
215 WsfWeaponEffects::Result GetIncidentalResult() const { return mEffectPtr->GetIncidentalResult(); }
216
219 std::string GetExtendedResult() const { return mExtendedResult; }
220
221 void GetTargetLocationWCS(WsfPlatform* aTargetPtr, double aTargetLocWCS[3]) const;
222 void SetTargetLocationWCS(WsfPlatform* aTargetPtr, const double aTargetLocWCS[3]);
223 void GetWeaponLocationWCS(WsfPlatform* aWeaponPtr, double aWeaponLocWCS[3]) const;
224 void SetWeaponLocationWCS(WsfPlatform* aWeaponPtr, const double aWeaponLocWCS[3]);
225
226 void GetWeaponVelocityWCS(double aWeaponVelWCS[3]) const;
227 void SetWeaponVelocityWCS(const double aWeaponVelWCS[3]);
228
229 void GetTargetLocationAtLaunchWCS(double aTargetLocWCS[3]) const;
230 void GetWeaponLocationAtLaunchWCS(double aWeaponLocWCS[3]) const;
231 void GetWeaponVelocityAtLaunchWCS(double aWeaponVelWCS[3]) const;
232
233 void GetWeaponLocationECS(double aWeaponLocECS[3]) const;
234 void GetWeaponVelocityECS(double aWeaponVelECS[3]) const;
235
236 double GetMissDistance(WsfPlatform* aTargetPtr) const;
237
241 void SetMissDistance(double aMissDistance) { mMissDistance = aMissDistance; }
243
244 WsfSimulation* GetSimulation() const { return mSimulationPtr; }
245
246 static void CopySerialNumber(const WsfWeaponEngagement* aRealEngPtr, WsfWeaponEngagement* aTempEngPtr);
247
249 void SetIFCEnabled(bool aEnabled) { mIFCEnabled = aEnabled; }
251
253 bool GetIFCEnabled() const { return mIFCEnabled; }
255
256protected:
257 void UpdateIntendedTarget() const;
258
261
262 // NOTE: See the code as to why this is protected.
263 virtual ~WsfWeaponEngagement();
264
265private:
266 class TerminateEvent;
267 friend class TerminateEvent;
268
269 class TerminateEvent : public WsfEvent
270 {
271 public:
272 TerminateEvent(double aSimTime, WsfWeaponEngagement* aEngagementPtr);
273 EventDisposition Execute() override;
274
275 WsfWeaponEngagement* mEngagementPtr;
276 };
277
278 virtual void PrivateTerminate(double aSimTime);
279
280 WsfSimulation* mSimulationPtr;
281 double mStartTime;
282 double mCompletionTime;
283 unsigned int mSerialNumber;
284 size_t mFiringPlatformIndex;
285 size_t mWeaponPlatformIndex; // Cannot immediately determine mWeaponPlatformIndex, set later
286 mutable size_t mIntendedTargetIndex;
287 mutable WsfStringId mIntendedTargetName; // Primarily used for output if the target is destroyed
288 WsfStringId mIntendedTargetOffsetName;
289 WsfStringId mWeaponSystemName;
290 WsfStringId mWeaponSystemType;
291
293 WsfTrackId mInitialTargetTrackId;
294
299 mutable WsfTrackId mTargetTrackId;
300
301 WsfWeaponEffects* mEffectPtr;
302
304 GeometryResult mGeometryResult;
305
307 std::string mExtendedResult;
308
310 double mWeaponLocAtLaunchWCS[3];
311 double mWeaponVelAtLaunchWCS[3];
312
315 double mWeaponVelWCS[3];
316
318 double mTargetLocAtLaunchWCS[3];
319
322 double mComputedWeaponLocWCS[3];
323 size_t mComputedWeaponIndex;
324
327 double mComputedTargetLocWCS[3];
328 size_t mComputedTargetIndex;
329
332 double mMissDistance;
333
335 bool mIsExternallyControlled;
336
338 bool mIsInitialized;
339
341 bool mIsComplete;
342
345 bool mTerminatePending;
346
349 bool mDestroyPending;
350
352 bool mInitialWeaponVelocitySet;
353
355 bool mInitialTargetLocationSet;
356
358 bool mIFCEnabled;
359};
360
361#endif
aObjectPtr Update(simTime)
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
Definition WsfEvent.hpp:29
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
The main controller for a simulation.
Definition WsfSimulation.hpp:109
Definition WsfTrackId.hpp:33
Definition WsfWeaponEffects.hpp:48
Result
Definition WsfWeaponEffects.hpp:63
Definition WsfWeaponEngagement.hpp:43
WsfWeaponEngagement(const WsfWeaponEngagement &aSrc)=delete
WsfSimulation * GetSimulation() const
Definition WsfWeaponEngagement.hpp:244
WsfStringId GetWeaponSystemName() const
Return the name of the firing weapon system (as a string ID).
Definition WsfWeaponEngagement.hpp:170
bool IsComplete() const
Return whether this engagement is complete.
Definition WsfWeaponEngagement.hpp:149
WsfWeaponEngagement & operator=(const WsfWeaponEngagement &aRhs)=delete
WsfStringId GetWeaponSystemType() const
Return the type of the firing weapon system (as a string ID).
Definition WsfWeaponEngagement.hpp:173
const char * GetScriptClassName() const override
Definition WsfWeaponEngagement.hpp:81
size_t GetFiringPlatformIndex() const
Return the platform index of the firing platform.
Definition WsfWeaponEngagement.hpp:163
void SetCompletionTime(double aCompletionTime)
Set the completion time of the engagement.
Definition WsfWeaponEngagement.hpp:146
GeometryResult GetGeometryResult() const
Definition WsfWeaponEngagement.hpp:206
std::string GetExtendedResult() const
Definition WsfWeaponEngagement.hpp:219
void SetIsExternallyControlled(bool aIsExternallyControlled)
Definition WsfWeaponEngagement.hpp:111
bool GetIFCEnabled() const
Returns 'true' if the platform supports IFC Integrated Fire Control).
Definition WsfWeaponEngagement.hpp:253
void SetIFCEnabled(bool aEnabled)
Set to true is IFC is supported.
Definition WsfWeaponEngagement.hpp:249
bool IsExternallyControlled() const
Is the engagement externally controlled?
Definition WsfWeaponEngagement.hpp:152
static void Delete(WsfWeaponEngagement *aEngagementPtr)
Definition WsfWeaponEngagement.cpp:172
size_t GetWeaponPlatformIndex() const
Definition WsfWeaponEngagement.hpp:179
unsigned int GetSerialNumber() const
Definition WsfWeaponEngagement.hpp:130
void Defeat()
Defeat the engagement (it will have no target effect after this call).
Definition WsfWeaponEngagement.hpp:94
WsfWeaponEngagement()=delete
WsfStringId GetIntendedTargetOffsetName() const
Definition WsfWeaponEngagement.hpp:196
WsfWeaponEffects::Result GetIncidentalResult() const
Definition WsfWeaponEngagement.hpp:215
WsfWeaponEffects::Result GetTargetResult() const
Definition WsfWeaponEngagement.hpp:210
double GetCompletionTime() const
Definition WsfWeaponEngagement.hpp:143
void SetExtendedResult(const std::string &aExtendedResult)
Definition WsfWeaponEngagement.hpp:104
double GetStartTime() const
Return the start time of the engagement.
Definition WsfWeaponEngagement.hpp:133
const WsfTrackId & GetInitialTargetTrackId() const
Definition WsfWeaponEngagement.hpp:186
GeometryResult
Definition WsfWeaponEngagement.hpp:46
@ cFAR_AWAY_ABOVE_GROUND
Above ground proximity burst not near any target.
Definition WsfWeaponEngagement.hpp:51
@ cFAR_AWAY_GROUND_IMPACT
Ground impact not near any target.
Definition WsfWeaponEngagement.hpp:52
@ cTARGET_PROXIMITY_AIR_BURST
Detonation was near a target, either in-air, or altitude unknown.
Definition WsfWeaponEngagement.hpp:53
@ cFAR_AWAY_IN_AIR
Air burst detonated far from any target.
Definition WsfWeaponEngagement.hpp:50
@ cPART_DISABLED_OR_DESTROYED
Temporary Lethal Effect on an attached platform part.
Definition WsfWeaponEngagement.hpp:56
@ cDUD
No lethal effect due to no detonation (failed to Arm, etc.).
Definition WsfWeaponEngagement.hpp:48
@ cIN_PROGRESS
Engagement not yet complete.
Definition WsfWeaponEngagement.hpp:47
@ cTARGET_PROXIMITY_ABOVE_GROUND
Above ground proximity burst near a target.
Definition WsfWeaponEngagement.hpp:54
@ cTARGET_IMPACT
Direct impact upon a target.
Definition WsfWeaponEngagement.hpp:49
@ cTARGET_PROXIMITY_GROUND_IMPACT
Impacted ground near a target.
Definition WsfWeaponEngagement.hpp:55
void SetMissDistance(double aMissDistance)
Definition WsfWeaponEngagement.hpp:241
WsfWeaponEffects * GetWeaponEffects() const
Access the WsfWeaponEffects model used during this engagement.
Definition WsfWeaponEngagement.hpp:126
Definition WsfWeapon.hpp:63
Copyrights Multiple, All Rights Reserved