TimedSwitch.h
Go to the documentation of this file.
00001 #ifndef _ROS_wiimote_TimedSwitch_h
00002 #define _ROS_wiimote_TimedSwitch_h
00003 
00004 #include <stdint.h>
00005 #include <string.h>
00006 #include <stdlib.h>
00007 #include "ros/msg.h"
00008 
00009 namespace wiimote
00010 {
00011 
00012   class TimedSwitch : public ros::Msg
00013   {
00014     public:
00015       int8_t switch_mode;
00016       int32_t num_cycles;
00017       uint8_t pulse_pattern_length;
00018       float st_pulse_pattern;
00019       float * pulse_pattern;
00020       enum { ON =   1 };
00021       enum { OFF =   0 };
00022       enum { NO_CHANGE =  -2 };
00023       enum { REPEAT =  -1 };
00024       enum { FOREVER =  -1 };
00025 
00026     virtual int serialize(unsigned char *outbuffer) const
00027     {
00028       int offset = 0;
00029       union {
00030         int8_t real;
00031         uint8_t base;
00032       } u_switch_mode;
00033       u_switch_mode.real = this->switch_mode;
00034       *(outbuffer + offset + 0) = (u_switch_mode.base >> (8 * 0)) & 0xFF;
00035       offset += sizeof(this->switch_mode);
00036       union {
00037         int32_t real;
00038         uint32_t base;
00039       } u_num_cycles;
00040       u_num_cycles.real = this->num_cycles;
00041       *(outbuffer + offset + 0) = (u_num_cycles.base >> (8 * 0)) & 0xFF;
00042       *(outbuffer + offset + 1) = (u_num_cycles.base >> (8 * 1)) & 0xFF;
00043       *(outbuffer + offset + 2) = (u_num_cycles.base >> (8 * 2)) & 0xFF;
00044       *(outbuffer + offset + 3) = (u_num_cycles.base >> (8 * 3)) & 0xFF;
00045       offset += sizeof(this->num_cycles);
00046       *(outbuffer + offset++) = pulse_pattern_length;
00047       *(outbuffer + offset++) = 0;
00048       *(outbuffer + offset++) = 0;
00049       *(outbuffer + offset++) = 0;
00050       for( uint8_t i = 0; i < pulse_pattern_length; i++){
00051       union {
00052         float real;
00053         uint32_t base;
00054       } u_pulse_patterni;
00055       u_pulse_patterni.real = this->pulse_pattern[i];
00056       *(outbuffer + offset + 0) = (u_pulse_patterni.base >> (8 * 0)) & 0xFF;
00057       *(outbuffer + offset + 1) = (u_pulse_patterni.base >> (8 * 1)) & 0xFF;
00058       *(outbuffer + offset + 2) = (u_pulse_patterni.base >> (8 * 2)) & 0xFF;
00059       *(outbuffer + offset + 3) = (u_pulse_patterni.base >> (8 * 3)) & 0xFF;
00060       offset += sizeof(this->pulse_pattern[i]);
00061       }
00062       return offset;
00063     }
00064 
00065     virtual int deserialize(unsigned char *inbuffer)
00066     {
00067       int offset = 0;
00068       union {
00069         int8_t real;
00070         uint8_t base;
00071       } u_switch_mode;
00072       u_switch_mode.base = 0;
00073       u_switch_mode.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
00074       this->switch_mode = u_switch_mode.real;
00075       offset += sizeof(this->switch_mode);
00076       union {
00077         int32_t real;
00078         uint32_t base;
00079       } u_num_cycles;
00080       u_num_cycles.base = 0;
00081       u_num_cycles.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00082       u_num_cycles.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00083       u_num_cycles.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00084       u_num_cycles.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00085       this->num_cycles = u_num_cycles.real;
00086       offset += sizeof(this->num_cycles);
00087       uint8_t pulse_pattern_lengthT = *(inbuffer + offset++);
00088       if(pulse_pattern_lengthT > pulse_pattern_length)
00089         this->pulse_pattern = (float*)realloc(this->pulse_pattern, pulse_pattern_lengthT * sizeof(float));
00090       offset += 3;
00091       pulse_pattern_length = pulse_pattern_lengthT;
00092       for( uint8_t i = 0; i < pulse_pattern_length; i++){
00093       union {
00094         float real;
00095         uint32_t base;
00096       } u_st_pulse_pattern;
00097       u_st_pulse_pattern.base = 0;
00098       u_st_pulse_pattern.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
00099       u_st_pulse_pattern.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
00100       u_st_pulse_pattern.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
00101       u_st_pulse_pattern.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
00102       this->st_pulse_pattern = u_st_pulse_pattern.real;
00103       offset += sizeof(this->st_pulse_pattern);
00104         memcpy( &(this->pulse_pattern[i]), &(this->st_pulse_pattern), sizeof(float));
00105       }
00106      return offset;
00107     }
00108 
00109     const char * getType(){ return "wiimote/TimedSwitch"; };
00110     const char * getMD5(){ return "e4c8d9327409cef6066fa6c368032c1e"; };
00111 
00112   };
00113 
00114 }
00115 #endif


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