No description
diagnostic_msgs/DiagnosticStatus.h@0:9e9b7db60fd5, 2016-12-31 (annotated)
- Committer:
- garyservin
- Date:
- Sat Dec 31 00:48:34 2016 +0000
- Revision:
- 0:9e9b7db60fd5
Initial commit, generated based on a clean kinetic-desktop-full
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
garyservin | 0:9e9b7db60fd5 | 1 | #ifndef _ROS_diagnostic_msgs_DiagnosticStatus_h |
garyservin | 0:9e9b7db60fd5 | 2 | #define _ROS_diagnostic_msgs_DiagnosticStatus_h |
garyservin | 0:9e9b7db60fd5 | 3 | |
garyservin | 0:9e9b7db60fd5 | 4 | #include <stdint.h> |
garyservin | 0:9e9b7db60fd5 | 5 | #include <string.h> |
garyservin | 0:9e9b7db60fd5 | 6 | #include <stdlib.h> |
garyservin | 0:9e9b7db60fd5 | 7 | #include "ros/msg.h" |
garyservin | 0:9e9b7db60fd5 | 8 | #include "diagnostic_msgs/KeyValue.h" |
garyservin | 0:9e9b7db60fd5 | 9 | |
garyservin | 0:9e9b7db60fd5 | 10 | namespace diagnostic_msgs |
garyservin | 0:9e9b7db60fd5 | 11 | { |
garyservin | 0:9e9b7db60fd5 | 12 | |
garyservin | 0:9e9b7db60fd5 | 13 | class DiagnosticStatus : public ros::Msg |
garyservin | 0:9e9b7db60fd5 | 14 | { |
garyservin | 0:9e9b7db60fd5 | 15 | public: |
garyservin | 0:9e9b7db60fd5 | 16 | typedef int8_t _level_type; |
garyservin | 0:9e9b7db60fd5 | 17 | _level_type level; |
garyservin | 0:9e9b7db60fd5 | 18 | typedef const char* _name_type; |
garyservin | 0:9e9b7db60fd5 | 19 | _name_type name; |
garyservin | 0:9e9b7db60fd5 | 20 | typedef const char* _message_type; |
garyservin | 0:9e9b7db60fd5 | 21 | _message_type message; |
garyservin | 0:9e9b7db60fd5 | 22 | typedef const char* _hardware_id_type; |
garyservin | 0:9e9b7db60fd5 | 23 | _hardware_id_type hardware_id; |
garyservin | 0:9e9b7db60fd5 | 24 | uint32_t values_length; |
garyservin | 0:9e9b7db60fd5 | 25 | typedef diagnostic_msgs::KeyValue _values_type; |
garyservin | 0:9e9b7db60fd5 | 26 | _values_type st_values; |
garyservin | 0:9e9b7db60fd5 | 27 | _values_type * values; |
garyservin | 0:9e9b7db60fd5 | 28 | enum { OK = 0 }; |
garyservin | 0:9e9b7db60fd5 | 29 | enum { WARN = 1 }; |
garyservin | 0:9e9b7db60fd5 | 30 | enum { ERROR = 2 }; |
garyservin | 0:9e9b7db60fd5 | 31 | enum { STALE = 3 }; |
garyservin | 0:9e9b7db60fd5 | 32 | |
garyservin | 0:9e9b7db60fd5 | 33 | DiagnosticStatus(): |
garyservin | 0:9e9b7db60fd5 | 34 | level(0), |
garyservin | 0:9e9b7db60fd5 | 35 | name(""), |
garyservin | 0:9e9b7db60fd5 | 36 | message(""), |
garyservin | 0:9e9b7db60fd5 | 37 | hardware_id(""), |
garyservin | 0:9e9b7db60fd5 | 38 | values_length(0), values(NULL) |
garyservin | 0:9e9b7db60fd5 | 39 | { |
garyservin | 0:9e9b7db60fd5 | 40 | } |
garyservin | 0:9e9b7db60fd5 | 41 | |
garyservin | 0:9e9b7db60fd5 | 42 | virtual int serialize(unsigned char *outbuffer) const |
garyservin | 0:9e9b7db60fd5 | 43 | { |
garyservin | 0:9e9b7db60fd5 | 44 | int offset = 0; |
garyservin | 0:9e9b7db60fd5 | 45 | union { |
garyservin | 0:9e9b7db60fd5 | 46 | int8_t real; |
garyservin | 0:9e9b7db60fd5 | 47 | uint8_t base; |
garyservin | 0:9e9b7db60fd5 | 48 | } u_level; |
garyservin | 0:9e9b7db60fd5 | 49 | u_level.real = this->level; |
garyservin | 0:9e9b7db60fd5 | 50 | *(outbuffer + offset + 0) = (u_level.base >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 51 | offset += sizeof(this->level); |
garyservin | 0:9e9b7db60fd5 | 52 | uint32_t length_name = strlen(this->name); |
garyservin | 0:9e9b7db60fd5 | 53 | varToArr(outbuffer + offset, length_name); |
garyservin | 0:9e9b7db60fd5 | 54 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 55 | memcpy(outbuffer + offset, this->name, length_name); |
garyservin | 0:9e9b7db60fd5 | 56 | offset += length_name; |
garyservin | 0:9e9b7db60fd5 | 57 | uint32_t length_message = strlen(this->message); |
garyservin | 0:9e9b7db60fd5 | 58 | varToArr(outbuffer + offset, length_message); |
garyservin | 0:9e9b7db60fd5 | 59 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 60 | memcpy(outbuffer + offset, this->message, length_message); |
garyservin | 0:9e9b7db60fd5 | 61 | offset += length_message; |
garyservin | 0:9e9b7db60fd5 | 62 | uint32_t length_hardware_id = strlen(this->hardware_id); |
garyservin | 0:9e9b7db60fd5 | 63 | varToArr(outbuffer + offset, length_hardware_id); |
garyservin | 0:9e9b7db60fd5 | 64 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 65 | memcpy(outbuffer + offset, this->hardware_id, length_hardware_id); |
garyservin | 0:9e9b7db60fd5 | 66 | offset += length_hardware_id; |
garyservin | 0:9e9b7db60fd5 | 67 | *(outbuffer + offset + 0) = (this->values_length >> (8 * 0)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 68 | *(outbuffer + offset + 1) = (this->values_length >> (8 * 1)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 69 | *(outbuffer + offset + 2) = (this->values_length >> (8 * 2)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 70 | *(outbuffer + offset + 3) = (this->values_length >> (8 * 3)) & 0xFF; |
garyservin | 0:9e9b7db60fd5 | 71 | offset += sizeof(this->values_length); |
garyservin | 0:9e9b7db60fd5 | 72 | for( uint32_t i = 0; i < values_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 73 | offset += this->values[i].serialize(outbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 74 | } |
garyservin | 0:9e9b7db60fd5 | 75 | return offset; |
garyservin | 0:9e9b7db60fd5 | 76 | } |
garyservin | 0:9e9b7db60fd5 | 77 | |
garyservin | 0:9e9b7db60fd5 | 78 | virtual int deserialize(unsigned char *inbuffer) |
garyservin | 0:9e9b7db60fd5 | 79 | { |
garyservin | 0:9e9b7db60fd5 | 80 | int offset = 0; |
garyservin | 0:9e9b7db60fd5 | 81 | union { |
garyservin | 0:9e9b7db60fd5 | 82 | int8_t real; |
garyservin | 0:9e9b7db60fd5 | 83 | uint8_t base; |
garyservin | 0:9e9b7db60fd5 | 84 | } u_level; |
garyservin | 0:9e9b7db60fd5 | 85 | u_level.base = 0; |
garyservin | 0:9e9b7db60fd5 | 86 | u_level.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0); |
garyservin | 0:9e9b7db60fd5 | 87 | this->level = u_level.real; |
garyservin | 0:9e9b7db60fd5 | 88 | offset += sizeof(this->level); |
garyservin | 0:9e9b7db60fd5 | 89 | uint32_t length_name; |
garyservin | 0:9e9b7db60fd5 | 90 | arrToVar(length_name, (inbuffer + offset)); |
garyservin | 0:9e9b7db60fd5 | 91 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 92 | for(unsigned int k= offset; k< offset+length_name; ++k){ |
garyservin | 0:9e9b7db60fd5 | 93 | inbuffer[k-1]=inbuffer[k]; |
garyservin | 0:9e9b7db60fd5 | 94 | } |
garyservin | 0:9e9b7db60fd5 | 95 | inbuffer[offset+length_name-1]=0; |
garyservin | 0:9e9b7db60fd5 | 96 | this->name = (char *)(inbuffer + offset-1); |
garyservin | 0:9e9b7db60fd5 | 97 | offset += length_name; |
garyservin | 0:9e9b7db60fd5 | 98 | uint32_t length_message; |
garyservin | 0:9e9b7db60fd5 | 99 | arrToVar(length_message, (inbuffer + offset)); |
garyservin | 0:9e9b7db60fd5 | 100 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 101 | for(unsigned int k= offset; k< offset+length_message; ++k){ |
garyservin | 0:9e9b7db60fd5 | 102 | inbuffer[k-1]=inbuffer[k]; |
garyservin | 0:9e9b7db60fd5 | 103 | } |
garyservin | 0:9e9b7db60fd5 | 104 | inbuffer[offset+length_message-1]=0; |
garyservin | 0:9e9b7db60fd5 | 105 | this->message = (char *)(inbuffer + offset-1); |
garyservin | 0:9e9b7db60fd5 | 106 | offset += length_message; |
garyservin | 0:9e9b7db60fd5 | 107 | uint32_t length_hardware_id; |
garyservin | 0:9e9b7db60fd5 | 108 | arrToVar(length_hardware_id, (inbuffer + offset)); |
garyservin | 0:9e9b7db60fd5 | 109 | offset += 4; |
garyservin | 0:9e9b7db60fd5 | 110 | for(unsigned int k= offset; k< offset+length_hardware_id; ++k){ |
garyservin | 0:9e9b7db60fd5 | 111 | inbuffer[k-1]=inbuffer[k]; |
garyservin | 0:9e9b7db60fd5 | 112 | } |
garyservin | 0:9e9b7db60fd5 | 113 | inbuffer[offset+length_hardware_id-1]=0; |
garyservin | 0:9e9b7db60fd5 | 114 | this->hardware_id = (char *)(inbuffer + offset-1); |
garyservin | 0:9e9b7db60fd5 | 115 | offset += length_hardware_id; |
garyservin | 0:9e9b7db60fd5 | 116 | uint32_t values_lengthT = ((uint32_t) (*(inbuffer + offset))); |
garyservin | 0:9e9b7db60fd5 | 117 | values_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); |
garyservin | 0:9e9b7db60fd5 | 118 | values_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); |
garyservin | 0:9e9b7db60fd5 | 119 | values_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); |
garyservin | 0:9e9b7db60fd5 | 120 | offset += sizeof(this->values_length); |
garyservin | 0:9e9b7db60fd5 | 121 | if(values_lengthT > values_length) |
garyservin | 0:9e9b7db60fd5 | 122 | this->values = (diagnostic_msgs::KeyValue*)realloc(this->values, values_lengthT * sizeof(diagnostic_msgs::KeyValue)); |
garyservin | 0:9e9b7db60fd5 | 123 | values_length = values_lengthT; |
garyservin | 0:9e9b7db60fd5 | 124 | for( uint32_t i = 0; i < values_length; i++){ |
garyservin | 0:9e9b7db60fd5 | 125 | offset += this->st_values.deserialize(inbuffer + offset); |
garyservin | 0:9e9b7db60fd5 | 126 | memcpy( &(this->values[i]), &(this->st_values), sizeof(diagnostic_msgs::KeyValue)); |
garyservin | 0:9e9b7db60fd5 | 127 | } |
garyservin | 0:9e9b7db60fd5 | 128 | return offset; |
garyservin | 0:9e9b7db60fd5 | 129 | } |
garyservin | 0:9e9b7db60fd5 | 130 | |
garyservin | 0:9e9b7db60fd5 | 131 | const char * getType(){ return "diagnostic_msgs/DiagnosticStatus"; }; |
garyservin | 0:9e9b7db60fd5 | 132 | const char * getMD5(){ return "d0ce08bc6e5ba34c7754f563a9cabaf1"; }; |
garyservin | 0:9e9b7db60fd5 | 133 | |
garyservin | 0:9e9b7db60fd5 | 134 | }; |
garyservin | 0:9e9b7db60fd5 | 135 | |
garyservin | 0:9e9b7db60fd5 | 136 | } |
garyservin | 0:9e9b7db60fd5 | 137 | #endif |