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

import nhfc_ros.msg

class genom_state_task(genpy.Message):
  _md5sum = "b6ebe21c3b706530495c8ef9b94c0cf3"
  _type = "nhfc_ros/genom_state_task"
  _has_header = False  # flag to mark the presence of a Header object
  _full_text = """# IDL struct ::genom::state::task
string name
genom_state_rusage rusage
genom_state_activity[] activity

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

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

================================================================================
MSG: nhfc_ros/genom_state_activity
# IDL struct ::genom::state::activity
uint32 id
string name
"""
  __slots__ = ['name','rusage','activity']
  _slot_types = ['string','nhfc_ros/genom_state_rusage','nhfc_ros/genom_state_activity[]']

  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:
       name,rusage,activity

    :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_task, self).__init__(*args, **kwds)
      # message fields cannot be None, assign default values for those that are
      if self.name is None:
        self.name = ''
      if self.rusage is None:
        self.rusage = nhfc_ros.msg.genom_state_rusage()
      if self.activity is None:
        self.activity = []
    else:
      self.name = ''
      self.rusage = nhfc_ros.msg.genom_state_rusage()
      self.activity = []

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

  def serialize(self, buff):
    """
    serialize message into buffer
    :param buff: buffer, ``StringIO``
    """
    try:
      _x = self.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
      buff.write(_get_struct_I6f().pack(_x.rusage.cycles, _x.rusage.timings.last, _x.rusage.timings.max, _x.rusage.timings.avg, _x.rusage.load.last, _x.rusage.load.max, _x.rusage.load.avg))
      length = len(self.activity)
      buff.write(_struct_I.pack(length))
      for val1 in self.activity:
        _x = val1.id
        buff.write(_get_struct_I().pack(_x))
        _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))
    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``
    """
    if python3:
      codecs.lookup_error("rosmsg").msg_type = self._type
    try:
      if self.rusage is None:
        self.rusage = nhfc_ros.msg.genom_state_rusage()
      if self.activity is None:
        self.activity = None
      end = 0
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.name = str[start:end].decode('utf-8', 'rosmsg')
      else:
        self.name = str[start:end]
      _x = self
      start = end
      end += 28
      (_x.rusage.cycles, _x.rusage.timings.last, _x.rusage.timings.max, _x.rusage.timings.avg, _x.rusage.load.last, _x.rusage.load.max, _x.rusage.load.avg,) = _get_struct_I6f().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.activity = []
      for i in range(0, length):
        val1 = nhfc_ros.msg.genom_state_activity()
        start = end
        end += 4
        (val1.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:
          val1.name = str[start:end].decode('utf-8', 'rosmsg')
        else:
          val1.name = str[start:end]
        self.activity.append(val1)
      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:
      _x = self.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
      buff.write(_get_struct_I6f().pack(_x.rusage.cycles, _x.rusage.timings.last, _x.rusage.timings.max, _x.rusage.timings.avg, _x.rusage.load.last, _x.rusage.load.max, _x.rusage.load.avg))
      length = len(self.activity)
      buff.write(_struct_I.pack(length))
      for val1 in self.activity:
        _x = val1.id
        buff.write(_get_struct_I().pack(_x))
        _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))
    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
    """
    if python3:
      codecs.lookup_error("rosmsg").msg_type = self._type
    try:
      if self.rusage is None:
        self.rusage = nhfc_ros.msg.genom_state_rusage()
      if self.activity is None:
        self.activity = None
      end = 0
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      start = end
      end += length
      if python3:
        self.name = str[start:end].decode('utf-8', 'rosmsg')
      else:
        self.name = str[start:end]
      _x = self
      start = end
      end += 28
      (_x.rusage.cycles, _x.rusage.timings.last, _x.rusage.timings.max, _x.rusage.timings.avg, _x.rusage.load.last, _x.rusage.load.max, _x.rusage.load.avg,) = _get_struct_I6f().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.activity = []
      for i in range(0, length):
        val1 = nhfc_ros.msg.genom_state_activity()
        start = end
        end += 4
        (val1.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:
          val1.name = str[start:end].decode('utf-8', 'rosmsg')
        else:
          val1.name = str[start:end]
        self.activity.append(val1)
      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_I6f = None
def _get_struct_I6f():
    global _struct_I6f
    if _struct_I6f is None:
        _struct_I6f = struct.Struct("<I6f")
    return _struct_I6f
