_VariantMap.py
Go to the documentation of this file.
00001 """autogenerated by genpy from nasa_r2_common_msgs/VariantMap.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 nasa_r2_common_msgs.msg
00008 
00009 class VariantMap(genpy.Message):
00010   _md5sum = "8356d002313ee472651f88ac3bf992a9"
00011   _type = "nasa_r2_common_msgs/VariantMap"
00012   _has_header = False #flag to mark the presence of a Header object
00013   _full_text = """string      name
00014 string      message
00015 ValueType[] value
00016 string[]    stringMap
00017 uint16[]    uint16Map
00018 int16[]     int16Map
00019 uint32[]    uint32Map
00020 int32[]     int32Map
00021 float32[]   float32Map
00022 bool[]      boolMap
00023 
00024 ================================================================================
00025 MSG: nasa_r2_common_msgs/ValueType
00026 string     key
00027 MappedType type
00028 uint32     index
00029 
00030 ================================================================================
00031 MSG: nasa_r2_common_msgs/MappedType
00032 uint8 STRING  = 0
00033 uint8 UINT16  = 1
00034 uint8 INT16   = 2
00035 uint8 UINT32  = 3
00036 uint8 INT32   = 4
00037 uint8 FLOAT32 = 5
00038 uint8 BOOL    = 6
00039 
00040 uint8 type
00041 
00042 """
00043   __slots__ = ['name','message','value','stringMap','uint16Map','int16Map','uint32Map','int32Map','float32Map','boolMap']
00044   _slot_types = ['string','string','nasa_r2_common_msgs/ValueType[]','string[]','uint16[]','int16[]','uint32[]','int32[]','float32[]','bool[]']
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        name,message,value,stringMap,uint16Map,int16Map,uint32Map,int32Map,float32Map,boolMap
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(VariantMap, self).__init__(*args, **kwds)
00062       #message fields cannot be None, assign default values for those that are
00063       if self.name is None:
00064         self.name = ''
00065       if self.message is None:
00066         self.message = ''
00067       if self.value is None:
00068         self.value = []
00069       if self.stringMap is None:
00070         self.stringMap = []
00071       if self.uint16Map is None:
00072         self.uint16Map = []
00073       if self.int16Map is None:
00074         self.int16Map = []
00075       if self.uint32Map is None:
00076         self.uint32Map = []
00077       if self.int32Map is None:
00078         self.int32Map = []
00079       if self.float32Map is None:
00080         self.float32Map = []
00081       if self.boolMap is None:
00082         self.boolMap = []
00083     else:
00084       self.name = ''
00085       self.message = ''
00086       self.value = []
00087       self.stringMap = []
00088       self.uint16Map = []
00089       self.int16Map = []
00090       self.uint32Map = []
00091       self.int32Map = []
00092       self.float32Map = []
00093       self.boolMap = []
00094 
00095   def _get_types(self):
00096     """
00097     internal API method
00098     """
00099     return self._slot_types
00100 
00101   def serialize(self, buff):
00102     """
00103     serialize message into buffer
00104     :param buff: buffer, ``StringIO``
00105     """
00106     try:
00107       _x = self.name
00108       length = len(_x)
00109       if python3 or type(_x) == unicode:
00110         _x = _x.encode('utf-8')
00111         length = len(_x)
00112       buff.write(struct.pack('<I%ss'%length, length, _x))
00113       _x = self.message
00114       length = len(_x)
00115       if python3 or type(_x) == unicode:
00116         _x = _x.encode('utf-8')
00117         length = len(_x)
00118       buff.write(struct.pack('<I%ss'%length, length, _x))
00119       length = len(self.value)
00120       buff.write(_struct_I.pack(length))
00121       for val1 in self.value:
00122         _x = val1.key
00123         length = len(_x)
00124         if python3 or type(_x) == unicode:
00125           _x = _x.encode('utf-8')
00126           length = len(_x)
00127         buff.write(struct.pack('<I%ss'%length, length, _x))
00128         _v1 = val1.type
00129         buff.write(_struct_B.pack(_v1.type))
00130         buff.write(_struct_I.pack(val1.index))
00131       length = len(self.stringMap)
00132       buff.write(_struct_I.pack(length))
00133       for val1 in self.stringMap:
00134         length = len(val1)
00135         if python3 or type(val1) == unicode:
00136           val1 = val1.encode('utf-8')
00137           length = len(val1)
00138         buff.write(struct.pack('<I%ss'%length, length, val1))
00139       length = len(self.uint16Map)
00140       buff.write(_struct_I.pack(length))
00141       pattern = '<%sH'%length
00142       buff.write(struct.pack(pattern, *self.uint16Map))
00143       length = len(self.int16Map)
00144       buff.write(_struct_I.pack(length))
00145       pattern = '<%sh'%length
00146       buff.write(struct.pack(pattern, *self.int16Map))
00147       length = len(self.uint32Map)
00148       buff.write(_struct_I.pack(length))
00149       pattern = '<%sI'%length
00150       buff.write(struct.pack(pattern, *self.uint32Map))
00151       length = len(self.int32Map)
00152       buff.write(_struct_I.pack(length))
00153       pattern = '<%si'%length
00154       buff.write(struct.pack(pattern, *self.int32Map))
00155       length = len(self.float32Map)
00156       buff.write(_struct_I.pack(length))
00157       pattern = '<%sf'%length
00158       buff.write(struct.pack(pattern, *self.float32Map))
00159       length = len(self.boolMap)
00160       buff.write(_struct_I.pack(length))
00161       pattern = '<%sB'%length
00162       buff.write(struct.pack(pattern, *self.boolMap))
00163     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00164     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00165 
00166   def deserialize(self, str):
00167     """
00168     unpack serialized message in str into this message instance
00169     :param str: byte array of serialized message, ``str``
00170     """
00171     try:
00172       if self.value is None:
00173         self.value = None
00174       end = 0
00175       start = end
00176       end += 4
00177       (length,) = _struct_I.unpack(str[start:end])
00178       start = end
00179       end += length
00180       if python3:
00181         self.name = str[start:end].decode('utf-8')
00182       else:
00183         self.name = str[start:end]
00184       start = end
00185       end += 4
00186       (length,) = _struct_I.unpack(str[start:end])
00187       start = end
00188       end += length
00189       if python3:
00190         self.message = str[start:end].decode('utf-8')
00191       else:
00192         self.message = str[start:end]
00193       start = end
00194       end += 4
00195       (length,) = _struct_I.unpack(str[start:end])
00196       self.value = []
00197       for i in range(0, length):
00198         val1 = nasa_r2_common_msgs.msg.ValueType()
00199         start = end
00200         end += 4
00201         (length,) = _struct_I.unpack(str[start:end])
00202         start = end
00203         end += length
00204         if python3:
00205           val1.key = str[start:end].decode('utf-8')
00206         else:
00207           val1.key = str[start:end]
00208         _v2 = val1.type
00209         start = end
00210         end += 1
00211         (_v2.type,) = _struct_B.unpack(str[start:end])
00212         start = end
00213         end += 4
00214         (val1.index,) = _struct_I.unpack(str[start:end])
00215         self.value.append(val1)
00216       start = end
00217       end += 4
00218       (length,) = _struct_I.unpack(str[start:end])
00219       self.stringMap = []
00220       for i in range(0, length):
00221         start = end
00222         end += 4
00223         (length,) = _struct_I.unpack(str[start:end])
00224         start = end
00225         end += length
00226         if python3:
00227           val1 = str[start:end].decode('utf-8')
00228         else:
00229           val1 = str[start:end]
00230         self.stringMap.append(val1)
00231       start = end
00232       end += 4
00233       (length,) = _struct_I.unpack(str[start:end])
00234       pattern = '<%sH'%length
00235       start = end
00236       end += struct.calcsize(pattern)
00237       self.uint16Map = struct.unpack(pattern, str[start:end])
00238       start = end
00239       end += 4
00240       (length,) = _struct_I.unpack(str[start:end])
00241       pattern = '<%sh'%length
00242       start = end
00243       end += struct.calcsize(pattern)
00244       self.int16Map = struct.unpack(pattern, str[start:end])
00245       start = end
00246       end += 4
00247       (length,) = _struct_I.unpack(str[start:end])
00248       pattern = '<%sI'%length
00249       start = end
00250       end += struct.calcsize(pattern)
00251       self.uint32Map = struct.unpack(pattern, str[start:end])
00252       start = end
00253       end += 4
00254       (length,) = _struct_I.unpack(str[start:end])
00255       pattern = '<%si'%length
00256       start = end
00257       end += struct.calcsize(pattern)
00258       self.int32Map = struct.unpack(pattern, str[start:end])
00259       start = end
00260       end += 4
00261       (length,) = _struct_I.unpack(str[start:end])
00262       pattern = '<%sf'%length
00263       start = end
00264       end += struct.calcsize(pattern)
00265       self.float32Map = struct.unpack(pattern, str[start:end])
00266       start = end
00267       end += 4
00268       (length,) = _struct_I.unpack(str[start:end])
00269       pattern = '<%sB'%length
00270       start = end
00271       end += struct.calcsize(pattern)
00272       self.boolMap = struct.unpack(pattern, str[start:end])
00273       self.boolMap = map(bool, self.boolMap)
00274       return self
00275     except struct.error as e:
00276       raise genpy.DeserializationError(e) #most likely buffer underfill
00277 
00278 
00279   def serialize_numpy(self, buff, numpy):
00280     """
00281     serialize message with numpy array types into buffer
00282     :param buff: buffer, ``StringIO``
00283     :param numpy: numpy python module
00284     """
00285     try:
00286       _x = self.name
00287       length = len(_x)
00288       if python3 or type(_x) == unicode:
00289         _x = _x.encode('utf-8')
00290         length = len(_x)
00291       buff.write(struct.pack('<I%ss'%length, length, _x))
00292       _x = self.message
00293       length = len(_x)
00294       if python3 or type(_x) == unicode:
00295         _x = _x.encode('utf-8')
00296         length = len(_x)
00297       buff.write(struct.pack('<I%ss'%length, length, _x))
00298       length = len(self.value)
00299       buff.write(_struct_I.pack(length))
00300       for val1 in self.value:
00301         _x = val1.key
00302         length = len(_x)
00303         if python3 or type(_x) == unicode:
00304           _x = _x.encode('utf-8')
00305           length = len(_x)
00306         buff.write(struct.pack('<I%ss'%length, length, _x))
00307         _v3 = val1.type
00308         buff.write(_struct_B.pack(_v3.type))
00309         buff.write(_struct_I.pack(val1.index))
00310       length = len(self.stringMap)
00311       buff.write(_struct_I.pack(length))
00312       for val1 in self.stringMap:
00313         length = len(val1)
00314         if python3 or type(val1) == unicode:
00315           val1 = val1.encode('utf-8')
00316           length = len(val1)
00317         buff.write(struct.pack('<I%ss'%length, length, val1))
00318       length = len(self.uint16Map)
00319       buff.write(_struct_I.pack(length))
00320       pattern = '<%sH'%length
00321       buff.write(self.uint16Map.tostring())
00322       length = len(self.int16Map)
00323       buff.write(_struct_I.pack(length))
00324       pattern = '<%sh'%length
00325       buff.write(self.int16Map.tostring())
00326       length = len(self.uint32Map)
00327       buff.write(_struct_I.pack(length))
00328       pattern = '<%sI'%length
00329       buff.write(self.uint32Map.tostring())
00330       length = len(self.int32Map)
00331       buff.write(_struct_I.pack(length))
00332       pattern = '<%si'%length
00333       buff.write(self.int32Map.tostring())
00334       length = len(self.float32Map)
00335       buff.write(_struct_I.pack(length))
00336       pattern = '<%sf'%length
00337       buff.write(self.float32Map.tostring())
00338       length = len(self.boolMap)
00339       buff.write(_struct_I.pack(length))
00340       pattern = '<%sB'%length
00341       buff.write(self.boolMap.tostring())
00342     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00343     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00344 
00345   def deserialize_numpy(self, str, numpy):
00346     """
00347     unpack serialized message in str into this message instance using numpy for array types
00348     :param str: byte array of serialized message, ``str``
00349     :param numpy: numpy python module
00350     """
00351     try:
00352       if self.value is None:
00353         self.value = None
00354       end = 0
00355       start = end
00356       end += 4
00357       (length,) = _struct_I.unpack(str[start:end])
00358       start = end
00359       end += length
00360       if python3:
00361         self.name = str[start:end].decode('utf-8')
00362       else:
00363         self.name = str[start:end]
00364       start = end
00365       end += 4
00366       (length,) = _struct_I.unpack(str[start:end])
00367       start = end
00368       end += length
00369       if python3:
00370         self.message = str[start:end].decode('utf-8')
00371       else:
00372         self.message = str[start:end]
00373       start = end
00374       end += 4
00375       (length,) = _struct_I.unpack(str[start:end])
00376       self.value = []
00377       for i in range(0, length):
00378         val1 = nasa_r2_common_msgs.msg.ValueType()
00379         start = end
00380         end += 4
00381         (length,) = _struct_I.unpack(str[start:end])
00382         start = end
00383         end += length
00384         if python3:
00385           val1.key = str[start:end].decode('utf-8')
00386         else:
00387           val1.key = str[start:end]
00388         _v4 = val1.type
00389         start = end
00390         end += 1
00391         (_v4.type,) = _struct_B.unpack(str[start:end])
00392         start = end
00393         end += 4
00394         (val1.index,) = _struct_I.unpack(str[start:end])
00395         self.value.append(val1)
00396       start = end
00397       end += 4
00398       (length,) = _struct_I.unpack(str[start:end])
00399       self.stringMap = []
00400       for i in range(0, length):
00401         start = end
00402         end += 4
00403         (length,) = _struct_I.unpack(str[start:end])
00404         start = end
00405         end += length
00406         if python3:
00407           val1 = str[start:end].decode('utf-8')
00408         else:
00409           val1 = str[start:end]
00410         self.stringMap.append(val1)
00411       start = end
00412       end += 4
00413       (length,) = _struct_I.unpack(str[start:end])
00414       pattern = '<%sH'%length
00415       start = end
00416       end += struct.calcsize(pattern)
00417       self.uint16Map = numpy.frombuffer(str[start:end], dtype=numpy.uint16, count=length)
00418       start = end
00419       end += 4
00420       (length,) = _struct_I.unpack(str[start:end])
00421       pattern = '<%sh'%length
00422       start = end
00423       end += struct.calcsize(pattern)
00424       self.int16Map = numpy.frombuffer(str[start:end], dtype=numpy.int16, count=length)
00425       start = end
00426       end += 4
00427       (length,) = _struct_I.unpack(str[start:end])
00428       pattern = '<%sI'%length
00429       start = end
00430       end += struct.calcsize(pattern)
00431       self.uint32Map = numpy.frombuffer(str[start:end], dtype=numpy.uint32, count=length)
00432       start = end
00433       end += 4
00434       (length,) = _struct_I.unpack(str[start:end])
00435       pattern = '<%si'%length
00436       start = end
00437       end += struct.calcsize(pattern)
00438       self.int32Map = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=length)
00439       start = end
00440       end += 4
00441       (length,) = _struct_I.unpack(str[start:end])
00442       pattern = '<%sf'%length
00443       start = end
00444       end += struct.calcsize(pattern)
00445       self.float32Map = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length)
00446       start = end
00447       end += 4
00448       (length,) = _struct_I.unpack(str[start:end])
00449       pattern = '<%sB'%length
00450       start = end
00451       end += struct.calcsize(pattern)
00452       self.boolMap = numpy.frombuffer(str[start:end], dtype=numpy.bool, count=length)
00453       self.boolMap = map(bool, self.boolMap)
00454       return self
00455     except struct.error as e:
00456       raise genpy.DeserializationError(e) #most likely buffer underfill
00457 
00458 _struct_I = genpy.struct_I
00459 _struct_B = struct.Struct("<B")


nasa_r2_common_msgs
Author(s): Paul Dinh. Maintained by Jennifer Turner
autogenerated on Mon Oct 6 2014 02:42:34