Fawkes API Fawkes Development Version

backend_thread.h

00001 
00002 /***************************************************************************
00003  *  backend_thread.h - World Info Viewer backend thread
00004  *
00005  *  Created: Thu April 10 21:53:24 2008
00006  *  Copyright  2008  Daniel Beck
00007  *
00008  ****************************************************************************/
00009 
00010 /*  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU Library General Public License for more details.
00019  *
00020  *  Read the full text in the LICENSE.GPL file in the doc directory.
00021  */
00022 
00023 #ifndef __TOOL_WORLDINFO_VIEWER_BACKEND_THREAD_H_
00024 #define __TOOL_WORLDINFO_VIEWER_BACKEND_THREAD_H_
00025 
00026 #include <netcomm/worldinfo/handler.h>
00027 #include <netcomm/utils/resolver.h>
00028 #include <netcomm/dns-sd/avahi_thread.h>
00029 #include <core/threading/thread.h>
00030 
00031 #include <gtkmm.h>
00032 #include <string>
00033 
00034 namespace fawkes {
00035   class WorldInfoTransceiver;
00036   class WorldInfoDataContainer;
00037 }
00038 
00039 class WorldInfoViewerBackendThread
00040 : public fawkes::Thread,
00041   public fawkes::WorldInfoHandler
00042 {
00043  public:
00044   WorldInfoViewerBackendThread( fawkes::WorldInfoDataContainer* data_container,
00045                                 const char* addr, unsigned short port,
00046                                 const char* key, const char* iv );
00047 
00048   virtual ~WorldInfoViewerBackendThread();
00049 
00050   Glib::Dispatcher& new_worldinfo_data();
00051   Glib::Dispatcher& new_gamestate_data();
00052 
00053   // thread
00054   void loop();
00055 
00056   // handler
00057   virtual void pose_rcvd( const char *from_host,
00058                           float x, float y, float theta,
00059                           float *covariance );
00060 
00061   virtual void velocity_rcvd( const char *from_host, float vel_x,
00062                               float vel_y, float vel_theta, float *covariance );
00063 
00064   virtual void ball_pos_rcvd( const char *from_host,
00065                               bool visible, int visibility_history,
00066                               float dist, float pitch, float yaw,
00067                               float *covariance );
00068 
00069   virtual void global_ball_pos_rcvd( const char *from_host,
00070                                      bool visible, int visibility_history,
00071                                      float x, float y, float z,
00072                                      float *covariance );
00073 
00074   virtual void ball_velocity_rcvd( const char *from_host,
00075                                    float vel_x, float vel_y, float vel_z,
00076                                    float *covariance );
00077 
00078   virtual void global_ball_velocity_rcvd(const char *from_host,
00079                                          float vel_x, float vel_y, float vel_z,
00080                                          float *covariance);
00081 
00082   virtual void opponent_pose_rcvd( const char *from_host, unsigned int uid,
00083                                    float distance, float angle,
00084                                    float *covarianceconst );
00085   
00086   virtual void opponent_disapp_rcvd( const char *from_host, unsigned int uid );
00087 
00088   virtual void gamestate_rcvd( const char *from_host,
00089                                unsigned int game_state, 
00090                                fawkes::worldinfo_gamestate_team_t state_team, 
00091                                unsigned int score_cyan, unsigned int score_magenta, 
00092                                fawkes::worldinfo_gamestate_team_t our_team, 
00093                                fawkes::worldinfo_gamestate_goalcolor_t our_goal_color,
00094                                fawkes::worldinfo_gamestate_half_t half );
00095 
00096   virtual void penalty_rcvd(const char *from_host,
00097                             unsigned int player, unsigned int penalty,
00098                             unsigned int seconds_remaining);
00099 
00100  private:
00101   fawkes::WorldInfoTransceiver*   m_transceiver;
00102   fawkes::WorldInfoDataContainer* m_data_container;
00103 
00104   Glib::Dispatcher m_signal_new_worldinfo_data;
00105   Glib::Dispatcher m_signal_new_gamestate_data;
00106 
00107   std::string    m_addr;
00108   unsigned short m_port;
00109   std::string    m_key;
00110   std::string    m_iv;
00111 
00112   fawkes::NetworkNameResolver* m_resolver;
00113   fawkes::AvahiThread*         m_avahi;
00114 
00115 };
00116 
00117 #endif /* __TOOL_WORLDINFO_VIEWER_BACKEND_THREAD_H_ */
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends