_RawFTDataSample.py
Go to the documentation of this file.
00001 """autogenerated by genpy from ethercat_hardware/RawFTDataSample.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 RawFTDataSample(genpy.Message):
00009   _md5sum = "6c3b6e352fd24802b2d95b606df80de6"
00010   _type = "ethercat_hardware/RawFTDataSample"
00011   _has_header = False #flag to mark the presence of a Header object
00012   _full_text = """# One raw Data sample from WG035 F/T input via WG006 (gripper MCB).
00013 uint64  sample_count
00014 int16[] data
00015 uint16  vhalf
00016 """
00017   __slots__ = ['sample_count','data','vhalf']
00018   _slot_types = ['uint64','int16[]','uint16']
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        sample_count,data,vhalf
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(RawFTDataSample, self).__init__(*args, **kwds)
00036       #message fields cannot be None, assign default values for those that are
00037       if self.sample_count is None:
00038         self.sample_count = 0
00039       if self.data is None:
00040         self.data = []
00041       if self.vhalf is None:
00042         self.vhalf = 0
00043     else:
00044       self.sample_count = 0
00045       self.data = []
00046       self.vhalf = 0
00047 
00048   def _get_types(self):
00049     """
00050     internal API method
00051     """
00052     return self._slot_types
00053 
00054   def serialize(self, buff):
00055     """
00056     serialize message into buffer
00057     :param buff: buffer, ``StringIO``
00058     """
00059     try:
00060       buff.write(_struct_Q.pack(self.sample_count))
00061       length = len(self.data)
00062       buff.write(_struct_I.pack(length))
00063       pattern = '<%sh'%length
00064       buff.write(struct.pack(pattern, *self.data))
00065       buff.write(_struct_H.pack(self.vhalf))
00066     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00067     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00068 
00069   def deserialize(self, str):
00070     """
00071     unpack serialized message in str into this message instance
00072     :param str: byte array of serialized message, ``str``
00073     """
00074     try:
00075       end = 0
00076       start = end
00077       end += 8
00078       (self.sample_count,) = _struct_Q.unpack(str[start:end])
00079       start = end
00080       end += 4
00081       (length,) = _struct_I.unpack(str[start:end])
00082       pattern = '<%sh'%length
00083       start = end
00084       end += struct.calcsize(pattern)
00085       self.data = struct.unpack(pattern, str[start:end])
00086       start = end
00087       end += 2
00088       (self.vhalf,) = _struct_H.unpack(str[start:end])
00089       return self
00090     except struct.error as e:
00091       raise genpy.DeserializationError(e) #most likely buffer underfill
00092 
00093 
00094   def serialize_numpy(self, buff, numpy):
00095     """
00096     serialize message with numpy array types into buffer
00097     :param buff: buffer, ``StringIO``
00098     :param numpy: numpy python module
00099     """
00100     try:
00101       buff.write(_struct_Q.pack(self.sample_count))
00102       length = len(self.data)
00103       buff.write(_struct_I.pack(length))
00104       pattern = '<%sh'%length
00105       buff.write(self.data.tostring())
00106       buff.write(_struct_H.pack(self.vhalf))
00107     except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(_x))))
00108     except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(_x))))
00109 
00110   def deserialize_numpy(self, str, numpy):
00111     """
00112     unpack serialized message in str into this message instance using numpy for array types
00113     :param str: byte array of serialized message, ``str``
00114     :param numpy: numpy python module
00115     """
00116     try:
00117       end = 0
00118       start = end
00119       end += 8
00120       (self.sample_count,) = _struct_Q.unpack(str[start:end])
00121       start = end
00122       end += 4
00123       (length,) = _struct_I.unpack(str[start:end])
00124       pattern = '<%sh'%length
00125       start = end
00126       end += struct.calcsize(pattern)
00127       self.data = numpy.frombuffer(str[start:end], dtype=numpy.int16, count=length)
00128       start = end
00129       end += 2
00130       (self.vhalf,) = _struct_H.unpack(str[start:end])
00131       return self
00132     except struct.error as e:
00133       raise genpy.DeserializationError(e) #most likely buffer underfill
00134 
00135 _struct_I = genpy.struct_I
00136 _struct_Q = struct.Struct("<Q")
00137 _struct_H = struct.Struct("<H")


ethercat_hardware
Author(s): Rob Wheeler (email: wheeler@willowgarage.com), Maintained by Derek King (email: dking@willowgarage.com)
autogenerated on Thu Apr 24 2014 15:43:44