device.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef _DEVICE_H
00030 #define _DEVICE_H
00031
00032 #include <libplayercore/player.h>
00033 #include <libplayercore/message.h>
00034
00035 #define LOCALHOST_ADDR 16777343
00036
00037
00038 class Driver;
00039
00045 class Device
00046 {
00047 private:
00048 public:
00049
00054 Device(player_devaddr_t addr, Driver *driver);
00055
00057 ~Device();
00058
00062 int Subscribe(MessageQueue* sub_queue);
00063
00067 int Unsubscribe(MessageQueue* sub_queue);
00068
00082 void PutMsg(MessageQueue* resp_queue,
00083 uint8_t type,
00084 uint8_t subtype,
00085 void* src,
00086 size_t len,
00087 double* timestamp);
00088
00097 void PutMsg(MessageQueue* resp_queue,
00098 player_msghdr_t* hdr,
00099 void* src);
00100
00123 Message* Request(MessageQueue* resp_queue,
00124 uint8_t type,
00125 uint8_t subtype,
00126 void* src,
00127 size_t len,
00128 double* timestamp,
00129 bool threaded = true);
00130
00136 static bool MatchDeviceAddress(player_devaddr_t addr1,
00137 player_devaddr_t addr2)
00138 {
00139
00140
00141
00142
00143
00144 return(((addr1.host == addr2.host) ||
00145 ((addr1.host == 0) && (addr2.host == LOCALHOST_ADDR)) ||
00146 ((addr1.host == LOCALHOST_ADDR) && (addr2.host == 0))) &&
00147 (addr1.robot == addr2.robot) &&
00148 (addr1.interf == addr2.interf) &&
00149 (addr1.index == addr2.index));
00150 }
00151
00153 Device* next;
00154
00156 player_devaddr_t addr;
00157
00159 char drivername[PLAYER_MAX_DRIVER_STRING_LEN];
00160
00162 Driver* driver;
00163
00165 MessageQueue** queues;
00166
00168 size_t len_queues;
00169 };
00170
00171 #endif
Last updated 12 September 2005 21:38:45
|