VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
DtAdsbDataManager Class Reference

The DtAdsbDataManager loads and manages Automatic Dependent Surveillance - Broadcast (ADS-B) data, which is used to track and monitor real world aircraft. This data can be used to create and simulate clutter entities in a simulation.

Inheritance diagram for DtAdsbDataManager:
Inheritance graph
[legend]

Public Types

typedef std::unordered_map
< DtIcaoAddress, DtAdsbTrack * > 
DtAdsbTrackMap
 
- Public Types inherited from DtAdsbDataServiceInterface
using DtIcaoAddress = int
 
using DtIcaoAddrSet = std::set< DtIcaoAddress >
 

Public Member Functions

 DtAdsbDataManager (DtSimulationServices *simServices)
 
virtual ~DtAdsbDataManager () override
 
virtual bool init ()
 
virtual double simTime ()
 
virtual void tick ()
 
virtual bool isDataLoading () const override
 
virtual bool isFileLoadError () const override
 
virtual DtAdsbDataJob::Ptr findTracksInArea (const DtVertexList &areaVertices, bool unownedOnly=true) override
 
virtual DtAdsbDataJob::Ptr findTracksInAreaDuringTime (const DtVertexList &areaVertices, double startSimTime, double endSimTime, bool unownedOnly) override
 
virtual DtTrackHandlePtr trackHandleForAddress (DtIcaoAddress trackId) const override
 
virtual const DtAdsbTracktrackObject (DtIcaoAddress trackId) const
 
virtual DtAdsbTracktrackObject (DtIcaoAddress trackId)
 
virtual DtAdsbDataJob::Ptr requestOwnershipOfTracks (const DtIcaoAddrSet &trackIds, const double lastSimTime) override
 
virtual DtAdsbDataJob::Ptr releaseOwnershipOfTracks (const DtIcaoAddrSet &trackIds) override
 
virtual double adsbTimeFromSimTime (double simTime) const override
 
virtual std::string stringForEpochTime (double t) const override
 
virtual double simTimeFromAdsbTime (double adsbTime) const override
 
virtual double finalDataSimTime () const override
 
virtual DtPointHandlePtr firstPointAfterTime (const DtTrackHandlePtr track, double simTime) const override
 
virtual DtPointHandlePtr firstPointAfterTime (const DtAdsbTrack *track, double simTime) const
 
virtual DtPointHandlePtr lastPointBeforeTime (const DtTrackHandlePtr track, double simTime) const override
 
virtual DtPointHandlePtr lastPointBeforeTime (const DtAdsbTrack *track, double simTime) const
 
virtual void updateSquawkChangedTimestamp (const int icaoAddress, const double &simTime) override
 
virtual DtPointHandlePtr clonePoint (const DtPointHandlePtr p) const override
 
virtual double barometricAltitudeAdjustment (const DtVector &localPosition, const double simTime) const override
 
virtual void resetData () override
 
virtual void loadAdsbData (const double startSimTime, const double endSimTime)
 
virtual int trackToDebug () const
 
virtual void stop ()
 
virtual bool timeToStop ()
 
- Public Member Functions inherited from DtAdsbDataServiceInterface
 DtAdsbDataServiceInterface ()
 
virtual ~DtAdsbDataServiceInterface ()
 

Static Public Member Functions

static void tickCallback (void *usr)
 

Protected Types

enum  DtIntervalResult { Before, Inside, After }
 
typedef tbb::spin_mutex QueryQueueMutex
 
typedef std::list
< DtAdsbDataJob::Ptr
JobQueue
 

Protected Member Functions

virtual void performDataReset ()
 
virtual void getDataFileName (const int dayOfWeek, const int hourOfDay, char *fName)
 
virtual void getNextFileDayAndHour (int &day, int &hour)
 
virtual void getPreviousFileDayAndHour (int &day, int &hour)
 
virtual bool secondTimeGreaterThanFirst (const int day1, const int hour1, const int day2, const int hour2)
 
virtual void updateSquawkChangedTimestamp (DtAdsbTrack &track, const double simTime)
 
virtual DtIntervalResult getDayHourForFileContainingTime (const double simTime, int &day, int &hour)
 
virtual bool readInfoFile ()
 
virtual void startAdsbDataLoad (const double startTime, const double endTime)
 
