VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
launcherController.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2012 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
10 
11 #pragma once
12 
20 #include <boost/signals2.hpp>
21 #include <tbb/spin_mutex.h>
22 
23 class DtLauncherControllerDescriptor;
24 class DtStringOutputPort;
25 class DtVectorOutputPort;
26 
27 namespace makVrfEvents
28 {
29  class DtEvent;
30 }
31 
66 {
67 
68 public:
69 
72  DtLauncherController(const DtString& name,
73  DtLocalObject* owner,
74  DtSimulationServices* simManager,
75  DtComponentDescriptor* desc = nullptr,
76  DtReaderWriterRegistry* parentRegistry = nullptr);
77 
79  virtual ~DtLauncherController() override;
80 
81  virtual bool init() override;
82 
84  virtual void registerTaskMsgCallbacks() override;
85 
88  virtual AcceptLevel acceptTask(const DtTaskMessage& task) override;
89 
92  virtual const char* type() const override;
93 
95  virtual void tick() override;
96 
99  virtual bool createMissileIdPort();
100  virtual bool createTargetPointPort();
101  virtual bool createTargetEntityIdPort();
102 
105  virtual void fire() override;
106 
113  virtual void missileDetonated(const makVrfEvents::DtDetonationEvent * detInter);
114 
118  virtual void detonationCallback(const makVrfEvents::DtEvent& e);
119 
128  virtual void disconnectMissileFromLauncher(const DtUUID& missId);
129 
131  virtual DtSimObjectReference mostRecentMissileFired();
132 
136  virtual bool missilePassedTarget(const DtMissileSimObjectFacade& lastMissile, double& distSquaredToTargetOut);
137 
138  virtual double abandonPassedMissileDistance();
139  virtual void setAbandonPassedMissileDistance(const double& distance);
140 
144  virtual void registerAttributeFunctions() override;
145 
149  static DtReaderWriter* provideLastMissileName(void* controller);
150 
154  static DtReaderWriter* provideMissilePassedTarget(void* controller);
155 
156 
160  static DtSimComponent * creator(const DtString& name,
161  DtLocalObject* owner,
162  DtSimulationServices* simManager,
163  DtComponentDescriptor* desc = nullptr,
164  DtReaderWriterRegistry* parentRegistry = nullptr);
165 
166 protected:
167 
169  virtual bool createPorts() override;
170 
175 
176  static void fireMissileLauncherTaskCallback(DtSimMessage* msg, void* usr);
177 
181  virtual void processFireMissileLauncherTask(DtSimMessage* msg);
183 
186  void updateFireMissileLauncherTask();
187 
189  virtual DtReaderWriter* processProvideLastMissileName();
190 
192  virtual DtReaderWriter* processProvideMissilePassedTarget();
193 
194  virtual void processObjectRemoved(const DtUUID& missileId);
195 
196  virtual void processDeleteObject(const DtUUID& missileId);
197 
199  virtual bool isSurrenderedLifeform(const DtSimObject* entity) const;
200 
201  virtual DtSimTask* createFireTask(const DtRwLocationReference& locRef,
202  const DtU8 hitZoneFunction) const;
203 
211  virtual bool bestMunitionForTargetNoSideEffects(
212  const DtRwLocationReference& targetLocation,
213  DtEntityType& munitionTypeOut,
215 
216 protected:
218  virtual void preFirstTickInit() override;
219 
220 protected:
221 
223  DtLauncherController() = delete;
224 
226  DtLauncherController(const DtLauncherController & orig) = delete;
227 
229  const DtLauncherController & operator=(const DtLauncherController & orig) = delete;
230 
231 
232 //=================================================================================================
239 //=================================================================================================
240 private:
242 
243  virtual bool isFireMissileLauncherTasked() const override;
244  virtual const DtFireMissileLauncherTask* getFireMissileLauncherTask() const override;
246 //=================================================================================================
247 
248 
249 protected:
250 
251  struct MissileInfo
252  {
253  MissileInfo() : uuid(DtUUID::nullUUID()), simObjectReference(DtSimObjectReference::nullReference()) {};
254  MissileInfo(const DtUUID& u, DtSimObjectReference r) : uuid(u), simObjectReference(r) {};
255  MissileInfo(const MissileInfo& orig) : uuid(orig.uuid), simObjectReference(orig.simObjectReference) {};
256 
257  MissileInfo& operator=(const MissileInfo& orig) { uuid = orig.uuid; simObjectReference = orig.simObjectReference; return *this; };
258 
259  DtUUID uuid;
261  };
262 
265 
271  DtStringOutputPort* myMissileIdPort = nullptr;
272 
278  DtIntegerOutputPort* myMunitionBinPort = nullptr;
279 
285  DtStringOutputPort* myTargetEntityIdPort = nullptr;
286 
292  DtVectorOutputPort* myTargetPointPort = nullptr;
293 
295 
300 
301  bool myRegisteredRemovedCallback = false;
302 
303  typedef std::map<DtUUID, DtMissileSimObjectFacade*> MissileSimObjectFacadeMap;
304  MissileSimObjectFacadeMap myMissileSimObjectFacadeMap{};
305 
306  mutable tbb::spin_mutex myRemovedMissilesMutex;
307  std::vector<DtUUID> myRemovedMissiles{};
308 
309  boost::signals2::scoped_connection myMissileRemovedFromActiveListConnection{};
310 };
UUID is a unique ID wrapper class.
Definition: uuid.h:59
tbb::spin_mutex myRemovedMissilesMutex
Definition: launcherController.h:306
DtUUID uuid
Definition: launcherController.h:257
#define DT_DLL_vrfmodel
This file is used to determine how to build.
Definition: vrfmodelDefines.h:24
virtual bool createPorts() override
Overridden to create the local ports.
const DtWeaponController & operator=(const DtWeaponController &orig)
assignment operator; not implemented
Instances of DtStringOutputPort are output ports through which data producers can send a DtString obj...
Definition: stringIOPort.h:52
Task for firing the missile launcher at a target.
Definition: fireMissileLauncherTask.h:25
DtWeaponController is a controller that extends the DtBaseWeaponController with the ability to accept...
Definition: weaponController.h:59
virtual void registerTaskMsgCallbacks()
AcceptLevel
Levels that a task controller can accept a task it has registered for.
Definition: taskControllerComponent.h:55
Holds a position of some form. May be an absolute position, or a reference to another object...
Definition: rwLocationReference.h:25
Definition: readerWriter.h:85
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
Definition: detonationEvent.h:20
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=nullptr, DtReaderWriterRegistry *parentRegistry=nullptr)
virtual bool isFireMissileLauncherTasked() const
The following private function are created temporarily during the weapon system refactoring. Their purpose is to bypass the target weapon interface and the target selection controller, when the new DtFireMissileLauncherTask is executed. The functions should be removed / replaced / modified as the refactoring goes along.
DtLauncherController is a controller that accepts input from a target sensor, and provides ammunition...
Definition: launcherController.h:65
virtual void fire() override
updates weapon interface
Definition: event.h:13
DT_DLL_VRVCORE double distance(const makVrv::DtCoordinateSystem &, const DtVector &from, const DtVector &to)
Returns the distance from the two points. Coordinates are in local database coordinates The coordinat...
Instances of DtVectorOutputPort are output ports through which data producers can send a DtVector...
Definition: vectorIOPort.h:52
File: simMsg.h.
Definition: simMessage.h:35
MissileInfo(const MissileInfo &orig)
Definition: launcherController.h:255
MissileInfo()
Definition: launcherController.h:253
std::map< DtEntityType, DtString > MunitionEvaluationReasons
Maps each evaluated munition type to a human-readable reason string. Selected munition maps to &quot;selec...
Definition: genericWeaponInfo.h:35
Definition: launcherController.h:251
std::map< DtUUID, DtMissileSimObjectFacade * > MissileSimObjectFacadeMap
Definition: launcherController.h:303
DtSimObjectReference simObjectReference
Definition: launcherController.h:260
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:97
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
double myAbandonPassedMissileDistance
If the missile passes its target within this distance, it will be abandoned and disconnected from the...
Definition: launcherController.h:299
DtSimTask is an abstract base class from which real tasks can derive. It manages the read/write capab...
Definition: simTask.h:30
virtual bool init() override
Overridden to initialize values obtained from the descriptor.
virtual void registerAttributeFunctions()
Called to register functions that provide system attribute values. Called by init(). Empty in this class. Overridden in different components to add attribute provider functions.
Definition: simComponent.h:132
virtual AcceptLevel acceptTask(const DtTaskMessage &task)
Called by the task manager when this controller is being considered to execute a task. Only tasks which already match types that this controller has registered for will be passed. This is used for the case where multiple task controllers have registered for the same task type. This gives the controller a chance to look at the parameters of the task and to reject the execution of the task based on parameters. Controllers can return any of the AcceptLevel levels. The task manager will choose a controller with the lowest AcceptLevel to execute, but will not choose any controller that returns AcceptLevel_NoAccept. Default implementation returns AcceptLevel_Accept. Override this to check parameters and conditionally return a different AccpetLevel.
Instances of DtIntegerOutputPort are output ports through which data producers can send integer value...
Definition: integerIOPort.h:45
virtual const DtFireMissileLauncherTask * getFireMissileLauncherTask() const
The following private function are created temporarily during the weapon system refactoring. Their purpose is to bypass the target weapon interface and the target selection controller, when the new DtFireMissileLauncherTask is executed. The functions should be removed / replaced / modified as the refactoring goes along.
virtual const char * type() const override
Returns a string identifies the class type of component. Type values are defined in compTypes...
virtual void tick() override
If the myWaitingForFire flag is set and the munition loader is still loaded, the weapon has not fired...
virtual void preFirstTickInit() override
Starts with weapon loaded, if the weapon has a full complement of ammunition.
A DtTaskMsg is a DtRadioMsg with a pointer to a task. The type of the taskMsg is just the type of the...
Definition: taskMessage.h:21
MissileInfo(const DtUUID &u, DtSimObjectReference r)
Definition: launcherController.h:254
A locally simulated VRF object.
Definition: localObject.h:98

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)