00001 /** 00002 * @file Process.cpp 00003 * 00004 * Implementation of class Process. 00005 */ 00006 00007 #define USE_GETMESSAGEIDNAME 00008 #include "Tools/Process.h" 00009 #include "Tools/Player.h" 00010 #include "Tools/RobotConfiguration.h" 00011 #include "Tools/Debugging/Debugging.h" 00012 00013 Process::Process(MessageQueue& debugIn, MessageQueue& debugOut) 00014 : debugIn(debugIn), debugOut(debugOut) 00015 { 00016 // read the player.cfg 00017 getPlayer().load(); 00018 getRobotConfiguration().load(); 00019 00020 // cannot initialize debugIn/debugOut here, because they have not yet been constructed 00021 // But there addresses can already be stored 00022 initDebugging(&debugOut.out,&debugKeyTable); 00023 initialized = false; 00024 } 00025 00026 int Process::processMain() 00027 { 00028 if(!initialized) 00029 { 00030 debugIn.setPlayerForNewMessages(getPlayer()); // This is not needed except in the Win32 version of OVirtualRobotComm 00031 init(); 00032 initialized = true; 00033 } 00034 // team color can change, so set it always 00035 debugOut.setPlayerForNewMessages(getPlayer()); 00036 00037 #ifndef NDEBUG 00038 debugIn.handleAllMessages(*this); 00039 debugIn.clear(); 00040 debugKeyTable.activate(); 00041 #endif 00042 00043 return this->main(); 00044 } 00045 00046 bool Process::handleMessage(InMessage& message) 00047 { 00048 switch (message.getMessageID()) 00049 { 00050 case idDebugKeyTable: 00051 message.bin >> debugKeyTable; 00052 return true; 00053 case idSolutionRequest: 00054 { 00055 SolutionRequest request; 00056 message.bin >> request; 00057 moduleHandler.selectSolutions(request); 00058 } 00059 return true; 00060 default: 00061 if (moduleHandler.handleMessage(message)) 00062 { 00063 // OUTPUT(idText,text,"Process::handleDebugMessage : Handled "<< getMessageIDName(message.getMessageID())); 00064 return true; 00065 } 00066 else 00067 { 00068 OUTPUT(idText,text,"Process::handleDebugMessage : Unhandled debug message ("<< getMessageIDName(message.getMessageID()) << ")"); 00069 return false; 00070 } 00071 } 00072 } 00073 00074 /* 00075 * Change log : 00076 * 00077 * $Log: Process.cpp,v $ 00078 * Revision 1.1.1.1 2004/05/22 17:35:54 cvsadm 00079 * created new repository GT2004_WM 00080 * 00081 * Revision 1.3 2004/04/11 18:49:46 roefer 00082 * Team color is sent again from Cognition to Motion. 00083 * Otherwise, messages sent by Motion may contain the wrong team color. 00084 * 00085 * Revision 1.2 2003/12/06 23:23:55 loetzsch 00086 * messages in a MessageQueue now contain 00087 * - the team color of the robot which sent the message 00088 * - the player number of the robot which sent the message 00089 * - if the message was sent from a physical robot or not 00090 * 00091 * Revision 1.1 2003/10/07 10:13:21 cvsadm 00092 * Created GT2004 (M.J.) 00093 * 00094 * Revision 1.1.1.1 2003/07/02 09:40:28 cvsadm 00095 * created new repository for the competitions in Padova from the 00096 * tamara CVS (Tuesday 2:00 pm) 00097 * 00098 * removed unused solutions 00099 * 00100 * Revision 1.10 2003/05/03 16:20:01 roefer 00101 * robot.cfg added 00102 * 00103 * Revision 1.9 2003/03/06 18:19:34 dueffert 00104 * reduced amount of warnings drastically by ifdefing global functions 00105 * 00106 * Revision 1.8 2003/01/17 12:48:19 jhoffman 00107 * added GenericDebugData 00108 * changes to the TestDataGenerator towards using sliders, min/max, and other cool stuff 00109 * 00110 * Revision 1.7 2003/01/16 09:54:49 jhoffman 00111 * Added "Generic Debug Data" data type. This can be used 00112 * for quick and dirty optimization and debugging, e.g. to send 00113 * parameters to a module through WLAN to adjust it's settings. 00114 * The DebugMessageGenerator is used to for parsing and 00115 * sendig the data 00116 * 00117 * Revision 1.6 2002/10/01 11:14:34 loetzsch 00118 * Redesigned DebugKey and DebugKeyTable 00119 * 00120 * Revision 1.5 2002/09/29 18:02:51 loetzsch 00121 * removed the INIT_DEBUG_KEY_TABLE macro from debugging.h 00122 * 00123 * Revision 1.4 2002/09/29 12:32:37 juengel 00124 * Changed semantics of "debug key is active". 00125 * If a debug key is active changes only before the execution of a process. 00126 * 00127 * Revision 1.3 2002/09/17 23:55:23 loetzsch 00128 * - unraveled several datatypes 00129 * - changed the WATCH macro 00130 * - completed the process restructuring 00131 * 00132 * Revision 1.2 2002/09/10 21:07:30 loetzsch 00133 * continued change of module/solution mechanisms 00134 * 00135 * Revision 1.1 2002/09/10 15:53:58 cvsadm 00136 * Created new project GT2003 (M.L.) 00137 * - Cleaned up the /Src/DataTypes directory 00138 * - Removed challenge related source code 00139 * - Removed processing of incoming audio data 00140 * - Renamed AcousticMessage to SoundRequest 00141 * 00142 * Revision 1.3 2002/07/23 13:48:40 loetzsch 00143 * - new streaming classes 00144 * - removed many #include statements 00145 * - exchanged StaticQueue by MessageQueue 00146 * - new debug message handling 00147 * - general clean up 00148 * 00149 * Revision 1.2 2002/06/28 10:26:22 roefer 00150 * OUTPUT is possible in constructors 00151 * 00152 * Revision 1.1.1.1 2002/05/10 12:40:32 cvsadm 00153 * Moved GT2002 Project from ute to tamara. 00154 * 00155 * Revision 1.15 2002/04/09 11:18:18 loetzsch 00156 * now handles idPlayerConfig 00157 * 00158 * Revision 1.14 2002/02/05 20:02:16 risler 00159 * handleDebugMessage now returns bool, added debug message handling to ImageProcessor 00160 * 00161 * Revision 1.13 2002/02/05 03:43:51 loetzsch 00162 * now loads the player configuration from player.cfg at startup 00163 * 00164 * Revision 1.12 2002/01/30 17:29:13 loetzsch 00165 * handleDebugMessage um Parameter timestamp erweitert 00166 * 00167 * Revision 1.11 2002/01/25 12:51:52 risler 00168 * added message id names 00169 * 00170 * Revision 1.10 2002/01/22 22:42:25 loetzsch 00171 * Added init() again. 00172 * 00173 * Revision 1.9 2002/01/19 12:43:16 risler 00174 * enabled SolutionRequest, changed HandleDebugMessage calls 00175 * 00176 * Revision 1.8 2002/01/18 23:27:51 loetzsch 00177 * solutionRequest and setSolutionRequest added 00178 * 00179 * Revision 1.7 2002/01/15 16:25:09 roefer 00180 * init() removed 00181 * 00182 * Revision 1.6 2001/12/20 17:12:25 loetzsch 00183 * Virtual function init(), that is called before the first main(), 00184 * added. 00185 * 00186 * Revision 1.5 2001/12/15 20:32:08 roefer 00187 * Senders and receivers are now part of the processes 00188 * 00189 * Revision 1.4 2001/12/12 18:08:56 loetzsch 00190 * Streaming- Operatoren für Bilder eingebaut, DebugKeyTable nicht- statisch gemacht, Debuggin Mechanismen weitergemacht, Bilder aus Logfiles in RobotControl anzeigen, Logfiles in HU1/Debug auf den Stick schreiben 00191 * 00192 * Revision 1.3 2001/12/10 17:47:10 risler 00193 * change log added 00194 * 00195 */