$search
00001 """autogenerated by genmsg_py from AIO.msg. Do not edit.""" 00002 import roslib.message 00003 import struct 00004 00005 00006 class AIO(roslib.message.Message): 00007 _md5sum = "80e4ca5770a3db29064af246946ff4fe" 00008 _type = "p2os_driver/AIO" 00009 _has_header = False #flag to mark the presence of a Header object 00010 _full_text = """uint8 voltages_count 00011 float32[] voltages 00012 00013 """ 00014 __slots__ = ['voltages_count','voltages'] 00015 _slot_types = ['uint8','float32[]'] 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 voltages_count,voltages 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(AIO, self).__init__(*args, **kwds) 00033 #message fields cannot be None, assign default values for those that are 00034 if self.voltages_count is None: 00035 self.voltages_count = 0 00036 if self.voltages is None: 00037 self.voltages = [] 00038 else: 00039 self.voltages_count = 0 00040 self.voltages = [] 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_B.pack(self.voltages_count)) 00056 length = len(self.voltages) 00057 buff.write(_struct_I.pack(length)) 00058 pattern = '<%sf'%length 00059 buff.write(struct.pack(pattern, *self.voltages)) 00060 except struct.error as se: self._check_types(se) 00061 except TypeError as 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 += 1 00073 (self.voltages_count,) = _struct_B.unpack(str[start:end]) 00074 start = end 00075 end += 4 00076 (length,) = _struct_I.unpack(str[start:end]) 00077 pattern = '<%sf'%length 00078 start = end 00079 end += struct.calcsize(pattern) 00080 self.voltages = struct.unpack(pattern, str[start:end]) 00081 return self 00082 except struct.error as e: 00083 raise roslib.message.DeserializationError(e) #most likely buffer underfill 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_B.pack(self.voltages_count)) 00096 length = len(self.voltages) 00097 buff.write(_struct_I.pack(length)) 00098 pattern = '<%sf'%length 00099 buff.write(self.voltages.tostring()) 00100 except struct.error as se: self._check_types(se) 00101 except TypeError as 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 += 1 00115 (self.voltages_count,) = _struct_B.unpack(str[start:end]) 00116 start = end 00117 end += 4 00118 (length,) = _struct_I.unpack(str[start:end]) 00119 pattern = '<%sf'%length 00120 start = end 00121 end += struct.calcsize(pattern) 00122 self.voltages = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length) 00123 return self 00124 except struct.error as e: 00125 raise roslib.message.DeserializationError(e) #most likely buffer underfill 00126 00127 _struct_I = roslib.message.struct_I 00128 _struct_B = struct.Struct("<B")