_ValueType.py
Go to the documentation of this file.
00001 """autogenerated by genpy from nasa_r2_common_msgs/ValueType.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 ValueType(genpy.Message):
00010   _md5sum = "77bd6714cc0b98aab863f096be2d2adc"
00011   _type = "nasa_r2_common_msgs/ValueType"
00012   _has_header = False #flag to mark the presence of a Header object
00013   _full_text = """string     key
00014 MappedType type
00015 uint32     index
00016 
00017 ================================================================================
00018 MSG: nasa_r2_common_msgs/MappedType
00019 uint8 STRING  = 0
00020 uint8 UINT16  = 1
00021 uint8 INT16   = 2
00022 uint8 UINT32  = 3
00023 uint8 INT32   = 4
00024 uint8 FLOAT32 = 5
00025 uint8 BOOL    = 6
00026 
00027 uint8 type
00028 
00029 """
00030   __slots__ = ['key','type','index']
00031   _slot_types = ['string','nasa_r2_common_msgs/MappedType','uint32']
00032 
00033   def __init__(self, *args, **kwds):
00034     """
00035     Constructor. Any message fields that are implicitly/explicitly
00036     set to None will be assigned a default value. The recommend
00037     use is keyword arguments as this is more robust to future message
00038     changes.  You cannot mix in-order arguments and keyword arguments.
00039 
00040     The available fields are:
00041        key,type,index
00042 
00043     :param args: complete set of field values, in .msg order
00044     :param kwds: use keyword arguments corresponding to message field names
00045     to set specific fields.
00046     """
00047     if args or kwds:
00048       super(ValueType, self).__init__(*args, **kwds)
00049       #message fields cannot be None, assign default values for those that are
00050       if self.key is None:
00051         self.key = ''
00052       if self.type is None:
00053         self.type = nasa_r2_common_msgs.msg.MappedType()
00054       if self.index is None:
00055         self.index = 0
00056     else:
00057       self.key = ''
00058       self.type = nasa_r2_common_msgs.msg.MappedType()
00059       self.index = 0
00060 
00061   def _get_types(self):
00062     """
00063     internal API method
00064     """
00065     return self._slot_types
00066 
00067   def serialize(self, buff):
00068     """
00069     serialize message into buffer
00070     :param buff: buffer, ``StringIO``
00071     """
00072     try:
00073       _x = self.key
00074       length = len(_x)
00075       if python3 or type(_x) == unicode:
00076         _x = _x.encode('utf-8')
00077         length = len(_x)
00078       buff.write(struct.pack('<I%ss'%length, length, _x))
00079       _x = self
00080       buff.write(_struct_BI.pack(_x.type.type, _x.index))
00081     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00082     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00083 
00084   def deserialize(self, str):
00085     """
00086     unpack serialized message in str into this message instance
00087     :param str: byte array of serialized message, ``str``
00088     """
00089     try:
00090       if self.type is None:
00091         self.type = nasa_r2_common_msgs.msg.MappedType()
00092       end = 0
00093       start = end
00094       end += 4
00095       (length,) = _struct_I.unpack(str[start:end])
00096       start = end
00097       end += length
00098       if python3:
00099         self.key = str[start:end].decode('utf-8')
00100       else:
00101         self.key = str[start:end]
00102       _x = self
00103       start = end
00104       end += 5
00105       (_x.type.type, _x.index,) = _struct_BI.unpack(str[start:end])
00106       return self
00107     except struct.error as e:
00108       raise genpy.DeserializationError(e) #most likely buffer underfill
00109 
00110 
00111   def serialize_numpy(self, buff, numpy):
00112     """
00113     serialize message with numpy array types into buffer
00114     :param buff: buffer, ``StringIO``
00115     :param numpy: numpy python module
00116     """
00117     try:
00118       _x = self.key
00119       length = len(_x)
00120       if python3 or type(_x) == unicode:
00121         _x = _x.encode('utf-8')
00122         length = len(_x)
00123       buff.write(struct.pack('<I%ss'%length, length, _x))
00124       _x = self
00125       buff.write(_struct_BI.pack(_x.type.type, _x.index))
00126     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00127     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00128 
00129   def deserialize_numpy(self, str, numpy):
00130     """
00131     unpack serialized message in str into this message instance using numpy for array types
00132     :param str: byte array of serialized message, ``str``
00133     :param numpy: numpy python module
00134     """
00135     try:
00136       if self.type is None:
00137         self.type = nasa_r2_common_msgs.msg.MappedType()
00138       end = 0
00139       start = end
00140       end += 4
00141       (length,) = _struct_I.unpack(str[start:end])
00142       start = end
00143       end += length
00144       if python3:
00145         self.key = str[start:end].decode('utf-8')
00146       else:
00147         self.key = str[start:end]
00148       _x = self
00149       start = end
00150       end += 5
00151       (_x.type.type, _x.index,) = _struct_BI.unpack(str[start:end])
00152       return self
00153     except struct.error as e:
00154       raise genpy.DeserializationError(e) #most likely buffer underfill
00155 
00156 _struct_I = genpy.struct_I
00157 _struct_BI = struct.Struct("<BI")


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