_Battery.py
Go to the documentation of this file.
00001 """autogenerated by genpy from laptop_battery/Battery.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 std_msgs.msg
00008 
00009 class Battery(genpy.Message):
00010   _md5sum = "21f54717ee47fec662ccdb9a6ca81a7d"
00011   _type = "laptop_battery/Battery"
00012   _has_header = True #flag to mark the presence of a Header object
00013   _full_text = """Header header
00014 bool charging
00015 float32 level                           # in %
00016 uint32 time_remaining           # in minutes
00017 
00018 ================================================================================
00019 MSG: std_msgs/Header
00020 # Standard metadata for higher-level stamped data types.
00021 # This is generally used to communicate timestamped data 
00022 # in a particular coordinate frame.
00023 # 
00024 # sequence ID: consecutively increasing ID 
00025 uint32 seq
00026 #Two-integer timestamp that is expressed as:
00027 # * stamp.secs: seconds (stamp_secs) since epoch
00028 # * stamp.nsecs: nanoseconds since stamp_secs
00029 # time-handling sugar is provided by the client library
00030 time stamp
00031 #Frame this data is associated with
00032 # 0: no frame
00033 # 1: global frame
00034 string frame_id
00035 
00036 """
00037   __slots__ = ['header','charging','level','time_remaining']
00038   _slot_types = ['std_msgs/Header','bool','float32','uint32']
00039 
00040   def __init__(self, *args, **kwds):
00041     """
00042     Constructor. Any message fields that are implicitly/explicitly
00043     set to None will be assigned a default value. The recommend
00044     use is keyword arguments as this is more robust to future message
00045     changes.  You cannot mix in-order arguments and keyword arguments.
00046 
00047     The available fields are:
00048        header,charging,level,time_remaining
00049 
00050     :param args: complete set of field values, in .msg order
00051     :param kwds: use keyword arguments corresponding to message field names
00052     to set specific fields.
00053     """
00054     if args or kwds:
00055       super(Battery, self).__init__(*args, **kwds)
00056       #message fields cannot be None, assign default values for those that are
00057       if self.header is None:
00058         self.header = std_msgs.msg.Header()
00059       if self.charging is None:
00060         self.charging = False
00061       if self.level is None:
00062         self.level = 0.
00063       if self.time_remaining is None:
00064         self.time_remaining = 0
00065     else:
00066       self.header = std_msgs.msg.Header()
00067       self.charging = False
00068       self.level = 0.
00069       self.time_remaining = 0
00070 
00071   def _get_types(self):
00072     """
00073     internal API method
00074     """
00075     return self._slot_types
00076 
00077   def serialize(self, buff):
00078     """
00079     serialize message into buffer
00080     :param buff: buffer, ``StringIO``
00081     """
00082     try:
00083       _x = self
00084       buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00085       _x = self.header.frame_id
00086       length = len(_x)
00087       if python3 or type(_x) == unicode:
00088         _x = _x.encode('utf-8')
00089         length = len(_x)
00090       buff.write(struct.pack('<I%ss'%length, length, _x))
00091       _x = self
00092       buff.write(_struct_BfI.pack(_x.charging, _x.level, _x.time_remaining))
00093     except struct.error as se: self._check_types(se)
00094     except TypeError as te: self._check_types(te)
00095 
00096   def deserialize(self, str):
00097     """
00098     unpack serialized message in str into this message instance
00099     :param str: byte array of serialized message, ``str``
00100     """
00101     try:
00102       if self.header is None:
00103         self.header = std_msgs.msg.Header()
00104       end = 0
00105       _x = self
00106       start = end
00107       end += 12
00108       (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00109       start = end
00110       end += 4
00111       (length,) = _struct_I.unpack(str[start:end])
00112       start = end
00113       end += length
00114       if python3:
00115         self.header.frame_id = str[start:end].decode('utf-8')
00116       else:
00117         self.header.frame_id = str[start:end]
00118       _x = self
00119       start = end
00120       end += 9
00121       (_x.charging, _x.level, _x.time_remaining,) = _struct_BfI.unpack(str[start:end])
00122       self.charging = bool(self.charging)
00123       return self
00124     except struct.error as e:
00125       raise genpy.DeserializationError(e) #most likely buffer underfill
00126 
00127 
00128   def serialize_numpy(self, buff, numpy):
00129     """
00130     serialize message with numpy array types into buffer
00131     :param buff: buffer, ``StringIO``
00132     :param numpy: numpy python module
00133     """
00134     try:
00135       _x = self
00136       buff.write(_struct_3I.pack(_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs))
00137       _x = self.header.frame_id
00138       length = len(_x)
00139       if python3 or type(_x) == unicode:
00140         _x = _x.encode('utf-8')
00141         length = len(_x)
00142       buff.write(struct.pack('<I%ss'%length, length, _x))
00143       _x = self
00144       buff.write(_struct_BfI.pack(_x.charging, _x.level, _x.time_remaining))
00145     except struct.error as se: self._check_types(se)
00146     except TypeError as te: self._check_types(te)
00147 
00148   def deserialize_numpy(self, str, numpy):
00149     """
00150     unpack serialized message in str into this message instance using numpy for array types
00151     :param str: byte array of serialized message, ``str``
00152     :param numpy: numpy python module
00153     """
00154     try:
00155       if self.header is None:
00156         self.header = std_msgs.msg.Header()
00157       end = 0
00158       _x = self
00159       start = end
00160       end += 12
00161       (_x.header.seq, _x.header.stamp.secs, _x.header.stamp.nsecs,) = _struct_3I.unpack(str[start:end])
00162       start = end
00163       end += 4
00164       (length,) = _struct_I.unpack(str[start:end])
00165       start = end
00166       end += length
00167       if python3:
00168         self.header.frame_id = str[start:end].decode('utf-8')
00169       else:
00170         self.header.frame_id = str[start:end]
00171       _x = self
00172       start = end
00173       end += 9
00174       (_x.charging, _x.level, _x.time_remaining,) = _struct_BfI.unpack(str[start:end])
00175       self.charging = bool(self.charging)
00176       return self
00177     except struct.error as e:
00178       raise genpy.DeserializationError(e) #most likely buffer underfill
00179 
00180 _struct_I = genpy.struct_I
00181 _struct_3I = struct.Struct("<3I")
00182 _struct_BfI = struct.Struct("<BfI")


laptop_battery
Author(s): Gonçalo Cabrita
autogenerated on Mon Jan 6 2014 11:28:25