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