![]() |
VR-Forces 4.0.4 Class Documentation
|
This class provides a base class for all controllers that are capable of executing a DtSimTask, and can only execute a single DtSimTask at a time. More...

Public Member Functions | |
| DtSingleTaskControllerComponent (const DtString &name, DtVrfObject *owner, DtSimManager *simManager, DtComponentDescriptor *compDesc=0, DtReaderWriterRegistry *parentRegistry=0) | |
| (const DtString& name, | |
| virtual | ~DtSingleTaskControllerComponent () |
| destructor | |
| virtual void | postTick () |
| Override to check if we're tasked and we want to give up (only performs the check if we're in play mode (dT() > 0)). | |
| virtual bool | beginProcessingTask (const DtTaskMessage &task, DtSimTaskStatePtr taskState) |
| Called by the task manager when this controller should start executing the specified task. | |
| virtual void | taskNotify (const DtSimTask &task) |
| This is called to let us know when some other component receives a task In the case of this component, we don't care what the task actually is. | |
| virtual void | taskComplete (bool success=true) |
| If we are currently tasked, this will cause us to notify the entity that we're done and delete the task. | |
| virtual void | clearTask () |
| If component is currently tasked, calls clearPendingSubtasks(), sets the tasked flag to false, and calls clearCurrentTaskMesage() to clear out the current task message. | |
| virtual int | sendSubtask (DtSimTask &task) |
| Sends subtask to ourself. | |
| virtual void | clearSubtask (int subtaskId) |
| Clears subtask with the given subtaskId (subtaskId is returned sendSubtask()). | |
| virtual void | addPendingSubtaskId (int subtaskId) |
| Adds given subtask Id to list of pending subtasks. | |
| virtual bool | findPendingSubtaskId (int subtaskId) |
| Checks to see if given subtaskId exists in our list of pending subtasks. | |
| virtual void | removePendingSubtaskId (int subtaskId) |
| Removes pending subtask from list of subtasks for this component. | |
| virtual void | removeAllPendingSubtaskIds () |
| Clear all pending subtasks from our list of subtasks. | |
| virtual std::vector< int > | currentPendingSubstaskIds () const |
| Returns the list of all currently pending subtask ids for this controller. | |
| virtual void | clearCurrentTaskMessage () |
| Returns the current subtask with the specified id. | |
| virtual DtTaskMessage * | currentTaskMessage () const |
| Get a pointer to the message that was used to task this entity. | |
| virtual DtSimTaskStatePtr | currentTaskState () const |
| virtual bool | decideToGiveUpTask () const |
| This function is used to determine if the controller should give up trying to execute the current task. | |
| virtual void | giveUpTask () |
| Called when controller is tasked and decideToGiveUp() returns true. | |
| virtual bool | taskActive (int taskId) const |
| | |
| virtual bool | clearTopLevelTasks () |
| If this controller has any top level tasks (not subtasks), they are cleared. | |
| virtual void | clearConflictingTopLevelTasks (int conflictId) |
| Clears any top level tasks on this controller that conflict with the conflictId. | |
| virtual void | clearTasksByType (int taskType) |
| Clears any tasks of the specified type running in this controller. | |
| virtual void | clearTaskById (int taskId) |
| Clears any task of the specified ID running in this controller. | |
| virtual std::list < DtTaskMessage * > | currentTaskMessages () const |
| | |
| virtual DtTaskWithTaskStateListPtr | topLevelTasks () const |
| | |
Protected Member Functions | |
| virtual void | clearPendingSubtasks () |
| Iterates over collection of all pending subtasks for this controller, and calls clearSubtask() for each subtask type. | |
| virtual void | clearSubtasksByType (int taskType) |
| Clear all subtasks of a given type. | |
This class provides a base class for all controllers that are capable of executing a DtSimTask, and can only execute a single DtSimTask at a time.
This is the typical case for most task controllers, so most controllers will be derived from this class.
| DtSingleTaskControllerComponent::DtSingleTaskControllerComponent | ( | const DtString & | name, |
| DtVrfObject * | owner, | ||
| DtSimManager * | simManager, | ||
| DtComponentDescriptor * | compDesc = 0, |
||
| DtReaderWriterRegistry * | parentRegistry = 0 |
||
| ) |
(const DtString& name,
| name | Reader writer name of this component. |
| owner | The DtVrfObject that owns this component |
| simManager | The simulation manager (provides access to terrain, message interface, simulation clock). |
| desc | The component descriptor used to initialize this component. |
| parentRegistry | Pointer to the parent reader writer registry (the containing object that reads/writes this object). |
| virtual DtSingleTaskControllerComponent::~DtSingleTaskControllerComponent | ( | ) | [virtual] |
destructor
| virtual void DtSingleTaskControllerComponent::postTick | ( | ) | [virtual] |
Override to check if we're tasked and we want to give up (only performs the check if we're in play mode (dT() > 0)).
Calls decideToGiveUpTask() to determine if we should give up. If true, calls giveUpTask().
Reimplemented from DtTaskControllerComponent.
| virtual bool DtSingleTaskControllerComponent::beginProcessingTask | ( | const DtTaskMessage & | task, |
| DtSimTaskStatePtr | taskState | ||
| ) | [virtual] |
Called by the task manager when this controller should start executing the specified task.
| taskState | Used to convey at what point the task should begin execution. If taskState exists, execution of task may begin at some point other than the logical start of the task. If taskState is 0, begin processing at the logical start of the task. |
Reimplemented from DtTaskControllerComponent.
Reimplemented in DtRotaryWingFlightCommandController, and DtFixedWingFlightCommandController.
| virtual void DtSingleTaskControllerComponent::taskNotify | ( | const DtSimTask & | task | ) | [virtual] |
This is called to let us know when some other component receives a task In the case of this component, we don't care what the task actually is.
Reimplemented from DtTaskControllerComponent.
| virtual void DtSingleTaskControllerComponent::taskComplete | ( | bool | success = true | ) | [virtual] |
If we are currently tasked, this will cause us to notify the entity that we're done and delete the task.
To indicate that the task has failed (and is being abandoned) call this method with success set to false.
Reimplemented in DtFixedWingMoveToController, DtDIGuyController, DtTargetSelectionController, and DtLaunchExpendableResourceController.
| virtual void DtSingleTaskControllerComponent::clearTask | ( | ) | [virtual] |
If component is currently tasked, calls clearPendingSubtasks(), sets the tasked flag to false, and calls clearCurrentTaskMesage() to clear out the current task message.
Reimplemented from DtControllerComponent.
Reimplemented in DtFixedWingMoveAlongController, DtFixedWingMoveToController, DtRailMovementController, DtRailPathController, DtAggregatedMoveToController, DtPathMovementController, DtHumanMoveToController, DtHumanMoveAlongController, DtGroundMoveAlongControllerComponent, DtAggregatedMoveAlongController, vrfLua::DtLuaScriptController, DtDisaggregatedEmbarkationController, DtHumanFollowController, DtDIGuyController, BHAVE::DtKynapseController, DtDisaggregatedMoveAlongController, DtSurfaceEntityPilotController, DtRotaryWingFlightCommandController, DtFixedWingTakeoffController, DtTurnAndMoveController, DtFixedWingLandingController, DtEmbarkationController, DtDisaggregatedMoveIntoFormationController, DtFixedWingFlightCommandController, DtFixedWingPilotController, DtIndirectFireController, DtLasingController, DtHumanTurnToController, DtDisaggregatedMoveToLocationController, DtConvoyTaskController, DtHumanStopMovingController, DtDisaggregatedMoveToController, DtGroundAutoControllerComponent, DtRotaryWingLandingController, and DtRotaryWingTaskController.
| virtual int DtSingleTaskControllerComponent::sendSubtask | ( | DtSimTask & | task | ) | [virtual] |
Sends subtask to ourself.
Creates task message and sends task to ourself through radio. Adds subtask Id to list of pending subtasks. Returns subtask Id.
| virtual void DtSingleTaskControllerComponent::clearSubtask | ( | int | subtaskId | ) | [virtual] |
Clears subtask with the given subtaskId (subtaskId is returned sendSubtask()).
Also removed the subtask ID from the pending subtask ID list.
| virtual void DtSingleTaskControllerComponent::addPendingSubtaskId | ( | int | subtaskId | ) | [virtual] |
Adds given subtask Id to list of pending subtasks.
This is done automatically by sendSubtask (user should not typically have to call this directly).
| virtual bool DtSingleTaskControllerComponent::findPendingSubtaskId | ( | int | subtaskId | ) | [virtual] |
Checks to see if given subtaskId exists in our list of pending subtasks.
Typically checked from within a task complete callback, to determine if given report corresponds to the specific subtask we issued.
| virtual void DtSingleTaskControllerComponent::removePendingSubtaskId | ( | int | subtaskId | ) | [virtual] |
Removes pending subtask from list of subtasks for this component.
Users will typically call this from within a task complete callback, upon receipt of the specific subtasking task complete report they were waiting for.
| virtual void DtSingleTaskControllerComponent::removeAllPendingSubtaskIds | ( | ) | [virtual] |
Clear all pending subtasks from our list of subtasks.
Users should not typically have to call this.
| virtual std::vector<int> DtSingleTaskControllerComponent::currentPendingSubstaskIds | ( | ) | const [virtual] |
Returns the list of all currently pending subtask ids for this controller.
| virtual void DtSingleTaskControllerComponent::clearCurrentTaskMessage | ( | ) | [virtual] |
Returns the current subtask with the specified id.
Also returns the controller that is responsible. If NULL, no task was found Clear the current task message.
Reimplemented in DtFixedWingLandingController, and DtEmbarkationController.
| virtual DtTaskMessage* DtSingleTaskControllerComponent::currentTaskMessage | ( | ) | const [virtual] |
Get a pointer to the message that was used to task this entity.
| virtual DtSimTaskStatePtr DtSingleTaskControllerComponent::currentTaskState | ( | ) | const [virtual] |
Reimplemented in DtAggregatedMoveAlongController, DtDisaggregatedMoveAlongController, DtWaitController, DtDisaggregatedPatrolAlongController, DtDisaggregatedPatrolBetweenController, and DtAggregatedPatrolController.
| virtual bool DtSingleTaskControllerComponent::decideToGiveUpTask | ( | ) | const [virtual] |
This function is used to determine if the controller should give up trying to execute the current task.
Override this function to provide the test for determining if the task controller should give up. For example, a derived move-to-waypoint controller tasked to reach an unreachable waypoint might decide to give up after a certain amount of time, or after circling the point and failing to reach it. This function is called from within tick. If the controller is tasked and this function returns true, it calls giveUp(). The implementation in this class always returns false.
Reimplemented in DtFixedWingPilotController, DtGroundMoveToDestinationControllerComponent, DtSurfaceEntityPilotController, DtRailMovementController, DtGroundAutoControllerComponent, DtHumanMoveToController, DtGroundMoveAlongControllerComponent, DtHumanMoveAlongController, and DerivedMoveToController.
| virtual void DtSingleTaskControllerComponent::giveUpTask | ( | ) | [virtual] |
Called when controller is tasked and decideToGiveUp() returns true.
Base class implementation calls clearTask(). Derived classes may override this function to perform some specific handling.
Reimplemented in DerivedMoveToController.
| virtual bool DtSingleTaskControllerComponent::taskActive | ( | int | taskId | ) | const [virtual] |
Implements DtTaskControllerComponent.
| virtual bool DtSingleTaskControllerComponent::clearTopLevelTasks | ( | ) | [virtual] |
If this controller has any top level tasks (not subtasks), they are cleared.
Implements DtTaskControllerComponent.
| virtual void DtSingleTaskControllerComponent::clearConflictingTopLevelTasks | ( | int | conflictId | ) | [virtual] |
Clears any top level tasks on this controller that conflict with the conflictId.
The task manager is used to determine what tasks conflict.
Implements DtTaskControllerComponent.
| virtual void DtSingleTaskControllerComponent::clearTasksByType | ( | int | taskType | ) | [virtual] |
Clears any tasks of the specified type running in this controller.
Implements DtTaskControllerComponent.
| virtual void DtSingleTaskControllerComponent::clearTaskById | ( | int | taskId | ) | [virtual] |
Clears any task of the specified ID running in this controller.
Implements DtTaskControllerComponent.
| virtual std::list<DtTaskMessage*> DtSingleTaskControllerComponent::currentTaskMessages | ( | ) | const [virtual] |
Implements DtTaskControllerComponent.
| virtual DtTaskWithTaskStateListPtr DtSingleTaskControllerComponent::topLevelTasks | ( | ) | const [virtual] |
Implements DtTaskControllerComponent.
| virtual void DtSingleTaskControllerComponent::clearPendingSubtasks | ( | ) | [protected, virtual] |
Iterates over collection of all pending subtasks for this controller, and calls clearSubtask() for each subtask type.
| virtual void DtSingleTaskControllerComponent::clearSubtasksByType | ( | int | taskType | ) | [protected, virtual] |
Clear all subtasks of a given type.
Should not normally be called (call clearSubtask(int subtaskId) to clear a given subtask instead). Provided as a utility function as an aid to backwards compatibility.