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

import digitaleye_msgs.msg

class Allocation(genpy.Message):
  _md5sum = "396c16c29657f2415efd418285c942e6"
  _type = "digitaleye_msgs/Allocation"
  _has_header = False  # flag to mark the presence of a Header object
  _full_text = """# Allocation in 4D

# allocation id
uint32 id

# action id, of which the allocation is part of
uint32 action_id

# allocation for the following entity id
uint64 entity_id

# 3D Volume of allocation
digitaleye_msgs/Volume volume

# start time of allocation (included) (Epoch timestamp in seconds)
uint64 start

# end time of allocation (included) (Epoch timestamp in seconds)
uint64 end

# category of allocation, use ALLOC_CAT_
uint32 assigned_category

# command on allocation entry
digitaleye_msgs/VehicleCommand[] commands

# action dependencies
uint32[] action_dep

================================================================================
MSG: digitaleye_msgs/Volume
# Volume definition

# Volume shape, use SHAPE_
uint32 shape

uint32 SHAPE_PRISM=1
uint32 SHAPE_SPHERE=2
uint32 SHAPE_CYLINDER=3

# Dimensions of volume
float64[] dimensions

# Prism: dimension is 1 + 2*PRISM_POINTS*PRISM_DIM_POINTS_SIZE
# (1 for number of points, and number of points * number of coordinates per point  * 2 for top and bottom)
# same number of points (PRISM_POINTS) for bottom and top polygon, points counter clockwise
uint32 PRISM_POINTS=0
uint32 PRISM_X=1
uint32 PRISM_Y=2
uint32 PRISM_Z=3
uint32 PRISM_DIM_POINTS_SIZE=3

# sphere: radius, centre point (x,y,z)
uint32 SPHERE_RADIUS=0
uint32 SPHERE_CENTRE_X=1
uint32 SPHERE_CENTRE_Y=2
uint32 SPHERE_CENTRE_Z=3
uint32 SPHERE_DIM_SIZE=4

# cylinder: duplicate for bottom and top: centre point (x,y,z), radius, end: spherical/flat (use END_)
uint32 CYLINDER_BOT_X=0
uint32 CYLINDER_BOT_Y=1
uint32 CYLINDER_BOT_Z=2
uint32 CYLINDER_BOT_RADIUS=3
uint32 CYLINDER_BOT_END=4
uint32 CYLINDER_TOP_X=5
uint32 CYLINDER_TOP_Y=6
uint32 CYLINDER_TOP_Z=7
uint32 CYLINDER_TOP_RADIUS=8
uint32 CYLINDER_TOP_END=9
uint32 CYLINDER_DIM_SIZE=10

# end of volume, spherical or flat
uint32 END_SPHERE=1
uint32 END_FLAT=2

================================================================================
MSG: digitaleye_msgs/VehicleCommand
# definition of vehicle commands

# The command, CMD_, see below
uint32 command

# Command
uint32 CMD_GOTO=0
uint32 CMD_TAKEOFF=1
uint32 CMD_LAND=2
uint32 CMD_STOP=3
uint32 CMD_CHANGE_YAW=4
uint32 CMD_CHANGE_SPEED=5
uint32 CMD_JUMP_CMD=6

# Parameters of the command
uint32 delay # delay of the command in second, mostly useful for missions
uint32[] int_param
float64[] float_param

## GOTO: Frame, use FRAME_; yaw angle in degrees, see specified frame;
## x, y, z see specified frame; ground speed m/s
# GOTO int parameters
uint32 GOTO_INT_FRAME=0
uint32 GOTO_INT_YAW=1
# GOTO float parameters
float64 GOTO_FLOAT_X=0
float64 GOTO_FLOAT_Y=1
float64 GOTO_FLOAT_Z=2
float64 GOTO_FLOAT_SPEED=3

## TAKEOFF: Frame, use FRAME_; yaw angle in degrees, see specified frame;
## z see specified frame; vertical speed m/s
# TAKEOFF int parameters
uint32 TAKEOFF_INT_FRAME=0
uint32 TAKEOFF_INT_YAW=1
# TAKEOFF float parameters
float64 TAKEOFF_FLOAT_Z=0
float64 TAKEOFF_FLOAT_SPEED=1

## LAND: no parameters

## STOP: no parameters

## CHANGE_YAW: Frame, use YAW_FRAME_; yaw angle in degrees, see specified frame; speed deg/s
# CHANGE_YAW int parameters
uint32 CHANGE_YAW_INT_FRAME=0
uint32 CHANGE_YAW_INT_YAW=1
uint32 CHANGE_YAW_INT_SPEED=2

## CHANGE_SPEED: ground speed in m/s
# TAKEOFF float parameters
float64 CHANGE_SPEED_FLOAT_Z=0

## JUMP_CMD: Command number to jump to; repeat giving the number of repeats
# JUMP_CMD int parameters
uint32 JUMP_CMD_INT_CMD_NB=0
uint32 JUMP_CMD_INT_REPEAT=1

## FRAME:
uint32 FRAME_PORTAL = 0 # Portal coordinate frame, coordinates in m, absolute yaw (-1 to not specify)
uint32 FRAME_GLOBAL = 1 # WGS84 coordinate frame (deg) + MSL altitude (m), absolute yaw (-1 to not specify)
uint32 FRAME_FRD = 2 # FRD local frame, x: Forward, y: Right, z: Down (m), relative yaw

"""
  __slots__ = ['id','action_id','entity_id','volume','start','end','assigned_category','commands','action_dep']
  _slot_types = ['uint32','uint32','uint64','digitaleye_msgs/Volume','uint64','uint64','uint32','digitaleye_msgs/VehicleCommand[]','uint32[]']

  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:
       id,action_id,entity_id,volume,start,end,assigned_category,commands,action_dep

    :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(Allocation, self).__init__(*args, **kwds)
      # message fields cannot be None, assign default values for those that are
      if self.id is None:
        self.id = 0
      if self.action_id is None:
        self.action_id = 0
      if self.entity_id is None:
        self.entity_id = 0
      if self.volume is None:
        self.volume = digitaleye_msgs.msg.Volume()
      if self.start is None:
        self.start = 0
      if self.end is None:
        self.end = 0
      if self.assigned_category is None:
        self.assigned_category = 0
      if self.commands is None:
        self.commands = []
      if self.action_dep is None:
        self.action_dep = []
    else:
      self.id = 0
      self.action_id = 0
      self.entity_id = 0
      self.volume = digitaleye_msgs.msg.Volume()
      self.start = 0
      self.end = 0
      self.assigned_category = 0
      self.commands = []
      self.action_dep = []

  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_2IQI().pack(_x.id, _x.action_id, _x.entity_id, _x.volume.shape))
      length = len(self.volume.dimensions)
      buff.write(_struct_I.pack(length))
      pattern = '<%sd'%length
      buff.write(struct.Struct(pattern).pack(*self.volume.dimensions))
      _x = self
      buff.write(_get_struct_2QI().pack(_x.start, _x.end, _x.assigned_category))
      length = len(self.commands)
      buff.write(_struct_I.pack(length))
      for val1 in self.commands:
        _x = val1
        buff.write(_get_struct_2I().pack(_x.command, _x.delay))
        length = len(val1.int_param)
        buff.write(_struct_I.pack(length))
        pattern = '<%sI'%length
        buff.write(struct.Struct(pattern).pack(*val1.int_param))
        length = len(val1.float_param)
        buff.write(_struct_I.pack(length))
        pattern = '<%sd'%length
        buff.write(struct.Struct(pattern).pack(*val1.float_param))
      length = len(self.action_dep)
      buff.write(_struct_I.pack(length))
      pattern = '<%sI'%length
      buff.write(struct.Struct(pattern).pack(*self.action_dep))
    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.volume is None:
        self.volume = digitaleye_msgs.msg.Volume()
      if self.commands is None:
        self.commands = None
      end = 0
      _x = self
      start = end
      end += 20
      (_x.id, _x.action_id, _x.entity_id, _x.volume.shape,) = _get_struct_2IQI().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.volume.dimensions = s.unpack(str[start:end])
      _x = self
      start = end
      end += 20
      (_x.start, _x.end, _x.assigned_category,) = _get_struct_2QI().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.commands = []
      for i in range(0, length):
        val1 = digitaleye_msgs.msg.VehicleCommand()
        _x = val1
        start = end
        end += 8
        (_x.command, _x.delay,) = _get_struct_2I().unpack(str[start:end])
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        pattern = '<%sI'%length
        start = end
        s = struct.Struct(pattern)
        end += s.size
        val1.int_param = s.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
        val1.float_param = s.unpack(str[start:end])
        self.commands.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      pattern = '<%sI'%length
      start = end
      s = struct.Struct(pattern)
      end += s.size
      self.action_dep = 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_2IQI().pack(_x.id, _x.action_id, _x.entity_id, _x.volume.shape))
      length = len(self.volume.dimensions)
      buff.write(_struct_I.pack(length))
      pattern = '<%sd'%length
      buff.write(self.volume.dimensions.tostring())
      _x = self
      buff.write(_get_struct_2QI().pack(_x.start, _x.end, _x.assigned_category))
      length = len(self.commands)
      buff.write(_struct_I.pack(length))
      for val1 in self.commands:
        _x = val1
        buff.write(_get_struct_2I().pack(_x.command, _x.delay))
        length = len(val1.int_param)
        buff.write(_struct_I.pack(length))
        pattern = '<%sI'%length
        buff.write(val1.int_param.tostring())
        length = len(val1.float_param)
        buff.write(_struct_I.pack(length))
        pattern = '<%sd'%length
        buff.write(val1.float_param.tostring())
      length = len(self.action_dep)
      buff.write(_struct_I.pack(length))
      pattern = '<%sI'%length
      buff.write(self.action_dep.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.volume is None:
        self.volume = digitaleye_msgs.msg.Volume()
      if self.commands is None:
        self.commands = None
      end = 0
      _x = self
      start = end
      end += 20
      (_x.id, _x.action_id, _x.entity_id, _x.volume.shape,) = _get_struct_2IQI().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.volume.dimensions = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
      _x = self
      start = end
      end += 20
      (_x.start, _x.end, _x.assigned_category,) = _get_struct_2QI().unpack(str[start:end])
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      self.commands = []
      for i in range(0, length):
        val1 = digitaleye_msgs.msg.VehicleCommand()
        _x = val1
        start = end
        end += 8
        (_x.command, _x.delay,) = _get_struct_2I().unpack(str[start:end])
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        pattern = '<%sI'%length
        start = end
        s = struct.Struct(pattern)
        end += s.size
        val1.int_param = numpy.frombuffer(str[start:end], dtype=numpy.uint32, count=length)
        start = end
        end += 4
        (length,) = _struct_I.unpack(str[start:end])
        pattern = '<%sd'%length
        start = end
        s = struct.Struct(pattern)
        end += s.size
        val1.float_param = numpy.frombuffer(str[start:end], dtype=numpy.float64, count=length)
        self.commands.append(val1)
      start = end
      end += 4
      (length,) = _struct_I.unpack(str[start:end])
      pattern = '<%sI'%length
      start = end
      s = struct.Struct(pattern)
      end += s.size
      self.action_dep = numpy.frombuffer(str[start:end], dtype=numpy.uint32, 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_2I = None
def _get_struct_2I():
    global _struct_2I
    if _struct_2I is None:
        _struct_2I = struct.Struct("<2I")
    return _struct_2I
_struct_2IQI = None
def _get_struct_2IQI():
    global _struct_2IQI
    if _struct_2IQI is None:
        _struct_2IQI = struct.Struct("<2IQI")
    return _struct_2IQI
_struct_2QI = None
def _get_struct_2QI():
    global _struct_2QI
    if _struct_2QI is None:
        _struct_2QI = struct.Struct("<2QI")
    return _struct_2QI
