# Copyright (c) 2016-2017 Anki, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License in the file LICENSE.txt or at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

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

from __future__ import absolute_import
from __future__ import print_function

def _modify_path():
  import inspect, os, sys
  search_paths = [
    '../..',
    '../../../../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.Cozmo = msgbuffers.Namespace()

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

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

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

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

class BehaviorStageTag(object):
  "Automatically-generated uint_8 enumeration."
  Feeding             = 0
  GuardDog            = 1
  PyramidConstruction = 2
  Workout             = 3
  Count               = 4

Anki.Cozmo.BehaviorStageTag = BehaviorStageTag
del BehaviorStageTag


class BehaviorStageStruct(object):
  "Generated message-passing structure."

  __slots__ = (
    '_behaviorStageTag',                # Anki.Cozmo.BehaviorStageTag
    '_currentFeedingStage',             # Anki.Cozmo.FeedingStage
    '_currentGuardDogStage',            # Anki.Cozmo.GuardDogStage
    '_currentPyramidConstructionStage', # Anki.Cozmo.PyramidConstructionStage
    '_currentWorkoutStage',             # Anki.Cozmo.WorkoutStage
  )

  @property
  def behaviorStageTag(self):
    "Anki.Cozmo.BehaviorStageTag behaviorStageTag struct property."
    return self._behaviorStageTag

  @behaviorStageTag.setter
  def behaviorStageTag(self, value):
    self._behaviorStageTag = msgbuffers.validate_integer(
      'BehaviorStageStruct.behaviorStageTag', value, 0, 255)

  @property
  def currentFeedingStage(self):
    "Anki.Cozmo.FeedingStage currentFeedingStage struct property."
    return self._currentFeedingStage

  @currentFeedingStage.setter
  def currentFeedingStage(self, value):
    self._currentFeedingStage = msgbuffers.validate_integer(
      'BehaviorStageStruct.currentFeedingStage', value, 0, 255)

  @property
  def currentGuardDogStage(self):
    "Anki.Cozmo.GuardDogStage currentGuardDogStage struct property."
    return self._currentGuardDogStage

  @currentGuardDogStage.setter
  def currentGuardDogStage(self, value):
    self._currentGuardDogStage = msgbuffers.validate_integer(
      'BehaviorStageStruct.currentGuardDogStage', value, 0, 255)

  @property
  def currentPyramidConstructionStage(self):
    "Anki.Cozmo.PyramidConstructionStage currentPyramidConstructionStage struct property."
    return self._currentPyramidConstructionStage

  @currentPyramidConstructionStage.setter
  def currentPyramidConstructionStage(self, value):
    self._currentPyramidConstructionStage = msgbuffers.validate_integer(
      'BehaviorStageStruct.currentPyramidConstructionStage', value, 0, 255)

  @property
  def currentWorkoutStage(self):
    "Anki.Cozmo.WorkoutStage currentWorkoutStage struct property."
    return self._currentWorkoutStage

  @currentWorkoutStage.setter
  def currentWorkoutStage(self, value):
    self._currentWorkoutStage = msgbuffers.validate_integer(
      'BehaviorStageStruct.currentWorkoutStage', value, 0, 255)

  def __init__(self, behaviorStageTag=Anki.Cozmo.BehaviorStageTag.Feeding, currentFeedingStage=Anki.Cozmo.FeedingStage.MildEnergy, currentGuardDogStage=Anki.Cozmo.GuardDogStage.Sleeping, currentPyramidConstructionStage=Anki.Cozmo.PyramidConstructionStage.NoneStage, currentWorkoutStage=Anki.Cozmo.WorkoutStage.NormalWorkout):
    self.behaviorStageTag = behaviorStageTag
    self.currentFeedingStage = currentFeedingStage
    self.currentGuardDogStage = currentGuardDogStage
    self.currentPyramidConstructionStage = currentPyramidConstructionStage
    self.currentWorkoutStage = currentWorkoutStage

  @classmethod
  def unpack(cls, buffer):
    "Reads a new BehaviorStageStruct from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('BehaviorStageStruct.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 BehaviorStageStruct from the given BinaryReader."
    _behaviorStageTag = reader.read('B')
    _currentFeedingStage = reader.read('B')
    _currentGuardDogStage = reader.read('B')
    _currentPyramidConstructionStage = reader.read('B')
    _currentWorkoutStage = reader.read('B')
    return cls(_behaviorStageTag, _currentFeedingStage, _currentGuardDogStage, _currentPyramidConstructionStage, _currentWorkoutStage)

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

  def pack_to(self, writer):
    "Writes the current BehaviorStageStruct to the given BinaryWriter."
    writer.write(self._behaviorStageTag, 'B')
    writer.write(self._currentFeedingStage, 'B')
    writer.write(self._currentGuardDogStage, 'B')
    writer.write(self._currentPyramidConstructionStage, 'B')
    writer.write(self._currentWorkoutStage, 'B')

  def __eq__(self, other):
    if type(self) is type(other):
      return (self._behaviorStageTag == other._behaviorStageTag and
        self._currentFeedingStage == other._currentFeedingStage and
        self._currentGuardDogStage == other._currentGuardDogStage and
        self._currentPyramidConstructionStage == other._currentPyramidConstructionStage and
        self._currentWorkoutStage == other._currentWorkoutStage)
    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._behaviorStageTag, 'B') +
      msgbuffers.size(self._currentFeedingStage, 'B') +
      msgbuffers.size(self._currentGuardDogStage, 'B') +
      msgbuffers.size(self._currentPyramidConstructionStage, 'B') +
      msgbuffers.size(self._currentWorkoutStage, 'B'))

  def __str__(self):
    return '{type}(behaviorStageTag={behaviorStageTag}, currentFeedingStage={currentFeedingStage}, currentGuardDogStage={currentGuardDogStage}, currentPyramidConstructionStage={currentPyramidConstructionStage}, currentWorkoutStage={currentWorkoutStage})'.format(
      type=type(self).__name__,
      behaviorStageTag=self._behaviorStageTag,
      currentFeedingStage=self._currentFeedingStage,
      currentGuardDogStage=self._currentGuardDogStage,
      currentPyramidConstructionStage=self._currentPyramidConstructionStage,
      currentWorkoutStage=self._currentWorkoutStage)

  def __repr__(self):
    return '{type}(behaviorStageTag={behaviorStageTag}, currentFeedingStage={currentFeedingStage}, currentGuardDogStage={currentGuardDogStage}, currentPyramidConstructionStage={currentPyramidConstructionStage}, currentWorkoutStage={currentWorkoutStage})'.format(
      type=type(self).__name__,
      behaviorStageTag=repr(self._behaviorStageTag),
      currentFeedingStage=repr(self._currentFeedingStage),
      currentGuardDogStage=repr(self._currentGuardDogStage),
      currentPyramidConstructionStage=repr(self._currentPyramidConstructionStage),
      currentWorkoutStage=repr(self._currentWorkoutStage))

