"""
Autogenerated python message buffer code.
Source: clad/types/offboardVision.clad
Full command line: victor-clad/tools/message-buffers/emitters/Python_emitter.py -I coretech/vision/clad_src coretech/common/clad_src -o generated/cladPython clad/types/offboardVision.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.Vision = msgbuffers.Namespace()

class OffboardCommsType(object):
  "Automatically-generated uint_8 enumeration."
  FileIO = 0
  CLAD   = 1

Anki.Vision.OffboardCommsType = OffboardCommsType
del OffboardCommsType


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

  __slots__ = (
    '_timestamp',    # uint_32
    '_numRows',      # uint_32
    '_numCols',      # uint_32
    '_numChannels',  # uint_32
    '_isCompressed', # bool
    '_isEncrypted',  # bool
    '_procTypes',    # string[uint_8][uint_8]
    '_filename',     # string[uint_8]
  )

  @property
  def timestamp(self):
    "uint_32 timestamp struct property."
    return self._timestamp

  @timestamp.setter
  def timestamp(self, value):
    self._timestamp = msgbuffers.validate_integer(
      'OffboardImageReady.timestamp', value, 0, 4294967295)

  @property
  def numRows(self):
    "uint_32 numRows struct property."
    return self._numRows

  @numRows.setter
  def numRows(self, value):
    self._numRows = msgbuffers.validate_integer(
      'OffboardImageReady.numRows', value, 0, 4294967295)

  @property
  def numCols(self):
    "uint_32 numCols struct property."
    return self._numCols

  @numCols.setter
  def numCols(self, value):
    self._numCols = msgbuffers.validate_integer(
      'OffboardImageReady.numCols', value, 0, 4294967295)

  @property
  def numChannels(self):
    "uint_32 numChannels struct property."
    return self._numChannels

  @numChannels.setter
  def numChannels(self, value):
    self._numChannels = msgbuffers.validate_integer(
      'OffboardImageReady.numChannels', value, 0, 4294967295)

  @property
  def isCompressed(self):
    "bool isCompressed struct property."
    return self._isCompressed

  @isCompressed.setter
  def isCompressed(self, value):
    self._isCompressed = msgbuffers.validate_bool(
      'OffboardImageReady.isCompressed', value)

  @property
  def isEncrypted(self):
    "bool isEncrypted struct property."
    return self._isEncrypted

  @isEncrypted.setter
  def isEncrypted(self, value):
    self._isEncrypted = msgbuffers.validate_bool(
      'OffboardImageReady.isEncrypted', value)

  @property
  def procTypes(self):
    "string[uint_8][uint_8] procTypes struct property."
    return self._procTypes

  @procTypes.setter
  def procTypes(self, value):
    self._procTypes = msgbuffers.validate_varray(
      'OffboardImageReady.procTypes', value, 255,
      lambda name, value_inner: msgbuffers.validate_string(
        name, value_inner, 255))

  @property
  def filename(self):
    "string[uint_8] filename struct property."
    return self._filename

  @filename.setter
  def filename(self, value):
    self._filename = msgbuffers.validate_string(
      'OffboardImageReady.filename', value, 255)

  def __init__(self, timestamp=0, numRows=0, numCols=0, numChannels=0, isCompressed=True, isEncrypted=False, procTypes=(), filename=''):
    self.timestamp = timestamp
    self.numRows = numRows
    self.numCols = numCols
    self.numChannels = numChannels
    self.isCompressed = isCompressed
    self.isEncrypted = isEncrypted
    self.procTypes = procTypes
    self.filename = filename

  @classmethod
  def unpack(cls, buffer):
    "Reads a new OffboardImageReady from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('OffboardImageReady.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 OffboardImageReady from the given BinaryReader."
    _timestamp = reader.read('I')
    _numRows = reader.read('I')
    _numCols = reader.read('I')
    _numChannels = reader.read('I')
    _isCompressed = bool(reader.read('b'))
    _isEncrypted = bool(reader.read('b'))
    _procTypes = reader.read_string_varray('B', 'B')
    _filename = reader.read_string('B')
    return cls(_timestamp, _numRows, _numCols, _numChannels, _isCompressed, _isEncrypted, _procTypes, _filename)

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

  def pack_to(self, writer):
    "Writes the current OffboardImageReady to the given BinaryWriter."
    writer.write(self._timestamp, 'I')
    writer.write(self._numRows, 'I')
    writer.write(self._numCols, 'I')
    writer.write(self._numChannels, 'I')
    writer.write(int(self._isCompressed), 'b')
    writer.write(int(self._isEncrypted), 'b')
    writer.write_string_varray(self._procTypes, 'B', 'B')
    writer.write_string(self._filename, 'B')

  def __eq__(self, other):
    if type(self) is type(other):
      return (self._timestamp == other._timestamp and
        self._numRows == other._numRows and
        self._numCols == other._numCols and
        self._numChannels == other._numChannels and
        self._isCompressed == other._isCompressed and
        self._isEncrypted == other._isEncrypted and
        self._procTypes == other._procTypes and
        self._filename == other._filename)
    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._timestamp, 'I') +
      msgbuffers.size(self._numRows, 'I') +
      msgbuffers.size(self._numCols, 'I') +
      msgbuffers.size(self._numChannels, 'I') +
      msgbuffers.size(self._isCompressed, 'b') +
      msgbuffers.size(self._isEncrypted, 'b') +
      msgbuffers.size_string_varray(self._procTypes, 'B', 'B') +
      msgbuffers.size_string(self._filename, 'B'))

  def __str__(self):
    return '{type}(timestamp={timestamp}, numRows={numRows}, numCols={numCols}, numChannels={numChannels}, isCompressed={isCompressed}, isEncrypted={isEncrypted}, procTypes={procTypes}, filename={filename})'.format(
      type=type(self).__name__,
      timestamp=self._timestamp,
      numRows=self._numRows,
      numCols=self._numCols,
      numChannels=self._numChannels,
      isCompressed=self._isCompressed,
      isEncrypted=self._isEncrypted,
      procTypes=msgbuffers.shorten_sequence(self._procTypes, msgbuffers.shorten_string),
      filename=msgbuffers.shorten_string(self._filename))

  def __repr__(self):
    return '{type}(timestamp={timestamp}, numRows={numRows}, numCols={numCols}, numChannels={numChannels}, isCompressed={isCompressed}, isEncrypted={isEncrypted}, procTypes={procTypes}, filename={filename})'.format(
      type=type(self).__name__,
      timestamp=repr(self._timestamp),
      numRows=repr(self._numRows),
      numCols=repr(self._numCols),
      numChannels=repr(self._numChannels),
      isCompressed=repr(self._isCompressed),
      isEncrypted=repr(self._isEncrypted),
      procTypes=repr(self._procTypes),
      filename=repr(self._filename))

Anki.Vision.OffboardImageReady = OffboardImageReady
del OffboardImageReady


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

  __slots__ = (
    '_timestamp',  # uint_32
    '_jsonResult', # string[uint_16]
  )

  @property
  def timestamp(self):
    "uint_32 timestamp struct property."
    return self._timestamp

  @timestamp.setter
  def timestamp(self, value):
    self._timestamp = msgbuffers.validate_integer(
      'OffboardResultReady.timestamp', value, 0, 4294967295)

  @property
  def jsonResult(self):
    "string[uint_16] jsonResult struct property."
    return self._jsonResult

  @jsonResult.setter
  def jsonResult(self, value):
    self._jsonResult = msgbuffers.validate_string(
      'OffboardResultReady.jsonResult', value, 65535)

  def __init__(self, timestamp=0, jsonResult=''):
    self.timestamp = timestamp
    self.jsonResult = jsonResult

  @classmethod
  def unpack(cls, buffer):
    "Reads a new OffboardResultReady from the given buffer."
    reader = msgbuffers.BinaryReader(buffer)
    value = cls.unpack_from(reader)
    if reader.tell() != len(reader):
      raise msgbuffers.ReadError(
        ('OffboardResultReady.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 OffboardResultReady from the given BinaryReader."
    _timestamp = reader.read('I')
    _jsonResult = reader.read_string('H')
    return cls(_timestamp, _jsonResult)

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

  def pack_to(self, writer):
    "Writes the current OffboardResultReady to the given BinaryWriter."
    writer.write(self._timestamp, 'I')
    writer.write_string(self._jsonResult, 'H')

  def __eq__(self, other):
    if type(self) is type(other):
      return (self._timestamp == other._timestamp and
        self._jsonResult == other._jsonResult)
    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._timestamp, 'I') +
      msgbuffers.size_string(self._jsonResult, 'H'))

  def __str__(self):
    return '{type}(timestamp={timestamp}, jsonResult={jsonResult})'.format(
      type=type(self).__name__,
      timestamp=self._timestamp,
      jsonResult=msgbuffers.shorten_string(self._jsonResult))

  def __repr__(self):
    return '{type}(timestamp={timestamp}, jsonResult={jsonResult})'.format(
      type=type(self).__name__,
      timestamp=repr(self._timestamp),
      jsonResult=repr(self._jsonResult))

Anki.Vision.OffboardResultReady = OffboardResultReady
del OffboardResultReady


