WSF
WsfWeaponThreatProcessor.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 WSFWEAPONTHREATPROCESSOR_HPP
13#define WSFWEAPONTHREATPROCESSOR_HPP
14
15#include "wsf_mil_export.h"
16
17#include <cfloat>
18#include <cstring>
19#include <list>
20#include <map>
21#include <sstream>
22#include <vector>
23
24#include "UtEntity.hpp"
25class UtLineSegment;
26
27#include "WsfLocalTrack.hpp"
28class WsfScenario;
30#include "WsfTrackList.hpp"
32
37class WSF_MIL_EXPORT WsfWeaponThreatProcessor : public WsfScriptProcessor
38{
39public:
47
49 {
50 double mDuration = std::numeric_limits<double>::max();
52 };
53
55 {
58 // int mEntityTypeId;
60 // int mWeaponTypeId;
62 // probability of entity type
63 double mPe;
64 // probability of weapons on-board
65 double mPw;
66 // probability of kill at time zero
67 double mPk_t0;
68 // probability of kill at time zero
69 double mPt_t0;
70 // time of max probability of threat
71 double mTimePtMax;
72 // probability of kill max
73 double mPk_max;
74 // probability of threat max
75 double mPt_max;
76 // probability of detection (1.0)
77 double mPoD;
78 };
79
81 {
83 : mQuerySort(aQuerySort)
84 {
85 }
86
88 {
89 bool greater = i.mPt_max > j.mPt_max;
90 switch (mQuerySort)
91 {
93 greater = i.mPk_t0 > j.mPk_t0;
94 break;
96 greater = i.mPt_t0 > j.mPt_t0;
97 break;
99 greater = i.mPk_max > j.mPk_max;
100 break;
102 greater = i.mPt_max > j.mPt_max;
103 break;
104 }
105 return greater;
106 }
107
109 };
110
111 using WsfThreatReportList = std::vector<WsfThreatReport>;
112
116 {
117 public:
118 ThreatEvaluator(WsfScenario& aScenario);
119 ThreatEvaluator(const ThreatEvaluator& aSrc) = default;
121 virtual ~ThreatEvaluator() = default;
122
123 virtual ThreatEvaluator* Clone() const = 0;
124 virtual bool ProcessInput(UtInput& aInput) = 0;
125
126 PkSearchParameters& GetPkSearchParameters() { return mPkSearchParameters; }
127
132 virtual void CreateThreatList(const WsfTrack& aShooterTrack,
133 WsfPlatform& aOwnship,
134 WsfThreatReportList& aThreatReportList) = 0;
135
136 WsfScenario* GetScenario() { return mScenarioPtr; }
137
138 private:
139 PkSearchParameters mPkSearchParameters;
140 WsfScenario* mScenarioPtr;
141 };
142
146 ~WsfWeaponThreatProcessor() override;
147
148 bool ProcessInput(UtInput& aInput) override;
149
150 bool Initialize(double aSimTime) override;
151
152 WsfProcessor* Clone() const override { return new WsfWeaponThreatProcessor(*this); }
153
154 // This override IS critical!!!!! If not implemented, the scripts calls
155 // just fails quietly!!!!!!!!!!!!
156 const char* GetScriptClassName() const override { return "WsfWeaponThreatProcessor"; }
157
158 bool ProcessMessage(double aSimTime, const WsfMessage& aMessage) override;
159
160 // This function iterates on the given platforms tracks and finds all threats
161 // from them against itself.
162 void CreateThreatList(WsfPlatform& aOwnship);
163
164 // This function appends the threat list, with threats from the given track.
165 void CreateThreatList(const WsfTrack& aShooterTrack, WsfPlatform& aOwnship, WsfThreatReportList& aThreatReportList);
166
167 // Script focused functions.
168 void SetQueryTime(double aQueryTime) { mThreatEvaluator->GetPkSearchParameters().mDuration = aQueryTime; }
169 // void SetQueryFanDeg(double aQueryArcDeg) { mThreatEvaluator->GetPkSearchParameters().mArcFan=
170 // UtMath::cRAD_PER_DEG*aQueryArcDeg; }
171 void SetQuerySort(QuerySort aQuerySort) { mThreatEvaluator->GetPkSearchParameters().mQuerySort = aQuerySort; }
172
174 /*const */ WsfThreatReportList& GetThreatList() { return mThreatReportList; }
175
176private:
177 ThreatEvaluator* mThreatEvaluator;
178 WsfThreatReportList mThreatReportList;
179};
180
181#endif
UtStringId WsfStringId
WsfStringId – the same thing as UtStringId.
Definition WsfStringId.hpp:23
WsfWeaponThreatProcessor::WsfThreatReportList WsfThreatReportList
Definition WsfWeaponThreatProcessor.cpp:53
WsfWeaponThreatProcessor::ThreatEvaluator ThreatEvaluator
Definition WsfWeaponThreatProcessor.cpp:54
A base class for messages sent among simulation communication objects, processors and sensors.
Definition WsfMessage.hpp:33
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
WsfProcessor(const WsfScenario &aScenario)
Definition WsfProcessor.cpp:25
Contains the data required to create a simulation, and acts as the entry point for input file process...
Definition WsfScenario.hpp:111
Definition WsfScriptContext.hpp:71
WsfScriptProcessor(const WsfScenario &aScenario)
Definition WsfScriptProcessor.cpp:30
bool Initialize(double aSimTime) override
Definition WsfScriptProcessor.cpp:104
bool ProcessInput(UtInput &aInput) override
Definition WsfScriptProcessor.cpp:186
bool ProcessMessage(double aSimTime, const WsfMessage &aMessage) override
Definition WsfScriptProcessor.cpp:300
Definition WsfTrackId.hpp:33
An object that represents an 'track' (perception) of something.
Definition WsfTrack.hpp:120
virtual void CreateThreatList(const WsfTrack &aShooterTrack, WsfPlatform &aOwnship, WsfThreatReportList &aThreatReportList)=0
Appends/inserts any threats from this track into the given list.
ThreatEvaluator(WsfScenario &aScenario)
Definition WsfWeaponThreatProcessor.cpp:840
virtual ThreatEvaluator * Clone() const =0
WsfScenario * GetScenario()
Definition WsfWeaponThreatProcessor.hpp:136
ThreatEvaluator & operator=(const ThreatEvaluator &)=default
ThreatEvaluator(const ThreatEvaluator &aSrc)=default
PkSearchParameters & GetPkSearchParameters()
Definition WsfWeaponThreatProcessor.hpp:126
virtual bool ProcessInput(UtInput &aInput)=0
Definition WsfWeaponThreatProcessor.hpp:38
WsfWeaponThreatProcessor(WsfScenario &aScenario)
Definition WsfWeaponThreatProcessor.cpp:1400
void SetQueryTime(double aQueryTime)
Definition WsfWeaponThreatProcessor.hpp:168
void SetQuerySort(QuerySort aQuerySort)
Definition WsfWeaponThreatProcessor.hpp:171
WsfProcessor * Clone() const override
Definition WsfWeaponThreatProcessor.hpp:152
QuerySort
Definition WsfWeaponThreatProcessor.hpp:41
@ QUERY_SORT_PK_MAX
Definition WsfWeaponThreatProcessor.hpp:44
@ QUERY_SORT_PK_T0
Definition WsfWeaponThreatProcessor.hpp:42
@ QUERY_SORT_PT_MAX
Definition WsfWeaponThreatProcessor.hpp:45
@ QUERY_SORT_PT_T0
Definition WsfWeaponThreatProcessor.hpp:43
const char * GetScriptClassName() const override
Definition WsfWeaponThreatProcessor.hpp:156
WsfThreatReportList & GetThreatList()
Running any query clears and also fills this list.
Definition WsfWeaponThreatProcessor.hpp:174
WsfWeaponThreatProcessor & operator=(const WsfWeaponThreatProcessor &)=delete
std::vector< WsfThreatReport > WsfThreatReportList
Definition WsfWeaponThreatProcessor.hpp:111
Definition WsfWeaponThreatProcessor.hpp:49
QuerySort mQuerySort
Definition WsfWeaponThreatProcessor.hpp:51
double mDuration
Definition WsfWeaponThreatProcessor.hpp:50
bool operator()(const WsfThreatReport &i, const WsfThreatReport &j)
Definition WsfWeaponThreatProcessor.hpp:87
QuerySort mQuerySort
Definition WsfWeaponThreatProcessor.hpp:108
ThreatReportComparitor(QuerySort aQuerySort)
Definition WsfWeaponThreatProcessor.hpp:82
Definition WsfWeaponThreatProcessor.hpp:55
double mTimePtMax
Definition WsfWeaponThreatProcessor.hpp:71
WsfTrackId mTrackId
Definition WsfWeaponThreatProcessor.hpp:57
double mPw
Definition WsfWeaponThreatProcessor.hpp:65
WsfStringId mWeaponTypeId
Definition WsfWeaponThreatProcessor.hpp:61
WsfStringId mEntityTypeId
Definition WsfWeaponThreatProcessor.hpp:59
double mPt_t0
Definition WsfWeaponThreatProcessor.hpp:69
double mPoD
Definition WsfWeaponThreatProcessor.hpp:77
double mPe
Definition WsfWeaponThreatProcessor.hpp:63
double mPk_t0
Definition WsfWeaponThreatProcessor.hpp:67
WsfStringId mTrackNameId
Definition WsfWeaponThreatProcessor.hpp:56
double mPt_max
Definition WsfWeaponThreatProcessor.hpp:75
double mPk_max
Definition WsfWeaponThreatProcessor.hpp:73
Copyrights Multiple, All Rights Reserved