DiagnosticStatus.h
Go to the documentation of this file.
00001 #ifndef ros_diagnostic_msgs_DiagnosticStatus_h
00002 #define ros_diagnostic_msgs_DiagnosticStatus_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "../ros/msg.h"
00008 #include "diagnostic_msgs/KeyValue.h"
00009 
00010 namespace diagnostic_msgs
00011 {
00012 
00013   class DiagnosticStatus : public ros::Msg
00014   {
00015     public:
00016       unsigned char level;
00017       char * name;
00018       char * message;
00019       char * hardware_id;
00020       unsigned char values_length;
00021       diagnostic_msgs::KeyValue st_values;
00022       diagnostic_msgs::KeyValue * values;
00023       enum { OK = 0 };
00024       enum { WARN = 1 };
00025       enum { ERROR = 2 };
00026 
00027     virtual int serialize(unsigned char *outbuffer)
00028     {
00029       int offset = 0;
00030       union {
00031         unsigned char real;
00032         unsigned char base;
00033       } u_level;
00034       u_level.real = this->level;
00035       *(outbuffer + offset + 0) = (u_level.base >> (8 * 0)) & 0xFF;
00036       offset += sizeof(this->level);
00037       long * length_name = (long *)(outbuffer + offset);
00038       *length_name = strlen( (const char*) this->name);
00039       offset += 4;
00040       memcpy(outbuffer + offset, this->name, *length_name);
00041       offset += *length_name;
00042       long * length_message = (long *)(outbuffer + offset);
00043       *length_message = strlen( (const char*) this->message);
00044       offset += 4;
00045       memcpy(outbuffer + offset, this->message, *length_message);
00046       offset += *length_message;
00047       long * length_hardware_id = (long *)(outbuffer + offset);
00048       *length_hardware_id = strlen( (const char*) this->hardware_id);
00049       offset += 4;
00050       memcpy(outbuffer + offset, this->hardware_id, *length_hardware_id);
00051       offset += *length_hardware_id;
00052       *(outbuffer + offset++) = values_length;
00053       *(outbuffer + offset++) = 0;
00054       *(outbuffer + offset++) = 0;
00055       *(outbuffer + offset++) = 0;
00056       for( unsigned char i = 0; i < values_length; i++){
00057       offset += this->values[i].serialize(outbuffer + offset);
00058       }
00059       return offset;
00060     }
00061 
00062     virtual int deserialize(unsigned char *inbuffer)
00063     {
00064       int offset = 0;
00065       union {
00066         unsigned char real;
00067         unsigned char base;
00068       } u_level;
00069       u_level.base = 0;
00070       u_level.base |= ((typeof(u_level.base)) (*(inbuffer + offset + 0))) << (8 * 0);
00071       this->level = u_level.real;
00072       offset += sizeof(this->level);
00073       uint32_t length_name = *(uint32_t *)(inbuffer + offset);
00074       offset += 4;
00075       for(unsigned int k= offset; k< offset+length_name; ++k){
00076           inbuffer[k-1]=inbuffer[k];
00077            }
00078       inbuffer[offset+length_name-1]=0;
00079       this->name = (char *)(inbuffer + offset-1);
00080       offset += length_name;
00081       uint32_t length_message = *(uint32_t *)(inbuffer + offset);
00082       offset += 4;
00083       for(unsigned int k= offset; k< offset+length_message; ++k){
00084           inbuffer[k-1]=inbuffer[k];
00085            }
00086       inbuffer[offset+length_message-1]=0;
00087       this->message = (char *)(inbuffer + offset-1);
00088       offset += length_message;
00089       uint32_t length_hardware_id = *(uint32_t *)(inbuffer + offset);
00090       offset += 4;
00091       for(unsigned int k= offset; k< offset+length_hardware_id; ++k){
00092           inbuffer[k-1]=inbuffer[k];
00093            }
00094       inbuffer[offset+length_hardware_id-1]=0;
00095       this->hardware_id = (char *)(inbuffer + offset-1);
00096       offset += length_hardware_id;
00097       unsigned char values_lengthT = *(inbuffer + offset++);
00098       if(values_lengthT > values_length)
00099         this->values = (diagnostic_msgs::KeyValue*)realloc(this->values, values_lengthT * sizeof(diagnostic_msgs::KeyValue));
00100       offset += 3;
00101       values_length = values_lengthT;
00102       for( unsigned char i = 0; i < values_length; i++){
00103       offset += this->st_values.deserialize(inbuffer + offset);
00104         memcpy( &(this->values[i]), &(this->st_values), sizeof(diagnostic_msgs::KeyValue));
00105       }
00106      return offset;
00107     }
00108 
00109     const char * getType(){ return "diagnostic_msgs/DiagnosticStatus"; };
00110 
00111   };
00112 
00113 }
00114 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


traxbot_robot
Author(s): André Gonçalves Araújo
autogenerated on Fri Feb 1 2013 13:21:12