Anki.Cozmo.BehaviorStageStruct = BehaviorStageStruct
del BehaviorStageStruct


class NeedsLevels(object):
  "Generated message-passing structure."

  __slots__ = (
    '_energy', # float_32
    '_repair', # float_32
    '_play',   # float_32
  )

  @property
  def energy(self):
    "float_32 energy struct property."
    return self._energy

  @energy.setter
  def energy(self, value):
    self._energy = msgbuffers.validate_float(
      'NeedsLevels.energy', value, 'f')

  @property
  def repair(self):
    "float_32 repair struct property."
    return self._repair

  @repair.setter
  def repair(self, value):
    self._repair = msgbuffers.validate_float(
      'NeedsLevels.repair', value, 'f')

  @property
  def play(self):
    "float_32 play struct property."
    return self._play

  @play.setter
  def play(self, value):
    self._play = msgbuffers.validate_float(
      'NeedsLevels.play', value, 'f')

  def __init__(self, energy=0.0, repair=0.0, play=0.0):
    self.energy = energy
    self.repair = repair
    self.play = play

  @classmethod
  def unpack(cls, buffer):
    "Reads a new NeedsLevels from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('NeedsLevels.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 NeedsLevels from the given BinaryReader."
    _energy = reader.read('f')
    _repair = reader.read('f')
    _play = reader.read('f')
    return cls(_energy, _repair, _play)

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

  def pack_to(self, writer):
    "Writes the current NeedsLevels to the given BinaryWriter."
    writer.write(self._energy, 'f')
    writer.write(self._repair, 'f')
    writer.write(self._play, 'f')

  def __eq__(self, other):
    if type(self) is type(other):
      return (self._energy == other._energy and
        self._repair == other._repair and
        self._play == other._play)
    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._energy, 'f') +
      msgbuffers.size(self._repair, 'f') +
      msgbuffers.size(self._play, 'f'))

  def __str__(self):
    return '{type}(energy={energy}, repair={repair}, play={play})'.format(
      type=type(self).__name__,
      energy=self._energy,
      repair=self._repair,
      play=self._play)

  def __repr__(self):
    return '{type}(energy={energy}, repair={repair}, play={play})'.format(
      type=type(self).__name__,
      energy=repr(self._energy),
      repair=repr(self._repair),
      play=repr(self._play))

