VR-Forces Development_Version Class Documentation
Home
Modules
Namespaces
Classes
Files
Examples
Behavior Models
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
examples
subtask
turnAndMoveController.h
Go to the documentation of this file.
1
/*******************************************************************************
2
** Copyright (c) 2005 MAK Technologies, Inc.
3
** All rights reserved.
4
*******************************************************************************/
5
/*******************************************************************************
6
** $RCSfile: turnAndMoveController.h,v $ $Revision: 1.3 $ $State: Exp $
7
*******************************************************************************/
8
9
#ifndef turnAndMoveController_H_
10
#define turnAndMoveController_H_
11
12
#include "
vrfobjcore/singleTaskControllerComponent.h
"
13
14
class
DtTurnAndMoveControllerPSR
;
15
16
const
char
DtTurnAndMoveControllerType
[] =
"turn-and-move-controller"
;
17
18
//This example controller responds to a user task with the name "turn-and-move"
19
//and argument 1 specifying the name of a destination object (i.e. a waypoint).
20
//The task is carried out by first issuing a Turn To Heading subtask, and
21
//when that completes, issuing a Move To task.
22
//The controller registers for DtTaskCompletedReport messages from itself
23
//in order to find out when a subtask has completed.
24
class
DtTurnAndMoveController
:
public
DtSingleTaskControllerComponent
25
{
26
private
:
27
//Not Implemented.
28
DtTurnAndMoveController
();
29
//Not Implemented.
30
DtTurnAndMoveController
(
const
DtTurnAndMoveController
& orig);
31
//Not Implemented.
32
DtTurnAndMoveController
&
operator=
(
const
DtTurnAndMoveController
& orig);
33
34
public
:
35
36
//\copydoc DtSimComponent(const DtString&,DtVrfObject*,DtSimManager*,
37
//DtComponentDescriptor*,DtReaderWriterRegistry* parentRegistry)
38
DtTurnAndMoveController
(
const
DtString
&
name
,
39
DtVrfObject
* owner,
40
DtSimManager
*
simManager
,
41
DtComponentDescriptor
* desc = NULL,
42
DtReaderWriterRegistry
* parentRegistry = NULL);
43
44
virtual
~DtTurnAndMoveController
();
45
46
//Initial setup of component after creation.
47
virtual
bool
init
();
48
49
//Creates the process state repository for this component.
50
virtual
bool
createPSR
();
51
52
//\copydoc DtSimComponent::type()
53
//\return DtTurnAndMoveControllerType.
54
virtual
DtString
type
()
const
;
55
56
//Overridden to register interest in user-task and task-completed
57
//radio messages.
58
virtual
void
registerTaskMsgCallbacks
();
59
60
//Callback for DtUserTask. Calls the virtual processUserTask().
61
static
void
userTaskCallback
(
DtSimMessage
* msg,
void
* usr);
62
63
//Starts this task.
64
//Looks for DtUserTasks with name of "turn-and-move" with
65
//the first argument being the name of the destination object.
66
virtual
void
processUserTask
(
DtSimMessage
* msg);
67
68
//Callback for DtTaskCompletedReport.
69
//Calls the virtual processTaskCompleteReport().
70
static
void
taskCompleteReportCallback
(
DtSimMessage
* msg,
void
* usr);
71
72
//Listens for task completed reports from the subtasks that
73
//are started by this task, and issues the next subtask,
74
//or completes the task as necessary when the reports arrive.
75
virtual
void
processTaskCompleteReport
(
DtSimMessage
* msg);
76
77
//Main processing for component.
78
virtual
void
tick
();
79
80
protected
:
81
82
//Calculates the heading to the destination and starts a
83
//turn to heading subtask.
84
virtual
bool
startTurningPhase
();
85
86
//Starts a move to subtask.
87
virtual
bool
startMovingPhase
();
88
89
//Overridden for any resource cleanup when task is cleared.
90
//For this example, only calls down to the base class.
91
virtual
void
clearTask
();
92
93
public
:
94
95
//\copydoc DtSimComponent(const DtString&,DtVrfObject*,DtSimManager*,
96
//DtComponentDescriptor*,DtReaderWriterRegistry* parentRegistry)
97
//\return New instance of this class.
98
static
DtSimComponent
*
creator
(
const
DtString
& name,
99
DtVrfObject
* owner,
100
DtSimManager
* simManager,
101
DtComponentDescriptor
* desc = 0,
102
DtReaderWriterRegistry
* parentRegistry = 0);
103
104
protected
:
105
enum
DtControllerStates
106
{
107
StateTurning
,
108
StateMoving
109
};
110
111
//All state values for this controller are stored in a process state
112
//repository, so that if the scenario is saved during the execution
113
//of the task, it will resume correctly when the scenario is reloaded.
114
//See the addPSR example for more information specifically about
115
//using process state repositories.
116
DtTurnAndMoveControllerPSR
*
myProcessState
;
117
};
118
119
#endif
Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (
www.mak.com
)