00001 """autogenerated by genpy from nasa_r2_common_msgs/SystemCore.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 SystemCore(genpy.Message):
00009 _md5sum = "f24d56ccce4448beee59c654a367c906"
00010 _type = "nasa_r2_common_msgs/SystemCore"
00011 _has_header = False
00012 _full_text = """string id
00013 float64 speed
00014 float64 load
00015 bool failure
00016 """
00017 __slots__ = ['id','speed','load','failure']
00018 _slot_types = ['string','float64','float64','bool']
00019
00020 def __init__(self, *args, **kwds):
00021 """
00022 Constructor. Any message fields that are implicitly/explicitly
00023 set to None will be assigned a default value. The recommend
00024 use is keyword arguments as this is more robust to future message
00025 changes. You cannot mix in-order arguments and keyword arguments.
00026
00027 The available fields are:
00028 id,speed,load,failure
00029
00030 :param args: complete set of field values, in .msg order
00031 :param kwds: use keyword arguments corresponding to message field names
00032 to set specific fields.
00033 """
00034 if args or kwds:
00035 super(SystemCore, self).__init__(*args, **kwds)
00036
00037 if self.id is None:
00038 self.id = ''
00039 if self.speed is None:
00040 self.speed = 0.
00041 if self.load is None:
00042 self.load = 0.
00043 if self.failure is None:
00044 self.failure = False
00045 else:
00046 self.id = ''
00047 self.speed = 0.
00048 self.load = 0.
00049 self.failure = False
00050
00051 def _get_types(self):
00052 """
00053 internal API method
00054 """
00055 return self._slot_types
00056
00057 def serialize(self, buff):
00058 """
00059 serialize message into buffer
00060 :param buff: buffer, ``StringIO``
00061 """
00062 try:
00063 _x = self.id
00064 length = len(_x)
00065 if python3 or type(_x) == unicode:
00066 _x = _x.encode('utf-8')
00067 length = len(_x)
00068 buff.write(struct.pack('<I%ss'%length, length, _x))
00069 _x = self
00070 buff.write(_struct_2dB.pack(_x.speed, _x.load, _x.failure))
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 end = 0
00081 start = end
00082 end += 4
00083 (length,) = _struct_I.unpack(str[start:end])
00084 start = end
00085 end += length
00086 if python3:
00087 self.id = str[start:end].decode('utf-8')
00088 else:
00089 self.id = str[start:end]
00090 _x = self
00091 start = end
00092 end += 17
00093 (_x.speed, _x.load, _x.failure,) = _struct_2dB.unpack(str[start:end])
00094 self.failure = bool(self.failure)
00095 return self
00096 except struct.error as e:
00097 raise genpy.DeserializationError(e)
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.id
00108 length = len(_x)
00109 if python3 or type(_x) == unicode:
00110 _x = _x.encode('utf-8')
00111 length = len(_x)
00112 buff.write(struct.pack('<I%ss'%length, length, _x))
00113 _x = self
00114 buff.write(_struct_2dB.pack(_x.speed, _x.load, _x.failure))
00115 except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00116 except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00117
00118 def deserialize_numpy(self, str, numpy):
00119 """
00120 unpack serialized message in str into this message instance using numpy for array types
00121 :param str: byte array of serialized message, ``str``
00122 :param numpy: numpy python module
00123 """
00124 try:
00125 end = 0
00126 start = end
00127 end += 4
00128 (length,) = _struct_I.unpack(str[start:end])
00129 start = end
00130 end += length
00131 if python3:
00132 self.id = str[start:end].decode('utf-8')
00133 else:
00134 self.id = str[start:end]
00135 _x = self
00136 start = end
00137 end += 17
00138 (_x.speed, _x.load, _x.failure,) = _struct_2dB.unpack(str[start:end])
00139 self.failure = bool(self.failure)
00140 return self
00141 except struct.error as e:
00142 raise genpy.DeserializationError(e)
00143
00144 _struct_I = genpy.struct_I
00145 _struct_2dB = struct.Struct("<2dB")