VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ballisticGunController.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2012 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
11 
12 #pragma once
13 
17 #include "vrfutil/simClock.h"
18 #include "vrfutil/simMunition.h"
19 #include <vlpi/disEnums.h>
22 #include <map>
23 
26 class DtIntegerInputPort;
28 class DtVrfBalGunPSR;
29 class DtOutputPortGroup;
30 class DtBooleanInputPort;
36 
52 {
53 
54 public:
55 
59  DtLocalObject* owner,
60  DtSimulationServices* simManager,
61  DtComponentDescriptor* desc = nullptr,
62  DtReaderWriterRegistry* parentRegistry = nullptr);
63 
65  virtual ~DtBallisticGunController() override;
66 
70  virtual bool postAddComponentsInit() override;
71 
74  virtual const char* type() const override;
75 
77  virtual bool init() override;
78 
80  virtual void registerTaskMsgCallbacks() override;
81 
84  virtual AcceptLevel acceptTask(const DtTaskMessage& task) override;
85 
89  virtual void preFirstTickInit() override;
90 
92  virtual void tick() override;
93 
96  virtual bool createTriggerPort();
97  virtual DtBooleanOutputPort * triggerPort() const;
98 
99  virtual bool createQuantityOutputPort();
100  virtual DtIntegerOutputPort* quantityOutputPort() const;
101 
102  virtual bool createLoadedPort();
103  virtual DtBooleanOutputPort * loadedPort() const;
104 
105  virtual bool createLosOutputPort();
106  virtual DtIntegerOutputPort * losOutputPort() const;
107 
108  virtual bool createLosInputPort();
109  virtual DtIntegerInputPort * losInputPort() const;
110 
111  virtual bool createWeaponsHoldInputPort();
112 
113  virtual bool createTargetToAcquireOutputPort();
114 
115  virtual void setLoadAmmoTime(DtTime loadAmmoTime);
116  virtual DtTime loadAmmoTime() const;
117 
118  virtual void setUnloadAmmoTime(DtTime unloadAmmoTime);
119  virtual DtTime unloadAmmoTime() const;
120 
124  virtual void fire();
125 
135  virtual bool chooseAmmo(const DtEntityType& targetType,
136  const DtUUID& target, DtSimMunition&
137  munition, DtDetonatorFuze& fuze, int& ammoAvailable,
138  bool recurse = true);
139 
143  typedef std::map<DtEntityType, DtString> MunitionEvaluationReasons;
144 
150  virtual bool bestMunitionForTargetNoSideEffects(
151  const DtRwLocationReference& targetLocation,
152  DtEntityType& munitionTypeOut,
153  MunitionEvaluationReasons& reasonsOut);
154 
160  virtual bool findMunitionForLoader(const DtString& loaderName,
161  DtSimMunition& outMunition, int& outRoundsAvailable);
162 
171  virtual bool preferLoadedIfApplicable(const DtEntityType& targetType,
172  DtSimMunition& outMunition, int& outRoundsAvailable);
173 
175  virtual bool checkCurrentAmmo(int& ammoAvailable);
176 
179  virtual bool ammoOKToUse(const DtEntityType& targetType);
180 
182  virtual void initProcessSR();
183 
187  static DtSimComponent * creator(const DtString& name,
188  DtLocalObject* owner,
189  DtSimulationServices* simManager,
190  DtComponentDescriptor* desc = nullptr,
191  DtReaderWriterRegistry* parentRegistry = nullptr);
192 
193 
194  virtual void enable() override;
195 
196 
197  virtual void disable() override;
198 
199  virtual void clearTask() override;
200 
201 protected:
202 
204  virtual bool createPorts() override;
205 
207  virtual bool createPortGroups() override;
208 
216  virtual void lookupAndCacheProcessSR();
217 
222 
223  static void fireBallisticGunTaskCallback(DtSimMessage* msg, void* usr);
224 
228  virtual void processFireBallisticGunTask(DtSimMessage* msg);
230 
234  bool updateFireBallisticGunTask();
235 
236  virtual DtSimTask* createFireTask(const DtRwLocationReference& locRef,
237  const DtU8 hitZoneFunction) const;
238 
243  virtual DtSimTask* createFireTask(const DtRwLocationReference& locRef,
244  const DtU8 hitZoneFunction, const DtEntityType& munitionType) const;
245 
249  static DtReaderWriter* roundsPerTriggerPullCallback(void* ctrlr);
250  virtual DtReaderWriter* provideRoundsPerTriggerPull();
252 
255  virtual const DtSimResource * lookupMunitionResource(const DtEntityType& resource) const;
256 
258  void getMunitionResources(std::list<DtEntityType>& resourceList);
259 
261  virtual void updateResourceList();
262 
265  virtual bool weaponsHoldState();
266 
268  virtual void resetResourceList();
269 
271  bool outOfAmmo() const;
272 
274  virtual bool isSurrenderedLifeform(const DtSimObject* entity) const;
275 
276  virtual DtWeaponInfoInterface::TargetApplicability targetApplicability(const DtEntityType& type);
277 
281  [[deprecated("Use canEngageTarget() on the PSR -- see TODO(DEPRECATED-TargetRegionFcn)")]]
282  virtual bool positionWithinTargetRegion(const DtVector& localPosition);
283  virtual void setupRegionEvaluator();
285  virtual void updateRegionEvaluator();
286 
287  virtual double maximumRange();
288  virtual double minimumRange();
289 
291  virtual DtString weaponId() const;
292 
293  virtual bool createWorkingTargetPoint(const DtVector worldLoc);
294 
295  virtual void deleteWorkingTargetPoint();
296 
297 protected:
300 
303 
306  orig);
307 
308 
309 protected:
310  bool isFireBallisticGunTasked() const;
311  const DtFireBallisticGunTask* getFireBallisticGunTask() const;
312  DtEntityTargetInformation createTargetInfo() const;
313  bool hasTarget() const;
314  DtEntityTargetInformation target() const;
315  void setRoundsFiredUponTarget(const int& roundsFired);
316  int roundsFiredUponTarget() const;
317  int totalRoundsToFireUponTarget() const;
318  void setIsExplicitlyTasked(const bool& explicitlyTasked);
319  bool isExplicitlyTasked() const;
320  void setIsInFiringCycle(const bool isIn);
321  bool isInFiringCycle()const;
322  void setWeaponStatus(const int weaponStatus);
323  int weaponStatus() const;
324  void addWeaponStatus(const DtBaseWeaponComponentInterface::DtWeaponStatus weaponStatus);
325  void removeWeaponStatus(const DtBaseWeaponComponentInterface::DtWeaponStatus weaponStatus);
326 
327 protected:
328 
331 
339 
346 
354 
361 
369 
373 
381 
382 
387 
389 
393 
396  DtDetonatorFuze myCurrentFuze;
397 
404 
407 
414 
417 
422 
427 
432  virtual bool hasSingleAvailableMunition() const;
433 
438  virtual bool shouldPreloadNow(DtTime currentTime) const;
439 
443  virtual void resetPreloadDeadline(DtTime currentTime);
444 
450  virtual void preloadAllLoaders(DtTime currentTime);
451 
455 
458 
459  std::shared_ptr<DtSpatialFilterEvaluator> myRegionEvaluator;
461  boost::signals2::connection myResourceChangedBySetConnection;
462 
463  };
DtWeaponComponentInterface * myWeaponComponentInterface
Interface between this weapon controller and the entity&#39;s DtTargetSelectionController.
Definition: ballisticGunController.h:454
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
DtTargetApplicability
Applicability tier of a weapon against a given target type.
Definition: targetApplicability.h:19
DtBooleanOutputPort * myTriggerPort
Output Port Name: trigger Output Port Description: Sends a new True value when trigger is pulled...
Definition: ballisticGunController.h:345
DtGenericWeaponInfo * myWeaponInfo
The weapon information shared with the rest of components on the entity.
Definition: ballisticGunController.h:457
virtual bool postAddComponentsInit() override
Calls enableTaskTypes()
DtOutputPortGroup * myGunControlPortGroup
Output Port Group Name: gun-control Output Port Group Description:
Definition: ballisticGunController.h:372
virtual const char * type() const override=0
Returns a string identifies the class type of component. Type values are defined in compTypes...
DtEntityListOutputPort * myTargetToAcquireOutputPort
Output Port Name: target-to-acquire Output Port Description: When there is a target in the weapon int...
Definition: ballisticGunController.h:386
Instances of DtBooleanOutputPort are output ports through which data producers can send boolean data...
Definition: boolIOPort.h:45
DtIntegerOutputPort * myLosOutputPort
Output Port Name: line-of-sight Output Port Description: Indicates the result of a line of sight calc...
Definition: ballisticGunController.h:368
virtual void registerTaskMsgCallbacks()
AcceptLevel
Levels that a task controller can accept a task it has registered for.
Definition: taskControllerComponent.h:55
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
Holds a position of some form. May be an absolute position, or a reference to another object...
Definition: rwLocationReference.h:25
bool myWaitingForFire
This flag is set to true when the controller pulls the trigger; it won&#39;t do anything in the tick func...
Definition: ballisticGunController.h:413
std::shared_ptr< DtSpatialFilterEvaluator > myRegionEvaluator
Definition: ballisticGunController.h:459
bool myOutOfAmmoWarn
Flag so an out-of-ammo warning is only sent once per target.
Definition: ballisticGunController.h:416
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
DtTime myLastRegionEvaluatorUpdateTime
Definition: ballisticGunController.h:460
Definition: readerWriterRegistry.h:39
Definition: entityTargetInformation.h:28
DtOutputPortGroup is a data port group of a data provider. It may contain any number of DtOutputPorts...
Definition: outputPortGroup.h:34
DtBooleanInputPort * myWeaponsHoldInputPort
Input Port Name: weapons-hold Input Port Description: When true, all firing is disabled. Connecting to this port is optional. If no connection is made, it will default to false. Input Port Range: True/False Input Port Default Value: False .
Definition: ballisticGunController.h:380
This file contains the class declaration for the.
Contains class declarations for DtIntegerInputPort, DtIntegerOutputPort, and DtIntegerPortData.
Definition: integerIOPort.h:25
DtTime myPreloadReadyAt
Sim time at which the peacetime preloader is allowed to commit a round. DtTime(-1) is the &quot;never arme...
Definition: ballisticGunController.h:421
boost::signals2::connection myResourceChangedBySetConnection
Definition: ballisticGunController.h:461
virtual bool init() override
Calls setRadio()
Instances of DtEntityListOutputPort are output ports through which data producers can send a list of ...
Definition: entListIOPort.h:45
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
File: vlClock.h.
virtual void tick()
This gives the thread of control to the component. The component is ticked once each simulation frame...
An abstract base class for all evaluators of spatial filters. The evaluation of spatial filters is sp...
Definition: spatialFilterEvaluator.h:31
DtBallisticGunController provides ammunition loading, unloading, and trigger inputs for use by a ball...
Definition: ballisticGunController.h:51
Contains class declarations for DtBooleanInputPort, DtBooleanOutputPort, and DtBooleanPortData.
Definition: boolIOPort.h:25
DtWeaponStatus
The status items below are used as bit fields. To set a state, OR the enumerated value into the weapo...
Definition: baseWeaponComponentInterface.h:36
DtVrfBalGunPSR * myProcessState
Pointer to a process state repository used to store state data associated with this component...
Definition: ballisticGunController.h:403
virtual bool createPorts()
Called by init. Derived classes should override this method to create all their input/output ports an...
virtual bool createPortGroups()
Called by init. Derived classes should override this method to create all their input/output port gro...
DtSimMunition myCurrentMunition
The correct munition and fuze for our current target.
Definition: ballisticGunController.h:395
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
DtIntegerOutputPort * myQuantityOutputPort
Output Port Name: quantity Output Port Description: Sends the number of rounds to be fired with a sin...
Definition: ballisticGunController.h:353
static const DtTime PreloadHoldSeconds
Length of the peacetime-preload hysteresis window in seconds. Matches the tactical intent: give the f...
Definition: ballisticGunController.h:426
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
const DtTaskControllerComponent & operator=(const DtTaskControllerComponent &orig)
assignment operator
virtual void enable() override
Overridden to call registerTaskMsgCallbacks().
DtSimResource is a class which will define a SISO Enumeration to use as a resource and the quantity o...
Definition: simResource.h:32
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...
std::map< DtEntityType, DtString > MunitionEvaluationReasons
Maps each evaluated munition type to a human-readable reason string. Selected munition maps to &quot;selec...
Definition: ballisticGunController.h:143
DtDetonatorFuze myCurrentFuze
Definition: ballisticGunController.h:396
DtIntegerInputPort * myLosInputPort
Input Port Name: line-of-sight Input Port Description: Indicates the result of a line of sight calcul...
Definition: ballisticGunController.h:338
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
Task for firing the ballistic gun at a target.
Definition: fireBallisticGunTask.h:27
const DtBallisticGunControllerDescriptor * myGunDescriptor
Get ammo select tables from here.
Definition: ballisticGunController.h:406
DtSimMunition class.
Definition: simMunition.h:31
DtUUID myPreviousTarget
Maintain the target we had last tick (if any) to detect changes in target (which will kick off possib...
Definition: ballisticGunController.h:392
DtBallisticGunControllerDescriptor, descriptor for the DtBallisticGunController component.
Definition: ballisticGunControllerDescriptor.h:29
DtBooleanOutputPort * myLoadedPort
Output Port Name: loaded Output Port Description: True when the gun is loaded. Output Port Range: Ou...
Definition: ballisticGunController.h:360
Class DtVrfBalGunPSR: Used to hold checkpointable state for the processes associated with ballistic g...
Definition: vrfBalGunPSR.h:36
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
Represents the interface between the DtTargetSelectionController and a weapon system.
Definition: weaponComponentInterface.h:20
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)