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) 1999-2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
12 #pragma once
13 
16 #include "vrfutil/simMunition.h"
17 
18 class DtVectorOutputPort;
19 class DtAnalogOutputPort;
21 class DtVectorInputPort;
25 class DtMunitionResource;
33 
42 {
43 
44 public:
45 
49  DtLocalObject* owner,
50  DtSimulationServices* simManager,
51  DtComponentDescriptor* desc = nullptr,
52  DtReaderWriterRegistry* parentRegistry = nullptr);
53 
56 
59  virtual const char* type() const override;
60 
61  virtual bool init() override;
62 
64  virtual bool createMountingController() override;
65 
69  virtual void preFirstTickInit() override;
70 
71  virtual void tick() override;
72 
74  virtual bool createTargetPointPort();
76  virtual DtVectorOutputPort * targetPointPort() const;
77 
79  virtual bool createMuzzleSpeedPort();
81  virtual DtAnalogOutputPort * muzzleSpeedPort() const;
82 
84  virtual bool createAngleOfFirePort();
86  virtual DtAnalogOutputPort * angleOfFirePort() const;
87 
89  virtual bool createAlignedDirectlyPort();
91  virtual DtBooleanOutputPort * alignedDirectlyPort() const;
92 
94  virtual bool createMuzzleOffsetPort();
96  virtual DtVectorInputPort * muzzleOffsetPort() const;
97 
101  static DtSimComponent * creator(const DtString& name,
102  DtLocalObject* owner,
103  DtSimulationServices* simManager,
104  DtComponentDescriptor* desc = nullptr,
105  DtReaderWriterRegistry* parentRegistry = nullptr);
106 
107  virtual DtVrfIndirectFirePSR* indirectFireProcessState();
108  virtual const DtVrfIndirectFirePSR* indirectFireProcessState() const;
109 
113  virtual void registerAttributeFunctions() override;
114 
121  static DtReaderWriter* provideWeaponName(void* controller);
123 
126  virtual bool haveAmmo(const DtString & ammoName) const;
127 
131  virtual int ammoAmount(const DtString & ammoName) const;
132 
135  virtual const DtString & findDefaultAmmo() const;
136 
139  virtual void getMunitionFromResourceName(const DtString & resourceName,
140  DtSimMunition& munition) const;
141 
144  virtual DtMunitionResource * lookupMunitionResource(const DtString &
145  resource) const;
147  virtual void setMyFuzeToUse(DtDetonatorFuze fuzeToUse);
149  virtual DtDetonatorFuze fuzeToUse() const;
150 
152  virtual void setCurrentMuzzleSpeed(DtReal speed);
153 
155  virtual DtReal currentMuzzleSpeed() const;
156 
157  virtual void addRangeItems();
158 
163  virtual bool initializeController(const DtString& ammoType,
164  DtReal heightAboveTerrain, const DtUUID & targetName, DtVector targetLocation,
165  bool& waitingForTerrain, DtDetonatorFuze fuseType,
166  bool generateKnownTargetPoint = false, const DtString& knownTargetPointName = "");
167 
168 protected:
169 
171  virtual bool createPorts() override;
172 
182  virtual void lookupAndCacheProcessSR() override;
183 
192  virtual bool calculateTrajectory(const DtVector& shooterLoc, const DtVector& detonationLoc,
193  const double maxRange);
194 
198  virtual void calculateTrajectoryWithHeight(double horizontalDist, double verticalDist,
199  double maxHeight, double& muzzleSpeed, double& launchAngle, double& flightTime);
200 
204  virtual bool calculateElevationAngle(double lateralDist, double verticalDist, double muzzleSpeed,
205  double& angle, double& flightTime, double& maxHeight) const;
206 
211  virtual bool checkMuzzleSpeedAndAngle(double lateralDist, double verticalDist,
212  double speed, double angle, double& flightTime, double& maxHeight) const;
213 
216  virtual void getMunitionResources(std::list<DtString>& resourceList);
217 
219  virtual void updateResourceList();
220 
224  static void setResourceCallback(DtSimMessage * msg, void * usrData);
225  virtual void processSetResource(DtSimMessage * msg);
227 
231  static void setRestoreCallback(DtSimMessage * msg, void * usrData);
232  virtual void processSetRestore(DtSimMessage * msg);
234 
237  static void setPreferredAltitudeCallback(DtSimMessage * msg, void * usrData);
238  virtual void processSetPreferredAltitude(DtSimMessage * msg);
240 
241  virtual AcceptLevel acceptTask(const DtTaskMessage& task) override;
242 
255 
256  //static void indirectFireAtLocationTaskCallback(DtSimMessage* msg, void* usr);
257  //virtual void processIndirectFireAtLocationTask(DtSimMessage* msg);
258 
259 
260  //static void indirectFireAtTargetTaskCallback(DtSimMessage* msg, void* usr);
261  //virtual void processIndirectFireAtTargetTask(DtSimMessage* msg);
263 
265  static void FFEOnTargetCallback(DtSimMessage * msg, void * usr);
267  static void FFEOnEntityCallback(DtSimMessage * msg, void * usr);
269  static void FFEOnLocationCallback(DtSimMessage * msg, void * usr);
270 
277  virtual bool processFFEOnTargetTask(DtSimMessage * msg);
278  virtual bool processFFEOnLocationTask(DtSimMessage * msg);
279  virtual bool processFFEOnEntityTask(DtSimMessage * msg);
281 
294 
295  static void indirectFireAtLocationTaskCallback(DtSimMessage* msg, void* usr);
296  virtual void processIndirectFireAtLocationTask(DtSimMessage* msg);
297 
298 
299  static void indirectFireAtTargetTaskCallback(DtSimMessage* msg, void* usr);
300  virtual void processIndirectFireAtTargetTask(DtSimMessage* msg);
302 
305  virtual void processFFETask(DtFireForEffectTask * task, const DtUUID& targetObj, const DtVector& targetLoc);
306 
309  virtual DtVector computeLeadPosition(const DtVector& position,
310  const DtVector& velocity);
311 
314  virtual const DtVector& muzzleLocalPosition();
315 
318  virtual DtReaderWriter* processProvideWeaponName();
319 
322  virtual double preferredAltitude() const;
323 
326 
329 
333 
334  virtual void enable() override;
335 
336  virtual void disable() override;
337 
338  virtual void clearTask() override;
339 
341  virtual void restartTask();
342 
344  virtual void getOrientation(DtRwString *orientString, DtRwTaitBryan & orientation) const;
345 
346  virtual bool positionWithinTargetRegion(const DtVector& localPos);
347  virtual DtSimTask* createFireTask(const DtRwLocationReference& locRef);
348 
349  virtual void parseWeaponParams(const DtRwString* weaponToUse,
350  DtString& weapId, DtString& weapName, DtString& ammoType);
351 
352 protected:
356 
358  DtDetonatorFuze myFuzeToUse;
359 
362 
365 
368 
372 
376 
378 
381 
388 
395 
402 
411 
419 
421 
427 
429 };
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
virtual void disable() override
Overridden to allow tasks controllers that can be disabled to call task complete. ...
DtBaseWeaponController is a controller that creates the ports needed to choose ammo for...
Definition: baseWeaponController.h:34
DtGenericWeaponInfo * myWeaponInfo
Definition: indirectFireWeaponController.h:428
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:426
DtIndirectWeaponComponentInterface * myWeaponComponentInterface
Interface between this weapon controller and the entity&#39;s DtIndirectFireController.
Definition: indirectFireWeaponController.h:355
DtIndirectFireControllerDescriptor; descriptor for the DtIndirectFireController compenent.
Definition: indirectFireControllerDescriptor.h:31
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
DtFireForEffectOnTargetTask represents an artillery task to fire for effect on the specified entity...
Definition: fireForEffectOnLocationTask.h:27
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
DtFireForEffectOnEntityTask represents an artillery task to fire for effect on the specified entity...
Definition: fireForEffectOnEntityTask.h:22
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:417
DtReal myCurrentElevationAngle
The elevation angle selected for the next shot.
Definition: indirectFireWeaponController.h:367
virtual bool createPorts() override
Overridden to create input &amp; output ports.
DtReal myCurrentMunitionFlightTime
The expected flight time for the next shot.
Definition: indirectFireWeaponController.h:364
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])
An implementation of DtWeaponInforInterface that allows for flexible registering of functions from ot...
Definition: genericWeaponInfo.h:17
File: simMsg.h.
Definition: simMessage.h:35
DtIndirectFireWeaponController is a controller that models firing an indirect fire weapon (e...
Definition: indirectFireWeaponController.h:41
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:410
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:95
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:91
DtDetonatorFuze myFuzeToUse
Set based on height above terrain value.
Definition: indirectFireWeaponController.h:358
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:377
bool myWeaponIsAimed
Whether the weapon is fully aimed at the target, or if adjustments still need to be made...
Definition: indirectFireWeaponController.h:371
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:22
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:133
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:401
DtVectorOutputPort * myTargetPointPort
Output Port Name: target-point-port Output Port Description: Local position to fire at...
Definition: indirectFireWeaponController.h:387
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:375
DtAnalogOutputPort * myMuzzleSpeedPort
Output Port Name: muzzle-speed-port Output Port Description: Muzzle speed in m/s. Output Port Range: ...
Definition: indirectFireWeaponController.h:394
DtSimMunition class.
Definition: simMunition.h:31
DtMountingController * myMountingController
Definition: indirectFireWeaponController.h:420
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
DtReal myCurrentMuzzleSpeed
The muzzle speed selected for the next shot.
Definition: indirectFireWeaponController.h:361
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
Contains the DtMunitionResource class declaration.
Definition: munitionResource.h:24

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)