VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
aisDataManager.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 
13 
14 #include <atomic>
15 #include <tbb/spin_mutex.h>
16 #include <tbb/task_arena.h>
17 #include <memory>
18 
20 
22 class DtEntityType;
23 class DtAisTrack;
24 class DtAisDataManagerJob;
25 
26 namespace MAKVRinTerra
27 {
28  class DtFeatureGeometry;
29 }
30 
35 {
36 public:
37 
38  typedef std::vector<DtAisTrack> DtAisTrackBuffer;
39  typedef std::list<DtAisTrack*> DtAisTrackList;
40  typedef std::unordered_map<DtMmsi, DtAisTrack*> DtAisTrackMap;
41 
44 
46  virtual ~DtAisDataManager() override;
47 
50  virtual bool init();
51 
53  static void tickCallback(void* usr);
54 
57  virtual void tick();
58 
60  virtual bool isDataLoaded() const override;
61 
62  //\copydoc DtAisDataServiceInterface::findTracksInArea()
63  virtual DtAisDataJob::Ptr findTracksInArea(const DtVertexList& areaVertices,
64  bool unownedOnly = true) override;
65 
66  //\copydoc DtAisDataServiceInterface::findTracksInAreaDuringTime()
67  virtual DtAisDataJob::Ptr findTracksInAreaDuringTime(const DtVertexList & areaVertices,
68  double startSimTime, double endSimTime, bool unownedOnly) override;
69 
70  //\copydoc DtAisDataServiceInterface::trackInfo()
71  virtual const DtAisTrack* trackInfo(DtMmsi trackId) const override;
72 
73  //\copydoc DtAisDataServiceInterface::takeOwnershipOfTrack()
74  virtual DtAisDataJob::Ptr requestOwnershipOfTracks(const DtMmsiSet& trackIds) override;
75 
76  //\copydoc DtAisDataServiceInterface::releaseOwnershipOfTrack()
77  virtual DtAisDataJob::Ptr releaseOwnershipOfTracks(const DtMmsiSet& trackIds) override;
78 
79  //\copydoc DtAisDataServiceInterface::aisTimeFromSimTime()
80  virtual double aisTimeFromSimTime(double simTime) const override;
81 
82  //\copydoc DtAisDataServiceInterface::simTimeFromAisTime()
83  virtual double simTimeFromAisTime(double aisTime) const override;
84 
85  //\copydoc DtAisDataServiceInterface::finalDataSimTime()
86  virtual double finalDataSimTime() const override;
87 
88  //\copydoc DtAisDataServiceInterface::getFirstPointAfterTime()
89  virtual bool getFirstPointAfterTime(const DtAisTrack& track, double simTime,
90  DtPathPointIter& pathPointIter) const override;
91 
92  //\copydoc DtAisDataServiceInterface::getLastPointBeforeTime()
93  virtual bool getLastPointBeforeTime(const DtAisTrack& track, double simTime,
94  DtPathPointIter& pathPointIter) const override;
95 
96  //\copydoc DtAisDataServiceInterface::getEndOfPath()
97  virtual DtPathPointIter getEndOfpath(const DtAisTrack& track) const override;
98 
99  //\copydoc DtAisDataServiceInterface::resetData()
100  virtual void resetData() override;
101 
102  //\copydoc DtAisDataServiceInterface::clearData()
103  virtual void clearData() override;
104 
108  virtual void loadAisData();
109 
110  virtual bool isDataLoading() const;
111  virtual bool timeToStop() const;
112  virtual void stop();
113 
114 protected:
115 
116  friend class DtAisDataManagerJob;
117 
119  virtual void performDataClear();
120 
122  virtual void performDataReset();
123 
125  virtual void startAisDataLoad();
126 
129  virtual void calculateTrackTimeOffset();
130 
131 private:
132 
134  DtAisDataManager(const DtAisDataManager& orig);
137 
138 protected:
139 
142 
145 
148 
151 
152  typedef tbb::spin_mutex QueryQueueMutex;
154 
155  typedef std::list<DtAisDataJob::Ptr> JobQueue;
157 
164 
165  std::atomic<bool> myClearData;
166  std::atomic<bool> myResetData;
167  std::atomic<bool> myResetTimeOffset;
168  std::atomic<bool> myDataIsLoaded;
169  std::atomic<bool> myLoadInProgress;
170 
171  std::atomic<bool> myWarnedOnce;
172  std::atomic<bool> myTimeToStop;
173  tbb::task_arena myArena;
174 };
DtAisTrackMap myTracksByMmsi
Index into the track data by MMSI.
Definition: aisDataManager.h:144
tbb::spin_mutex QueryQueueMutex
Definition: aisDataManager.h:152
DtSimulationServices * mySimulationServices
Definition: aisDataManager.h:158
std::atomic< bool > myLoadInProgress
Definition: aisDataManager.h:169
std::atomic< bool > myResetTimeOffset
Definition: aisDataManager.h:167
std::atomic< bool > myWarnedOnce
Definition: aisDataManager.h:171
virtual bool isDataLoaded() const =0
Returns true if AIS data has been loaded.
DtTime myFinalDataAisTime
Definition: aisDataManager.h:162
virtual double simTimeFromAisTime(double aisTime) const =0
Converts the AIS data time to sim time. Needed to understand how sim time relates to the timestamps i...
tbb::task_arena myArena
Definition: aisDataManager.h:173
Abstract interface class to the AIS data service. This service provides access to Automatic Identific...
Definition: aisDataServiceInterface.h:28
JobQueue myJobQueue
Definition: aisDataManager.h:156
virtual bool getFirstPointAfterTime(const DtAisTrack &track, double simTime, DtPathPointIter &pathPointIter) const =0
Find the first point in the track&#39;s path that occurs after (or at) the specified sim time...
QueryQueueMutex myQueryQueueMutex
Definition: aisDataManager.h:153
DtTime myTrackTimeAtSimTime0
Definition: aisDataManager.h:159
virtual bool getLastPointBeforeTime(const DtAisTrack &track, double simTime, DtPathPointIter &pathPointIter) const =0
Find the last point in the track&#39;s path that occurs before (or at) the specified sim time...
virtual double aisTimeFromSimTime(double simTime) const =0
Converts a sim time to AIS data time. Needed to understand how sim time relates to the timestamps in ...
std::atomic< bool > myDataIsLoaded
Definition: aisDataManager.h:168
virtual void clearData()=0
Marks AIS data to be cleared. Data will be completely unloaded.
virtual DtAisDataJob::Ptr findTracksInAreaDuringTime(const DtVertexList &areaVertices, double startSimTime, double endSimTime, bool unownedOnly)=0
Starts a query for all tracks in the specified area. If unownedOnly is true (the default) then only u...
std::set< DtMmsi > DtMmsiSet
Definition: aisDataServiceInterface.h:34
std::list< DtAisDataJob::Ptr > JobQueue
Definition: aisDataManager.h:155
virtual DtAisDataJob::Ptr requestOwnershipOfTracks(const DtMmsiSet &trackIds)=0
Request ownership of the specified given tracks.
std::atomic< bool > myResetData
Definition: aisDataManager.h:166
DtTime myFinalDataSimTime
Definition: aisDataManager.h:163
#define DT_DLL_vrfobjcore
This file is used to determine how to build.
Definition: vrfobjcoreDefines.h:24
virtual DtAisDataJob::Ptr releaseOwnershipOfTracks(const DtMmsiSet &trackIds)=0
Release ownership of the specified tracks.
std::atomic< bool > myTimeToStop
Definition: aisDataManager.h:172
std::list< DtAisTrack * > DtAisTrackList
Definition: aisDataManager.h:39
class DtVertexList:
Definition: vertexList.h:22
Class definition for one track created from AIS messages, i.e. the identifying information and time-s...
Definition: aisTrack.h:60
virtual DtPathPointIter getEndOfpath(const DtAisTrack &track) const =0
Returns an iterator to the end of the path (i.e. path.end()).
virtual const DtAisTrack * trackInfo(DtMmsi trackId) const =0
Returns information for the track with the specified MMSI, or nullptr if it could not be found...
std::unordered_map< DtMmsi, DtAisTrack * > DtAisTrackMap
Definition: aisDataManager.h:40
DtMmsiSet myUnusedTracks
List of the subset of tracks that are not in use.
Definition: aisDataManager.h:147
DtMmsiSet myTracksInUse
List of the subset of tracks that are in use.
Definition: aisDataManager.h:150
virtual void resetData()=0
Marks AIS data to be reset. Data will not be unloaded, but ownership of all tracks will be reset to u...
virtual double finalDataSimTime() const =0
Returns the sim time for the last point of AIS data available.
DtAisTrackBuffer myTracks
Buffer containing information on all loaded AIS tracks.
Definition: aisDataManager.h:141
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:96
std::map< double, DtPathPoint >::const_iterator DtPathPointIter
Definition: aisDataServiceInterface.h:36
DT_DLL_DEBUGDRAWRENDERER void init(makVrv::DtDe &de)
Work function for the plugin initialization.
std::vector< DtAisTrack > DtAisTrackBuffer
Definition: aisDataManager.h:38
DtTime myFirstDataAisTime
Definition: aisDataManager.h:160
std::atomic< bool > myClearData
Definition: aisDataManager.h:165
virtual DtAisDataJob::Ptr findTracksInArea(const DtVertexList &areaVertices, bool unownedOnly=true)=0
Starts a query for all tracks in the specified area. If unownedOnly is true (the default) then only u...
The DtAisDataManager loads and manages Automatic Identification System (AIS) data, which is used to track and monitor real world ships. This data can be used to create and simulate clutter entities in a simulation.
Definition: aisDataManager.h:34
DtAisDataServiceInterface & operator=(const DtAisDataServiceInterface &)
Assignment operator not implemented.
DtTime myFirstDataSimTime
Definition: aisDataManager.h:161

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)