00001 """autogenerated by genmsg_py from WithDuration.msg. Do not edit."""
00002 import roslib.message
00003 import struct
00004
00005 import roslib.rostime
00006
00007 class WithDuration(roslib.message.Message):
00008 _md5sum = "7ad52ba9d0229ba8b9c032400c77c367"
00009 _type = "test_roscpp_serialization/WithDuration"
00010 _has_header = False
00011 _full_text = """duration my_duration
00012 """
00013 __slots__ = ['my_duration']
00014 _slot_types = ['duration']
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 my_duration
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(WithDuration, self).__init__(*args, **kwds)
00032
00033 if self.my_duration is None:
00034 self.my_duration = roslib.rostime.Duration()
00035 else:
00036 self.my_duration = roslib.rostime.Duration()
00037
00038 def _get_types(self):
00039 """
00040 internal API method
00041 """
00042 return self._slot_types
00043
00044 def serialize(self, buff):
00045 """
00046 serialize message into buffer
00047 @param buff: buffer
00048 @type buff: StringIO
00049 """
00050 try:
00051 _x = self
00052 buff.write(_struct_2i.pack(_x.my_duration.secs, _x.my_duration.nsecs))
00053 except struct.error, se: self._check_types(se)
00054 except TypeError, te: self._check_types(te)
00055
00056 def deserialize(self, str):
00057 """
00058 unpack serialized message in str into this message instance
00059 @param str: byte array of serialized message
00060 @type str: str
00061 """
00062 try:
00063 if self.my_duration is None:
00064 self.my_duration = roslib.rostime.Duration()
00065 end = 0
00066 _x = self
00067 start = end
00068 end += 8
00069 (_x.my_duration.secs, _x.my_duration.nsecs,) = _struct_2i.unpack(str[start:end])
00070 self.my_duration.canon()
00071 return self
00072 except struct.error, e:
00073 raise roslib.message.DeserializationError(e)
00074
00075
00076 def serialize_numpy(self, buff, numpy):
00077 """
00078 serialize message with numpy array types into buffer
00079 @param buff: buffer
00080 @type buff: StringIO
00081 @param numpy: numpy python module
00082 @type numpy module
00083 """
00084 try:
00085 _x = self
00086 buff.write(_struct_2i.pack(_x.my_duration.secs, _x.my_duration.nsecs))
00087 except struct.error, se: self._check_types(se)
00088 except TypeError, te: self._check_types(te)
00089
00090 def deserialize_numpy(self, str, numpy):
00091 """
00092 unpack serialized message in str into this message instance using numpy for array types
00093 @param str: byte array of serialized message
00094 @type str: str
00095 @param numpy: numpy python module
00096 @type numpy: module
00097 """
00098 try:
00099 if self.my_duration is None:
00100 self.my_duration = roslib.rostime.Duration()
00101 end = 0
00102 _x = self
00103 start = end
00104 end += 8
00105 (_x.my_duration.secs, _x.my_duration.nsecs,) = _struct_2i.unpack(str[start:end])
00106 self.my_duration.canon()
00107 return self
00108 except struct.error, e:
00109 raise roslib.message.DeserializationError(e)
00110
00111 _struct_I = roslib.message.struct_I
00112 _struct_2i = struct.Struct("<2i")