VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
indirectFireWeaponController.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2024 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
12 #pragma once
13 
17 #include "vrfutil/simMunition.h"
18 
19 class DtVectorOutputPort;
20 class DtAnalogOutputPort;
22 class DtVectorInputPort;
26 class DtSimResource;
32 
41 {
42 
43 public:
44 
48  DtLocalObject* owner,
49  DtSimulationServices* simManager,
50  DtComponentDescriptor* desc = nullptr,
51  DtReaderWriterRegistry* parentRegistry = nullptr);
52 
54  virtual ~DtIndirectFireWeaponController() override;
55 
58  virtual const char* type() const override;
59 
60  virtual bool init() override;
61 
63  virtual bool createMountingController() override;
64 
68  virtual void preFirstTickInit() override;
69 
70  virtual void tick() override;
71 
73  virtual bool createTargetPointPort();
75  virtual DtVectorOutputPort * targetPointPort() const;
76 
78  virtual bool createMuzzleSpeedPort();
80  virtual DtAnalogOutputPort * muzzleSpeedPort() const;
81 
83  virtual bool createAngleOfFirePort();
85  virtual DtAnalogOutputPort * angleOfFirePort() const;
86 
88  virtual bool createAlignedDirectlyPort();
90  virtual DtBooleanOutputPort * alignedDirectlyPort() const;
91 
93  virtual bool createMuzzleOffsetPort();
95  virtual DtVectorInputPort * muzzleOffsetPort() const;
96 
100  static DtSimComponent * creator(const DtString& name,
101  DtLocalObject* owner,
102  DtSimulationServices* simManager,
103  DtComponentDescriptor* desc = nullptr,
104  DtReaderWriterRegistry* parentRegistry = nullptr);
105 
106  virtual DtVrfIndirectFirePSR* indirectFireProcessState();
107  virtual const DtVrfIndirectFirePSR* indirectFireProcessState() const;
108 
112  virtual void registerAttributeFunctions() override;
113 
120  static DtReaderWriter* provideWeaponName(void* controller);
122 
125  virtual bool haveAmmo(const DtEntityType & ammoName) const;
126 
130  virtual int ammoAmount(const DtEntityType & ammoName) const;
131 
134  virtual DtEntityType findDefaultAmmo() const;
135 
138  virtual void getMunitionFromResourceName(const DtEntityType & resourceName,
139  DtSimMunition& munition) const;
140 
143  virtual const DtSimResource * lookupMunitionResource(const DtEntityType &
144  resource) const;
146  virtual void setMyFuzeToUse(DtDetonatorFuze fuzeToUse);
148  virtual DtDetonatorFuze fuzeToUse() const;
149 
151  virtual void setCurrentMuzzleSpeed(DtReal speed);
152 
154  virtual DtReal currentMuzzleSpeed() const;
155 
156  virtual void addRangeItems();
157 
170  virtual bool initializeController(const DtEntityType& ammoType,
171  bool applyHeightAboveTerrain, DtReal heightAboveTerrain, bool allowTargetInsideStructure,
172  const DtSimObjectReference& target, DtU8 hitZoneFunction,
173  bool& waitingForTerrain, DtDetonatorFuze fuseType,
174  bool generateKnownTargetPoint = false, const DtString& knownTargetPointName = "");
175 
176 protected:
177 
179  virtual bool createPorts() override;
180 
190  virtual void lookupAndCacheProcessSR() override;
191 
200  virtual bool calculateTrajectory(const DtVector& shooterLoc, const DtVector& detonationLoc,
201  const double maxRange);
202 
206  virtual void calculateTrajectoryWithHeight(double horizontalDist, double verticalDist,
207  double maxHeight, double& muzzleSpeed, double& launchAngle, double& flightTime);
208 
212  virtual bool calculateElevationAngle(double lateralDist, double verticalDist, double muzzleSpeed,
213  double& angle, double& flightTime, double& maxHeight) const;
214 
219  virtual bool checkMuzzleSpeedAndAngle(double lateralDist, double verticalDist,
220  double speed, double angle, double& flightTime, double& maxHeight) const;
221 
224  virtual void getMunitionResources(std::list<DtEntityType>& resourceList);
225 
227  virtual void updateResourceList();
228 
230  virtual void resetResourceList();
231 
234  static void setPreferredAltitudeCallback(DtSimMessage * msg, void * usrData);
235  virtual void processSetPreferredAltitude(DtSimMessage * msg);
237 
238  virtual AcceptLevel acceptTask(const DtTaskMessage& task) override;
239 
252 
253  //static void indirectFireAtLocationTaskCallback(DtSimMessage* msg, void* usr);
254  //virtual void processIndirectFireAtLocationTask(DtSimMessage* msg);
255 
256 
257  //static void indirectFireAtTargetTaskCallback(DtSimMessage* msg, void* usr);
258  //virtual void processIndirectFireAtTargetTask(DtSimMessage* msg);
260 
262  static void FFEOnTargetCallback(DtSimMessage * msg, void * usr);
263 
270  virtual bool processFFEOnTargetTask(DtSimMessage * msg);
272 
273  virtual bool processFFEOnLocation(DtFireForEffectOnTargetTask* ffeTask);
274  virtual bool processFFEOnEnvironmental(DtFireForEffectOnTargetTask* ffeTask);
275 
288 
289  static void indirectFireAtLocationTaskCallback(DtSimMessage* msg, void* usr);
290  virtual void processIndirectFireAtLocationTask(DtSimMessage* msg);
291 
292 
293  static void indirectFireAtTargetTaskCallback(DtSimMessage* msg, void* usr);
294  virtual void processIndirectFireAtTargetTask(DtSimMessage* msg);
296 
299  virtual void processFFETask(DtFireForEffectTask * task, const DtUUID& targetObj, const DtVector& targetLoc, DtU8 hitZoneFunction = 0);
300 
303  virtual DtVector computeLeadPosition(const DtVector& position,
304  const DtVector& velocity);
305 
308  virtual DtVector muzzleLocalPosition();
309 
312  virtual DtReaderWriter* processProvideWeaponName();
313 
316  virtual double preferredAltitude() const;
317 
320 
323 
327 
328  virtual void enable() override;
329 
330  virtual void disable() override;
331 
332  virtual void clearTask() override;
333 
335  virtual void restartTask();
336 
338  virtual void getOrientation(DtRwString *orientString, DtRwTaitBryan & orientation) const;
339 
340  virtual bool positionWithinTargetRegion(const DtVector& localPos);
341  virtual DtSimTask* createFireTask(const DtRwLocationReference& locRef,
342  const DtU8 hitZoneFunction);
343 
344  virtual double maximumRange();
345  virtual double minimumRange();
346 
357  virtual bool bestMunitionForTargetNoSideEffects(
358  const DtRwLocationReference& targetLocation,
359  DtEntityType& munitionTypeOut,
361 
362  virtual void parseWeaponParams(const DtRwString* weaponToUse,
363  DtString& weapId, DtString& weapName, DtEntityType& ammoType);
364 
365 protected:
369 
371  DtDetonatorFuze myFuzeToUse;
372 
375 
378 
381 
385 
389 
391 
394 
401 
408 
415 
424 
432 
434 
440 
442  boost::signals2::connection myResourceChangedBySetConnection;
443 };
UUID is a unique ID wrapper class.
Definition: uuid.h:59
#define DT_DLL_vrfmodel
This file is used to determine how to build.
Definition: vrfmodelDefines.h:24
DtMountingController; models rotation of a launcher.
Definition: mountingController.h:23
DtBaseWeaponController is a controller that creates the ports needed to choose ammo for...
Definition: baseWeaponController.h:34
DtGenericWeaponInfo * myWeaponInfo
Definition: indirectFireWeaponController.h:441
bool myIsDirectFire
If weapon is capable of directly firing on a target like a naval gun then check if the target is with...
Definition: indirectFireWeaponController.h:439
DtIndirectWeaponComponentInterface * myWeaponComponentInterface
Interface between this weapon controller and the entity&#39;s DtIndirectFireController.
Definition: indirectFireWeaponController.h:368
DtIndirectFireControllerDescriptor; descriptor for the DtIndirectFireController compenent.
Definition: indirectFireControllerDescriptor.h:32
Instances of DtBooleanOutputPort are output ports through which data producers can send boolean data...
Definition: boolIOPort.h:45
AcceptLevel
Levels that a task controller can accept a task it has registered for.
Definition: taskControllerComponent.h:55
virtual const char * type() const override
Returns a string identifies the class type of component. Type values are defined in compTypes...
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
Description: Readable, Writable DtString Variable substitutions are done on this object when it is re...
Definition: rwString.h:20
A readable, writable type whose name is the name of a component and that has a list of component name...
Definition: componentDescriptor.h:49
Description: Readable, Writable DtTaitBryan.
Definition: rwTaitBryan.h:20
Definition: readerWriterRegistry.h:39
This file contains the class declaration for the.
const DtBaseWeaponController & operator=(const DtBaseWeaponController &orig)
assignment operator; not implemented
Contains class declarations for DtVectorInputPort, DtVectorOutputPort, and DtVectorPortData.
Definition: vectorIOPort.h:27
DtVectorInputPort * myMuzzleOffsetPort
Input Port Name: muzzle-offset-port Input Port Description: The entity&#39;s muzzle offset location...
Definition: indirectFireWeaponController.h:430
DtReal myCurrentElevationAngle
The elevation angle selected for the next shot.
Definition: indirectFireWeaponController.h:380
virtual bool createPorts() override
Overridden to create input &amp; output ports.
DtReal myCurrentMunitionFlightTime
The expected flight time for the next shot.
Definition: indirectFireWeaponController.h:377
Instances of DtAnalogOutputPort are input ports through which data producers can send real numbers...
Definition: analogIOPort.h:45
virtual void lookupAndCacheProcessSR()
This function looks up a process state repository in the process state repository manager by name...
Instances of DtVectorOutputPort are output ports through which data producers can send a DtVector...
Definition: vectorIOPort.h:52
DT_DLL_vrfutil double angle(double vec1[3], double vec2[3])
virtual void disable() override
Overridden to 1) remove any task message callbacks registered by this controller 2) call clear task...
An implementation of DtWeaponInforInterface that allows for flexible registering of functions from ot...
Definition: genericWeaponInfo.h:18
File: simMsg.h.
Definition: simMessage.h:35
DtIndirectFireWeaponController is a controller that models firing an indirect fire weapon (e...
Definition: indirectFireWeaponController.h:40
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
virtual void preFirstTickInit() override
This function can be overridden to initialize a component before it is ticked for the first time...
virtual bool createMountingController()
Creates myBaseMountingController.
virtual void tick() override
Sets the current dT on the base mounting controller and ticks it.
DtBooleanOutputPort * myAlignedDirectlyPort
Output Port Name: aligned-directly-port Output Port Description: If the target is close enough for th...
Definition: indirectFireWeaponController.h:423
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:97
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=nullptr, DtReaderWriterRegistry *parentRegistry=nullptr)
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:89
DtDetonatorFuze myFuzeToUse
Set based on height above terrain value.
Definition: indirectFireWeaponController.h:371
Represents the interface between the DtIndirectFireController and an indirect fire weapon system...
Definition: indirectWeaponComponentInterface.h:24
virtual void enable() override
Overridden to call registerTaskMsgCallbacks().
DtIndirectFireControllerDescriptor * myIndFireDescriptor
Definition: indirectFireWeaponController.h:390
DtSimResource is a class which will define a SISO Enumeration to use as a resource and the quantity o...
Definition: simResource.h:32
bool myWeaponIsAimed
Whether the weapon is fully aimed at the target, or if adjustments still need to be made...
Definition: indirectFireWeaponController.h:384
DtSimTask is an abstract base class from which real tasks can derive. It manages the read/write capab...
Definition: simTask.h:30
virtual void clearTask() override
If component is currently tasked, calls clearPendingSubtasks(), sets the tasked flag to false...
DtFireForEffectOnTargetTask represents an artillery task to fire for effect on the specified entity...
Definition: fireForEffectOnTargetTask.h:18
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.
DtAnalogOutputPort * myAngleOfFirePort
Output Port Name: angle-of-fire-port Output Port Description: The elevation angle of fire...
Definition: indirectFireWeaponController.h:414
DtVectorOutputPort * myTargetPointPort
Output Port Name: target-point-port Output Port Description: Local position to fire at...
Definition: indirectFireWeaponController.h:400
virtual bool init() override
Overridden to initialize values obtained from the descriptor.
File: indirectFirePSR.h.
Definition: vrfIndirectFirePSR.h:30
DtSimMunition myMunitionToUse
This could just be a stack variable in tick, but since these are expensive to construct, we create on and reuse it.
Definition: indirectFireWeaponController.h:388
DtAnalogOutputPort * myMuzzleSpeedPort
Output Port Name: muzzle-speed-port Output Port Description: Muzzle speed in m/s. Output Port Range: ...
Definition: indirectFireWeaponController.h:407
DtSimMunition class.
Definition: simMunition.h:31
DtMountingController * myMountingController
Definition: indirectFireWeaponController.h:433
File: fireForEff.h.
Definition: fireForEffectTask.h:32
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
boost::signals2::connection myResourceChangedBySetConnection
Definition: indirectFireWeaponController.h:442
DtReal myCurrentMuzzleSpeed
The muzzle speed selected for the next shot.
Definition: indirectFireWeaponController.h:374
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)