virtual void calculateTrackTimeOffset ()
 
virtual bool readOneDataFile (const int day, const int hour)
 

Protected Attributes

DtAdsbTrackMap myTrackPtrsByIcaoAddress
 
DtIcaoAddrSet myUnusedTracks
 
DtIcaoAddrSet myTracksInUse
 
QueryQueueMutex myQueryQueueMutex
 
tbb::spin_rw_mutex myAdsbDataMutex
 
JobQueue myNewDataJobs
 
JobQueue myJobsWaitingForLoad
 
JobQueue myJobsReadyToExecute
 
int myFirstDataFileDayOfWeek
 
int myFirstDataFileHourOfDay
 
int myDataFileTimeInterval
 
DtTime myFirstDataDayStartTime
 
std::string myBaseFileName
 
int myLastDataFileDayOfWeek
 
int myLastDataFileHourOfDay
 
bool myInfoFileWasRead
 
int myLastLoadedDayOfWeek
 
int myLastLoadedHourOfDay
 
DtSimulationServicesmySimulationServices
 
DtTime myAdsbTimeAtSimTime0
 
DtTime myFirstDataAdsbTime
 
DtTime myFirstDataSimTime
 
DtTime myFinalDataAdsbTime
 
DtTime myFinalDataSimTime
 
DtTime myLatestRequestedTime
 
DtTime myLatestLoadedTime
 
std::atomic< boolmyResetData
 
std::atomic< boolmyLoadInProgress
 
std::atomic< boolmyLoadError
 
std::atomic< boolmyTimeToStop
 
int myTrackToDebug
 
tbb::task_arena myArena
 

Private Member Functions

 DtAdsbDataManager (const DtAdsbDataManager &orig)
 
DtAdsbDataManageroperator= (const DtAdsbDataManager &other)
 

Friends

class DtAdsbDataManagerJob
 

Member Typedef Documentation

typedef tbb::spin_mutex DtAdsbDataManager::QueryQueueMutex
protected
typedef std::list<DtAdsbDataJob::Ptr> DtAdsbDataManager::JobQueue
protected

Member Enumeration Documentation

Enumerator
Before 
Inside 
After 

Constructor & Destructor Documentation

DtAdsbDataManager::DtAdsbDataManager ( DtSimulationServices simServices)

Constructs the ADSB data manager.

virtual DtAdsbDataManager::~DtAdsbDataManager ( )
overridevirtual

The destructor.

DtAdsbDataManager::DtAdsbDataManager ( const DtAdsbDataManager orig)
private

copy constructor not defined

Member Function Documentation

virtual bool DtAdsbDataManager::init ( )
virtual

Initializes the ADSB data manager.

Returns
a boolean signifying success or failure.
virtual double DtAdsbDataManager::simTime ( )
virtual

Provide current sim time.

static void DtAdsbDataManager::tickCallback ( void *  usr)
static

Static tick method that is registered with DtSimulationServices callbacks. Calls tick().

virtual void DtAdsbDataManager::tick ( )
virtual

Tick the ADSB data manager. Determines whether tracks have entered or exited areas of interest and calls registered functions to notify them of the change.

virtual bool DtAdsbDataManager::isDataLoading ( ) const
overridevirtual

Returns true if ADSB data has been loaded.

Implements DtAdsbDataServiceInterface.

virtual bool DtAdsbDataManager::isFileLoadError ( ) const
overridevirtual

Indicates that there was an error during the reading of data files, and the data manager cannot provide data.

Implements DtAdsbDataServiceInterface.

virtual DtAdsbDataJob::Ptr DtAdsbDataManager::findTracksInArea ( const DtVertexList areaVertices,
bool  unownedOnly = true 
)
overridevirtual

Starts a query for all tracks in the specified area. The last point in a track before the current sim time must be in the area for the track to be considered in the area.
If unownedOnly is true (the default) then only unowned tracks are returned. areaVertices are in geocentric coordinates.

Implements DtAdsbDataServiceInterface.

virtual DtAdsbDataJob::Ptr DtAdsbDataManager::findTracksInAreaDuringTime ( const DtVertexList areaVertices,
double  startSimTime,
double  endSimTime,
bool  unownedOnly 
)
overridevirtual