Anki.Cozmo.NeedsLevels = NeedsLevels
del NeedsLevels


class RobotPublicState(object):
  "Generated message-passing structure."

  __slots__ = (
    '_currentSpark',                  # Anki.Cozmo.UnlockId
    '_isCubeInLift',                  # bool
    '_isRequestingGame',              # bool
    '_tallestStackHeight',            # uint_8
    '_needsLevels',                   # Anki.Cozmo.NeedsLevels
    '_currentActivity',               # Anki.Cozmo.ActivityID
    '_currentReactionTrigger',        # Anki.Cozmo.ReactionTrigger
    '_userFacingBehaviorStageStruct', # Anki.Cozmo.BehaviorStageStruct
  )

  @property
  def currentSpark(self):
    "Anki.Cozmo.UnlockId currentSpark struct property."
    return self._currentSpark

  @currentSpark.setter
  def currentSpark(self, value):
    self._currentSpark = msgbuffers.validate_integer(
      'RobotPublicState.currentSpark', value, -2147483648, 2147483647)

  @property
  def isCubeInLift(self):
    "bool isCubeInLift struct property."
    return self._isCubeInLift

  @isCubeInLift.setter
  def isCubeInLift(self, value):
    self._isCubeInLift = msgbuffers.validate_bool(
      'RobotPublicState.isCubeInLift', value)

  @property
  def isRequestingGame(self):
    "bool isRequestingGame struct property."
    return self._isRequestingGame

  @isRequestingGame.setter
  def isRequestingGame(self, value):
    self._isRequestingGame = msgbuffers.validate_bool(
      'RobotPublicState.isRequestingGame', value)

  @property
  def tallestStackHeight(self):
    "uint_8 tallestStackHeight struct property."
    return self._tallestStackHeight

  @tallestStackHeight.setter
  def tallestStackHeight(self, value):
    self._tallestStackHeight = msgbuffers.validate_integer(
      'RobotPublicState.tallestStackHeight', value, 0, 255)

  @property
  def needsLevels(self):
    "Anki.Cozmo.NeedsLevels needsLevels struct property."
    return self._needsLevels

  @needsLevels.setter
  def needsLevels(self, value):
    self._needsLevels = msgbuffers.validate_object(
      'RobotPublicState.needsLevels', value, Anki.Cozmo.NeedsLevels)

  @property
  def currentActivity(self):
    "Anki.Cozmo.ActivityID currentActivity struct property."
    return self._currentActivity

  @currentActivity.setter
  def currentActivity(self, value):
    self._currentActivity = msgbuffers.validate_integer(
      'RobotPublicState.currentActivity', value, 0, 255)

  @property
  def currentReactionTrigger(self):
    "Anki.Cozmo.ReactionTrigger currentReactionTrigger struct property."
    return self._currentReactionTrigger

  @currentReactionTrigger.setter
  def currentReactionTrigger(self, value):
    self._currentReactionTrigger = msgbuffers.validate_integer(
      'RobotPublicState.currentReactionTrigger', value, 0, 255)

  @property
  def userFacingBehaviorStageStruct(self):
    "Anki.Cozmo.BehaviorStageStruct userFacingBehaviorStageStruct struct property."
    return self._userFacingBehaviorStageStruct

  @userFacingBehaviorStageStruct.setter
  def userFacingBehaviorStageStruct(self, value):
    self._userFacingBehaviorStageStruct = msgbuffers.validate_object(
      'RobotPublicState.userFacingBehaviorStageStruct', value, Anki.Cozmo.BehaviorStageStruct)

  def __init__(self, currentSpark, isCubeInLift, isRequestingGame, tallestStackHeight, needsLevels, currentActivity, currentReactionTrigger, userFacingBehaviorStageStruct):
    self.currentSpark = currentSpark
    self.isCubeInLift = isCubeInLift
    self.isRequestingGame = isRequestingGame
    self.tallestStackHeight = tallestStackHeight
    self.needsLevels = needsLevels
    self.currentActivity = currentActivity
    self.currentReactionTrigger = currentReactionTrigger
    self.userFacingBehaviorStageStruct = userFacingBehaviorStageStruct

  @classmethod
  def unpack(cls, buffer):
    "Reads a new RobotPublicState from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('RobotPublicState.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 RobotPublicState from the given BinaryReader."
    _currentSpark = reader.read('i')
    _isCubeInLift = bool(reader.read('b'))
    _isRequestingGame = bool(reader.read('b'))
    _tallestStackHeight = reader.read('B')
    _needsLevels = reader.read_object(Anki.Cozmo.NeedsLevels.unpack_from)
    _currentActivity = reader.read('B')
    _currentReactionTrigger = reader.read('B')
    _userFacingBehaviorStageStruct = reader.read_object(Anki.Cozmo.BehaviorStageStruct.unpack_from)
    return cls(_currentSpark, _isCubeInLift, _isRequestingGame, _tallestStackHeight, _needsLevels, _currentActivity, _currentReactionTrigger, _userFacingBehaviorStageStruct)

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

  def pack_to(self, writer):
    "Writes the current RobotPublicState to the given BinaryWriter."
    writer.write(self._currentSpark, 'i')
    writer.write(int(self._isCubeInLift), 'b')
    writer.write(int(self._isRequestingGame), 'b')
    writer.write(self._tallestStackHeight, 'B')
    writer.write_object(self._needsLevels)
    writer.write(self._currentActivity, 'B')
    writer.write(self._currentReactionTrigger, 'B')
    writer.write_object(self._userFacingBehaviorStageStruct)

  def __eq__(self, other):
    if type(self) is type(other):
      return (self._currentSpark == other._currentSpark and
        self._isCubeInLift == other._isCubeInLift and
        self._isRequestingGame == other._isRequestingGame and
        self._tallestStackHeight == other._tallestStackHeight and
        self._needsLevels == other._needsLevels and
        self._currentActivity == other._currentActivity and
        self._currentReactionTrigger == other._currentReactionTrigger and
        self._userFacingBehaviorStageStruct == other._userFacingBehaviorStageStruct)
    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._currentSpark, 'i') +
      msgbuffers.size(self._isCubeInLift, 'b') +
      msgbuffers.size(self._isRequestingGame, 'b') +
      msgbuffers.size(self._tallestStackHeight, 'B') +
      msgbuffers.size_object(self._needsLevels) +
      msgbuffers.size(self._currentActivity, 'B') +
      msgbuffers.size(self._currentReactionTrigger, 'B') +
      msgbuffers.size_object(self._userFacingBehaviorStageStruct))

  def __str__(self):
    return '{type}(currentSpark={currentSpark}, isCubeInLift={isCubeInLift}, isRequestingGame={isRequestingGame}, tallestStackHeight={tallestStackHeight}, needsLevels={needsLevels}, currentActivity={currentActivity}, currentReactionTrigger={currentReactionTrigger}, userFacingBehaviorStageStruct={userFacingBehaviorStageStruct})'.format(
      type=type(self).__name__,
      currentSpark=self._currentSpark,
      isCubeInLift=self._isCubeInLift,
      isRequestingGame=self._isRequestingGame,
      tallestStackHeight=self._tallestStackHeight,
      needsLevels=self._needsLevels,
      currentActivity=self._currentActivity,
      currentReactionTrigger=self._currentReactionTrigger,
      userFacingBehaviorStageStruct=self._userFacingBehaviorStageStruct)

  def __repr__(self):
    return '{type}(currentSpark={currentSpark}, isCubeInLift={isCubeInLift}, isRequestingGame={isRequestingGame}, tallestStackHeight={tallestStackHeight}, needsLevels={needsLevels}, currentActivity={currentActivity}, currentReactionTrigger={currentReactionTrigger}, userFacingBehaviorStageStruct={userFacingBehaviorStageStruct})'.format(
      type=type(self).__name__,
      currentSpark=repr(self._currentSpark),
      isCubeInLift=repr(self._isCubeInLift),
      isRequestingGame=repr(self._isRequestingGame),
      tallestStackHeight=repr(self._tallestStackHeight),
      needsLevels=repr(self._needsLevels),
      currentActivity=repr(self._currentActivity),
      currentReactionTrigger=repr(self._currentReactionTrigger),
      userFacingBehaviorStageStruct=repr(self._userFacingBehaviorStageStruct))

Anki.Cozmo.RobotPublicState = RobotPublicState
del RobotPublicState


