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