"""
Autogenerated python message buffer code.
Source: clad/types/robotCompletedAction.clad
Full command line: victor-clad/tools/message-buffers/emitters/Python_emitter.py -C src -I clad/src lib/util/source/anki/clad robot/clad/src coretech/vision/clad_src coretech/common/clad_src -o generated/cladPython clad/types/robotCompletedAction.clad
"""

from __future__ import absolute_import
from __future__ import print_function

def _modify_path():
  import inspect, os, sys
  search_paths = [
    '../..',
    '../../../../victor-clad/tools/message-buffers/support/python',
  ]
  currentpath = os.path.abspath(os.path.dirname(inspect.getfile(inspect.currentframe())))
  for search_path in search_paths:
    search_path = os.path.normpath(os.path.abspath(os.path.realpath(os.path.join(currentpath, search_path))))
    if search_path not in sys.path:
      sys.path.insert(0, search_path)
_modify_path()

import msgbuffers

Anki = msgbuffers.Namespace()
Anki.AudioMetaData = msgbuffers.Namespace()
Anki.AudioMetaData.GameEvent = msgbuffers.Namespace()
Anki.Vector = msgbuffers.Namespace()
Anki.Vector.ExternalInterface = msgbuffers.Namespace()

from clad.types.actionResults import Anki as _Anki
Anki.update(_Anki.deep_clone())

from clad.types.actionTypes import Anki as _Anki
Anki.update(_Anki.deep_clone())

class RobotCompletedAction(object):
  "Generated message-passing message."

  __slots__ = (
    '_idTag',            # uint_32
    '_actionType',       # Anki.Vector.RobotActionType
    '_result',           # Anki.Vector.ActionResult
    '_subActionResults', # ActionResult[uint_8]
    '_completionInfo',   # Anki.Vector.ActionCompletedUnion
  )

  @property
  def idTag(self):
    "uint_32 idTag struct property."
    return self._idTag

  @idTag.setter
  def idTag(self, value):
    self._idTag = msgbuffers.validate_integer(
      'RobotCompletedAction.idTag', value, 0, 4294967295)

  @property
  def actionType(self):
    "Anki.Vector.RobotActionType actionType struct property."
    return self._actionType

  @actionType.setter
  def actionType(self, value):
    self._actionType = msgbuffers.validate_integer(
      'RobotCompletedAction.actionType', value, -2147483648, 2147483647)

  @property
  def result(self):
    "Anki.Vector.ActionResult result struct property."
    return self._result

  @result.setter
  def result(self, value):
    self._result = msgbuffers.validate_integer(
      'RobotCompletedAction.result', value, 0, 4294967295)

  @property
  def subActionResults(self):
    "ActionResult[uint_8] subActionResults struct property."
    return self._subActionResults

  @subActionResults.setter
  def subActionResults(self, value):
    self._subActionResults = msgbuffers.validate_varray(
      'RobotCompletedAction.subActionResults', value, 255,
      lambda name, value_inner: msgbuffers.validate_integer(
        name, value_inner, 0, 4294967295))

  @property
  def completionInfo(self):
    "Anki.Vector.ActionCompletedUnion completionInfo struct property."
    return self._completionInfo

  @completionInfo.setter
  def completionInfo(self, value):
    self._completionInfo = msgbuffers.validate_object(
      'RobotCompletedAction.completionInfo', value, Anki.Vector.ActionCompletedUnion)

  def __init__(self, idTag=0, actionType=Anki.Vector.RobotActionType.COMPOUND, result=Anki.Vector.ActionResult.SUCCESS, subActionResults=(), completionInfo=Anki.Vector.ActionCompletedUnion()):
    self.idTag = idTag
    self.actionType = actionType
    self.result = result
    self.subActionResults = subActionResults
    self.completionInfo = completionInfo

  @classmethod
  def unpack(cls, buffer):
    "Reads a new RobotCompletedAction from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('RobotCompletedAction.unpack received a buffer of length {length}, ' +
        'but only {position} bytes were read.').format(
        length=len(reader), position=reader.tell()))
    return value

  @classmethod
  def unpack_from(cls, reader):
    "Reads a new RobotCompletedAction from the given BinaryReader."
    _idTag = reader.read('I')
    _actionType = reader.read('i')
    _result = reader.read('I')
    _subActionResults = reader.read_varray('I', 'B')
    _completionInfo = reader.read_object(Anki.Vector.ActionCompletedUnion.unpack_from)
    return cls(_idTag, _actionType, _result, _subActionResults, _completionInfo)

  def pack(self):
    "Writes the current RobotCompletedAction, returning bytes."
    writer = msgbuffers.BinaryWriter()
    self.pack_to(writer)
    return writer.dumps()

  def pack_to(self, writer):
    "Writes the current RobotCompletedAction to the given BinaryWriter."
    writer.write(self._idTag, 'I')
    writer.write(self._actionType, 'i')
    writer.write(self._result, 'I')
    writer.write_varray(self._subActionResults, 'I', 'B')
    writer.write_object(self._completionInfo)

  def __eq__(self, other):
    if type(self) is type(other):
      return (self._idTag == other._idTag and
        self._actionType == other._actionType and
        self._result == other._result and
        self._subActionResults == other._subActionResults and
        self._completionInfo == other._completionInfo)
    else:
      return NotImplemented

  def __ne__(self, other):
    if type(self) is type(other):
      return not self.__eq__(other)
    else:
      return NotImplemented

  def __len__(self):
    return (msgbuffers.size(self._idTag, 'I') +
      msgbuffers.size(self._actionType, 'i') +
      msgbuffers.size(self._result, 'I') +
      msgbuffers.size_varray(self._subActionResults, 'I', 'B') +
      msgbuffers.size_object(self._completionInfo))

  def __str__(self):
    return '{type}(idTag={idTag}, actionType={actionType}, result={result}, subActionResults={subActionResults}, completionInfo={completionInfo})'.format(
      type=type(self).__name__,
      idTag=self._idTag,
      actionType=self._actionType,
      result=self._result,
      subActionResults=msgbuffers.shorten_sequence(self._subActionResults),
      completionInfo=self._completionInfo)

  def __repr__(self):
    return '{type}(idTag={idTag}, actionType={actionType}, result={result}, subActionResults={subActionResults}, completionInfo={completionInfo})'.format(
      type=type(self).__name__,
      idTag=repr(self._idTag),
      actionType=repr(self._actionType),
      result=repr(self._result),
      subActionResults=repr(self._subActionResults),
      completionInfo=repr(self._completionInfo))

Anki.Vector.ExternalInterface.RobotCompletedAction = RobotCompletedAction
del RobotCompletedAction


