# This Python file uses the following encoding: utf-8
"""autogenerated by genpy from nhfc_ros/or_rotorcraft_input.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 or_rotorcraft_input(genpy.Message):
  _md5sum = "06f760fd6dab42272fe2b6dddf8483be"
  _type = "nhfc_ros/or_rotorcraft_input"
  _has_header = False  # flag to mark the presence of a Header object
  _full_text = """# IDL struct ::or_rotorcraft::input
or_time_ts ts
or_rotorcraft_control_type control
or_rotorcraft_rotor_control desired

================================================================================
MSG: nhfc_ros/or_time_ts
# IDL struct ::or::time::ts
int32 sec
int32 nsec

================================================================================
MSG: nhfc_ros/or_rotorcraft_control_type
# IDL enum ::or_rotorcraft::control_type
uint32 or_rotorcraft_velocity = 0
uint32 or_rotorcraft_throttle = 1

uint32 value

================================================================================
MSG: nhfc_ros/or_rotorcraft_rotor_control
# IDL typedef ::or_rotorcraft::rotor_control
float64[] rotor_control
"""
  __slots__ = ['ts','control','desired']
  _slot_types = ['nhfc_ros/or_time_ts','nhfc_ros/or_rotorcraft_control_type','nhfc_ros/or_rotorcraft_rotor_control']

  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:
       ts,control,desired

    :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(or_rotorcraft_input, self).__init__(*args, **kwds)
      # message fields cannot be None, assign default values for those that are
      if self.ts is None:
        self.ts = nhfc_ros.msg.or_time_ts()
      if self.control is None:
        self.control = nhfc_ros.msg.or_rotorcraft_control_type()
      if self.desired is None:
        self.desired = nhfc_ros.msg.or_rotorcraft_rotor_control()
    else:
      self.ts = nhfc_ros.msg.or_time_ts()
      self.control = nhfc_ros.msg.or_rotorcraft_control_type()
      self.desired = nhfc_ros.msg.or_rotorcraft_rotor_control()

  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_2iI().pack(_x.ts.sec, _x.ts.nsec, _x.control.value))
      length = len(self.desired.rotor_control)
      buff.write(_struct_I.pack(length))
      pattern = '<%sd'%length
      buff.write(struct.Struct(pattern).pack(*self.desired.rotor_control))
    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.ts is None:
        self.ts = nhfc_ros.msg.or_time_ts()
      if self.control is None:
        self.control = nhfc_ros.msg.or_rotorcraft_control_type()
      if self.desired is None:
        self.desired = nhfc_ros.msg.or_rotorcraft_rotor_control()
      end = 0
      _x = self
      start = end
      end += 12
      (_x.ts.sec, _x.ts.nsec, _x.control.value,) = _get_struct_2iI().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      pattern = '<%sd'%length
      start = end
      s = struct.Struct(pattern)
      end += s.size
      self.desired.rotor_control = s.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_2iI().pack(_x.ts.sec, _x.ts.nsec, _x.control.value))
      length = len(self.desired.rotor_control)
      buff.write(_struct_I.pack(length))
      pattern = '<%sd'%length
      buff.write(self.desired.rotor_control.tostring())
    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.ts is None:
        self.ts = nhfc_ros.msg.or_time_ts()
      if self.control is None:
        self.control = nhfc_ros.msg.or_rotorcraft_control_type()
      if self.desired is None:
        self.desired = nhfc_ros.msg.or_rotorcraft_rotor_control()
      end = 0
      _x = self
      start = end
      end += 12
      (_x.ts.sec, _x.ts.nsec, _x.control.value,) = _get_struct_2iI().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      pattern = '<%sd'%length
      start = end
      s = struct.Struct(pattern)
      end += s.size
      self.desired.rotor_control = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
      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_2iI = None
def _get_struct_2iI():
    global _struct_2iI
    if _struct_2iI is None:
        _struct_2iI = struct.Struct("<2iI")
    return _struct_2iI
