VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
13 
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.
25 {
26 private:
27  //Not Implemented.
29  //Not Implemented.
31  //Not Implemented.
33 
34 public:
35 
36  //\copydoc DtSimComponent(const DtString&,DtVrfObject*,DtSimManager*,
37  //DtComponentDescriptor*,DtReaderWriterRegistry* parentRegistry)
39  DtVrfObject* owner,
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:
106  {
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.
117 };
118 
119 #endif

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)