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