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