00001 """autogenerated by genpy from genpy/TestFillEmbedTime.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 genpy
00008 import genpy.msg
00009
00010 class TestFillEmbedTime(genpy.Message):
00011 _md5sum = "90e08039be001a899b8c20e680c289b0"
00012 _type = "genpy/TestFillEmbedTime"
00013 _has_header = False
00014 _full_text = """time t
00015 duration d
00016 genpy/TestString str_msg
00017 genpy/TestString[] str_msg_array
00018 int32 i32
00019 ================================================================================
00020 MSG: genpy/TestString
00021 string data
00022
00023 """
00024 __slots__ = ['t','d','str_msg','str_msg_array','i32']
00025 _slot_types = ['time','duration','genpy/TestString','genpy/TestString[]','int32']
00026
00027 def __init__(self, *args, **kwds):
00028 """
00029 Constructor. Any message fields that are implicitly/explicitly
00030 set to None will be assigned a default value. The recommend
00031 use is keyword arguments as this is more robust to future message
00032 changes. You cannot mix in-order arguments and keyword arguments.
00033
00034 The available fields are:
00035 t,d,str_msg,str_msg_array,i32
00036
00037 :param args: complete set of field values, in .msg order
00038 :param kwds: use keyword arguments corresponding to message field names
00039 to set specific fields.
00040 """
00041 if args or kwds:
00042 super(TestFillEmbedTime, self).__init__(*args, **kwds)
00043
00044 if self.t is None:
00045 self.t = genpy.Time()
00046 if self.d is None:
00047 self.d = genpy.Duration()
00048 if self.str_msg is None:
00049 self.str_msg = genpy.msg.TestString()
00050 if self.str_msg_array is None:
00051 self.str_msg_array = []
00052 if self.i32 is None:
00053 self.i32 = 0
00054 else:
00055 self.t = genpy.Time()
00056 self.d = genpy.Duration()
00057 self.str_msg = genpy.msg.TestString()
00058 self.str_msg_array = []
00059 self.i32 = 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
00074 buff.write(_struct_2I2i.pack(_x.t.secs, _x.t.nsecs, _x.d.secs, _x.d.nsecs))
00075 _x = self.str_msg.data
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 length = len(self.str_msg_array)
00082 buff.write(_struct_I.pack(length))
00083 for val1 in self.str_msg_array:
00084 _x = val1.data
00085 length = len(_x)
00086 if python3 or type(_x) == unicode:
00087 _x = _x.encode('utf-8')
00088 length = len(_x)
00089 buff.write(struct.pack('<I%ss'%length, length, _x))
00090 buff.write(_struct_i.pack(self.i32))
00091 except struct.error as se: self._check_types(se)
00092 except TypeError as te: self._check_types(te)
00093
00094 def deserialize(self, str):
00095 """
00096 unpack serialized message in str into this message instance
00097 :param str: byte array of serialized message, ``str``
00098 """
00099 try:
00100 if self.t is None:
00101 self.t = genpy.Time()
00102 if self.d is None:
00103 self.d = genpy.Duration()
00104 if self.str_msg is None:
00105 self.str_msg = genpy.msg.TestString()
00106 if self.str_msg_array is None:
00107 self.str_msg_array = None
00108 end = 0
00109 _x = self
00110 start = end
00111 end += 16
00112 (_x.t.secs, _x.t.nsecs, _x.d.secs, _x.d.nsecs,) = _struct_2I2i.unpack(str[start:end])
00113 start = end
00114 end += 4
00115 (length,) = _struct_I.unpack(str[start:end])
00116 start = end
00117 end += length
00118 if python3:
00119 self.str_msg.data = str[start:end].decode('utf-8')
00120 else:
00121 self.str_msg.data = str[start:end]
00122 start = end
00123 end += 4
00124 (length,) = _struct_I.unpack(str[start:end])
00125 self.str_msg_array = []
00126 for i in range(0, length):
00127 val1 = genpy.msg.TestString()
00128 start = end
00129 end += 4
00130 (length,) = _struct_I.unpack(str[start:end])
00131 start = end
00132 end += length
00133 if python3:
00134 val1.data = str[start:end].decode('utf-8')
00135 else:
00136 val1.data = str[start:end]
00137 self.str_msg_array.append(val1)
00138 start = end
00139 end += 4
00140 (self.i32,) = _struct_i.unpack(str[start:end])
00141 self.t.canon()
00142 self.d.canon()
00143 return self
00144 except struct.error as e:
00145 raise genpy.DeserializationError(e)
00146
00147
00148 def serialize_numpy(self, buff, numpy):
00149 """
00150 serialize message with numpy array types into buffer
00151 :param buff: buffer, ``StringIO``
00152 :param numpy: numpy python module
00153 """
00154 try:
00155 _x = self
00156 buff.write(_struct_2I2i.pack(_x.t.secs, _x.t.nsecs, _x.d.secs, _x.d.nsecs))
00157 _x = self.str_msg.data
00158 length = len(_x)
00159 if python3 or type(_x) == unicode:
00160 _x = _x.encode('utf-8')
00161 length = len(_x)
00162 buff.write(struct.pack('<I%ss'%length, length, _x))
00163 length = len(self.str_msg_array)
00164 buff.write(_struct_I.pack(length))
00165 for val1 in self.str_msg_array:
00166 _x = val1.data
00167 length = len(_x)
00168 if python3 or type(_x) == unicode:
00169 _x = _x.encode('utf-8')
00170 length = len(_x)
00171 buff.write(struct.pack('<I%ss'%length, length, _x))
00172 buff.write(_struct_i.pack(self.i32))
00173 except struct.error as se: self._check_types(se)
00174 except TypeError as te: self._check_types(te)
00175
00176 def deserialize_numpy(self, str, numpy):
00177 """
00178 unpack serialized message in str into this message instance using numpy for array types
00179 :param str: byte array of serialized message, ``str``
00180 :param numpy: numpy python module
00181 """
00182 try:
00183 if self.t is None:
00184 self.t = genpy.Time()
00185 if self.d is None:
00186 self.d = genpy.Duration()
00187 if self.str_msg is None:
00188 self.str_msg = genpy.msg.TestString()
00189 if self.str_msg_array is None:
00190 self.str_msg_array = None
00191 end = 0
00192 _x = self
00193 start = end
00194 end += 16
00195 (_x.t.secs, _x.t.nsecs, _x.d.secs, _x.d.nsecs,) = _struct_2I2i.unpack(str[start:end])
00196 start = end
00197 end += 4
00198 (length,) = _struct_I.unpack(str[start:end])
00199 start = end
00200 end += length
00201 if python3:
00202 self.str_msg.data = str[start:end].decode('utf-8')
00203 else:
00204 self.str_msg.data = str[start:end]
00205 start = end
00206 end += 4
00207 (length,) = _struct_I.unpack(str[start:end])
00208 self.str_msg_array = []
00209 for i in range(0, length):
00210 val1 = genpy.msg.TestString()
00211 start = end
00212 end += 4
00213 (length,) = _struct_I.unpack(str[start:end])
00214 start = end
00215 end += length
00216 if python3:
00217 val1.data = str[start:end].decode('utf-8')
00218 else:
00219 val1.data = str[start:end]
00220 self.str_msg_array.append(val1)
00221 start = end
00222 end += 4
00223 (self.i32,) = _struct_i.unpack(str[start:end])
00224 self.t.canon()
00225 self.d.canon()
00226 return self
00227 except struct.error as e:
00228 raise genpy.DeserializationError(e)
00229
00230 _struct_I = genpy.struct_I
00231 _struct_2I2i = struct.Struct("<2I2i")
00232 _struct_i = struct.Struct("<i")