00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00024
00025
00026
00027
00029
00030 #include "toranger.h"
00031
00033
00035
00036
00037
00038 ToRanger::ToRanger (ConfigFile* cf, int section)
00039 : Driver (cf, section, false, PLAYER_MSGQUEUE_DEFAULT_MAXLEN, PLAYER_RANGER_CODE)
00040 {
00041 inputDevice = NULL;
00042 }
00043
00044
00045 ToRanger::~ToRanger (void)
00046 {
00047 if (deviceGeom.sensor_poses != NULL)
00048 delete deviceGeom.sensor_poses;
00049 if (deviceGeom.sensor_sizes != NULL)
00050 delete deviceGeom.sensor_sizes;
00051 }
00052
00053
00054
00055 int ToRanger::Setup (void)
00056 {
00057
00058 memset (&deviceGeom, 0, sizeof (deviceGeom));
00059
00060 return 0;
00061 }
00062
00063
00064
00065 int ToRanger::Shutdown (void)
00066 {
00067 if (deviceGeom.sensor_poses != NULL)
00068 {
00069 delete deviceGeom.sensor_poses;
00070 deviceGeom.sensor_poses = NULL;
00071 }
00072 if (deviceGeom.sensor_sizes != NULL)
00073 {
00074 delete deviceGeom.sensor_sizes;
00075 deviceGeom.sensor_sizes = NULL;
00076 }
00077
00078 return 0;
00079 }
00080
00082
00084
00085
00086 int ToRanger::ProcessMessage (QueuePointer &respQueue, player_msghdr *hdr, void *data)
00087 {
00088
00089 HANDLE_CAPABILITY_REQUEST (device_addr, respQueue, hdr, data, PLAYER_MSGTYPE_REQ, PLAYER_CAPABILTIES_REQ);
00090
00091
00092 if (Message::MatchMessage (hdr, PLAYER_MSGTYPE_REQ, PLAYER_GET_INTPROP_REQ, device_addr) ||
00093 Message::MatchMessage (hdr, PLAYER_MSGTYPE_REQ, PLAYER_SET_INTPROP_REQ, device_addr) ||
00094 Message::MatchMessage (hdr, PLAYER_MSGTYPE_REQ, PLAYER_GET_DBLPROP_REQ, device_addr) ||
00095 Message::MatchMessage (hdr, PLAYER_MSGTYPE_REQ, PLAYER_SET_DBLPROP_REQ, device_addr) ||
00096 Message::MatchMessage (hdr, PLAYER_MSGTYPE_REQ, PLAYER_GET_STRPROP_REQ, device_addr) ||
00097 Message::MatchMessage (hdr, PLAYER_MSGTYPE_REQ, PLAYER_SET_STRPROP_REQ, device_addr))
00098 {
00099 inputDevice->PutMsg (InQueue, hdr, data);
00100 ret_queue = respQueue;
00101 return 0;
00102 }
00103
00104 else if (Message::MatchMessage (hdr, PLAYER_MSGTYPE_RESP_ACK, PLAYER_GET_INTPROP_REQ, inputDeviceAddr) ||
00105 Message::MatchMessage (hdr, PLAYER_MSGTYPE_RESP_ACK, PLAYER_SET_INTPROP_REQ, inputDeviceAddr) ||
00106 Message::MatchMessage (hdr, PLAYER_MSGTYPE_RESP_ACK, PLAYER_GET_DBLPROP_REQ, inputDeviceAddr) ||
00107 Message::MatchMessage (hdr, PLAYER_MSGTYPE_RESP_ACK, PLAYER_SET_DBLPROP_REQ, inputDeviceAddr) ||
00108 Message::MatchMessage (hdr, PLAYER_MSGTYPE_RESP_ACK, PLAYER_GET_STRPROP_REQ, inputDeviceAddr) ||
00109 Message::MatchMessage (hdr, PLAYER_MSGTYPE_RESP_ACK, PLAYER_SET_STRPROP_REQ, inputDeviceAddr) ||
00110 Message::MatchMessage (hdr, PLAYER_MSGTYPE_RESP_NACK, PLAYER_GET_INTPROP_REQ, inputDeviceAddr) ||
00111 Message::MatchMessage (hdr, PLAYER_MSGTYPE_RESP_NACK, PLAYER_SET_INTPROP_REQ, inputDeviceAddr) ||
00112 Message::MatchMessage (hdr, PLAYER_MSGTYPE_RESP_NACK, PLAYER_GET_DBLPROP_REQ, inputDeviceAddr) ||
00113 Message::MatchMessage (hdr, PLAYER_MSGTYPE_RESP_NACK, PLAYER_SET_DBLPROP_REQ, inputDeviceAddr) ||
00114 Message::MatchMessage (hdr, PLAYER_MSGTYPE_RESP_NACK, PLAYER_GET_STRPROP_REQ, inputDeviceAddr) ||
00115 Message::MatchMessage (hdr, PLAYER_MSGTYPE_RESP_NACK, PLAYER_SET_STRPROP_REQ, inputDeviceAddr))
00116 {
00117 hdr->addr = device_addr;
00118 Publish (ret_queue, hdr, data);
00119 return 0;
00120 }
00121
00122 return -1;
00123 }