Go to the documentation of this file.00001 """autogenerated by genpy from rosbridge_test/DurationArrayTest.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
00009 class DurationArrayTest(genpy.Message):
00010 _md5sum = "8b3bcadc803a7fcbc857c6a1dab53bcd"
00011 _type = "rosbridge_test/DurationArrayTest"
00012 _has_header = False
00013 _full_text = """duration[] durations
00014 """
00015 __slots__ = ['durations']
00016 _slot_types = ['duration[]']
00017
00018 def __init__(self, *args, **kwds):
00019 """
00020 Constructor. Any message fields that are implicitly/explicitly
00021 set to None will be assigned a default value. The recommend
00022 use is keyword arguments as this is more robust to future message
00023 changes. You cannot mix in-order arguments and keyword arguments.
00024
00025 The available fields are:
00026 durations
00027
00028 :param args: complete set of field values, in .msg order
00029 :param kwds: use keyword arguments corresponding to message field names
00030 to set specific fields.
00031 """
00032 if args or kwds:
00033 super(DurationArrayTest, self).__init__(*args, **kwds)
00034
00035 if self.durations is None:
00036 self.durations = []
00037 else:
00038 self.durations = []
00039
00040 def _get_types(self):
00041 """
00042 internal API method
00043 """
00044 return self._slot_types
00045
00046 def serialize(self, buff):
00047 """
00048 serialize message into buffer
00049 :param buff: buffer, ``StringIO``
00050 """
00051 try:
00052 length = len(self.durations)
00053 buff.write(_struct_I.pack(length))
00054 for val1 in self.durations:
00055 _x = val1
00056 buff.write(_struct_2i.pack(_x.secs, _x.nsecs))
00057 except struct.error as se: self._check_types(se)
00058 except TypeError as te: self._check_types(te)
00059
00060 def deserialize(self, str):
00061 """
00062 unpack serialized message in str into this message instance
00063 :param str: byte array of serialized message, ``str``
00064 """
00065 try:
00066 if self.durations is None:
00067 self.durations = None
00068 end = 0
00069 start = end
00070 end += 4
00071 (length,) = _struct_I.unpack(str[start:end])
00072 self.durations = []
00073 for i in range(0, length):
00074 val1 = genpy.Duration()
00075 _x = val1
00076 start = end
00077 end += 8
00078 (_x.secs, _x.nsecs,) = _struct_2i.unpack(str[start:end])
00079 self.durations.append(val1)
00080 return self
00081 except struct.error as e:
00082 raise genpy.DeserializationError(e)
00083
00084
00085 def serialize_numpy(self, buff, numpy):
00086 """
00087 serialize message with numpy array types into buffer
00088 :param buff: buffer, ``StringIO``
00089 :param numpy: numpy python module
00090 """
00091 try:
00092 length = len(self.durations)
00093 buff.write(_struct_I.pack(length))
00094 for val1 in self.durations:
00095 _x = val1
00096 buff.write(_struct_2i.pack(_x.secs, _x.nsecs))
00097 except struct.error as se: self._check_types(se)
00098 except TypeError as te: self._check_types(te)
00099
00100 def deserialize_numpy(self, str, numpy):
00101 """
00102 unpack serialized message in str into this message instance using numpy for array types
00103 :param str: byte array of serialized message, ``str``
00104 :param numpy: numpy python module
00105 """
00106 try:
00107 if self.durations is None:
00108 self.durations = None
00109 end = 0
00110 start = end
00111 end += 4
00112 (length,) = _struct_I.unpack(str[start:end])
00113 self.durations = []
00114 for i in range(0, length):
00115 val1 = genpy.Duration()
00116 _x = val1
00117 start = end
00118 end += 8
00119 (_x.secs, _x.nsecs,) = _struct_2i.unpack(str[start:end])
00120 self.durations.append(val1)
00121 return self
00122 except struct.error as e:
00123 raise genpy.DeserializationError(e)
00124
00125 _struct_I = genpy.struct_I
00126 _struct_2i = struct.Struct("<2i")