SelfTest.h
Go to the documentation of this file.
00001 #ifndef _ROS_SERVICE_SelfTest_h
00002 #define _ROS_SERVICE_SelfTest_h
00003 #include <stdint.h>
00004 #include <string.h>
00005 #include <stdlib.h>
00006 #include "ros/msg.h"
00007 #include "diagnostic_msgs/DiagnosticStatus.h"
00008 
00009 namespace diagnostic_msgs
00010 {
00011 
00012 static const char SELFTEST[] = "diagnostic_msgs/SelfTest";
00013 
00014   class SelfTestRequest : public ros::Msg
00015   {
00016     public:
00017 
00018     virtual int serialize(unsigned char *outbuffer) const
00019     {
00020       int offset = 0;
00021       return offset;
00022     }
00023 
00024     virtual int deserialize(unsigned char *inbuffer)
00025     {
00026       int offset = 0;
00027      return offset;
00028     }
00029 
00030     const char * getType(){ return SELFTEST; };
00031     const char * getMD5(){ return "d41d8cd98f00b204e9800998ecf8427e"; };
00032 
00033   };
00034 
00035   class SelfTestResponse : public ros::Msg
00036   {
00037     public:
00038       const char* id;
00039       int8_t passed;
00040       uint8_t status_length;
00041       diagnostic_msgs::DiagnosticStatus st_status;
00042       diagnostic_msgs::DiagnosticStatus * status;
00043 
00044     virtual int serialize(unsigned char *outbuffer) const
00045     {
00046       int offset = 0;
00047       uint32_t length_id = strlen(this->id);
00048       memcpy(outbuffer + offset, &length_id, sizeof(uint32_t));
00049       offset += 4;
00050       memcpy(outbuffer + offset, this->id, length_id);
00051       offset += length_id;
00052       union {
00053         int8_t real;
00054         uint8_t base;
00055       } u_passed;
00056       u_passed.real = this->passed;
00057       *(outbuffer + offset + 0) = (u_passed.base >> (8 * 0)) & 0xFF;
00058       offset += sizeof(this->passed);
00059       *(outbuffer + offset++) = status_length;
00060       *(outbuffer + offset++) = 0;
00061       *(outbuffer + offset++) = 0;
00062       *(outbuffer + offset++) = 0;
00063       for( uint8_t i = 0; i < status_length; i++){
00064       offset += this->status[i].serialize(outbuffer + offset);
00065       }
00066       return offset;
00067     }
00068 
00069     virtual int deserialize(unsigned char *inbuffer)
00070     {
00071       int offset = 0;
00072       uint32_t length_id;
00073       memcpy(&length_id, (inbuffer + offset), sizeof(uint32_t));
00074       offset += 4;
00075       for(unsigned int k= offset; k< offset+length_id; ++k){
00076           inbuffer[k-1]=inbuffer[k];
00077       }
00078       inbuffer[offset+length_id-1]=0;
00079       this->id = (char *)(inbuffer + offset-1);
00080       offset += length_id;
00081       union {
00082         int8_t real;
00083         uint8_t base;
00084       } u_passed;
00085       u_passed.base = 0;
00086       u_passed.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00087       this->passed = u_passed.real;
00088       offset += sizeof(this->passed);
00089       uint8_t status_lengthT = *(inbuffer + offset++);
00090       if(status_lengthT > status_length)
00091         this->status = (diagnostic_msgs::DiagnosticStatus*)realloc(this->status, status_lengthT * sizeof(diagnostic_msgs::DiagnosticStatus));
00092       offset += 3;
00093       status_length = status_lengthT;
00094       for( uint8_t i = 0; i < status_length; i++){
00095       offset += this->st_status.deserialize(inbuffer + offset);
00096         memcpy( &(this->status[i]), &(this->st_status), sizeof(diagnostic_msgs::DiagnosticStatus));
00097       }
00098      return offset;
00099     }
00100 
00101     const char * getType(){ return SELFTEST; };
00102     const char * getMD5(){ return "74c9372c870a76da4fc2b3973978b898"; };
00103 
00104   };
00105 
00106   class SelfTest {
00107     public:
00108     typedef SelfTestRequest Request;
00109     typedef SelfTestResponse Response;
00110   };
00111 
00112 }
00113 #endif


ric_mc
Author(s): RoboTiCan
autogenerated on Fri May 20 2016 03:48:56