p_driver.h

Go to the documentation of this file.
00001 #ifndef _STAGE_PLAYER_DRIVER_H
00002 #define _STAGE_PLAYER_DRIVER_H
00003 
00004 #include <unistd.h>
00005 #include <string.h>
00006 #include <netinet/in.h>
00007 #include <math.h>
00008 
00009 #include "player.h"
00010 #include "player/device.h"
00011 #include "player/driver.h"
00012 #include "player/configfile.h"
00013 #include "player/drivertable.h"
00014 #include <player/drivertable.h>
00015 #include <player/driver.h>
00016 #include <player/error.h>
00017 #include "playercommon.h"
00018 
00019 #include "stage_internal.h"
00020 #include "stg_time.h"
00021 
00022 #define DRIVER_ERROR(X) printf( "Stage driver error: %s\n", X )
00023 
00024 // foward declare;
00025 class Interface;
00026 
00027 class StgDriver : public Driver
00028 {
00029  public:
00030   // Constructor; need that
00031   StgDriver(ConfigFile* cf, int section);
00032   
00033   // Destructor
00034   ~StgDriver(void);
00035   
00036   // Must implement the following methods.
00037   virtual int Setup();
00038   virtual int Shutdown();
00039   virtual int Subscribe(player_device_id_t id);
00040   virtual int Unsubscribe(player_device_id_t id);
00041     
00044   virtual void Update();
00045 
00048   virtual int PutConfig(player_device_id_t id, void* cli, 
00049                         void* src, size_t len,
00050                         struct timeval* timestamp);
00051 
00053   static stg_world_t* world;
00054   
00056   Interface* LookupDevice( player_device_id_t id );
00057   
00058   stg_model_t* LocateModel( const char* basename, 
00059                             stg_model_initializer_t init );
00060   
00061  protected: 
00062   
00064   GPtrArray* devices;  
00065 };
00066 
00067 
00068 class Interface
00069 {
00070  public:
00071   Interface( player_device_id_t id,  StgDriver* driver,ConfigFile* cf, int section );
00072   
00073   virtual ~Interface( void ){ /* TODO: clean up*/ };
00074 
00075   player_device_id_t id;
00076   stg_model_t* mod;
00077   
00078   StgDriver* driver; // the driver instance that created this device
00079   
00080   size_t data_len;
00081   size_t cmd_len;
00082   size_t req_qlen;
00083   size_t rep_qlen;
00084 
00085   // pure virtual methods
00086   virtual void Command( void* buffer, size_t len ){}; // empty implementation
00087   virtual void Configure( void* client, void* buffer, size_t len ){}; // empty implementation
00088   virtual void Publish( void ){}; // empty implementation
00089 };
00090 
00091 
00092 class InterfaceSimulation : public Interface
00093 {
00094  public: 
00095   InterfaceSimulation( player_device_id_t id,  StgDriver* driver,ConfigFile* cf, int section );
00096   virtual ~InterfaceSimulation( void ){ /* TODO: clean up*/ };
00097 
00098   //virtual void Command( void* buffer, size_t len ); 
00099   virtual void Configure( void* client, void* buffer, size_t len );
00100 };
00101 
00102 
00103 class InterfaceModel : public Interface
00104 {
00105  public: 
00106   InterfaceModel( player_device_id_t id,  
00107                   StgDriver* driver,
00108                   ConfigFile* cf, 
00109                   int section, 
00110                   stg_model_initializer_t init );
00111   
00112   virtual ~InterfaceModel( void ){ /* TODO: clean up*/ };
00113 };
00114 
00115 class InterfacePosition : public InterfaceModel
00116 {
00117  public: 
00118   InterfacePosition( player_device_id_t id, StgDriver* driver, ConfigFile* cf, int section );
00119   virtual ~InterfacePosition( void ){ /* TODO: clean up*/ };
00120   virtual void Command( void* buffer, size_t len ); 
00121   virtual void Configure( void* client, void* buffer, size_t len );
00122   virtual void Publish( void );
00123 };
00124  
00125 class InterfaceGripper : public InterfaceModel
00126 {
00127  public: 
00128   InterfaceGripper( player_device_id_t id, StgDriver* driver, ConfigFile* cf, int section );
00129   virtual ~InterfaceGripper( void ){ /* TODO: clean up*/ };
00130   virtual void Command( void* buffer, size_t len ); 
00131   virtual void Configure( void* client, void* buffer, size_t len );
00132   virtual void Publish( void );
00133 };
00134 
00135 class InterfaceLaser : public InterfaceModel
00136 {
00137  public: 
00138   InterfaceLaser( player_device_id_t id, StgDriver* driver, ConfigFile* cf, int section );
00139   virtual ~InterfaceLaser( void ){ /* TODO: clean up*/ };
00140   //virtual void Command( void* buffer, size_t len ); 
00141   virtual void Configure( void* client, void* buffer, size_t len );
00142   virtual void Publish( void );
00143 };
00144 
00145 class InterfaceFiducial : public InterfaceModel
00146 {
00147  public: 
00148   InterfaceFiducial( player_device_id_t id, StgDriver* driver, ConfigFile* cf, int section );
00149   virtual ~InterfaceFiducial( void ){ /* TODO: clean up*/ };
00150   //virtual void Command( void* buffer, size_t len ); 
00151   virtual void Configure( void* client, void* buffer, size_t len );
00152   virtual void Publish( void );
00153 };
00154  
00155 class InterfaceBlobfinder : public InterfaceModel
00156 {
00157  public: 
00158   InterfaceBlobfinder( player_device_id_t id, StgDriver* driver, ConfigFile* cf, int section );
00159   virtual ~InterfaceBlobfinder( void ){ /* TODO: clean up*/ };
00160   //virtual void Command( void* buffer, size_t len ); 
00161   virtual void Configure( void* client, void* buffer, size_t len );
00162   virtual void Publish( void );
00163 };
00164 
00165 class InterfaceSonar : public InterfaceModel
00166 {
00167  public: 
00168   InterfaceSonar( player_device_id_t id, StgDriver* driver, ConfigFile* cf, int section );
00169   virtual ~InterfaceSonar( void ){ /* TODO: clean up*/ };
00170   //virtual void Command( void* buffer, size_t len ); 
00171   virtual void Configure( void* client, void* buffer, size_t len );
00172   virtual void Publish( void );
00173 };
00174 
00175 
00176 
00177 #endif

Generated on Thu Aug 11 13:08:10 2005 for Stage by  doxygen 1.4.0