Starts a query for all tracks in the specified area. A track must cross the area between the given sim times for the track to be considered in the area. Note that if the startSimTime is before the current sim time, the Data Service may no longer have that path data available.
If unownedOnly is true (the default) then only unowned tracks are returned. areaVertices are in geocentric coordinates.

Implements DtAdsbDataServiceInterface.

virtual DtTrackHandlePtr DtAdsbDataManager::trackHandleForAddress ( DtIcaoAddress  trackId) const
overridevirtual

This will actually return a DtAdsbManagerTrackHandle.

Implements DtAdsbDataServiceInterface.

virtual const DtAdsbTrack* DtAdsbDataManager::trackObject ( DtIcaoAddress  trackId) const
virtual

Not part of the service interface. Gets the underlying track storage structure from an ID. Used by adsb manager jobs.

virtual DtAdsbTrack* DtAdsbDataManager::trackObject ( DtIcaoAddress  trackId)
virtual
virtual DtAdsbDataJob::Ptr DtAdsbDataManager::requestOwnershipOfTracks ( const DtIcaoAddrSet trackIds,
const double  lastSimTime 
)
overridevirtual

Request ownership of the specified given tracks.

Parameters
trackIdsis the set of track IDs that the requester would like to own.
lastSimTimeis the last time of interest for these tracks. This time is used to determine what data to read from files, if the data is not already in memory.

Implements DtAdsbDataServiceInterface.

virtual DtAdsbDataJob::Ptr DtAdsbDataManager::releaseOwnershipOfTracks ( const DtIcaoAddrSet trackIds)
overridevirtual

Release ownership of the specified tracks.

Implements DtAdsbDataServiceInterface.

virtual double DtAdsbDataManager::adsbTimeFromSimTime ( double  simTime) const
overridevirtual

Converts a sim time to ADSB data time. Needed to understand how sim time relates to the timestamps in the ADSB track data.

Implements DtAdsbDataServiceInterface.

virtual std::string DtAdsbDataManager::stringForEpochTime ( double  t) const
overridevirtual

Provides a string for the "adsb time" in a path point time stamp. This is useful in finding points in the source ADSB data for debugging.

Implements DtAdsbDataServiceInterface.

virtual double DtAdsbDataManager::simTimeFromAdsbTime ( double  adsbTime) const
overridevirtual

Converts the ADSB data time to sim time. Needed to understand how sim time relates to the timestamps in the ADSB track data.

Implements DtAdsbDataServiceInterface.

virtual double DtAdsbDataManager::finalDataSimTime ( ) const
overridevirtual

Returns the sim time for the last point of ADSB data available.

Implements DtAdsbDataServiceInterface.

virtual DtPointHandlePtr DtAdsbDataManager::firstPointAfterTime ( const DtTrackHandlePtr  track,
double  simTime 
) const
overridevirtual

Find the first point in the track's path that occurs after (or at) the specified sim time. If no points meet this criteria, an empty pointer is returned. (The caller of this function should check that result.get() != nullPtr before using the result.)

Implements DtAdsbDataServiceInterface.

virtual DtPointHandlePtr DtAdsbDataManager::firstPointAfterTime ( const DtAdsbTrack track,
double  simTime 
) const
virtual

This version of the function is used by manager jobs; it is not part of the adsbDataServiceInterface.

virtual DtPointHandlePtr DtAdsbDataManager::lastPointBeforeTime ( const DtTrackHandlePtr  track,
double  simTime 
) const
overridevirtual

Find the last point in the track's path that occurs before (or at) the specified sim time. If no points meet this criteria, an empty pointer is returned. (The caller of this function should check that result.get() != nullPtr before using the result.)

Implements DtAdsbDataServiceInterface.

virtual DtPointHandlePtr DtAdsbDataManager::lastPointBeforeTime ( const DtAdsbTrack track,
double  simTime 
) const
virtual

This version of the function is used by manager jobs; it is not part of the adsbDataServiceInterface.

virtual void DtAdsbDataManager::updateSquawkChangedTimestamp ( const int  icaoAddress,
const double simTime 
)
overridevirtual

Find the first point in the track's path that occurs after the specified sim time that contains a new squawk code and update the track's mySquawkChangedTimestamp value. If no points meet this criteria, the track's mySquawkChangedTimestamp value is set to infinity, indicating there is no new squawk code in the path points thus far.

Implements DtAdsbDataServiceInterface.

virtual DtPointHandlePtr DtAdsbDataManager::clonePoint ( const DtPointHandlePtr  p) const
overridevirtual

Makes a new point handle that refers to the same path point as p. The original or new handle can later be changed (e.g., with the ++ operator) without affecting the other handle.

Implements DtAdsbDataServiceInterface.

virtual double DtAdsbDataManager::barometricAltitudeAdjustment ( const DtVector &  localPosition,
const double  simTime 
) const
overridevirtual

Returns barometric altitude adjustment. This is a distance in meters that is added to the pressure altitude data in ADSB to determine an altitude in the simulation. Ideally this function would use the measured sea level pressure at the (2D) location at the given time compared to the Standard Atmosphere to calculate the offset. The default function just returns a constant, however.

Implements DtAdsbDataServiceInterface.

virtual void DtAdsbDataManager::resetData ( )
overridevirtual

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.

Implements DtAdsbDataServiceInterface.

virtual void DtAdsbDataManager::loadAdsbData ( const double  startSimTime,
const double  endSimTime 
)
virtual

Loads the ADSB data.

Warning
Should only be called by the thread spawned to load ADSB data. DO NOT CALL THIS FUNCTION DIRECTLY.
virtual int DtAdsbDataManager::trackToDebug ( ) const
inlinevirtual
virtual void DtAdsbDataManager::stop ( )
virtual
virtual bool DtAdsbDataManager::timeToStop ( )
virtual
virtual void DtAdsbDataManager::performDataReset ( )
protectedvirtual

Resets all ADSB data to be unowned. Resets status so that data files must all be read again. Clears all data.

virtual void DtAdsbDataManager::getDataFileName ( const int  dayOfWeek,
const int  hourOfDay,
char fName 
)
protectedvirtual

Uses myBaseFileName and the two arguments to construct a string which is the name of an ADSB data file to read. Puts the string in fName.

virtual void DtAdsbDataManager::getNextFileDayAndHour ( int day,
int hour 
)
protectedvirtual

Given a day and hour, adds one myDataFileInterval and changes day and hour to reflect the new time. Day may increase without bound, but hour is always 0 - 23. The day and hour are expected to be valid values corresponding to an input data file; the result will be the next data file in time.

virtual void DtAdsbDataManager::getPreviousFileDayAndHour ( int day,
int hour 
)
protectedvirtual

Like getNextFileDayAndHour, but the day and hour are decremented by myDataFileInterval. The day may decrease without bound (i.e. to negative values).

virtual bool DtAdsbDataManager::secondTimeGreaterThanFirst ( const int  day1,
const int  hour1,
const int  day2,
const int  hour2 
)
protectedvirtual

Returns true if the second day-hour time is greater than the first.

virtual void DtAdsbDataManager::updateSquawkChangedTimestamp ( DtAdsbTrack track,
const double  simTime 
)
protectedvirtual

This version of the function is not part of the adsb service interface, but is used internally by the adsb data manager.

virtual DtIntervalResult DtAdsbDataManager::getDayHourForFileContainingTime ( const double  simTime,
int day,
int hour 
)
protectedvirtual

Given a day of the week and an hour of the day, find the day and hour of a data file that contains this time. The file day and hour are passed back to the caller in the function arguments. The function uses the conversion from sim time to ADSB data time computed when the info file was read, and it uses myFirst/Final DataAdsbTime computed then as well to determine if the input simTime is in the range covered by the data. If not, false is returned and the day and hour arguments are not set. (Otherwise, true is returned.) The function starts day and hour with the values in myFirsDatafileDayOfWeek/Hour of Day and increments forward by myDataFileTimeInterval to generate day and hour values that correspond to data files.

virtual bool DtAdsbDataManager::readInfoFile ( )
protectedvirtual

Reads the info file for the ADSB data files, which is expected to be in the same directory as the data files and have the name adsbInfo.txt. This file starts with these lines (with the appropriate values):
Data version: 01.00
Start day of week: 0
Start hour of day: 0
Time interval in each file: 6
File name base: adsbData.ads
This data is read into myFirstInputFileDayOfWeek, myFirstInputFileHourOfDay, myDatafileTimeInterval, and myBaseFileName.

Returns
true if successful, false otherwise.
virtual void DtAdsbDataManager::startAdsbDataLoad ( const double  startTime,
const double  endTime 
)
protectedvirtual

Spawns a thread to begin loading ADSB data.

virtual void DtAdsbDataManager::calculateTrackTimeOffset ( )
protectedvirtual

Calculates and sets #myTrackTimeAtSimTime0, which is used to translate between sim time and ADSB track data time.

virtual bool DtAdsbDataManager::readOneDataFile ( const int  day,
const int  hour 
)
protectedvirtual

Read the data file for the give day and hour.

Returns
true if read is successful; false otherwise.
DtAdsbDataManager& DtAdsbDataManager::operator= ( const DtAdsbDataManager other)
private

assignment operator not defined

Friends And Related Function Documentation

friend class DtAdsbDataManagerJob
friend

Member Data Documentation

DtAdsbTrackMap DtAdsbDataManager::myTrackPtrsByIcaoAddress
protected

Index into the track data by ICAO address.

DtIcaoAddrSet DtAdsbDataManager::myUnusedTracks
protected

List of the subset of tracks that are not in use. An unordered set of addresses.

DtIcaoAddrSet DtAdsbDataManager::myTracksInUse
protected

List of the subset of tracks that are in use.

QueryQueueMutex DtAdsbDataManager::myQueryQueueMutex
mutableprotected
tbb::spin_rw_mutex DtAdsbDataManager::myAdsbDataMutex
mutableprotected
JobQueue DtAdsbDataManager::myNewDataJobs
protected

These jobs are new, and haven't been checked to see if they can execute immediately or not.

JobQueue DtAdsbDataManager::myJobsWaitingForLoad
protected

These jobs are waiting for more data to be loaded.

JobQueue DtAdsbDataManager::myJobsReadyToExecute
protected

These jobs can be executed without loading more data.

int DtAdsbDataManager::myFirstDataFileDayOfWeek
protected

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 >= 0 (should be >= myFirstDataFiledayOfWeek + 6).

int DtAdsbDataManager::myFirstDataFileHourOfDay
protected
int DtAdsbDataManager::myDataFileTimeInterval
protected
DtTime DtAdsbDataManager::myFirstDataDayStartTime
protected
std::string DtAdsbDataManager::myBaseFileName
protected

ADSB Epoch time of beginning of day for first data.

int DtAdsbDataManager::myLastDataFileDayOfWeek
protected
int DtAdsbDataManager::myLastDataFileHourOfDay
protected
bool DtAdsbDataManager::myInfoFileWasRead
protected

Even if the data is reset and reused, the info file doesn't have to be re-read. This flag also indicates that no data has been read yet (when it is false).

int DtAdsbDataManager::myLastLoadedDayOfWeek
protected

Indices for last file read.

int DtAdsbDataManager::myLastLoadedHourOfDay
protected
DtSimulationServices* DtAdsbDataManager::mySimulationServices
protected
DtTime DtAdsbDataManager::myAdsbTimeAtSimTime0
protected
DtTime DtAdsbDataManager::myFirstDataAdsbTime
protected

This is the dateTime at the beginning of the hour of the first ADSB time.

DtTime DtAdsbDataManager::myFirstDataSimTime
protected

Computed from above.

DtTime DtAdsbDataManager::myFinalDataAdsbTime
protected

This is the dateTime of the end of the last ADSB data file.

DtTime DtAdsbDataManager::myFinalDataSimTime
protected

Computed from above.

DtTime DtAdsbDataManager::myLatestRequestedTime
protected

The latest end time of all data requests received (sim time).

DtTime DtAdsbDataManager::myLatestLoadedTime
protected

The latest time of all data loaded. (sim time)

std::atomic<bool> DtAdsbDataManager::myResetData
protected
std::atomic<bool> DtAdsbDataManager::myLoadInProgress
protected
std::atomic<bool> DtAdsbDataManager::myLoadError
protected
std::atomic<bool> DtAdsbDataManager::myTimeToStop
protected
int DtAdsbDataManager::myTrackToDebug
protected

For debugging. Optionally read in from info file in data. An ICAO address.

tbb::task_arena DtAdsbDataManager::myArena
protected

The documentation for this class was generated from the following file:

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)