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