"""autogenerated by genmsg_py from TestFixedArray.msg. Do not edit."""
import roslib.message
import struct


class TestFixedArray(roslib.message.Message):
  _md5sum = "1557473dc09f1a01a00123a713c822a7"
  _type = "test_rospy/TestFixedArray"
  _has_header = False #flag to mark the presence of a Header object
  _full_text = """float32[1] f32_1
float32[3] f32_3
float64[1] f64_1
float64[3] f64_3
int8[1] i8_1
int8[3] i8_3
uint8[1] u8_1
uint8[3] u8_3
int32[1] i32_1
int32[3] i32_3
uint32[1] u32_1
uint32[3] u32_3
string[1] s_1
string[3] s_3
bool[1] b_1
bool[3] b_3
"""
  __slots__ = ['f32_1','f32_3','f64_1','f64_3','i8_1','i8_3','u8_1','u8_3','i32_1','i32_3','u32_1','u32_3','s_1','s_3','b_1','b_3']
  _slot_types = ['float32[1]','float32[3]','float64[1]','float64[3]','int8[1]','int8[3]','uint8[1]','uint8[3]','int32[1]','int32[3]','uint32[1]','uint32[3]','string[1]','string[3]','bool[1]','bool[3]']

  def __init__(self, *args, **kwds):
    """
    Constructor. Any message fields that are implicitly/explicitly
    set to None will be assigned a default value. The recommend
    use is keyword arguments as this is more robust to future message
    changes.  You cannot mix in-order arguments and keyword arguments.
    
    The available fields are:
       f32_1,f32_3,f64_1,f64_3,i8_1,i8_3,u8_1,u8_3,i32_1,i32_3,u32_1,u32_3,s_1,s_3,b_1,b_3
    
    @param args: complete set of field values, in .msg order
    @param kwds: use keyword arguments corresponding to message field names
    to set specific fields. 
    """
    if args or kwds:
      super(TestFixedArray, self).__init__(*args, **kwds)
      #message fields cannot be None, assign default values for those that are
      if self.f32_1 is None:
        self.f32_1 = [0.]
      if self.f32_3 is None:
        self.f32_3 = [0.,0.,0.]
      if self.f64_1 is None:
        self.f64_1 = [0.]
      if self.f64_3 is None:
        self.f64_3 = [0.,0.,0.]
      if self.i8_1 is None:
        self.i8_1 = [0]
      if self.i8_3 is None:
        self.i8_3 = [0,0,0]
      if self.u8_1 is None:
        self.u8_1 = chr(0)*1
      if self.u8_3 is None:
        self.u8_3 = chr(0)*3
      if self.i32_1 is None:
        self.i32_1 = [0]
      if self.i32_3 is None:
        self.i32_3 = [0,0,0]
      if self.u32_1 is None:
        self.u32_1 = [0]
      if self.u32_3 is None:
        self.u32_3 = [0,0,0]
      if self.s_1 is None:
        self.s_1 = ['']
      if self.s_3 is None:
        self.s_3 = ['','','']
      if self.b_1 is None:
        self.b_1 = [False]
      if self.b_3 is None:
        self.b_3 = [False,False,False]
    else:
      self.f32_1 = [0.]
      self.f32_3 = [0.,0.,0.]
      self.f64_1 = [0.]
      self.f64_3 = [0.,0.,0.]
      self.i8_1 = [0]
      self.i8_3 = [0,0,0]
      self.u8_1 = chr(0)*1
      self.u8_3 = chr(0)*3
      self.i32_1 = [0]
      self.i32_3 = [0,0,0]
      self.u32_1 = [0]
      self.u32_3 = [0,0,0]
      self.s_1 = ['']
      self.s_3 = ['','','']
      self.b_1 = [False]
      self.b_3 = [False,False,False]

  def _get_types(self):
    """
    internal API method
    """
    return self._slot_types

  def serialize(self, buff):
    """
    serialize message into buffer
    @param buff: buffer
    @type  buff: StringIO
    """
    try:
      buff.write(_struct_1f.pack(*self.f32_1))
      buff.write(_struct_3f.pack(*self.f32_3))
      buff.write(_struct_1d.pack(*self.f64_1))
      buff.write(_struct_3d.pack(*self.f64_3))
      buff.write(_struct_1b.pack(*self.i8_1))
      buff.write(_struct_3b.pack(*self.i8_3))
      _x = self.u8_1
      # - if encoded as a list instead, serialize as bytes instead of string
      if type(_x) in [list, tuple]:
        buff.write(_struct_1B.pack(*_x))
      else:
        buff.write(_struct_1s.pack(_x))
      _x = self.u8_3
      # - if encoded as a list instead, serialize as bytes instead of string
      if type(_x) in [list, tuple]:
        buff.write(_struct_3B.pack(*_x))
      else:
        buff.write(_struct_3s.pack(_x))
      buff.write(_struct_1i.pack(*self.i32_1))
      buff.write(_struct_3i.pack(*self.i32_3))
      buff.write(_struct_1I.pack(*self.u32_1))
      buff.write(_struct_3I.pack(*self.u32_3))
      for val1 in self.s_1:
        length = len(val1)
        buff.write(struct.pack('<I%ss'%length, length, val1))
      for val1 in self.s_3:
        length = len(val1)
        buff.write(struct.pack('<I%ss'%length, length, val1))
      buff.write(_struct_1B.pack(*self.b_1))
      buff.write(_struct_3B.pack(*self.b_3))
    except struct.error, se: self._check_types(se)
    except TypeError, te: self._check_types(te)

  def deserialize(self, str):
    """
    unpack serialized message in str into this message instance
    @param str: byte array of serialized message
    @type  str: str
    """
    try:
      end = 0
      start = end
      end += 4
      self.f32_1 = _struct_1f.unpack(str[start:end])
      start = end
      end += 12
      self.f32_3 = _struct_3f.unpack(str[start:end])
      start = end
      end += 8
      self.f64_1 = _struct_1d.unpack(str[start:end])
      start = end
      end += 24
      self.f64_3 = _struct_3d.unpack(str[start:end])
      start = end
      end += 1
      self.i8_1 = _struct_1b.unpack(str[start:end])
      start = end
      end += 3
      self.i8_3 = _struct_3b.unpack(str[start:end])
      start = end
      end += 1
      self.u8_1 = str[start:end]
      start = end
      end += 3
      self.u8_3 = str[start:end]
      start = end
      end += 4
      self.i32_1 = _struct_1i.unpack(str[start:end])
      start = end
      end += 12
      self.i32_3 = _struct_3i.unpack(str[start:end])
      start = end
      end += 4
      self.u32_1 = _struct_1I.unpack(str[start:end])
      start = end
      end += 12
      self.u32_3 = _struct_3I.unpack(str[start:end])
      self.s_1 = []
      for i in xrange(0, 1):
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        start = end
        end += length
        val1 = str[start:end]
        self.s_1.append(val1)
      self.s_3 = []
      for i in xrange(0, 3):
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        start = end
        end += length
        val1 = str[start:end]
        self.s_3.append(val1)
      start = end
      end += 1
      self.b_1 = _struct_1B.unpack(str[start:end])
      self.b_1 = map(bool, self.b_1)
      start = end
      end += 3
      self.b_3 = _struct_3B.unpack(str[start:end])
      self.b_3 = map(bool, self.b_3)
      return self
    except struct.error, e:
      raise roslib.message.DeserializationError(e) #most likely buffer underfill


  def serialize_numpy(self, buff, numpy):
    """
    serialize message with numpy array types into buffer
    @param buff: buffer
    @type  buff: StringIO
    @param numpy: numpy python module
    @type  numpy module
    """
    try:
      buff.write(self.f32_1.tostring())
      buff.write(self.f32_3.tostring())
      buff.write(self.f64_1.tostring())
      buff.write(self.f64_3.tostring())
      buff.write(self.i8_1.tostring())
      buff.write(self.i8_3.tostring())
      _x = self.u8_1
      # - if encoded as a list instead, serialize as bytes instead of string
      if type(_x) in [list, tuple]:
        buff.write(_struct_1B.pack(*_x))
      else:
        buff.write(_struct_1s.pack(_x))
      _x = self.u8_3
      # - if encoded as a list instead, serialize as bytes instead of string
      if type(_x) in [list, tuple]:
        buff.write(_struct_3B.pack(*_x))
      else:
        buff.write(_struct_3s.pack(_x))
      buff.write(self.i32_1.tostring())
      buff.write(self.i32_3.tostring())
      buff.write(self.u32_1.tostring())
      buff.write(self.u32_3.tostring())
      for val1 in self.s_1:
        length = len(val1)
        buff.write(struct.pack('<I%ss'%length, length, val1))
      for val1 in self.s_3:
        length = len(val1)
        buff.write(struct.pack('<I%ss'%length, length, val1))
      buff.write(self.b_1.tostring())
      buff.write(self.b_3.tostring())
    except struct.error, se: self._check_types(se)
    except TypeError, te: self._check_types(te)

  def deserialize_numpy(self, str, numpy):
    """
    unpack serialized message in str into this message instance using numpy for array types
    @param str: byte array of serialized message
    @type  str: str
    @param numpy: numpy python module
    @type  numpy: module
    """
    try:
      end = 0
      start = end
      end += 4
      self.f32_1 = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=1)
      start = end
      end += 12
      self.f32_3 = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=3)
      start = end
      end += 8
      self.f64_1 = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=1)
      start = end
      end += 24
      self.f64_3 = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=3)
      start = end
      end += 1
      self.i8_1 = numpy.frombuffer(str[start:end], dtype=numpy.int8, count=1)
      start = end
      end += 3
      self.i8_3 = numpy.frombuffer(str[start:end], dtype=numpy.int8, count=3)
      start = end
      end += 1
      self.u8_1 = str[start:end]
      start = end
      end += 3
      self.u8_3 = str[start:end]
      start = end
      end += 4
      self.i32_1 = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=1)
      start = end
      end += 12
      self.i32_3 = numpy.frombuffer(str[start:end], dtype=numpy.int32, count=3)
      start = end
      end += 4
      self.u32_1 = numpy.frombuffer(str[start:end], dtype=numpy.uint32, count=1)
      start = end
      end += 12
      self.u32_3 = numpy.frombuffer(str[start:end], dtype=numpy.uint32, count=3)
      self.s_1 = []
      for i in xrange(0, 1):
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        start = end
        end += length
        val1 = str[start:end]
        self.s_1.append(val1)
      self.s_3 = []
      for i in xrange(0, 3):
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        start = end
        end += length
        val1 = str[start:end]
        self.s_3.append(val1)
      start = end
      end += 1
      self.b_1 = numpy.frombuffer(str[start:end], dtype=numpy.bool, count=1)
      self.b_1 = map(bool, self.b_1)
      start = end
      end += 3
      self.b_3 = numpy.frombuffer(str[start:end], dtype=numpy.bool, count=3)
      self.b_3 = map(bool, self.b_3)
      return self
    except struct.error, e:
      raise roslib.message.DeserializationError(e) #most likely buffer underfill

_struct_I = roslib.message.struct_I
_struct_1s = struct.Struct("<1s")
_struct_3s = struct.Struct("<3s")
_struct_3I = struct.Struct("<3I")
_struct_1I = struct.Struct("<1I")
_struct_3B = struct.Struct("<3B")
_struct_1i = struct.Struct("<1i")
_struct_3i = struct.Struct("<3i")
_struct_1b = struct.Struct("<1b")
_struct_1d = struct.Struct("<1d")
_struct_1f = struct.Struct("<1f")
_struct_1B = struct.Struct("<1B")
_struct_3b = struct.Struct("<3b")
_struct_3f = struct.Struct("<3f")
_struct_3d = struct.Struct("<3d")
