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


asebaros
Author(s): Stéphane Magnenat
autogenerated on Sun Oct 5 2014 23:47:01