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 int8_t level;
00017 const char* name;
00018 const char* message;
00019 const char* hardware_id;
00020 uint8_t 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) const
00028 {
00029 int offset = 0;
00030 union {
00031 int8_t real;
00032 uint8_t 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 uint32_t length_name = strlen(this->name);
00038 memcpy(outbuffer + offset, &length_name, sizeof(uint32_t));
00039 offset += 4;
00040 memcpy(outbuffer + offset, this->name, length_name);
00041 offset += length_name;
00042 uint32_t length_message = strlen(this->message);
00043 memcpy(outbuffer + offset, &length_message, sizeof(uint32_t));
00044 offset += 4;
00045 memcpy(outbuffer + offset, this->message, length_message);
00046 offset += length_message;
00047 uint32_t length_hardware_id = strlen(this->hardware_id);
00048 memcpy(outbuffer + offset, &length_hardware_id, sizeof(uint32_t));
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( uint8_t 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 int8_t real;
00067 uint8_t base;
00068 } u_level;
00069 u_level.base = 0;
00070 u_level.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00071 this->level = u_level.real;
00072 offset += sizeof(this->level);
00073 uint32_t length_name;
00074 memcpy(&length_name, (inbuffer + offset), sizeof(uint32_t));
00075 offset += 4;
00076 for(unsigned int k= offset; k< offset+length_name; ++k){
00077 inbuffer[k-1]=inbuffer[k];
00078 }
00079 inbuffer[offset+length_name-1]=0;
00080 this->name = (char *)(inbuffer + offset-1);
00081 offset += length_name;
00082 uint32_t length_message;
00083 memcpy(&length_message, (inbuffer + offset), sizeof(uint32_t));
00084 offset += 4;
00085 for(unsigned int k= offset; k< offset+length_message; ++k){
00086 inbuffer[k-1]=inbuffer[k];
00087 }
00088 inbuffer[offset+length_message-1]=0;
00089 this->message = (char *)(inbuffer + offset-1);
00090 offset += length_message;
00091 uint32_t length_hardware_id;
00092 memcpy(&length_hardware_id, (inbuffer + offset), sizeof(uint32_t));
00093 offset += 4;
00094 for(unsigned int k= offset; k< offset+length_hardware_id; ++k){
00095 inbuffer[k-1]=inbuffer[k];
00096 }
00097 inbuffer[offset+length_hardware_id-1]=0;
00098 this->hardware_id = (char *)(inbuffer + offset-1);
00099 offset += length_hardware_id;
00100 uint8_t values_lengthT = *(inbuffer + offset++);
00101 if(values_lengthT > values_length)
00102 this->values = (diagnostic_msgs::KeyValue*)realloc(this->values, values_lengthT * sizeof(diagnostic_msgs::KeyValue));
00103 offset += 3;
00104 values_length = values_lengthT;
00105 for( uint8_t i = 0; i < values_length; i++){
00106 offset += this->st_values.deserialize(inbuffer + offset);
00107 memcpy( &(this->values[i]), &(this->st_values), sizeof(diagnostic_msgs::KeyValue));
00108 }
00109 return offset;
00110 }
00111
00112 const char * getType(){ return "diagnostic_msgs/DiagnosticStatus"; };
00113 const char * getMD5(){ return "67d15a62edb26e9d52b0f0efa3ef9da7"; };
00114
00115 };
00116
00117 }
00118 #endif