src/SenseHandler.h

Go to the documentation of this file.
00001 /*
00002 Copyright (c) 2000-2003, Jelle Kok, University of Amsterdam
00003 All rights reserved.
00004 
00005 Redistribution and use in source and binary forms, with or without
00006 modification, are permitted provided that the following conditions are met:
00007 
00008 1. Redistributions of source code must retain the above copyright notice, this
00009 list of conditions and the following disclaimer.
00010 
00011 2. Redistributions in binary form must reproduce the above copyright notice,
00012 this list of conditions and the following disclaimer in the documentation
00013 and/or other materials provided with the distribution.
00014 
00015 3. Neither the name of the University of Amsterdam nor the names of its
00016 contributors may be used to endorse or promote products derived from this
00017 software without specific prior written permission.
00018 
00019 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00020 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00022 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
00023 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00024 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00025 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00026 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00027 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00028 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00029 */
00030 
00047 #ifndef _SENSEHANDLER_
00048 #define _SENSEHANDLER_
00049 
00050 #include "Connection.h"
00051 #include "WorldModel.h"
00052 #include "ActionScheduler.h"
00053 
00054 extern Logger Log; 
00056 #ifdef WIN32
00057   DWORD WINAPI sense_callback( LPVOID v );
00058 #else
00059   void* sense_callback( void *v );
00060 #endif
00061 
00062 using namespace std;
00063 
00064 /*****************************************************************************/
00065 /********************* CLASS SENSEHANDLER ************************************/
00066 /*****************************************************************************/
00067 
00079 class SenseHandler {
00080   WorldModel     *WM;        
00081   ServerSettings *SS;        
00082   PlayerSettings *PS;        
00083   Connection* connection;    
00084   ActionScheduler *AS;       
00085   int         iTimeSignal;   
00086   int         iTriCounter;   
00087   int         m_iSeeCounter; 
00088   int         iSimStep;      
00089   int             iLastCycle;
00090 #ifdef WIN32
00091   UINT        iTimer;        
00092   UINT        timerRes;      
00093 #else
00094   struct      itimerval itv; 
00095 #endif
00096 
00097 
00098 public:
00099   SenseHandler( Connection* c, WorldModel* wm, ServerSettings *ss,
00100                 PlayerSettings *ps, ActionScheduler *as );
00101 
00102   // start the loop to handle the messages from the server
00103   void    handleMessagesFromServer      (              );
00104 
00105   // methods to determine when the next action should be sent to the server.
00106   void    setTimeSignal                 (                            );
00107 
00108   // method to analyze incoming messages
00109   bool    analyzeMessage                ( char *strMsg               );
00110   bool    analyzeSeeGlobalMessage       ( char *strMsg               );
00111   bool    analyzeFullStateMessage       ( char *strMsg               );  
00112   bool    analyzeSeeMessage             ( char *strMsg               );
00113   bool    analyzeSenseMessage           ( char *strMsg               );
00114   bool    analyzeInitMessage            ( char *strMsg               );
00115   bool    analyzeHearMessage            ( char *strMsg               );
00116   bool    analyzePlayerMessage          ( int  iTime  , char *strMsg );
00117   bool    analyzeCoachMessage           ( char *strMsg               );  
00118   bool    analyzeChangePlayerTypeMessage( char *strMsg               );
00119   bool    analyzeServerParamMessage     ( char *strMsg               );
00120   bool    analyzeCheckBall              ( char *strMsg               );
00121   bool    analyzePlayerTypeMessage      ( char *strMsg               );
00122   bool    analyzePlayerParamMessage     ( char *strMsg               );
00123         
00124   // utility functions
00125   bool    readServerParam               ( char *strParam, 
00126                                           char *strMsg               );
00127 };
00128 
00129 #endif

Generated on Thu Apr 26 22:45:27 2007 for GangOfSix(GOS)-RoboCupTeamProject by  doxygen 1.5.1-p1