Go to the documentation of this file.00001 """autogenerated by genpy from kobuki_comms/DigitalOutput.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 DigitalOutput(genpy.Message):
00009 _md5sum = "1e97cd7f196a0270516b506e8bf29ca2"
00010 _type = "kobuki_comms/DigitalOutput"
00011 _has_header = False
00012 _full_text = """# Digital output - only four pins.
00013
00014 # Array of values indices represent pins 0-3 respectively.
00015 bool[4] values
00016
00017 # Set indices to true to set a pin, false to ignore.
00018 bool[4] mask
00019
00020 """
00021 __slots__ = ['values','mask']
00022 _slot_types = ['bool[4]','bool[4]']
00023
00024 def __init__(self, *args, **kwds):
00025 """
00026 Constructor. Any message fields that are implicitly/explicitly
00027 set to None will be assigned a default value. The recommend
00028 use is keyword arguments as this is more robust to future message
00029 changes. You cannot mix in-order arguments and keyword arguments.
00030
00031 The available fields are:
00032 values,mask
00033
00034 :param args: complete set of field values, in .msg order
00035 :param kwds: use keyword arguments corresponding to message field names
00036 to set specific fields.
00037 """
00038 if args or kwds:
00039 super(DigitalOutput, self).__init__(*args, **kwds)
00040
00041 if self.values is None:
00042 self.values = [False,False,False,False]
00043 if self.mask is None:
00044 self.mask = [False,False,False,False]
00045 else:
00046 self.values = [False,False,False,False]
00047 self.mask = [False,False,False,False]
00048
00049 def _get_types(self):
00050 """
00051 internal API method
00052 """
00053 return self._slot_types
00054
00055 def serialize(self, buff):
00056 """
00057 serialize message into buffer
00058 :param buff: buffer, ``StringIO``
00059 """
00060 try:
00061 buff.write(_struct_4B.pack(*self.values))
00062 buff.write(_struct_4B.pack(*self.mask))
00063 except struct.error as se: self._check_types(se)
00064 except TypeError as te: self._check_types(te)
00065
00066 def deserialize(self, str):
00067 """
00068 unpack serialized message in str into this message instance
00069 :param str: byte array of serialized message, ``str``
00070 """
00071 try:
00072 end = 0
00073 start = end
00074 end += 4
00075 self.values = _struct_4B.unpack(str[start:end])
00076 self.values = map(bool, self.values)
00077 start = end
00078 end += 4
00079 self.mask = _struct_4B.unpack(str[start:end])
00080 self.mask = map(bool, self.mask)
00081 return self
00082 except struct.error as e:
00083 raise genpy.DeserializationError(e)
00084
00085
00086 def serialize_numpy(self, buff, numpy):
00087 """
00088 serialize message with numpy array types into buffer
00089 :param buff: buffer, ``StringIO``
00090 :param numpy: numpy python module
00091 """
00092 try:
00093 buff.write(self.values.tostring())
00094 buff.write(self.mask.tostring())
00095 except struct.error as se: self._check_types(se)
00096 except TypeError as te: self._check_types(te)
00097
00098 def deserialize_numpy(self, str, numpy):
00099 """
00100 unpack serialized message in str into this message instance using numpy for array types
00101 :param str: byte array of serialized message, ``str``
00102 :param numpy: numpy python module
00103 """
00104 try:
00105 end = 0
00106 start = end
00107 end += 4
00108 self.values = numpy.frombuffer(str[start:end], dtype=numpy.bool, count=4)
00109 self.values = map(bool, self.values)
00110 start = end
00111 end += 4
00112 self.mask = numpy.frombuffer(str[start:end], dtype=numpy.bool, count=4)
00113 self.mask = map(bool, self.mask)
00114 return self
00115 except struct.error as e:
00116 raise genpy.DeserializationError(e)
00117
00118 _struct_I = genpy.struct_I
00119 _struct_4B = struct.Struct("<4B")