VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
spawnController.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2022 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
15 #include <vrfmsgs/rwSpawnData.h>
18 
22 
24 #include <tbb/mutex.h>
25 
26 class DtString;
28 class DtVrfObjectMessage;
29 class DtRwEntityTypeInfo;
30 class DtSimMessage;
32 
37 
43 {
44 public:
45 
46 //****************************************************************************
48 //****************************************************************************
49  DtSpawnController(const DtString& name,
50  DtLocalObject* owner,
51  DtSimulationServices* simManager,
52  DtComponentDescriptor* desc = 0,
53  DtReaderWriterRegistry* parentRegistry = 0);
54 
56  virtual ~DtSpawnController() override;
57 
58  virtual const char* type() const override;
59 
63  static DtSimComponent * creator(const DtString& name,
64  DtLocalObject* owner,
65  DtSimulationServices* simManager,
66  DtComponentDescriptor* desc = 0,
67  DtReaderWriterRegistry* parentRegistry = 0);
68 
70  const DtString& templateName() const;
71 
72 //****************************************************************************
74 //****************************************************************************
75  static void settingConsumerCallback(const DtSettingsObject* settingsObject,
76  void* usr);
77 
79 
81  virtual void registerTaskMsgCallbacks();
83 
85  virtual void unregisterTaskMsgCallbacks();
86 
87  virtual bool init() override;
88  virtual void refreshSpawnTemplateData();
89 
90 protected:
91  virtual void processSetting(const DtBoolSetting* setting);
92 
93  virtual DtSpawnControllerPSR* createPSR();
94 
96  virtual DtCollisionDetector* createCollisionDetector();
97 
98 //****************************************************************************
100 //****************************************************************************
101  static void requestSpawnPtDataCallback(const DtVrfObjectMessage * msg,
102  void* usr);
103  virtual void processRequestSpawnPtDataCallback(const DtVrfObjectMessage * msg);
104 
105  static void setTemplateUUIDCallback(const DtVrfObjectMessage * msg, void* usr);
106  virtual void processSetTemplateUUIDCallback(const DtVrfObjectMessage * msg);
107 
108  virtual void processSimObjectDeleted(DtSimObjectReference ref);
109 
113  virtual void embarkIfSpawnAttached(DtVrfLocalObjectCreateInformation& info);
114 
115 //****************************************************************************
117 //****************************************************************************
118 public:
124  virtual void preFirstTickInit() override;
125 
127  virtual void tick() override;
128 
129 protected:
130 
131 //****************************************************************************
133 //****************************************************************************
136  virtual std::list<DtSimObjectReference> testAndSinkTraffic();
139  virtual bool shouldSinkObject(const DtSimObject* trafficObject,
140  const DtSimObject* sinkPoint) const;
142  virtual void deleteObjects(const std::list<DtSimObjectReference>& objectList);
143 
155  virtual bool canCreateNow(DtTime timeNow, DtRwSpawnData* spawnData) const;
156 
158  virtual DtUUID findSinkPoint();
159 
163  virtual DtTime nextCreationTime(DtTime timeNow, DtRwSpawnData* spawnData);
164 
165  virtual DtCreateObjectHandle createObject(const DtUUID& spawnObjectUUID, const DtSimObject* sinkPoint, const DtRwSpawnData* spawnData,
166  bool& dataAvailable, const DtPlan& entityPlan);
168  virtual DtVector creationLocationAndOrientation(double& heading,
169  const DtSimObject* sinkPoint, const DtRwSpawnData* spawnData, bool& dataAvailable);
170 
173  virtual DtPlan createDefaultPlan(const DtUUID& objectUUID, const DtUUID& sinkPoint, DtRwSpawnData* spawnData);
174 
177  virtual double trafficSpeed(DtRwSpawnData* spawnData);
178 
182  virtual bool trafficObjectType(DtRwEntityTypeInfo& objType, const DtRwSpawnData* spawnData);
183 
185  void findClosestRoadSpawnPoints();
186 
187  static void clearTemplatesCallback(void* user);
188  virtual void processClearTemplates();
189 
190  static void refreshSpawnTemplateDataCallback(void* user);
191  virtual void processRefreshSpawnTemplateData();
192 
195  virtual bool startLocationTaken(const DtSimObject*, const DtVector& geocentricLocation);
196  virtual bool startLocationTaken(const DtEntityType&, const DtVector& geocentricLocation);
197 
198 protected:
199 
200  virtual DtRwSpawnData* lookupSpawnTemplateData();
201 
202 private:
205 
208 
210  const DtSpawnController & operator=(const DtSpawnController & orig);
211 
212 
213 protected:
214 
219 
225 
228 
233  //DtRwSpawnData* mySpawnTemplateData;
234 
237 
239 
240  boost::signals2::scoped_connection mySimObjectDeletedConnection;
242  tbb::mutex myRemovalMutex;
243 };
UUID is a unique ID wrapper class.
Definition: uuid.h:59
DtPoint myClosestRoadEdgeA
Definition: spawnController.h:223
tbb::mutex myRemovalMutex
Definition: spawnController.h:242
#define DT_DLL_vrfmodel
This file is used to determine how to build.
Definition: vrfmodelDefines.h:24
bool myShowRoadDistanceWarning
Definition: spawnController.h:226
const DtControllerComponent & operator=(const DtControllerComponent &orig)
assignment operator
Handle returned from Create Object Service calls.
Definition: createObjectHandle.h:12
Definition: boolSetting.h:30
This controller is part of the traffic spawn system. It creates new entities at a defined interval an...
Definition: spawnController.h:42
DtPoint myClosestRoadEdgeB
Definition: spawnController.h:224
virtual void preFirstTickInit()
This function can be overridden to initialize a component before it is ticked for the first time...
bool myWarnedSinkOnce
Definition: spawnController.h:232
A readable, writable type whose name is the name of a component and that has a list of component name...
Definition: componentDescriptor.h:49
Descriptor for DtSpawnController.
Definition: spawnControllerDescriptor.h:21
virtual const char * type() const override=0
This returns a string from compTypes.h, and identifies the type of component.
Definition: readerWriterRegistry.h:39
The DtLocalObjectCreateInformation class is a subset of the information used in the DtIfCreateVrfObje...
Definition: vrfLocalObjectCreateInformation.h:26
DtCollisionDetector * myCollisionDetector
Definition: spawnController.h:236
Definition: settingsObject.h:27
bool myWarnedOnce
Definition: spawnController.h:231
boost::signals2::scoped_connection mySimObjectDeletedConnection
Definition: spawnController.h:240
DtPoint myCachedLocation
Definition: spawnController.h:220
Process state repository used to store runtime state of the DtSpawnController.
Definition: spawnControllerPSR.h:23
bool myDrivingOnLeftEnabled
Definition: spawnController.h:217
virtual bool init() override
Calls setRadio()
DtTacticalGraphicLocalObjectFacade myTacticalGraphicLocalObjectFacade
Definition: spawnController.h:241
int myAwaitingToBeCreated
Count of number of objects that are pending to be created due to data not being available.
Definition: spawnController.h:230
Base library for data that is used to control how spawn points generate entities. This data structure...
Definition: rwSpawnData.h:37
File: simMsg.h.
Definition: simMessage.h:35
virtual void tick()
This gives the thread of control to the component. The component is ticked once each simulation from ...
The DtCollisionDetector is a class used to detect collisions between a specified list of obstructions...
Definition: collisionDetector.h:57
The base class for all messages to/from a specific DtVrfObject. Various subclasses of this class will...
Definition: vrfObjectMessage.h:30
DtVrfOverlayObjectStateRepository * myStateRepository
Definition: spawnController.h:235
DtReal mySinkPointRadiusSq
Definition: spawnController.h:218
End User Description: DtControllerComponent is the base class for all controllers components...
Definition: controllerComponent.h:31
class DtPlan:
Definition: plan.h:92
const DtSpawnControllerDescriptor * myTrafficSourceDescriptor
Definition: spawnController.h:216
DtRwEntityTypeInfo holds a display name and force number along with the type enumeration. Used in spawn data messages.
Definition: rwEntityTypeInfo.h:17
float myScaleFactor
Definition: spawnController.h:238
DtPoint myClosestRoadPoint
Definition: spawnController.h:222
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:96
bool myFoundRoadPoints
Definition: spawnController.h:221
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:89
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:80
Definition: vrfOverlayObjectStateRepository.h:30
bool myDataReady
Definition: spawnController.h:227
DtSpawnControllerPSR * myProcessState
Definition: spawnController.h:215
Definition: point.h:34
A locally simulated VRF object.
Definition: localObject.h:98

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)