# This Python file uses the following encoding: utf-8
"""autogenerated by genpy from uavpos_ros/genom_state_component.msg. Do not edit."""
import codecs
import sys
python3 = True if sys.hexversion > 0x03000000 else False
import genpy
import struct

import uavpos_ros.msg

class genom_state_component(genpy.Message):
  _md5sum = "d7045eed14f90201e8d03c3bee8bd266"
  _type = "uavpos_ros/genom_state_component"
  _has_header = False  # flag to mark the presence of a Header object
  _full_text = """# IDL struct ::genom::state::component
genom_state_task[] task
string digest
string date
string version

================================================================================
MSG: uavpos_ros/genom_state_task
# IDL struct ::genom::state::task
string name
genom_state_rusage rusage
genom_state_activity[] activity

================================================================================
MSG: uavpos_ros/genom_state_rusage
# IDL struct ::genom::state::rusage
uint32 cycles
genom_state_stats timings
genom_state_stats load

================================================================================
MSG: uavpos_ros/genom_state_stats
# IDL struct ::genom::state::stats
float32 last
float32 max
float32 avg

================================================================================
MSG: uavpos_ros/genom_state_activity
# IDL struct ::genom::state::activity
uint32 id
string name
"""
  __slots__ = ['task','digest','date','version']
  _slot_types = ['uavpos_ros/genom_state_task[]','string','string','string']

  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:
       task,digest,date,version

    :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(genom_state_component, self).__init__(*args, **kwds)
      # message fields cannot be None, assign default values for those that are
      if self.task is None:
        self.task = []
      if self.digest is None:
        self.digest = ''
      if self.date is None:
        self.date = ''
      if self.version is None:
        self.version = ''
    else:
      self.task = []
      self.digest = ''
      self.date = ''
      self.version = ''

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

  def serialize(self, buff):
    """
    serialize message into buffer
    :param buff: buffer, ``StringIO``
    """
    try:
      length = len(self.task)
      buff.write(_struct_I.pack(length))
      for val1 in self.task:
        _x = val1.name
        length = len(_x)
        if python3 or type(_x) == unicode:
          _x = _x.encode('utf-8')
          length = len(_x)
        buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
        _v1 = val1.rusage
        _x = _v1.cycles
        buff.write(_get_struct_I().pack(_x))
        _v2 = _v1.timings
        _x = _v2
        buff.write(_get_struct_3f().pack(_x.last, _x.max, _x.avg))
        _v3 = _v1.load
        _x = _v3
        buff.write(_get_struct_3f().pack(_x.last, _x.max, _x.avg))
        length = len(val1.activity)
        buff.write(_struct_I.pack(length))
        for val2 in val1.activity:
          _x = val2.id
          buff.write(_get_struct_I().pack(_x))
          _x = val2.name
          length = len(_x)
          if python3 or type(_x) == unicode:
            _x = _x.encode('utf-8')
            length = len(_x)
          buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
      _x = self.digest
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
      _x = self.date
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
      _x = self.version
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
    except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
    except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))

  def deserialize(self, str):
    """
    unpack serialized message in str into this message instance
    :param str: byte array of serialized message, ``str``
    """
    codecs.lookup_error("rosmsg").msg_type = self._type
    try:
      if self.task is None:
        self.task = None
      end = 0
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.task = []
      for i in range(0, length):
        val1 = uavpos_ros.msg.genom_state_task()
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        start = end
        end += length
        if python3:
          val1.name = str[start:end].decode('utf-8', 'rosmsg')
        else:
          val1.name = str[start:end]
        _v4 = val1.rusage
        start = end
        end += 4
        (_v4.cycles,) = _get_struct_I().unpack(str[start:end])
        _v5 = _v4.timings
        _x = _v5
        start = end
        end += 12
        (_x.last, _x.max, _x.avg,) = _get_struct_3f().unpack(str[start:end])
        _v6 = _v4.load
        _x = _v6
        start = end
        end += 12
        (_x.last, _x.max, _x.avg,) = _get_struct_3f().unpack(str[start:end])
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        val1.activity = []
        for i in range(0, length):
          val2 = uavpos_ros.msg.genom_state_activity()
          start = end
          end += 4
          (val2.id,) = _get_struct_I().unpack(str[start:end])
          start = end
          end += 4
          (length,) = _struct_I.unpack(str[start:end])
          start = end
          end += length
          if python3:
            val2.name = str[start:end].decode('utf-8', 'rosmsg')
          else:
            val2.name = str[start:end]
          val1.activity.append(val2)
        self.task.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.digest = str[start:end].decode('utf-8', 'rosmsg')
      else:
        self.digest = str[start:end]
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.date = str[start:end].decode('utf-8', 'rosmsg')
      else:
        self.date = str[start:end]
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.version = str[start:end].decode('utf-8', 'rosmsg')
      else:
        self.version = str[start:end]
      return self
    except struct.error as e:
      raise genpy.DeserializationError(e)  # most likely buffer underfill


  def serialize_numpy(self, buff, numpy):
    """
    serialize message with numpy array types into buffer
    :param buff: buffer, ``StringIO``
    :param numpy: numpy python module
    """
    try:
      length = len(self.task)
      buff.write(_struct_I.pack(length))
      for val1 in self.task:
        _x = val1.name
        length = len(_x)
        if python3 or type(_x) == unicode:
          _x = _x.encode('utf-8')
          length = len(_x)
        buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
        _v7 = val1.rusage
        _x = _v7.cycles
        buff.write(_get_struct_I().pack(_x))
        _v8 = _v7.timings
        _x = _v8
        buff.write(_get_struct_3f().pack(_x.last, _x.max, _x.avg))
        _v9 = _v7.load
        _x = _v9
        buff.write(_get_struct_3f().pack(_x.last, _x.max, _x.avg))
        length = len(val1.activity)
        buff.write(_struct_I.pack(length))
        for val2 in val1.activity:
          _x = val2.id
          buff.write(_get_struct_I().pack(_x))
          _x = val2.name
          length = len(_x)
          if python3 or type(_x) == unicode:
            _x = _x.encode('utf-8')
            length = len(_x)
          buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
      _x = self.digest
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
      _x = self.date
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
      _x = self.version
      length = len(_x)
      if python3 or type(_x) == unicode:
        _x = _x.encode('utf-8')
        length = len(_x)
      buff.write(struct.Struct('<I%ss'%length).pack(length, _x))
    except struct.error as se: self._check_types(struct.error("%s: '%s' when writing '%s'" % (type(se), str(se), str(locals().get('_x', self)))))
    except TypeError as te: self._check_types(ValueError("%s: '%s' when writing '%s'" % (type(te), str(te), str(locals().get('_x', self)))))

  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, ``str``
    :param numpy: numpy python module
    """
    codecs.lookup_error("rosmsg").msg_type = self._type
    try:
      if self.task is None:
        self.task = None
      end = 0
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.task = []
      for i in range(0, length):
        val1 = uavpos_ros.msg.genom_state_task()
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        start = end
        end += length
        if python3:
          val1.name = str[start:end].decode('utf-8', 'rosmsg')
        else:
          val1.name = str[start:end]
        _v10 = val1.rusage
        start = end
        end += 4
        (_v10.cycles,) = _get_struct_I().unpack(str[start:end])
        _v11 = _v10.timings
        _x = _v11
        start = end
        end += 12
        (_x.last, _x.max, _x.avg,) = _get_struct_3f().unpack(str[start:end])
        _v12 = _v10.load
        _x = _v12
        start = end
        end += 12
        (_x.last, _x.max, _x.avg,) = _get_struct_3f().unpack(str[start:end])
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        val1.activity = []
        for i in range(0, length):
          val2 = uavpos_ros.msg.genom_state_activity()
          start = end
          end += 4
          (val2.id,) = _get_struct_I().unpack(str[start:end])
          start = end
          end += 4
          (length,) = _struct_I.unpack(str[start:end])
          start = end
          end += length
          if python3:
            val2.name = str[start:end].decode('utf-8', 'rosmsg')
          else:
            val2.name = str[start:end]
          val1.activity.append(val2)
        self.task.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.digest = str[start:end].decode('utf-8', 'rosmsg')
      else:
        self.digest = str[start:end]
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.date = str[start:end].decode('utf-8', 'rosmsg')
      else:
        self.date = str[start:end]
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.version = str[start:end].decode('utf-8', 'rosmsg')
      else:
        self.version = str[start:end]
      return self
    except struct.error as e:
      raise genpy.DeserializationError(e)  # most likely buffer underfill

_struct_I = genpy.struct_I
def _get_struct_I():
    global _struct_I
    return _struct_I
_struct_3f = None
def _get_struct_3f():
    global _struct_3f
    if _struct_3f is None:
        _struct_3f = struct.Struct("<3f")
    return _struct_3f
