VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
adsbDataManager.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2022 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
10 
11 #include <vrfutil/adsbTrack.h>
14 #include <vrfutil/scriptGeometry.h>
15 #include <vlpi/entityType.h>
16 
17 #include <atomic>
18 #include <tbb/spin_mutex.h>
19 #include <tbb/spin_rw_mutex.h>
20 #include <tbb/task_arena.h>
21 #include <memory>
22 
24 
26 class DtEntityType;
27 class DtAdsbTrack;
28 class DtAdsbDataManagerJob;
29 
30 namespace MAKVRinTerra
31 {
32  class DtFeatureGeometry;
33 }
34 
35 using DtPathPointIter = std::map<double, DtAdsb::DtPathPoint>::const_iterator;
36 using DtTrackTypeMap = std::map<int, DtEntityType>;
37 
42 {
43 public:
44  typedef std::unordered_map<DtIcaoAddress, DtAdsbTrack*> DtAdsbTrackMap;
45 
48 
50  virtual ~DtAdsbDataManager() override;
51 
54  class DtAdsbManagerTrackHandle;
55  class DtAdsbManagerPointHandle;
56 
59  virtual bool init();
60 
62  virtual double simTime();
63 
65  static void tickCallback(void* usr);
66 
69  virtual void tick();
70 
72  virtual bool isDataLoading() const override;
73 
74  virtual bool isFileLoadError() const override;
75 
76  //\copydoc DtAdsbDataServiceInterface::findTracksInArea()
77  virtual DtAdsbDataJob::Ptr findTracksInArea(const DtVertexList& areaVertices,
78  bool unownedOnly = true) override;
79 
80  //\copydoc DtAdsbDataServiceInterface::findTracksInAreaDuringTime()
81  virtual DtAdsbDataJob::Ptr findTracksInAreaDuringTime(const DtVertexList & areaVertices,
82  double startSimTime, double endSimTime, bool unownedOnly) override;
83 
84 
85  //\copydoc DtAdsbDataServiceInterface::trackInfo()
87  virtual DtTrackHandlePtr trackHandleForAddress(DtIcaoAddress trackId) const override;
88 
91  virtual const DtAdsbTrack* trackObject(DtIcaoAddress trackId) const;
92  virtual DtAdsbTrack* trackObject(DtIcaoAddress trackId);
93 
94 
95  //\copydoc DtAdsbDataServiceInterface::takeOwnershipOfTrack()
96  virtual DtAdsbDataJob::Ptr requestOwnershipOfTracks(
97  const DtIcaoAddrSet& trackIds, const double lastSimTime) override;
98 
99  //\copydoc DtAdsbDataServiceInterface::releaseOwnershipOfTrack()
100  virtual DtAdsbDataJob::Ptr releaseOwnershipOfTracks(const DtIcaoAddrSet& trackIds) override;
101 
102  //\copydoc DtAdsbDataServiceInterface::adsbTimeFromSimTime()
103  virtual double adsbTimeFromSimTime(double simTime) const override;
104 
105  //\copydoc DtAdsbDataServiceInterface::stringForEpochTime()
106  virtual std::string stringForEpochTime(double t) const override;
107 
108  //\copydoc DtAdsbDataServiceInterface::simTimeFromAdsbTime()
109  virtual double simTimeFromAdsbTime(double adsbTime) const override;
110 
111  //\copydoc DtAdsbDataServiceInterface::finalDataSimTime()
112  virtual double finalDataSimTime() const override;
113 
114  //\copydoc DtAdsbDataServiceInterface::firstPointAfterTime()
116  const DtTrackHandlePtr track, double simTime) const override;
117 
118  //\copydoc DtAdsbDataServiceInterface::firstPointAfterTime()
122  const DtAdsbTrack* track, double simTime) const;
123 
124 
125  //\copydoc DtAdsbDataServiceInterface::lastPointBeforeTime()
126  virtual DtPointHandlePtr lastPointBeforeTime(const DtTrackHandlePtr track, double simTime) const override;
127 
128  //\copydoc DtAdsbDataServiceInterface::lastPointBeforeTime()
132  const DtAdsbTrack* track, double simTime) const;
133 
134 
139  virtual void updateSquawkChangedTimestamp(const int icaoAddress, const double& simTime) override;
140 
141  //\copydoc DtAdsbDataServiceInterface::clonePoint()
142  virtual DtPointHandlePtr clonePoint(const DtPointHandlePtr p) const override;
143 
144  //\copydoc DtAdsbDataServiceInterface::getBarometricAltitudeAdjustment()
145  virtual double barometricAltitudeAdjustment(const DtVector& localPosition, const double simTime) const override;
146 
147  //\copydoc DtAdsbDataServiceInterface::resetData()
148  virtual void resetData() override;
149 
154  virtual void loadAdsbData(const double startSimTime, const double endSimTime);
155 
156  virtual int trackToDebug() const { return myTrackToDebug; }
157 
158  virtual void stop();
159  virtual bool timeToStop();
160 
161 protected:
162 
163  friend class DtAdsbDataManagerJob;
164 
167  virtual void performDataReset();
168 
171  virtual void getDataFileName(const int dayOfWeek, const int hourOfDay,
172  char* fName);
173 
178  virtual void getNextFileDayAndHour(int& day, int& hour);
179 
183  virtual void getPreviousFileDayAndHour(int& day, int& hour);
184 
186  virtual bool secondTimeGreaterThanFirst(const int day1, const int hour1,
187  const int day2, const int hour2);
188 
191  virtual void updateSquawkChangedTimestamp(DtAdsbTrack& track, const double simTime);
192 
194  {
197  After
198  };
209  virtual DtIntervalResult getDayHourForFileContainingTime(const double simTime, int& day, int& hour);
210 
222  virtual bool readInfoFile();
223 
225  virtual void startAdsbDataLoad(const double startTime, const double endTime);
226 
229  virtual void calculateTrackTimeOffset();
230 
233  virtual bool readOneDataFile(const int day, const int hour);
234 
235 private:
236 
241 
242 protected:
245 
249 
252 
253  typedef tbb::spin_mutex QueryQueueMutex;
255 
256  mutable tbb::spin_rw_mutex myAdsbDataMutex;
257 
258  typedef std::list<DtAdsbDataJob::Ptr> JobQueue;
266 
277  std::string myBaseFileName;
280 
284 
288 
299 
304 
305  std::atomic<bool> myResetData;
306  std::atomic<bool> myLoadInProgress;
307  std::atomic<bool> myLoadError;
308  std::atomic<bool> myTimeToStop;
309 
312 
313  tbb::task_arena myArena;
314 };
std::list< DtAdsbDataJob::Ptr > JobQueue
Definition: adsbDataManager.h:258
int myLastDataFileHourOfDay
Definition: adsbDataManager.h:279
tbb::spin_rw_mutex myAdsbDataMutex
Definition: adsbDataManager.h:256
JobQueue myNewDataJobs
These jobs are new, and haven&#39;t been checked to see if they can execute immediately or not...
Definition: adsbDataManager.h:261
DtAdsbDataServiceInterface & operator=(const DtAdsbDataServiceInterface &)
Assignment operator not implemented.
virtual void resetData()=0
Marks ADSB data to be reset. This is called in the cgf module when a scenario is rewound, rolled back, or closed. Since as a scenario plays, ADSB data is incrementally deleted from memory, a scenario rewind in general requires that data files be re-read. Therefore this function clears and resets everything in the ADSB data manager so that it reads all files again.
virtual int trackToDebug() const
Definition: adsbDataManager.h:156
tbb::spin_mutex QueryQueueMutex
Definition: adsbDataManager.h:253
DtTime myFirstDataAdsbTime
This is the dateTime at the beginning of the hour of the first ADSB time.
Definition: adsbDataManager.h:292
virtual DtPointHandlePtr firstPointAfterTime(const DtTrackHandlePtr track, double simTime) const =0
Find the first point in the track&#39;s path that occurs after (or at) the specified sim time...
Definition: adsbDataManager.h:196
virtual double finalDataSimTime() const =0
Returns the sim time for the last point of ADSB data available.
virtual DtAdsbDataJob::Ptr requestOwnershipOfTracks(const DtIcaoAddrSet &trackIds, const double lastSimTime)=0
Request ownership of the specified given tracks.
The DtAdsbDataManager loads and manages Automatic Dependent Surveillance - Broadcast (ADS-B) data...
Definition: adsbDataManager.h:41
std::map< double, DtAdsb::DtPathPoint >::const_iterator DtPathPointIter
Definition: adsbDataManager.h:35
int myDataFileTimeInterval
Definition: adsbDataManager.h:275
std::unordered_map< DtIcaoAddress, DtAdsbTrack * > DtAdsbTrackMap
Definition: adsbDataManager.h:44
virtual double adsbTimeFromSimTime(double simTime) const =0
Converts a sim time to ADSB data time. Needed to understand how sim time relates to the timestamps in...
DtIntervalResult
Definition: adsbDataManager.h:193
std::atomic< bool > myLoadError
Definition: adsbDataManager.h:307
JobQueue myJobsReadyToExecute
These jobs can be executed without loading more data.
Definition: adsbDataManager.h:265
std::map< int, DtEntityType > DtTrackTypeMap
Definition: adsbDataManager.h:36
virtual DtAdsbDataJob::Ptr findTracksInAreaDuringTime(const DtVertexList &areaVertices, double startSimTime, double endSimTime, bool unownedOnly)=0
Starts a query for all tracks in the specified area. A track must cross the area between the given si...
JobQueue myJobsWaitingForLoad
These jobs are waiting for more data to be loaded.
Definition: adsbDataManager.h:263
Abstract interface class to the ADSB data service. This service provides access to Automatic Dependen...
Definition: adsbDataServiceInterface.h:121
DtIcaoAddrSet myTracksInUse
List of the subset of tracks that are in use.
Definition: adsbDataManager.h:251
virtual DtAdsbDataJob::Ptr releaseOwnershipOfTracks(const DtIcaoAddrSet &trackIds)=0
Release ownership of the specified tracks.
int myFirstDataFileHourOfDay
Definition: adsbDataManager.h:274
#define DT_DLL_vrfobjcore
This file is used to determine how to build.
Definition: vrfobjcoreDefines.h:24
bool myInfoFileWasRead
Even if the data is reset and reused, the info file doesn&#39;t have to be re-read. This flag also indica...
Definition: adsbDataManager.h:283
virtual DtAdsbDataJob::Ptr findTracksInArea(const DtVertexList &areaVertices, bool unownedOnly=true)=0
Starts a query for all tracks in the specified area. The last point in a track before the current sim...
DtTime myFirstDataDayStartTime
Definition: adsbDataManager.h:276
std::atomic< bool > myLoadInProgress
Definition: adsbDataManager.h:306
std::shared_ptr< DtAdsbTrackHandle > DtTrackHandlePtr
Shared_ptr so that copy constructor will work on the pointer without destroying the rhs...
Definition: adsbDataServiceInterface.h:60
class DtVertexList:
Definition: vertexList.h:22
int myFirstDataFileDayOfWeek
Information read from the info text file that is accompanies the flight track files. The DoW and HoD, when combined with the baseName, indicate the name of the first and last flight track files. The interval (in hours), determines the name of succeeding files. Note that the firstDataFileDayOfWeek is in [0-6], but the lastDataFileDayOfWeek is &gt;= 0 (should be &gt;= myFirstDataFiledayOfWeek + 6).
Definition: adsbDataManager.h:273
virtual bool isDataLoading() const =0
Returns true if ADSB data is being loaded. Tracks should not be accessed when this is true...
DtTime myFirstDataSimTime
Computed from above.
Definition: adsbDataManager.h:294
DtTime myLatestRequestedTime
The latest end time of all data requests received (sim time).
Definition: adsbDataManager.h:301
Definition: adsbDataManager.h:195
DtSimulationServices * mySimulationServices
Definition: adsbDataManager.h:289
virtual bool isFileLoadError() const =0
Indicates that there was an error during the reading of data files, and the data manager cannot provi...
DtTime myAdsbTimeAtSimTime0
Definition: adsbDataManager.h:290
int myLastLoadedDayOfWeek
Indices for last file read.
Definition: adsbDataManager.h:286
DtTime myLatestLoadedTime
The latest time of all data loaded. (sim time)
Definition: adsbDataManager.h:303
QueryQueueMutex myQueryQueueMutex
Definition: adsbDataManager.h:254
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:96
std::set< DtIcaoAddress > DtIcaoAddrSet
Definition: adsbDataServiceInterface.h:127
virtual double simTimeFromAdsbTime(double adsbTime) const =0
Converts the ADSB data time to sim time. Needed to understand how sim time relates to the timestamps ...
DtIcaoAddrSet myUnusedTracks
List of the subset of tracks that are not in use. An unordered set of addresses.
Definition: adsbDataManager.h:248
virtual std::string stringForEpochTime(double t) const =0
Provides a string for the &quot;adsb time&quot; in a path point time stamp. This is useful in finding points in...
DtTime myFinalDataSimTime
Computed from above.
Definition: adsbDataManager.h:298
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
int myLastLoadedHourOfDay
Definition: adsbDataManager.h:287
std::shared_ptr< DtAdsbPathPointHandle > DtPointHandlePtr
Shared_ptr so that copy constructor will work on the pointer without destroying the rhs...
Definition: adsbDataServiceInterface.h:113
Class definition for one track created from ADSB messages, i.e. the identifying information and time-...
Definition: adsbTrack.h:97
virtual void updateSquawkChangedTimestamp(const int icaoAddress, const double &simTime)=0
Find the first point in the track&#39;s path that occurs after the specified sim time that contains a new...
std::string myBaseFileName
ADSB Epoch time of beginning of day for first data.
Definition: adsbDataManager.h:277
std::atomic< bool > myTimeToStop
Definition: adsbDataManager.h:308
tbb::task_arena myArena
Definition: adsbDataManager.h:313
std::atomic< bool > myResetData
Definition: adsbDataManager.h:305
virtual DtPointHandlePtr lastPointBeforeTime(const DtTrackHandlePtr track, double simTime) const =0
Find the last point in the track&#39;s path that occurs before (or at) the specified sim time...
virtual double barometricAltitudeAdjustment(const DtVector &localPosition, const double simTime) const =0
Returns barometric altitude adjustment. This is a distance in meters that is added to the pressure al...
DtAdsbTrackMap myTrackPtrsByIcaoAddress
Index into the track data by ICAO address.
Definition: adsbDataManager.h:244
DtTime myFinalDataAdsbTime
This is the dateTime of the end of the last ADSB data file.
Definition: adsbDataManager.h:296
virtual DtTrackHandlePtr trackHandleForAddress(DtIcaoAddress trackId) const =0
Returns information for the track with the specified address, or an empty pointer if it could not be ...
int myLastDataFileDayOfWeek
Definition: adsbDataManager.h:278
int myTrackToDebug
For debugging. Optionally read in from info file in data. An ICAO address.
Definition: adsbDataManager.h:311
virtual DtPointHandlePtr clonePoint(const DtPointHandlePtr p) const =0
Makes a new point handle that refers to the same path point as p. The original or new handle can late...

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)