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


rosserial_msgs
Author(s): Michael Ferguson
autogenerated on Fri Dec 6 2013 20:35:42