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/byte.h" 00009 #include "diagnostic_msgs/KeyValue.h" 00010 00011 namespace diagnostic_msgs 00012 { 00013 00014 class DiagnosticStatus : public ros::Msg 00015 { 00016 public: 00017 diagnostic_msgs::byte level; 00018 char * name; 00019 char * message; 00020 char * hardware_id; 00021 uint8_t values_length; 00022 diagnostic_msgs::KeyValue st_values; 00023 diagnostic_msgs::KeyValue * values; 00024 enum { OK = 0 }; 00025 enum { WARN = 1 }; 00026 enum { ERROR = 2 }; 00027 00028 virtual int serialize(unsigned char *outbuffer) const 00029 { 00030 int offset = 0; 00031 offset += this->level.serialize(outbuffer + offset); 00032 uint32_t * length_name = (uint32_t *)(outbuffer + offset); 00033 *length_name = strlen( (const char*) this->name); 00034 offset += 4; 00035 memcpy(outbuffer + offset, this->name, *length_name); 00036 offset += *length_name; 00037 uint32_t * length_message = (uint32_t *)(outbuffer + offset); 00038 *length_message = strlen( (const char*) this->message); 00039 offset += 4; 00040 memcpy(outbuffer + offset, this->message, *length_message); 00041 offset += *length_message; 00042 uint32_t * length_hardware_id = (uint32_t *)(outbuffer + offset); 00043 *length_hardware_id = strlen( (const char*) this->hardware_id); 00044 offset += 4; 00045 memcpy(outbuffer + offset, this->hardware_id, *length_hardware_id); 00046 offset += *length_hardware_id; 00047 *(outbuffer + offset++) = values_length; 00048 *(outbuffer + offset++) = 0; 00049 *(outbuffer + offset++) = 0; 00050 *(outbuffer + offset++) = 0; 00051 for( uint8_t i = 0; i < values_length; i++){ 00052 offset += this->values[i].serialize(outbuffer + offset); 00053 } 00054 return offset; 00055 } 00056 00057 virtual int deserialize(unsigned char *inbuffer) 00058 { 00059 int offset = 0; 00060 offset += this->level.deserialize(inbuffer + offset); 00061 uint32_t length_name = *(uint32_t *)(inbuffer + offset); 00062 offset += 4; 00063 for(unsigned int k= offset; k< offset+length_name; ++k){ 00064 inbuffer[k-1]=inbuffer[k]; 00065 } 00066 inbuffer[offset+length_name-1]=0; 00067 this->name = (char *)(inbuffer + offset-1); 00068 offset += length_name; 00069 uint32_t length_message = *(uint32_t *)(inbuffer + offset); 00070 offset += 4; 00071 for(unsigned int k= offset; k< offset+length_message; ++k){ 00072 inbuffer[k-1]=inbuffer[k]; 00073 } 00074 inbuffer[offset+length_message-1]=0; 00075 this->message = (char *)(inbuffer + offset-1); 00076 offset += length_message; 00077 uint32_t length_hardware_id = *(uint32_t *)(inbuffer + offset); 00078 offset += 4; 00079 for(unsigned int k= offset; k< offset+length_hardware_id; ++k){ 00080 inbuffer[k-1]=inbuffer[k]; 00081 } 00082 inbuffer[offset+length_hardware_id-1]=0; 00083 this->hardware_id = (char *)(inbuffer + offset-1); 00084 offset += length_hardware_id; 00085 uint8_t values_lengthT = *(inbuffer + offset++); 00086 if(values_lengthT > values_length) 00087 this->values = (diagnostic_msgs::KeyValue*)realloc(this->values, values_lengthT * sizeof(diagnostic_msgs::KeyValue)); 00088 offset += 3; 00089 values_length = values_lengthT; 00090 for( uint8_t i = 0; i < values_length; i++){ 00091 offset += this->st_values.deserialize(inbuffer + offset); 00092 memcpy( &(this->values[i]), &(this->st_values), sizeof(diagnostic_msgs::KeyValue)); 00093 } 00094 return offset; 00095 } 00096 00097 const char * getType(){ return "diagnostic_msgs/DiagnosticStatus"; }; 00098 const char * getMD5(){ return "67d15a62edb26e9d52b0f0efa3ef9da7"; }; 00099 00100 }; 00101 00102 } 00103 #endif