_WMPMessage.py
Go to the documentation of this file.
00001 """autogenerated by genpy from ros_rt_wmp_msgs/WMPMessage.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006 
00007 import ros_rt_wmp_msgs.msg
00008 
00009 class WMPMessage(genpy.Message):
00010   _md5sum = "fa7fd663ecc1e6348e06454a200ecbe3"
00011   _type = "ros_rt_wmp_msgs/WMPMessage"
00012   _has_header = False #flag to mark the presence of a Header object
00013   _full_text = """WMPHeader header
00014 uint8[] data
00015 
00016 
00017 ================================================================================
00018 MSG: ros_rt_wmp_msgs/WMPHeader
00019 uint8 source
00020 uint8[] dest
00021 uint8 priority
00022 uint8 deadline
00023 string sub_topic
00024 
00025 
00026 """
00027   __slots__ = ['header','data']
00028   _slot_types = ['ros_rt_wmp_msgs/WMPHeader','uint8[]']
00029 
00030   def __init__(self, *args, **kwds):
00031     """
00032     Constructor. Any message fields that are implicitly/explicitly
00033     set to None will be assigned a default value. The recommend
00034     use is keyword arguments as this is more robust to future message
00035     changes.  You cannot mix in-order arguments and keyword arguments.
00036 
00037     The available fields are:
00038        header,data
00039 
00040     :param args: complete set of field values, in .msg order
00041     :param kwds: use keyword arguments corresponding to message field names
00042     to set specific fields.
00043     """
00044     if args or kwds:
00045       super(WMPMessage, self).__init__(*args, **kwds)
00046       #message fields cannot be None, assign default values for those that are
00047       if self.header is None:
00048         self.header = ros_rt_wmp_msgs.msg.WMPHeader()
00049       if self.data is None:
00050         self.data = ''
00051     else:
00052       self.header = ros_rt_wmp_msgs.msg.WMPHeader()
00053       self.data = ''
00054 
00055   def _get_types(self):
00056     """
00057     internal API method
00058     """
00059     return self._slot_types
00060 
00061   def serialize(self, buff):
00062     """
00063     serialize message into buffer
00064     :param buff: buffer, ``StringIO``
00065     """
00066     try:
00067       buff.write(_struct_B.pack(self.header.source))
00068       _x = self.header.dest
00069       length = len(_x)
00070       # - if encoded as a list instead, serialize as bytes instead of string
00071       if type(_x) in [list, tuple]:
00072         buff.write(struct.pack('<I%sB'%length, length, *_x))
00073       else:
00074         buff.write(struct.pack('<I%ss'%length, length, _x))
00075       _x = self
00076       buff.write(_struct_2B.pack(_x.header.priority, _x.header.deadline))
00077       _x = self.header.sub_topic
00078       length = len(_x)
00079       if python3 or type(_x) == unicode:
00080         _x = _x.encode('utf-8')
00081         length = len(_x)
00082       buff.write(struct.pack('<I%ss'%length, length, _x))
00083       _x = self.data
00084       length = len(_x)
00085       # - if encoded as a list instead, serialize as bytes instead of string
00086       if type(_x) in [list, tuple]:
00087         buff.write(struct.pack('<I%sB'%length, length, *_x))
00088       else:
00089         buff.write(struct.pack('<I%ss'%length, length, _x))
00090     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00091     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00092 
00093   def deserialize(self, str):
00094     """
00095     unpack serialized message in str into this message instance
00096     :param str: byte array of serialized message, ``str``
00097     """
00098     try:
00099       if self.header is None:
00100         self.header = ros_rt_wmp_msgs.msg.WMPHeader()
00101       end = 0
00102       start = end
00103       end += 1
00104       (self.header.source,) = _struct_B.unpack(str[start:end])
00105       start = end
00106       end += 4
00107       (length,) = _struct_I.unpack(str[start:end])
00108       start = end
00109       end += length
00110       self.header.dest = str[start:end]
00111       _x = self
00112       start = end
00113       end += 2
00114       (_x.header.priority, _x.header.deadline,) = _struct_2B.unpack(str[start:end])
00115       start = end
00116       end += 4
00117       (length,) = _struct_I.unpack(str[start:end])
00118       start = end
00119       end += length
00120       if python3:
00121         self.header.sub_topic = str[start:end].decode('utf-8')
00122       else:
00123         self.header.sub_topic = str[start:end]
00124       start = end
00125       end += 4
00126       (length,) = _struct_I.unpack(str[start:end])
00127       start = end
00128       end += length
00129       self.data = str[start:end]
00130       return self
00131     except struct.error as e:
00132       raise genpy.DeserializationError(e) #most likely buffer underfill
00133 
00134 
00135   def serialize_numpy(self, buff, numpy):
00136     """
00137     serialize message with numpy array types into buffer
00138     :param buff: buffer, ``StringIO``
00139     :param numpy: numpy python module
00140     """
00141     try:
00142       buff.write(_struct_B.pack(self.header.source))
00143       _x = self.header.dest
00144       length = len(_x)
00145       # - if encoded as a list instead, serialize as bytes instead of string
00146       if type(_x) in [list, tuple]:
00147         buff.write(struct.pack('<I%sB'%length, length, *_x))
00148       else:
00149         buff.write(struct.pack('<I%ss'%length, length, _x))
00150       _x = self
00151       buff.write(_struct_2B.pack(_x.header.priority, _x.header.deadline))
00152       _x = self.header.sub_topic
00153       length = len(_x)
00154       if python3 or type(_x) == unicode:
00155         _x = _x.encode('utf-8')
00156         length = len(_x)
00157       buff.write(struct.pack('<I%ss'%length, length, _x))
00158       _x = self.data
00159       length = len(_x)
00160       # - if encoded as a list instead, serialize as bytes instead of string
00161       if type(_x) in [list, tuple]:
00162         buff.write(struct.pack('<I%sB'%length, length, *_x))
00163       else:
00164         buff.write(struct.pack('<I%ss'%length, length, _x))
00165     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00166     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00167 
00168   def deserialize_numpy(self, str, numpy):
00169     """
00170     unpack serialized message in str into this message instance using numpy for array types
00171     :param str: byte array of serialized message, ``str``
00172     :param numpy: numpy python module
00173     """
00174     try:
00175       if self.header is None:
00176         self.header = ros_rt_wmp_msgs.msg.WMPHeader()
00177       end = 0
00178       start = end
00179       end += 1
00180       (self.header.source,) = _struct_B.unpack(str[start:end])
00181       start = end
00182       end += 4
00183       (length,) = _struct_I.unpack(str[start:end])
00184       start = end
00185       end += length
00186       self.header.dest = str[start:end]
00187       _x = self
00188       start = end
00189       end += 2
00190       (_x.header.priority, _x.header.deadline,) = _struct_2B.unpack(str[start:end])
00191       start = end
00192       end += 4
00193       (length,) = _struct_I.unpack(str[start:end])
00194       start = end
00195       end += length
00196       if python3:
00197         self.header.sub_topic = str[start:end].decode('utf-8')
00198       else:
00199         self.header.sub_topic = str[start:end]
00200       start = end
00201       end += 4
00202       (length,) = _struct_I.unpack(str[start:end])
00203       start = end
00204       end += length
00205       self.data = str[start:end]
00206       return self
00207     except struct.error as e:
00208       raise genpy.DeserializationError(e) #most likely buffer underfill
00209 
00210 _struct_I = genpy.struct_I
00211 _struct_B = struct.Struct("<B")
00212 _struct_2B = struct.Struct("<2B")


ros_rt_wmp_msgs
Author(s): Pablo Urcola
autogenerated on Mon Oct 6 2014 08:26:58