# This Python file uses the following encoding: utf-8
"""autogenerated by genpy from nhfc_ros/genom_state_rusage.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_rusage(genpy.Message):
  _md5sum = "9320d7fd882241a75db2adb6f1c2cacb"
  _type = "nhfc_ros/genom_state_rusage"
  _has_header = False  # flag to mark the presence of a Header object
  _full_text = """# 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
"""
  __slots__ = ['cycles','timings','load']
  _slot_types = ['uint32','nhfc_ros/genom_state_stats','nhfc_ros/genom_state_stats']

  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:
       cycles,timings,load

    :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_rusage, self).__init__(*args, **kwds)
      # message fields cannot be None, assign default values for those that are
      if self.cycles is None:
        self.cycles = 0
      if self.timings is None:
        self.timings = nhfc_ros.msg.genom_state_stats()
      if self.load is None:
        self.load = nhfc_ros.msg.genom_state_stats()
    else:
      self.cycles = 0
      self.timings = nhfc_ros.msg.genom_state_stats()
      self.load = nhfc_ros.msg.genom_state_stats()

  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
      buff.write(_get_struct_I6f().pack(_x.cycles, _x.timings.last, _x.timings.max, _x.timings.avg, _x.load.last, _x.load.max, _x.load.avg))
    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.timings is None:
        self.timings = nhfc_ros.msg.genom_state_stats()
      if self.load is None:
        self.load = nhfc_ros.msg.genom_state_stats()
      end = 0
      _x = self
      start = end
      end += 28
      (_x.cycles, _x.timings.last, _x.timings.max, _x.timings.avg, _x.load.last, _x.load.max, _x.load.avg,) = _get_struct_I6f().unpack(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:
      _x = self
      buff.write(_get_struct_I6f().pack(_x.cycles, _x.timings.last, _x.timings.max, _x.timings.avg, _x.load.last, _x.load.max, _x.load.avg))
    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.timings is None:
        self.timings = nhfc_ros.msg.genom_state_stats()
      if self.load is None:
        self.load = nhfc_ros.msg.genom_state_stats()
      end = 0
      _x = self
      start = end
      end += 28
      (_x.cycles, _x.timings.last, _x.timings.max, _x.timings.avg, _x.load.last, _x.load.max, _x.load.avg,) = _get_struct_I6f().unpack(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_I6f = None
def _get_struct_I6f():
    global _struct_I6f
    if _struct_I6f is None:
        _struct_I6f = struct.Struct("<I6f")
    return _struct_I6f
