WSF
WsfLOS_Manager.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 WSFLOSMANAGER_HPP
13#define WSFLOSMANAGER_HPP
14
15#include "wsf_export.h"
16
17#include <list>
18#include <map>
19#include <mutex>
20#include <set>
21
22#include "UtCallbackHolder.hpp"
23class UtInput;
24#include "UtVec3.hpp"
25
27class WsfEM_Antenna;
28class WsfPlatform;
31#include "WsfThread.hpp"
32
72
76{
77public:
79
80 void SimulationCreated(WsfSimulation& aSimulation) override;
81
82 bool ProcessInput(UtInput& aInput) override;
83
84private:
86};
87
94{
95public:
96 static WsfLOS_Manager* Find(const WsfSimulation& aSimulation);
97
99 ~WsfLOS_Manager() override;
100
102 bool Initialize() override;
103
105 void PlatformDeleted(double aSimTime, WsfPlatform* aPlatformPtr);
106
108 void Update(double aSimTime);
109
111 bool DebugEnabled() const { return mDebugEnabled; }
112
115 void SetDebugEnabled(bool aDebugEnabled) { mDebugEnabled = aDebugEnabled; }
116
118
119
120 bool IsTargetVisible(WsfPlatform* aPlatformPtr, WsfPlatform* aTargetPtr, double aMaxRange = 0.0, double aRadiusScale = 1.0);
121
122 bool IsTargetVisible(WsfEM_Antenna* aAntennaPtr, WsfPlatform* aTargetPtr, double aMaxRange = 0.0, double aRadiusScale = 1.0);
123
124 bool IsTargetVisible(WsfEM_Antenna* aAntennaPtr,
125 WsfEM_Antenna* aTargetPtr,
126 double aMaxRange = 0.0,
127 double aRadiusScale = 1.0);
129
131
132
133 bool MaskedByTerrain(WsfPlatform* aPlatformPtr, WsfPlatform* aTargetPtr, double aMaxRange = 0.0, double aRadiusScale = 1.0);
134
135 bool MaskedByTerrain(WsfEM_Antenna* aAntennaPtr, WsfPlatform* aTargetPtr, double aMaxRange = 0.0, double aRadiusScale = 1.0);
136
137 bool MaskedByTerrain(WsfEM_Antenna* aAntennaPtr,
138 WsfEM_Antenna* aTargetPtr,
139 double aMaxRange = 0.0,
140 double aRadiusScale = 1.0);
141
143
145
146
147 bool MaskedByVegetation(WsfPlatform* aPlatformPtr,
148 WsfPlatform* aTargetPtr,
149 double aMaxRange = 0.0,
150 double aRadiusScale = 1.0);
151
152 bool MaskedByVegetation(WsfEM_Antenna* aAntennaPtr,
153 WsfPlatform* aTargetPtr,
154 double aMaxRange = 0.0,
155 double aRadiusScale = 1.0);
156
157 bool MaskedByVegetation(WsfEM_Antenna* aAntennaPtr,
158 WsfEM_Antenna* aTargetPtr,
159 double aMaxRange = 0.0,
160 double aRadiusScale = 1.0);
161
163
165 class State
166 {
167 public:
169 : mPlatformIndex(0)
170 , mTime(-1.0)
171 , mMoved(true)
172 {
173 UtVec3d::Set(mLocationWCS, 0.0);
174 UtVec3d::Set(mLLA, 0.0);
175 };
176 virtual ~State(){};
177
178 size_t mPlatformIndex; // Platform index
179 double mTime; // Sim time of location data update
180 double mLocationWCS[3]; // Location in WCS
181 double mLLA[3]; // Latitude, longitude, altitude
182 bool mMoved; // True if the platform has moved
183 };
184
185 typedef std::map<unsigned int, State> StateMapType;
186 typedef std::map<unsigned int, State>::iterator StateMapTypeIterator;
187 typedef std::pair<unsigned int, State> StateMapTypePair;
188
190 StateMapType& GetStateData() { return mStateData; };
191
194 {
195 public:
196 LOS_Key(unsigned int aUniqueId1, unsigned int aUniqueId2);
197 virtual ~LOS_Key(){};
198
199 bool operator<(const LOS_Key& aRhs) const;
200 bool operator==(const LOS_Key& aRhs) const;
201 bool operator==(const unsigned int& aRhs) const;
202 bool operator!=(const LOS_Key& aRhs) const;
203
204 unsigned int mID1;
205 unsigned int mID2;
206 };
207
208 typedef std::map<LOS_Key, bool> LOS_MapType;
209 typedef std::map<LOS_Key, bool>::iterator LOS_MapTypeIterator;
210 typedef std::pair<LOS_Key, bool> LOS_MapTypePair;
211
212 typedef std::list<unsigned int> LOS_RequestType;
213 typedef std::list<unsigned int>::iterator LOS_RequestTypeIterator;
214
215 typedef std::map<unsigned int, unsigned int> PriorityQueueType;
216 typedef std::map<unsigned int, unsigned int>::iterator PriorityQueueTypeIterator;
217 typedef std::pair<unsigned int, unsigned int> PriorityQueueTypePair;
218
219protected:
221
222
223 bool IsTargetVisibleNow(WsfPlatform* aPlatformPtr,
224 WsfPlatform* aTargetPtr,
225 double aMaxRange = 0.0,
226 double aRadiusScale = 1.0);
227
228 bool IsTargetVisibleNow(WsfEM_Antenna* aAntennaPtr,
229 WsfPlatform* aTargetPtr,
230 double aMaxRange = 0.0,
231 double aRadiusScale = 1.0);
232
233 bool IsTargetVisibleNow(WsfEM_Antenna* aAntennaPtr,
234 WsfEM_Antenna* aTargetPtr,
235 double aMaxRange = 0.0,
236 double aRadiusScale = 1.0);
237
239
241 bool Moved(WsfEM_Antenna* aAntennaPtr);
242 bool Moved(WsfPlatform* aPlatformPtr);
243
245 bool LOS_DataExists(/*input*/ unsigned int aID1, unsigned int aID2);
246 bool LOS_DataExists(/*input*/ unsigned int aID1, unsigned int aID2, /*output*/ LOS_MapTypeIterator& aIter);
247 bool LOS_DataExists(/*input*/ unsigned int aID1,
248 unsigned int aID2,
249 LOS_MapType& aLOS_Map,
250 /*output*/ LOS_MapTypeIterator& aIter);
251
253 bool StateDataExists(/*input*/ unsigned int aID);
254 bool StateDataExists(/*input*/ unsigned int aID, /*output*/ StateMapTypeIterator& iter);
255
257 bool SetLOS_Data(/*input*/ unsigned int aID1, unsigned int aID2, bool aVisible);
258 bool SetLOS_Data(/*input*/ unsigned int aID1, unsigned int aID2, bool aVisible, /*output*/ LOS_MapTypeIterator& aIter);
259
261 bool SetStateData(/*input*/ unsigned int aID, State& aNewState);
262 bool SetStateData(/*input*/ unsigned int aID, State& aNewState, /*output*/ StateMapTypeIterator& aIter);
263
265 void DeleteLOS_Data(unsigned int aID, LOS_MapType& aLOS_Map);
266
268 void UpdateStateData(/*output*/ LOS_RequestType& aLOS_RequestQueue);
269
271
272
273 bool PlatformMoved(WsfPlatform* aPlatformPtr);
274 bool PlatformMoveCheck(WsfPlatform* aPlatformPtr, StateMapTypeIterator& aIter);
275
276 bool PartMoved(WsfArticulatedPart* aPartPtr);
278
280
281private:
283 WsfLOS_Manager(const WsfLOS_Manager& aSrc);
284
286 WsfLOS_Manager& operator=(const WsfLOS_Manager& aRhs) = delete;
287
289 class LOS_Thread : public WsfThread, public WsfLOS_ManagerData::ThreadData
290 {
291 public:
293 LOS_Thread(WsfLOS_ManagerData::ThreadData& aData);
294 ~LOS_Thread() override{};
295
296 FunctionType DoWork() override;
297 FunctionType Pause() override { return AVAILABLE; };
298
300 void Initialize(WsfLOS_Manager* aManagerPtr);
301
302 typedef std::set<unsigned int> IdSetType;
303 typedef std::set<unsigned int>::iterator IdSetTypeIterator;
304
306 void ProcessRequests();
307
309 void ProcessPriorityQueue(/*output*/ IdSetType& aIdSet);
310
312 void ProcessThreadLOSData(/*input*/ IdSetType& aIdSet);
313
316 void ProcessRequest(unsigned int aID);
317
319 void CleanUpPriorityQueues(unsigned int aID);
320
322 bool SetThreadLOS_Data(LOS_Key aLOS_Key, bool aVisible);
323
325 bool NoWork();
326
327 WsfLOS_Manager* mManagerPtr;
328 double mTime;
329 LOS_RequestType mRequestQueue;
330
331 IdSetType mIdsToDelete;
332
333 std::vector<PriorityQueueType> mPriorityQueues;
334
335
336 LOS_MapType mThreadLOS_Data;
337 };
338
340 double mLOS_Time;
341
343 LOS_MapType mLOS_Data;
344
346 StateMapType mStateData;
347
349 UtCallbackHolder mCallbacks;
350
352 LOS_Thread mWorkerThread;
353
355 mutable std::recursive_mutex mMutex;
356};
357
358#endif
aObjectPtr Update(simTime)
bool operator!=(int aId, const WsfStringInt &aRhs)
Not equal relational operator for the case of an integer on the LHS and a StringId on the RHS.
Definition WsfStringId.hpp:75
bool operator==(int aId, const WsfStringInt &aRhs)
Equal relational operator for the case of an integer on the LHS and a StringId on the RHS.
Definition WsfStringId.hpp:69
#define WSF_EXPORT
Definition WsfXIO_Export.hpp:35
Definition WsfArticulatedPart.hpp:36
Definition WsfEM_Antenna.hpp:49
WsfLOS_ManagerExtension()
Definition WsfLOS_Manager.hpp:78
Line-of-sight key - a combination of the unique IDs of the two entities.
Definition WsfLOS_Manager.hpp:194
unsigned int mID1
Definition WsfLOS_Manager.hpp:204
virtual ~LOS_Key()
Definition WsfLOS_Manager.hpp:197
unsigned int mID2
Definition WsfLOS_Manager.hpp:205
LOS_Key(unsigned int aUniqueId1, unsigned int aUniqueId2)
Definition WsfLOS_Manager.cpp:1380
State data used in LOS calculations.
Definition WsfLOS_Manager.hpp:166
virtual ~State()
Definition WsfLOS_Manager.hpp:176
double mTime
Definition WsfLOS_Manager.hpp:179
State()
Definition WsfLOS_Manager.hpp:168
double mLLA[3]
Definition WsfLOS_Manager.hpp:181
double mLocationWCS[3]
Definition WsfLOS_Manager.hpp:180
bool mMoved
Definition WsfLOS_Manager.hpp:182
size_t mPlatformIndex
Definition WsfLOS_Manager.hpp:178
std::map< unsigned int, unsigned int > PriorityQueueType
Definition WsfLOS_Manager.hpp:215
bool PlatformMoveCheck(WsfPlatform *aPlatformPtr, StateMapTypeIterator &aIter)
Definition WsfLOS_Manager.cpp:1214
std::list< unsignedint >::iterator LOS_RequestTypeIterator
Definition WsfLOS_Manager.hpp:213
bool Moved(WsfEM_Antenna *aAntennaPtr)
Returns true if entity's movement is greater than the move tolerance (default is true).
Definition WsfLOS_Manager.cpp:916
void SetDebugEnabled(bool aDebugEnabled)
Definition WsfLOS_Manager.hpp:115
std::pair< unsigned int, State > StateMapTypePair
Definition WsfLOS_Manager.hpp:187
std::map< unsignedint, State >::iterator StateMapTypeIterator
Definition WsfLOS_Manager.hpp:186
StateMapType & GetStateData()
Reference to the LOS manager state data so worker thread can use it.
Definition WsfLOS_Manager.hpp:190
std::map< unsignedint, unsignedint >::iterator PriorityQueueTypeIterator
Definition WsfLOS_Manager.hpp:216
std::list< unsigned int > LOS_RequestType
Definition WsfLOS_Manager.hpp:212
std::map< unsigned int, State > StateMapType
Definition WsfLOS_Manager.hpp:185
void PlatformDeleted(double aSimTime, WsfPlatform *aPlatformPtr)
Removes LOS data when a platform is deleted.
Definition WsfLOS_Manager.cpp:198
std::map< LOS_Key, bool > LOS_MapType
Definition WsfLOS_Manager.hpp:208
bool PartMoved(WsfArticulatedPart *aPartPtr)
Definition WsfLOS_Manager.cpp:1276
std::pair< LOS_Key, bool > LOS_MapTypePair
Definition WsfLOS_Manager.hpp:210
bool LOS_DataExists(unsigned int aID1, unsigned int aID2)
Returns true if LOS data exists for the two entities.
Definition WsfLOS_Manager.cpp:939
bool PlatformMoved(WsfPlatform *aPlatformPtr)
Definition WsfLOS_Manager.cpp:1174
void UpdateStateData(LOS_RequestType &aLOS_RequestQueue)
Used in multi-threaded mode; updates the platform and part state data.
Definition WsfLOS_Manager.cpp:1097
bool StateDataExists(unsigned int aID)
Returns true is state data exists for the entity.
Definition WsfLOS_Manager.cpp:982
std::pair< unsigned int, unsigned int > PriorityQueueTypePair
Definition WsfLOS_Manager.hpp:217
void DeleteLOS_Data(unsigned int aID, LOS_MapType &aLOS_Map)
Removes all map entries from the given map with a LOS_Key containing the given ID.
Definition WsfLOS_Manager.cpp:1149
bool SetStateData(unsigned int aID, State &aNewState)
Returns true if state data was successfully updated.
Definition WsfLOS_Manager.cpp:1058
bool IsTargetVisibleNow(WsfPlatform *aPlatformPtr, WsfPlatform *aTargetPtr, double aMaxRange=0.0, double aRadiusScale=1.0)
Definition WsfLOS_Manager.cpp:701
bool PartMoveCheck(WsfArticulatedPart *aPartPtr, StateMapTypeIterator &aIter)
Definition WsfLOS_Manager.cpp:1317
static WsfLOS_Manager * Find(const WsfSimulation &aSimulation)
Definition WsfLOS_Manager.cpp:63
bool SetLOS_Data(unsigned int aID1, unsigned int aID2, bool aVisible)
Returns true if LOS data was successfully updated.
Definition WsfLOS_Manager.cpp:1010
WsfLOS_Manager(WsfLOS_ManagerData &aData)
Definition WsfLOS_Manager.cpp:680
bool DebugEnabled() const
Determine if debugging is enabled.
Definition WsfLOS_Manager.hpp:111
std::map< LOS_Key, bool >::iterator LOS_MapTypeIterator
Definition WsfLOS_Manager.hpp:209
bool Initialize() override
Initialize the LOS manager.
Definition WsfLOS_Manager.cpp:86
Platforms represent a entity within the simulation.
Definition WsfPlatform.hpp:115
WsfScenarioExtension()
Definition WsfScenarioExtension.cpp:21
WsfSimulationExtension()
Definition WsfSimulationExtension.cpp:23
friend class WsfSimulation
Definition WsfSimulationExtension.hpp:43
The main controller for a simulation.
Definition WsfSimulation.hpp:109
Definition WsfThread.hpp:23
WSF_EXPORT InitializeCallback & Initialize(const WsfSimulation *aSimulationPtr)
Definition WsfLOS_Manager.hpp:42
unsigned int mNumPriorityQueues
Definition WsfLOS_Manager.hpp:45
unsigned int mProcessingRate
Definition WsfLOS_Manager.hpp:49
unsigned int mMaxCountPriorityQueue
Number of priority queues; default 3; minimum 1.
Definition WsfLOS_Manager.hpp:46
ThreadData()
Definition WsfLOS_Manager.cpp:1766
bool mDebugEnabled
Number of priority queue entries to process at a time.
Definition WsfLOS_Manager.hpp:50
Definition WsfLOS_Manager.hpp:38
bool mMultiThreaded
Thread behavior.
Definition WsfLOS_Manager.hpp:60
bool mDebugEnabled
Debug flag.
Definition WsfLOS_Manager.hpp:63
ThreadData mThreadData
Definition WsfLOS_Manager.hpp:70
double mMaxAllowableLocDelta
Maximum location change allowed to determine if move occurred.
Definition WsfLOS_Manager.hpp:57
bool ProcessInput(UtInput &aInput)
Process the line_of_sight_manager block.
Definition WsfLOS_Manager.cpp:124
WsfLOS_ManagerData()
Definition WsfLOS_Manager.cpp:1757
bool mVegLayerMaskingEnabled
Vegetation Layer Masking.
Definition WsfLOS_Manager.hpp:66
bool mUseHeightForGroundPlatforms
Definition WsfLOS_Manager.hpp:68
Copyrights Multiple, All Rights Reserved