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 
25 class DtIntegerInputPort;
27 class DtVrfBalGunPSR;
28 class DtOutputPortGroup;
29 class DtBooleanInputPort;
35 
51 {
52 
53 public:
54 
58  DtLocalObject* owner,
59  DtSimulationServices* simManager,
60  DtComponentDescriptor* desc = nullptr,
61  DtReaderWriterRegistry* parentRegistry = nullptr);
62 
64  virtual ~DtBallisticGunController();
65 
69  virtual bool postAddComponentsInit() override;
70 
73  virtual const char* type() const override;
74 
76  virtual bool init() override;
77 
79  virtual void registerTaskMsgCallbacks() override;
80 
83  virtual AcceptLevel acceptTask(const DtTaskMessage& task) override;
84 
88  virtual void preFirstTickInit() override;
89 
91  virtual void tick() override;
92 
95  virtual bool createTriggerPort();
96  virtual DtBooleanOutputPort * triggerPort() const;
97 
98  virtual bool createQuantityOutputPort();
99  virtual DtIntegerOutputPort* quantityOutputPort() const;
100 
101  virtual bool createLoadedPort();
102  virtual DtBooleanOutputPort * loadedPort() const;
103 
104  virtual bool createLosOutputPort();
105  virtual DtIntegerOutputPort * losOutputPort() const;
106 
107  virtual bool createLosInputPort();
108  virtual DtIntegerInputPort * losInputPort() const;
109 
110  virtual bool createWeaponsHoldInputPort();
111 
112  virtual bool createTargetToAcquireOutputPort();
113 
114  virtual void setLoadAmmoTime(DtTime loadAmmoTime);
115  virtual DtTime loadAmmoTime() const;
116 
117  virtual void setUnloadAmmoTime(DtTime unloadAmmoTime);
118  virtual DtTime unloadAmmoTime() const;
119 
123  virtual void fire();
124 
134  virtual bool chooseAmmo(const DtEntityType& targetType,
135  const DtUUID& target, DtSimMunition&
136  munition, DtDetonatorFuze& fuze, int& ammoAvailable,
137  bool recurse = true);
138 
140  virtual bool checkCurrentAmmo(int& ammoAvailable);
141 
144  virtual bool ammoOKToUse(const DtEntityType& targetType);
145 
147  virtual void initProcessSR();
148 
152  static DtSimComponent * creator(const DtString& name,
153  DtLocalObject* owner,
154  DtSimulationServices* simManager,
155  DtComponentDescriptor* desc = nullptr,
156  DtReaderWriterRegistry* parentRegistry = nullptr);
157 
158 
159  virtual void enable() override;
160 
161 
162  virtual void disable() override;
163 
164  virtual void clearTask() override;
165 
166 protected:
167 
169  virtual bool createPorts() override;
170 
172  virtual bool createPortGroups() override;
173 
181  virtual void lookupAndCacheProcessSR();
182 
187 
188  static void fireBallisticGunTaskCallback(DtSimMessage* msg, void* usr);
189 
193  virtual void processFireBallisticGunTask(DtSimMessage* msg);
195 
199  bool updateFireBallisticGunTask();
200 
201  virtual DtSimTask* createFireTask(const DtRwLocationReference& locRef) const;
202 
206  static DtReaderWriter* roundsPerTriggerPullCallback(void* ctrlr);
207  virtual DtReaderWriter* provideRoundsPerTriggerPull();
209 
212  virtual DtIntegerResource * lookupMunitionResource(const DtString &
213  resource) const;
214 
216  void getMunitionResources(std::list<DtString>& resourceList);
217 
219  virtual void updateResourceList();
220 
223  virtual bool weaponsHoldState();
224 
228  static void setResourceCallback(DtSimMessage * msg, void * usrData);
229  virtual void processSetResource(DtSimMessage * msg);
231 
235  static void setRestoreCallback(DtSimMessage * msg, void * usrData);
236  virtual void processSetRestore(DtSimMessage * msg);
238 
240  bool outOfAmmo() const;
241 
243  virtual bool isSurrenderedLifeform(const DtSimObject* entity) const;
244 
245  virtual DtWeaponInfoInterface::TargetApplicability targetApplicability(const DtEntityType& type);
246 
247  virtual bool positionWithinTargetRegion(const DtVector& localPosition);
248  virtual void setupRegionEvaluator();
250  virtual void updateRegionEvaluator();
251 
253  virtual DtString weaponId() const;
254 
256 
258 
259 protected:
262 
265 
268  orig);
269 
270 
271 //=================================================================================================
278 //=================================================================================================
279 private:
281 
282  bool isFireBallisticGunTasked() const;
283  const DtFireBallisticGunTask* getFireBallisticGunTask() const;
284  const DtEntityTargetInformation createTargetInfo() const;
285  bool hasTarget() const;
286  const DtEntityTargetInformation target() const;
287  void setRoundsFiredUponTarget(const int& roundsFired);
288  const int roundsFiredUponTarget() const;
289  const int totalRoundsToFireUponTarget() const;
290  void setIsExplicitlyTasked(const bool& explicitlyTasked);
291  const bool isExplicitlyTasked() const;
292  void setIsInFiringCycle(const bool isIn);
293  const bool isInFiringCycle()const;
294  void setWeaponStatus(const int weaponStatus);
295  const int weaponStatus() const;
296  void addWeaponStatus(const DtBaseWeaponComponentInterface::DtWeaponStatus weaponStatus);
297  void removeWeaponStatus(const DtBaseWeaponComponentInterface::DtWeaponStatus weaponStatus);
299 //=================================================================================================
300 
301 
302 protected:
303 
306 
314 
321 
329 
336 
344 
348 
356 
357 
363 
367 
370  DtDetonatorFuze myCurrentFuze;
371 
374 
381 
384 
391 
394 
398 
401 
402  DtBoost::shared_ptr<DtSpatialFilterEvaluator> myRegionEvaluator;
404 };
DtWeaponComponentInterface * myWeaponComponentInterface
Interface between this weapon controller and the entity&#39;s DtTargetSelectionController.
Definition: ballisticGunController.h:397
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
DtBooleanOutputPort * myTriggerPort
Output Port Name: trigger Output Port Description: Sends a new True value when trigger is pulled...
Definition: ballisticGunController.h:320
DtGenericWeaponInfo * myWeaponInfo
The weapon information shared with the rest of components on the entity.
Definition: ballisticGunController.h:400
virtual void disable() override
Overridden to allow tasks controllers that can be disabled to call task complete. ...
virtual bool postAddComponentsInit() override
Calls enableTaskTypes()
DtOutputPortGroup * myGunControlPortGroup
Output Port Group Name: gun-control Output Port Group Description:
Definition: ballisticGunController.h:347
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:361
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:343
virtual bool createWorkingTargetPoint(const DtVector worldLoc)
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:390
bool myOutOfAmmoWarn
Flag so an out-of-ammo warning is only sent once per target.
Definition: ballisticGunController.h:393
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:403
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:355
This file contains the class declaration for the.
Contains class declarations for DtIntegerInputPort, DtIntegerOutputPort, and DtIntegerPortData.
Definition: integerIOPort.h:25
virtual bool init() override
Calls setRadio()
int myRoundsAvailable
The quantity of the current munition in the resources store.
Definition: ballisticGunController.h:373
Instances of DtEntityListOutputPort are output ports through which data producers can send a list of ...
Definition: entListIOPort.h:45
An implementation of DtWeaponInforInterface that allows for flexible registering of functions from ot...
Definition: genericWeaponInfo.h:17
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 from ...
An abstract base class for all evaluators of spatial filters. The evaluation of spatial filters is sp...
Definition: spatialFilterEvaluator.h:30
DtBallisticGunController provides ammunition loading, unloading, and trigger inputs for use by a ball...
Definition: ballisticGunController.h:50
Contains class declarations for DtBooleanInputPort, DtBooleanOutputPort, and DtBooleanPortData.
Definition: boolIOPort.h:25
DtIntegerResource implements the required functions for a resource that can be measured by an integer...
Definition: integerResource.h:17
DtWeaponStatus
The status items below are used as bit fields. To set a state, OR the enumerated value into the weapo...
Definition: baseWeaponComponentInterface.h:34
TargetApplicability
Definition: weaponInfoInterface.h:21
DtVrfBalGunPSR * myProcessState
Pointer to a process state repository used to store state data associated with this component...
Definition: ballisticGunController.h:380
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:369
Central access point of all non-object-specific the services and managers that are available for use ...
Definition: simulationServices.h:95
The DtSimComponent class is the base class for the entire simulation model component hierarchy...
Definition: simComponent.h:91
DtIntegerOutputPort * myQuantityOutputPort
Output Port Name: quantity Output Port Description: Sends the number of rounds to be fired with a sin...
Definition: ballisticGunController.h:328
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:88
const DtTaskControllerComponent & operator=(const DtTaskControllerComponent &orig)
assignment operator
virtual void enable() override
Overridden to call registerTaskMsgCallbacks().
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...
DtDetonatorFuze myCurrentFuze
Definition: ballisticGunController.h:370
DtIntegerInputPort * myLosInputPort
Input Port Name: line-of-sight Input Port Description: Indicates the result of a line of sight calcul...
Definition: ballisticGunController.h:313
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.
DtBoost::shared_ptr< DtSpatialFilterEvaluator > myRegionEvaluator
Definition: ballisticGunController.h:402
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:25
const DtBallisticGunControllerDescriptor * myGunDescriptor
Get ammo select tables from here.
Definition: ballisticGunController.h:383
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:366
DtBallisticGunControllerDescriptor, descriptor for the DtBallisticGunController component.
Definition: ballisticGunControllerDescriptor.h:28
DtBooleanOutputPort * myLoadedPort
Output Port Name: loaded Output Port Description: True when the gun is loaded. Output Port Range: Ou...
Definition: ballisticGunController.h:335
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
virtual void deleteWorkingTargetPoint()
Represents the interface between the DtTargetSelectionController and a weapon system.
Definition: weaponComponentInterface.h:20
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

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)