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


cob_phidgets
Author(s): Florian Weisshardt, Benjamin Maidel
autogenerated on Sun Oct 5 2014 23:10:20