00001 """autogenerated by genpy from clearpath_base/PowerSource.msg. Do not edit."""
00002 import sys
00003 python3 = True if sys.hexversion > 0x03000000 else False
00004 import genpy
00005 import struct
00006
00007
00008 class PowerSource(genpy.Message):
00009 _md5sum = "adbe384d7d69a337a7f2b6bf1d0139cb"
00010 _type = "clearpath_base/PowerSource"
00011 _has_header = False
00012 _full_text = """float32 charge
00013 int16 capacity
00014 bool present
00015 bool in_use
00016 uint8 description
00017
00018 """
00019 __slots__ = ['charge','capacity','present','in_use','description']
00020 _slot_types = ['float32','int16','bool','bool','uint8']
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 charge,capacity,present,in_use,description
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(PowerSource, self).__init__(*args, **kwds)
00038
00039 if self.charge is None:
00040 self.charge = 0.
00041 if self.capacity is None:
00042 self.capacity = 0
00043 if self.present is None:
00044 self.present = False
00045 if self.in_use is None:
00046 self.in_use = False
00047 if self.description is None:
00048 self.description = 0
00049 else:
00050 self.charge = 0.
00051 self.capacity = 0
00052 self.present = False
00053 self.in_use = False
00054 self.description = 0
00055
00056 def _get_types(self):
00057 """
00058 internal API method
00059 """
00060 return self._slot_types
00061
00062 def serialize(self, buff):
00063 """
00064 serialize message into buffer
00065 :param buff: buffer, ``StringIO``
00066 """
00067 try:
00068 _x = self
00069 buff.write(_struct_fh3B.pack(_x.charge, _x.capacity, _x.present, _x.in_use, _x.description))
00070 except struct.error as se: self._check_types(se)
00071 except TypeError as te: self._check_types(te)
00072
00073 def deserialize(self, str):
00074 """
00075 unpack serialized message in str into this message instance
00076 :param str: byte array of serialized message, ``str``
00077 """
00078 try:
00079 end = 0
00080 _x = self
00081 start = end
00082 end += 9
00083 (_x.charge, _x.capacity, _x.present, _x.in_use, _x.description,) = _struct_fh3B.unpack(str[start:end])
00084 self.present = bool(self.present)
00085 self.in_use = bool(self.in_use)
00086 return self
00087 except struct.error as e:
00088 raise genpy.DeserializationError(e)
00089
00090
00091 def serialize_numpy(self, buff, numpy):
00092 """
00093 serialize message with numpy array types into buffer
00094 :param buff: buffer, ``StringIO``
00095 :param numpy: numpy python module
00096 """
00097 try:
00098 _x = self
00099 buff.write(_struct_fh3B.pack(_x.charge, _x.capacity, _x.present, _x.in_use, _x.description))
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, ``str``
00107 :param numpy: numpy python module
00108 """
00109 try:
00110 end = 0
00111 _x = self
00112 start = end
00113 end += 9
00114 (_x.charge, _x.capacity, _x.present, _x.in_use, _x.description,) = _struct_fh3B.unpack(str[start:end])
00115 self.present = bool(self.present)
00116 self.in_use = bool(self.in_use)
00117 return self
00118 except struct.error as e:
00119 raise genpy.DeserializationError(e)
00120
00121 _struct_I = genpy.struct_I
00122 _struct_fh3B = struct.Struct("<fh3B")