VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
shipClutterAreaController.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 
11 #include <vrfutil/aisTrack.h>
12 
15 
19 {
20 public:
21 
22  using DtMmsiList = std::list<DtAisDataServiceInterface::DtMmsi>;
25  using DtBorderCrossing = std::pair<double, DtVector>;
26  using DtBorderCrossingList = std::vector<DtBorderCrossing>;
27  using DtTrackEventMap = std::multimap<double, DtMmsi>;
28 
30  {
37  GeneralPhase
38  };
39 
42  DtSimulationServices* simManager, DtComponentDescriptor* desc=0, DtReaderWriterRegistry *parentRegistry=0);
43 
45  virtual ~DtShipClutterAreaController();
46 
48  virtual bool init() override;
49 
51  virtual bool postAddComponentsInit() override;
52 
54  virtual void preFirstTickInit() override;
55 
57  virtual const char* type() const override;
58 
60  virtual void registerTaskMsgCallbacks() override;
61 
63  virtual void tick() override;
64 
66  static void setMaxEntitiesCallback(DtSimMessage * msg, void * usr);
67  virtual void processSetMaxEntities(DtSimMessage* msg);
68 
70  static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
71  DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
72 
74  virtual bool taskVisualizationsActive() const override;
75 
76 protected:
77 
79  bool createPSR();
80 
82  virtual void requestPhaseTick();
83 
85  virtual void processTrackInfoPhaseTick();
86 
88  virtual void ownershipAcquisitionPhaseTick();
89 
91  virtual void creationPhaseTick();
92 
95  virtual void deletionPhaseTick();
96 
99  virtual void generalPhaseTick();
100 
102  virtual void requestTracksInArea();
103 
106  virtual bool processTrackAdditionEvents();
107 
110  virtual bool processTrackRemovalEvents();
111 
113  virtual void processTrackOwnershipResponse(const DtMmsiSet& tracks);
114 
116  virtual void updateKnownTracks(const DtMmsiSet& tracks);
117 
120  virtual void calculateAdditionAndRemovalTimes();
121 
123  virtual bool requestTrackOwnership(DtMmsiSet& tracks);
124 
126  virtual void releaseTrackOwnership(const DtMmsiSet& tracks);
127 
129  virtual bool createEntitiesForTracks();
130 
133  virtual void monitorNewEntities();
134 
136  virtual void processEntityDeleted(const DtSimObject* entity);
137 
139  virtual void processEntityPromoted(const DtSimObject* entity);
140 
142  void cleanupRemovedEntities();
143 
145  void recordPromotedEntities();
146 
148  virtual DtObjectType objectTypeForTrack(const DtAisTrack& track) const;
149 
154  virtual bool calculateTrackPositionAtTime(double simTime, const DtAisTrack& track,
155  DtVector& worldLocation, double& heading, DtVector& velocity,
156  const DtPathPoint** previousPathPoint) const;
157 
159  virtual bool findLastBorderCrossingTime(
160  const DtPathPoint& pt1, const DtPathPoint& pt2,
161  std::vector<DtVector>& areaBorder,
162  const DtMmsi trackId, double& crossingTime);
163 
165  virtual bool locationNear2IsInside(const DtVector& location1,
166  const DtVector& location2,
167  const DtLocalVertexList& areaVertices, Coordinate_System* coordSys);
168 
169 
173  virtual void trackPositionAtPoint(const DtAisTrack& track,
174  const DtAisPathPointMap::const_iterator point,
175  DtVector& worldLocation, double& heading, DtVector& worldVelocity) const;
176 
184  virtual bool approximateBorderCrossings(double startTime, const DtVector& startLocation,
185  double endTime, const DtVector& endLocation, std::vector<DtVector>& areaBorder,
186  DtBorderCrossingList& borderLocations) const;
187 
189  virtual void markAllEntitiesForDeletion();
190 
193  virtual void markEntitiesOutsideOfAreaForDeletion();
194 
197  virtual void markExcessEntitiesForDeletion();
198 
200  virtual void deleteMarkedEntities();
201 
203  virtual bool isTimeToRequestTracks(double simTime) const;
204 
206  virtual bool isTimeForTrackAdditionEvent(double simTime) const;
207 
209  virtual bool isTimeForTrackRemovalEvent(double simTime) const;
210 
212  virtual void logEntityCreationStatistics();
213 
215  virtual void updateTaskVisualizations() override;
216 
218  virtual void setPhase(ProcessingPhase);
219 
220 private:
227 
228 protected:
229 
231 
233 
241  std::list<DtUUID> myEntitiesToDelete;
242  std::list<DtUUID> myNewEntities;
243 
245 
246  tbb::spin_mutex myRemovedEntitiesMutex;
248 
249  tbb::spin_mutex myPromotedEntitiesMutex;
251 
255  mutable tbb::spin_mutex myExcludedModelsMutex;
256  mutable std::set<DtObjectType> excludedModels;
257 
258  using EntityDeletionSignalMap = std::map<DtMmsi, boost::signals2::connection>;
260 
261  using EntityPromotedSignalMap = std::map<DtMmsi, boost::signals2::connection>;
263 
267 
270 
274 
277  mutable std::vector<DtVector> myPreCreatePts;
278  mutable std::vector<DtVector> myPostCreatePts;
279  mutable std::vector<DtVector> myCreatePts;
280 
281  mutable std::vector<DtVector> myPreExitPts;
282  mutable std::vector<DtVector> myPostExitPts;
283  mutable std::vector<DtVector> myExitPts;
284 
285  mutable std::vector<DtVector> myPreEnterPts;
286  mutable std::vector<DtVector> myPostEnterPts;
287  mutable std::vector<DtVector> myEnterPts;
288 };
289 
std::vector< DtVector > myPreCreatePts
Definition: shipClutterAreaController.h:277
Instances of DtShipClutterAreaPSR are used to hold the checkpointable state data for the DtShipClutte...
Definition: shipClutterAreaPSR.h:15
DtMmsiSet myRemovedEntities
Definition: shipClutterAreaController.h:247
Definition: shipClutterAreaController.h:34
#define DT_DLL_vrfmodel
This file is used to determine how to build.
Definition: vrfmodelDefines.h:24
bool myDebugEnabled
The following are for debug purposes only.
Definition: shipClutterAreaController.h:276
Definition: shipClutterAreaController.h:32
DtTrackEventMap myTrackAdditionTimes
Definition: shipClutterAreaController.h:235
unsigned myNumberSkippedRecently
Definition: shipClutterAreaController.h:273
DtTime myDataEndTime
Definition: shipClutterAreaController.h:244
DtAisDataServiceInterface::DtMmsiSet DtMmsiSet
Definition: shipClutterAreaController.h:23
std::vector< DtVector > myPostEnterPts
Definition: shipClutterAreaController.h:286
Definition: shipClutterAreaController.h:36
virtual bool postAddComponentsInit() override
Calls enableTaskTypes()
int DtMmsi
Definition: aisDataServiceInterface.h:33
DtAisDataServiceInterface::DtAisDataJob::Ptr myAisOwnershipReq
Definition: shipClutterAreaController.h:266
virtual const char * type() const override=0
Returns a string identifies the class type of component. Type values are defined in compTypes...
std::vector< DtVector > myExitPts
Definition: shipClutterAreaController.h:283
virtual void registerTaskMsgCallbacks()
std::list< DtAisDataServiceInterface::DtMmsi > DtMmsiList
Definition: shipClutterAreaController.h:22
std::multimap< double, DtMmsi > DtTrackEventMap
Definition: shipClutterAreaController.h:27
virtual void preFirstTickInit()
This function can be overridden to initialize a component before it is ticked for the first time...
This class provides a base class for all controllers that are capable of executing a DtSimTask...
Definition: singleTaskControllerComponent.h:22
std::map< DtMmsi, boost::signals2::connection > EntityDeletionSignalMap
Definition: shipClutterAreaController.h:258
A readable, writable type whose name is the name of a component and that has a list of component name...
Definition: componentDescriptor.h:49
Definition: readerWriterRegistry.h:39
DtShipClutterAreaPSR * myProcessState
Definition: shipClutterAreaController.h:232
This class hold ship data that is obtained from AIS messages. It is generated initially by the proces...
Definition: aisTrack.h:24
tbb::spin_mutex myPromotedEntitiesMutex
Definition: shipClutterAreaController.h:249
ProcessingPhase
Definition: shipClutterAreaController.h:29
virtual bool taskVisualizationsActive() const override
Returns true if task visualizations are currently active for this component. Default behavior for tas...
DtAisDataServiceInterface::DtAisDataJob::Ptr myAisTrackReq
Requests to the AIS data manager.
Definition: shipClutterAreaController.h:265
DtMmsiSet myPromotedEntities
Definition: shipClutterAreaController.h:250
EntityDeletionSignalMap myEntityDeletionSignals
Definition: shipClutterAreaController.h:259
std::set< DtMmsi > DtMmsiSet
Definition: aisDataServiceInterface.h:34
std::vector< DtVector > myPostExitPts
Definition: shipClutterAreaController.h:282
Definition: objectType.h:27
std::vector< DtVector > myPreExitPts
Definition: shipClutterAreaController.h:281
virtual void updateTaskVisualizations()
Called to update task visualizations after every tick. Implemented by subclasses. ...
Definition: simComponent.h:437
virtual bool init() override
Calls setRadio()
std::shared_ptr< DtAisDataJob > Ptr
Definition: aisDataServiceInterface.h:43
tbb::spin_mutex myRemovedEntitiesMutex
Definition: shipClutterAreaController.h:246
Definition: coordSystem.h:54
std::pair< double, DtVector > DtBorderCrossing
Definition: shipClutterAreaController.h:25
File: simMsg.h.
Definition: simMessage.h:35
Class definition for one track created from AIS messages, i.e. the identifying information and time-s...
Definition: aisTrack.h:60
virtual void tick()
This gives the thread of control to the component. The component is ticked once each simulation from ...
Definition: shipClutterAreaController.h:33
ProcessingPhase myPhase
Definition: shipClutterAreaController.h:268
std::set< DtObjectType > excludedModels
Definition: shipClutterAreaController.h:256
std::list< DtUUID > myEntitiesToDelete
Definition: shipClutterAreaController.h:241
DtMmsiList myKnownTracksToProcess
Definition: shipClutterAreaController.h:234
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:94
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:91
DtMmsiList myTracksToCreate
Definition: shipClutterAreaController.h:240
DtMmsiSet myTracksToRequest
Definition: shipClutterAreaController.h:238
Represents a single simulation object in the exercise. Object may be VRF simulation, or non-VRF simulated, and may be simulated by the local sim engine, or by a remote sim engine. Only public (external) state of the object is available. All data is read-only. All access to data of the object is thread safe within the simulation frame.
Definition: simObject.h:88
const DtTaskControllerComponent & operator=(const DtTaskControllerComponent &orig)
assignment operator
tbb::spin_mutex myExcludedModelsMutex
A cache of object type patterns that are to be excluded. An empty set is also valid. This is compared against to limit the object types possible to be represented for a track.
Definition: shipClutterAreaController.h:255
std::vector< DtVector > myCreatePts
Definition: shipClutterAreaController.h:279
std::vector< DtVector > myPostCreatePts
Definition: shipClutterAreaController.h:278
std::list< DtUUID > myNewEntities
Definition: shipClutterAreaController.h:242
/******************************************************************************* ** Copyright (c) 202...
Definition: shipClutterAreaControllerDescriptor.h:18
DtTrackEventMap myDelayedAdditionTimes
Definition: shipClutterAreaController.h:237
bool myCreatingEntitiesFromSave
Definition: shipClutterAreaController.h:269
Definition: shipClutterAreaController.h:31
Definition: shipClutterAreaController.h:35
DtMmsiSet myTracksRequested
Definition: shipClutterAreaController.h:239
DtShipClutterAreaController is a controller that runs on an area tactical graphic to create and manag...
Definition: shipClutterAreaController.h:18
DtShipClutterAreaControllerDescriptor * myShipClutterAreaDescriptor
Definition: shipClutterAreaController.h:230
EntityPromotedSignalMap myEntityPromotedSignals
Definition: shipClutterAreaController.h:262
class DtLocalVertexList:
Definition: localVertexList.h:20
std::vector< DtVector > myEnterPts
Definition: shipClutterAreaController.h:287
std::vector< DtBorderCrossing > DtBorderCrossingList
sim time and world location to cross a border
Definition: shipClutterAreaController.h:26
DtTrackEventMap myTrackRemovalTimes
Definition: shipClutterAreaController.h:236
std::map< DtMmsi, boost::signals2::connection > EntityPromotedSignalMap
Definition: shipClutterAreaController.h:261
A locally simulated VRF object. Holds all internal and external data for the object, and provides access to both the current frame and next frame state data for the object. All current frame data is read-only, and next-frame data can be written to. No thread safety guarantees are made on this object during the simulation frame and it should only be accessed by the thread that is simulating the object.
Definition: localObject.h:86
std::vector< DtVector > myPreEnterPts
Definition: shipClutterAreaController.h:285
unsigned myNumberCreatedRecently
For logging purposes only.
Definition: shipClutterAreaController.h:272

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)