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


linux_hardware
Author(s): Daniel Stonier
autogenerated on Mon Oct 6 2014 08:01:08