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