# SPDX-License-Identifier: BSD-3-Clause
#
# Copyright 2020 Raritan Inc. All rights reserved.
#
# This is an auto-generated file.

#
# Section generated by IdlC from "Webcam.idl"
#

import raritan.rpc
from raritan.rpc import Interface, Structure, ValueObject, Enumeration, typecheck, DecodeException
import raritan.rpc.event

import raritan.rpc.webcam


# enumeration
class PixelFormat(Enumeration):
    idlType = "webcam.PixelFormat:1.0.0"
    values = ["MJPEG", "JPEG", "RGB", "YUV"]

PixelFormat.MJPEG = PixelFormat(0)
PixelFormat.JPEG = PixelFormat(1)
PixelFormat.RGB = PixelFormat(2)
PixelFormat.YUV = PixelFormat(3)

# enumeration
class PowerLineFrequency(Enumeration):
    idlType = "webcam.PowerLineFrequency:1.0.0"
    values = ["NOT_SUPPORTED", "HZ50", "HZ60", "DISABLED"]

PowerLineFrequency.NOT_SUPPORTED = PowerLineFrequency(0)
PowerLineFrequency.HZ50 = PowerLineFrequency(1)
PowerLineFrequency.HZ60 = PowerLineFrequency(2)
PowerLineFrequency.DISABLED = PowerLineFrequency(3)

# structure
class Format(Structure):
    idlType = "webcam.Format:2.0.0"
    elements = ["width", "height", "pixelFormat"]

    def __init__(self, width, height, pixelFormat):
        typecheck.is_int(width, AssertionError)
        typecheck.is_int(height, AssertionError)
        typecheck.is_enum(pixelFormat, raritan.rpc.webcam.PixelFormat, AssertionError)

        self.width = width
        self.height = height
        self.pixelFormat = pixelFormat

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            width = json['width'],
            height = json['height'],
            pixelFormat = raritan.rpc.webcam.PixelFormat.decode(json['pixelFormat']),
        )
        return obj

    def encode(self):
        json = {}
        json['width'] = self.width
        json['height'] = self.height
        json['pixelFormat'] = raritan.rpc.webcam.PixelFormat.encode(self.pixelFormat)
        return json

# structure
class Controls(Structure):
    idlType = "webcam.Controls:1.0.0"
    elements = ["brightness", "contrast", "saturation", "gain", "gamma", "powerLineFrequency"]

    def __init__(self, brightness, contrast, saturation, gain, gamma, powerLineFrequency):
        typecheck.is_int(brightness, AssertionError)
        typecheck.is_int(contrast, AssertionError)
        typecheck.is_int(saturation, AssertionError)
        typecheck.is_int(gain, AssertionError)
        typecheck.is_int(gamma, AssertionError)
        typecheck.is_enum(powerLineFrequency, raritan.rpc.webcam.PowerLineFrequency, AssertionError)

        self.brightness = brightness
        self.contrast = contrast
        self.saturation = saturation
        self.gain = gain
        self.gamma = gamma
        self.powerLineFrequency = powerLineFrequency

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            brightness = json['brightness'],
            contrast = json['contrast'],
            saturation = json['saturation'],
            gain = json['gain'],
            gamma = json['gamma'],
            powerLineFrequency = raritan.rpc.webcam.PowerLineFrequency.decode(json['powerLineFrequency']),
        )
        return obj

    def encode(self):
        json = {}
        json['brightness'] = self.brightness
        json['contrast'] = self.contrast
        json['saturation'] = self.saturation
        json['gain'] = self.gain
        json['gamma'] = self.gamma
        json['powerLineFrequency'] = raritan.rpc.webcam.PowerLineFrequency.encode(self.powerLineFrequency)
        return json

# structure
class Location(Structure):
    idlType = "webcam.Location:1.0.0"
    elements = ["name", "x", "y", "z"]

    def __init__(self, name, x, y, z):
        typecheck.is_string(name, AssertionError)
        typecheck.is_string(x, AssertionError)
        typecheck.is_string(y, AssertionError)
        typecheck.is_string(z, AssertionError)

        self.name = name
        self.x = x
        self.y = y
        self.z = z

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            name = json['name'],
            x = json['x'],
            y = json['y'],
            z = json['z'],
        )
        return obj

    def encode(self):
        json = {}
        json['name'] = self.name
        json['x'] = self.x
        json['y'] = self.y
        json['z'] = self.z
        return json

# structure
class ImageMetaData(Structure):
    idlType = "webcam.ImageMetaData:1.0.0"
    elements = ["format", "timestamp", "location"]

    def __init__(self, format, timestamp, location):
        typecheck.is_struct(format, raritan.rpc.webcam.Format, AssertionError)
        typecheck.is_long(timestamp, AssertionError)
        typecheck.is_struct(location, raritan.rpc.webcam.Location, AssertionError)

        self.format = format
        self.timestamp = timestamp
        self.location = location

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            format = raritan.rpc.webcam.Format.decode(json['format'], agent),
            timestamp = int(json['timestamp']),
            location = raritan.rpc.webcam.Location.decode(json['location'], agent),
        )
        return obj

    def encode(self):
        json = {}
        json['format'] = raritan.rpc.webcam.Format.encode(self.format)
        json['timestamp'] = self.timestamp
        json['location'] = raritan.rpc.webcam.Location.encode(self.location)
        return json

# structure
class Image(Structure):
    idlType = "webcam.Image:2.0.0"
    elements = ["meta", "data"]

    def __init__(self, meta, data):
        typecheck.is_struct(meta, raritan.rpc.webcam.ImageMetaData, AssertionError)
        typecheck.is_string(data, AssertionError)

        self.meta = meta
        self.data = data

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            meta = raritan.rpc.webcam.ImageMetaData.decode(json['meta'], agent),
            data = json['data'],
        )
        return obj

    def encode(self):
        json = {}
        json['meta'] = raritan.rpc.webcam.ImageMetaData.encode(self.meta)
        json['data'] = self.data
        return json

# structure
class Settings(Structure):
    idlType = "webcam.Settings:2.0.0"
    elements = ["format", "controls", "name", "location", "refreshInterval"]

    def __init__(self, format, controls, name, location, refreshInterval):
        typecheck.is_struct(format, raritan.rpc.webcam.Format, AssertionError)
        typecheck.is_struct(controls, raritan.rpc.webcam.Controls, AssertionError)
        typecheck.is_string(name, AssertionError)
        typecheck.is_struct(location, raritan.rpc.webcam.Location, AssertionError)
        typecheck.is_int(refreshInterval, AssertionError)

        self.format = format
        self.controls = controls
        self.name = name
        self.location = location
        self.refreshInterval = refreshInterval

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            format = raritan.rpc.webcam.Format.decode(json['format'], agent),
            controls = raritan.rpc.webcam.Controls.decode(json['controls'], agent),
            name = json['name'],
            location = raritan.rpc.webcam.Location.decode(json['location'], agent),
            refreshInterval = json['refreshInterval'],
        )
        return obj

    def encode(self):
        json = {}
        json['format'] = raritan.rpc.webcam.Format.encode(self.format)
        json['controls'] = raritan.rpc.webcam.Controls.encode(self.controls)
        json['name'] = self.name
        json['location'] = raritan.rpc.webcam.Location.encode(self.location)
        json['refreshInterval'] = self.refreshInterval
        return json

# structure
class Information(Structure):
    idlType = "webcam.Information:3.0.0"
    elements = ["id", "model", "supportedFormats"]

    def __init__(self, id, model, supportedFormats):
        typecheck.is_string(id, AssertionError)
        typecheck.is_string(model, AssertionError)
        for x0 in supportedFormats:
            typecheck.is_struct(x0, raritan.rpc.webcam.Format, AssertionError)

        self.id = id
        self.model = model
        self.supportedFormats = supportedFormats

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            id = json['id'],
            model = json['model'],
            supportedFormats = [raritan.rpc.webcam.Format.decode(x0, agent) for x0 in json['supportedFormats']],
        )
        return obj

    def encode(self):
        json = {}
        json['id'] = self.id
        json['model'] = self.model
        json['supportedFormats'] = [raritan.rpc.webcam.Format.encode(x0) for x0 in self.supportedFormats]
        return json

# interface
class Webcam(Interface):
    idlType = "webcam.Webcam:2.0.1"

    # value object
    class SettingsChangedEvent(raritan.rpc.event.UserEvent):
        idlType = "webcam.Webcam_2_0_1.SettingsChangedEvent:1.0.0"

        def __init__(self, oldSettings, newSettings, actUserName, actIpAddr, source):
            super(raritan.rpc.webcam.Webcam.SettingsChangedEvent, self).__init__(actUserName, actIpAddr, source)
            typecheck.is_struct(oldSettings, raritan.rpc.webcam.Settings, AssertionError)
            typecheck.is_struct(newSettings, raritan.rpc.webcam.Settings, AssertionError)

            self.oldSettings = oldSettings
            self.newSettings = newSettings

        def encode(self):
            json = super(raritan.rpc.webcam.Webcam.SettingsChangedEvent, self).encode()
            json['oldSettings'] = raritan.rpc.webcam.Settings.encode(self.oldSettings)
            json['newSettings'] = raritan.rpc.webcam.Settings.encode(self.newSettings)
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                oldSettings = raritan.rpc.webcam.Settings.decode(json['oldSettings'], agent),
                newSettings = raritan.rpc.webcam.Settings.decode(json['newSettings'], agent),
                # for event.UserEvent
                actUserName = json['actUserName'],
                actIpAddr = json['actIpAddr'],
                # for idl.Event
                source = Interface.decode(json['source'], agent),
            )
            return obj

        def listElements(self):
            elements = ["oldSettings", "newSettings"]
            elements = elements + super(raritan.rpc.webcam.Webcam.SettingsChangedEvent, self).listElements()
            return elements

    class _getInformation(Interface.Method):
        name = 'getInformation'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = raritan.rpc.webcam.Information.decode(rsp['_ret_'], agent)
            typecheck.is_struct(_ret_, raritan.rpc.webcam.Information, DecodeException)
            return _ret_

    class _getSettings(Interface.Method):
        name = 'getSettings'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = raritan.rpc.webcam.Settings.decode(rsp['_ret_'], agent)
            typecheck.is_struct(_ret_, raritan.rpc.webcam.Settings, DecodeException)
            return _ret_

    class _setSettings(Interface.Method):
        name = 'setSettings'

        @staticmethod
        def encode(settings):
            typecheck.is_struct(settings, raritan.rpc.webcam.Settings, AssertionError)
            args = {}
            args['settings'] = raritan.rpc.webcam.Settings.encode(settings)
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_

    class _setControls(Interface.Method):
        name = 'setControls'

        @staticmethod
        def encode(controls):
            typecheck.is_struct(controls, raritan.rpc.webcam.Controls, AssertionError)
            args = {}
            args['controls'] = raritan.rpc.webcam.Controls.encode(controls)
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_

    class _getControlDefaults(Interface.Method):
        name = 'getControlDefaults'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = raritan.rpc.webcam.Controls.decode(rsp['_ret_'], agent)
            typecheck.is_struct(_ret_, raritan.rpc.webcam.Controls, DecodeException)
            return _ret_
    def __init__(self, target, agent):
        super(Webcam, self).__init__(target, agent)
        self.getInformation = Webcam._getInformation(self)
        self.getSettings = Webcam._getSettings(self)
        self.setSettings = Webcam._setSettings(self)
        self.setControls = Webcam._setControls(self)
        self.getControlDefaults = Webcam._getControlDefaults(self)

#
# Section generated by IdlC from "StorageManager.idl"
#

import raritan.rpc
from raritan.rpc import Interface, Structure, ValueObject, Enumeration, typecheck, DecodeException
import raritan.rpc.event

import raritan.rpc.webcam


# interface
class StorageManager(Interface):
    idlType = "webcam.StorageManager:1.0.2"

    NO_ERROR = 0

    ERR_INVALID_PARAM = 1

    ERR_INIT_IN_PROGRESS = 2

    ERR_ALREADY_RUNNING = 3

    ERR_TOO_LARGE = 4

    ERR_OPERATION_NOT_SUPPORTED = 5

    # enumeration
    class StorageType(Enumeration):
        idlType = "webcam.StorageManager_1_0_2.StorageType:1.0.0"
        values = ["LOCAL", "FTP", "CIFS", "NFS"]

    StorageType.LOCAL = StorageType(0)
    StorageType.FTP = StorageType(1)
    StorageType.CIFS = StorageType(2)
    StorageType.NFS = StorageType(3)

    # enumeration
    class Direction(Enumeration):
        idlType = "webcam.StorageManager_1_0_2.Direction:1.0.0"
        values = ["ASCENDING", "DESCENDING"]

    Direction.ASCENDING = Direction(0)
    Direction.DESCENDING = Direction(1)

    # enumeration
    class StorageStatus(Enumeration):
        idlType = "webcam.StorageManager_1_0_2.StorageStatus:1.0.0"
        values = ["INITIALIZING", "READY"]

    StorageStatus.INITIALIZING = StorageStatus(0)
    StorageStatus.READY = StorageStatus(1)

    # structure
    class WebcamStorageInfo(Structure):
        idlType = "webcam.StorageManager_1_0_2.WebcamStorageInfo:1.0.0"
        elements = ["webcam", "newestIndex", "oldestIndex", "count"]

        def __init__(self, webcam, newestIndex, oldestIndex, count):
            typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)
            typecheck.is_long(newestIndex, AssertionError)
            typecheck.is_long(oldestIndex, AssertionError)
            typecheck.is_int(count, AssertionError)

            self.webcam = webcam
            self.newestIndex = newestIndex
            self.oldestIndex = oldestIndex
            self.count = count

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                webcam = Interface.decode(json['webcam'], agent),
                newestIndex = int(json['newestIndex']),
                oldestIndex = int(json['oldestIndex']),
                count = json['count'],
            )
            return obj

        def encode(self):
            json = {}
            json['webcam'] = Interface.encode(self.webcam)
            json['newestIndex'] = self.newestIndex
            json['oldestIndex'] = self.oldestIndex
            json['count'] = self.count
            return json

    # structure
    class StorageInformation(Structure):
        idlType = "webcam.StorageManager_1_0_2.StorageInformation:1.0.0"
        elements = ["status", "capacity", "used", "webcamStorageInfo"]

        def __init__(self, status, capacity, used, webcamStorageInfo):
            typecheck.is_enum(status, raritan.rpc.webcam.StorageManager.StorageStatus, AssertionError)
            typecheck.is_int(capacity, AssertionError)
            typecheck.is_int(used, AssertionError)
            for x0 in webcamStorageInfo:
                typecheck.is_struct(x0, raritan.rpc.webcam.StorageManager.WebcamStorageInfo, AssertionError)

            self.status = status
            self.capacity = capacity
            self.used = used
            self.webcamStorageInfo = webcamStorageInfo

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                status = raritan.rpc.webcam.StorageManager.StorageStatus.decode(json['status']),
                capacity = json['capacity'],
                used = json['used'],
                webcamStorageInfo = [raritan.rpc.webcam.StorageManager.WebcamStorageInfo.decode(x0, agent) for x0 in json['webcamStorageInfo']],
            )
            return obj

        def encode(self):
            json = {}
            json['status'] = raritan.rpc.webcam.StorageManager.StorageStatus.encode(self.status)
            json['capacity'] = self.capacity
            json['used'] = self.used
            json['webcamStorageInfo'] = [raritan.rpc.webcam.StorageManager.WebcamStorageInfo.encode(x0) for x0 in self.webcamStorageInfo]
            return json

    # structure
    class StorageSettings(Structure):
        idlType = "webcam.StorageManager_1_0_2.StorageSettings:1.0.0"
        elements = ["type", "capacity", "server", "username", "password"]

        def __init__(self, type, capacity, server, username, password):
            typecheck.is_enum(type, raritan.rpc.webcam.StorageManager.StorageType, AssertionError)
            typecheck.is_int(capacity, AssertionError)
            typecheck.is_string(server, AssertionError)
            typecheck.is_string(username, AssertionError)
            typecheck.is_string(password, AssertionError)

            self.type = type
            self.capacity = capacity
            self.server = server
            self.username = username
            self.password = password

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                type = raritan.rpc.webcam.StorageManager.StorageType.decode(json['type']),
                capacity = json['capacity'],
                server = json['server'],
                username = json['username'],
                password = json['password'],
            )
            return obj

        def encode(self):
            json = {}
            json['type'] = raritan.rpc.webcam.StorageManager.StorageType.encode(self.type)
            json['capacity'] = self.capacity
            json['server'] = self.server
            json['username'] = self.username
            json['password'] = self.password
            return json

    # structure
    class StorageMetaData(Structure):
        idlType = "webcam.StorageManager_1_0_2.StorageMetaData:1.0.0"
        elements = ["index", "webcam"]

        def __init__(self, index, webcam):
            typecheck.is_long(index, AssertionError)
            typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)

            self.index = index
            self.webcam = webcam

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                index = int(json['index']),
                webcam = Interface.decode(json['webcam'], agent),
            )
            return obj

        def encode(self):
            json = {}
            json['index'] = self.index
            json['webcam'] = Interface.encode(self.webcam)
            return json

    # structure
    class ImageStorageMetaData(Structure):
        idlType = "webcam.StorageManager_1_0_2.ImageStorageMetaData:1.0.0"
        elements = ["imageMeta", "fileSize", "storageMeta"]

        def __init__(self, imageMeta, fileSize, storageMeta):
            typecheck.is_struct(imageMeta, raritan.rpc.webcam.ImageMetaData, AssertionError)
            typecheck.is_int(fileSize, AssertionError)
            typecheck.is_struct(storageMeta, raritan.rpc.webcam.StorageManager.StorageMetaData, AssertionError)

            self.imageMeta = imageMeta
            self.fileSize = fileSize
            self.storageMeta = storageMeta

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                imageMeta = raritan.rpc.webcam.ImageMetaData.decode(json['imageMeta'], agent),
                fileSize = json['fileSize'],
                storageMeta = raritan.rpc.webcam.StorageManager.StorageMetaData.decode(json['storageMeta'], agent),
            )
            return obj

        def encode(self):
            json = {}
            json['imageMeta'] = raritan.rpc.webcam.ImageMetaData.encode(self.imageMeta)
            json['fileSize'] = self.fileSize
            json['storageMeta'] = raritan.rpc.webcam.StorageManager.StorageMetaData.encode(self.storageMeta)
            return json

    # structure
    class StorageImage(Structure):
        idlType = "webcam.StorageManager_1_0_2.StorageImage:1.0.0"
        elements = ["image", "metaData"]

        def __init__(self, image, metaData):
            typecheck.is_struct(image, raritan.rpc.webcam.Image, AssertionError)
            typecheck.is_struct(metaData, raritan.rpc.webcam.StorageManager.StorageMetaData, AssertionError)

            self.image = image
            self.metaData = metaData

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                image = raritan.rpc.webcam.Image.decode(json['image'], agent),
                metaData = raritan.rpc.webcam.StorageManager.StorageMetaData.decode(json['metaData'], agent),
            )
            return obj

        def encode(self):
            json = {}
            json['image'] = raritan.rpc.webcam.Image.encode(self.image)
            json['metaData'] = raritan.rpc.webcam.StorageManager.StorageMetaData.encode(self.metaData)
            return json

    # structure
    class Activity(Structure):
        idlType = "webcam.StorageManager_1_0_2.Activity:1.0.0"
        elements = ["webcam", "interval", "count", "done"]

        def __init__(self, webcam, interval, count, done):
            typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)
            typecheck.is_int(interval, AssertionError)
            typecheck.is_int(count, AssertionError)
            typecheck.is_int(done, AssertionError)

            self.webcam = webcam
            self.interval = interval
            self.count = count
            self.done = done

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                webcam = Interface.decode(json['webcam'], agent),
                interval = json['interval'],
                count = json['count'],
                done = json['done'],
            )
            return obj

        def encode(self):
            json = {}
            json['webcam'] = Interface.encode(self.webcam)
            json['interval'] = self.interval
            json['count'] = self.count
            json['done'] = self.done
            return json

    # value object
    class ImageUploadStartedEvent(raritan.rpc.event.UserEvent):
        idlType = "webcam.StorageManager_1_0_2.ImageUploadStartedEvent:1.0.0"

        def __init__(self, webcam, folderUrl, actUserName, actIpAddr, source):
            super(raritan.rpc.webcam.StorageManager.ImageUploadStartedEvent, self).__init__(actUserName, actIpAddr, source)
            typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)
            typecheck.is_string(folderUrl, AssertionError)

            self.webcam = webcam
            self.folderUrl = folderUrl

        def encode(self):
            json = super(raritan.rpc.webcam.StorageManager.ImageUploadStartedEvent, self).encode()
            json['webcam'] = Interface.encode(self.webcam)
            json['folderUrl'] = self.folderUrl
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                webcam = Interface.decode(json['webcam'], agent),
                folderUrl = json['folderUrl'],
                # for event.UserEvent
                actUserName = json['actUserName'],
                actIpAddr = json['actIpAddr'],
                # for idl.Event
                source = Interface.decode(json['source'], agent),
            )
            return obj

        def listElements(self):
            elements = ["webcam", "folderUrl"]
            elements = elements + super(raritan.rpc.webcam.StorageManager.ImageUploadStartedEvent, self).listElements()
            return elements

    class _getSupportedStorageTypes(Interface.Method):
        name = 'getSupportedStorageTypes'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = [raritan.rpc.webcam.StorageManager.StorageType.decode(x0) for x0 in rsp['_ret_']]
            for x0 in _ret_:
                typecheck.is_enum(x0, raritan.rpc.webcam.StorageManager.StorageType, DecodeException)
            return _ret_

    class _getInformation(Interface.Method):
        name = 'getInformation'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = raritan.rpc.webcam.StorageManager.StorageInformation.decode(rsp['_ret_'], agent)
            typecheck.is_struct(_ret_, raritan.rpc.webcam.StorageManager.StorageInformation, DecodeException)
            return _ret_

    class _getSettings(Interface.Method):
        name = 'getSettings'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = raritan.rpc.webcam.StorageManager.StorageSettings.decode(rsp['_ret_'], agent)
            typecheck.is_struct(_ret_, raritan.rpc.webcam.StorageManager.StorageSettings, DecodeException)
            return _ret_

    class _setSettings(Interface.Method):
        name = 'setSettings'

        @staticmethod
        def encode(settings):
            typecheck.is_struct(settings, raritan.rpc.webcam.StorageManager.StorageSettings, AssertionError)
            args = {}
            args['settings'] = raritan.rpc.webcam.StorageManager.StorageSettings.encode(settings)
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_

    class _addImage(Interface.Method):
        name = 'addImage'

        @staticmethod
        def encode(webcam, image):
            typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)
            typecheck.is_struct(image, raritan.rpc.webcam.Image, AssertionError)
            args = {}
            args['webcam'] = Interface.encode(webcam)
            args['image'] = raritan.rpc.webcam.Image.encode(image)
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            index = int(rsp['index'])
            typecheck.is_int(_ret_, DecodeException)
            typecheck.is_long(index, DecodeException)
            return (_ret_, index)

    class _removeImages(Interface.Method):
        name = 'removeImages'

        @staticmethod
        def encode(webcam, start, count, direction):
            typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)
            typecheck.is_long(start, AssertionError)
            typecheck.is_int(count, AssertionError)
            typecheck.is_enum(direction, raritan.rpc.webcam.StorageManager.Direction, AssertionError)
            args = {}
            args['webcam'] = Interface.encode(webcam)
            args['start'] = start
            args['count'] = count
            args['direction'] = raritan.rpc.webcam.StorageManager.Direction.encode(direction)
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_

    class _getMetaData(Interface.Method):
        name = 'getMetaData'

        @staticmethod
        def encode(webcam, start, count, direction):
            typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)
            typecheck.is_long(start, AssertionError)
            typecheck.is_int(count, AssertionError)
            typecheck.is_enum(direction, raritan.rpc.webcam.StorageManager.Direction, AssertionError)
            args = {}
            args['webcam'] = Interface.encode(webcam)
            args['start'] = start
            args['count'] = count
            args['direction'] = raritan.rpc.webcam.StorageManager.Direction.encode(direction)
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            meta = [raritan.rpc.webcam.StorageManager.ImageStorageMetaData.decode(x0, agent) for x0 in rsp['meta']]
            typecheck.is_int(_ret_, DecodeException)
            for x0 in meta:
                typecheck.is_struct(x0, raritan.rpc.webcam.StorageManager.ImageStorageMetaData, DecodeException)
            return (_ret_, meta)

    class _getImages(Interface.Method):
        name = 'getImages'

        @staticmethod
        def encode(webcam, start, count, direction):
            typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)
            typecheck.is_long(start, AssertionError)
            typecheck.is_int(count, AssertionError)
            typecheck.is_enum(direction, raritan.rpc.webcam.StorageManager.Direction, AssertionError)
            args = {}
            args['webcam'] = Interface.encode(webcam)
            args['start'] = start
            args['count'] = count
            args['direction'] = raritan.rpc.webcam.StorageManager.Direction.encode(direction)
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            image = [raritan.rpc.webcam.StorageManager.StorageImage.decode(x0, agent) for x0 in rsp['image']]
            typecheck.is_int(_ret_, DecodeException)
            for x0 in image:
                typecheck.is_struct(x0, raritan.rpc.webcam.StorageManager.StorageImage, DecodeException)
            return (_ret_, image)

    class _getActivities(Interface.Method):
        name = 'getActivities'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = [raritan.rpc.webcam.StorageManager.Activity.decode(x0, agent) for x0 in rsp['_ret_']]
            for x0 in _ret_:
                typecheck.is_struct(x0, raritan.rpc.webcam.StorageManager.Activity, DecodeException)
            return _ret_

    class _startActivity(Interface.Method):
        name = 'startActivity'

        @staticmethod
        def encode(webcam, count, interval):
            typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)
            typecheck.is_int(count, AssertionError)
            typecheck.is_int(interval, AssertionError)
            args = {}
            args['webcam'] = Interface.encode(webcam)
            args['count'] = count
            args['interval'] = interval
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_

    class _startActivityWithFolder(Interface.Method):
        name = 'startActivityWithFolder'

        @staticmethod
        def encode(webcam, count, interval, folder):
            typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)
            typecheck.is_int(count, AssertionError)
            typecheck.is_int(interval, AssertionError)
            typecheck.is_string(folder, AssertionError)
            args = {}
            args['webcam'] = Interface.encode(webcam)
            args['count'] = count
            args['interval'] = interval
            args['folder'] = folder
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_

    class _stopActivity(Interface.Method):
        name = 'stopActivity'

        @staticmethod
        def encode(webcam):
            typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)
            args = {}
            args['webcam'] = Interface.encode(webcam)
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_
    def __init__(self, target, agent):
        super(StorageManager, self).__init__(target, agent)
        self.getSupportedStorageTypes = StorageManager._getSupportedStorageTypes(self)
        self.getInformation = StorageManager._getInformation(self)
        self.getSettings = StorageManager._getSettings(self)
        self.setSettings = StorageManager._setSettings(self)
        self.addImage = StorageManager._addImage(self)
        self.removeImages = StorageManager._removeImages(self)
        self.getMetaData = StorageManager._getMetaData(self)
        self.getImages = StorageManager._getImages(self)
        self.getActivities = StorageManager._getActivities(self)
        self.startActivity = StorageManager._startActivity(self)
        self.startActivityWithFolder = StorageManager._startActivityWithFolder(self)
        self.stopActivity = StorageManager._stopActivity(self)

#
# Section generated by IdlC from "WebcamChannel.idl"
#

import raritan.rpc
from raritan.rpc import Interface, Structure, ValueObject, Enumeration, typecheck, DecodeException
import raritan.rpc.webcam


# interface
class Channel(Interface):
    idlType = "webcam.Channel:1.0.1"

    NO_ERROR = 0

    ERR_NOT_AVAILABLE = 2

    ERR_NO_SUCH_OBJECT = 3

    class _getClientType(Interface.Method):
        name = 'getClientType'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_string(_ret_, DecodeException)
            return _ret_

    class _getWebcam(Interface.Method):
        name = 'getWebcam'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = Interface.decode(rsp['_ret_'], agent)
            typecheck.is_interface(_ret_, raritan.rpc.webcam.Webcam, DecodeException)
            return _ret_

    class _isAvailable(Interface.Method):
        name = 'isAvailable'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_bool(_ret_, DecodeException)
            return _ret_

    class _release(Interface.Method):
        name = 'release'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            return None

    class _captureImage(Interface.Method):
        name = 'captureImage'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            image = raritan.rpc.webcam.Image.decode(rsp['image'], agent)
            typecheck.is_int(_ret_, DecodeException)
            typecheck.is_struct(image, raritan.rpc.webcam.Image, DecodeException)
            return (_ret_, image)

    class _triggerCapture(Interface.Method):
        name = 'triggerCapture'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            captureToken = rsp['captureToken']
            typecheck.is_int(_ret_, DecodeException)
            typecheck.is_string(captureToken, DecodeException)
            return (_ret_, captureToken)
    def __init__(self, target, agent):
        super(Channel, self).__init__(target, agent)
        self.getClientType = Channel._getClientType(self)
        self.getWebcam = Channel._getWebcam(self)
        self.isAvailable = Channel._isAvailable(self)
        self.release = Channel._release(self)
        self.captureImage = Channel._captureImage(self)
        self.triggerCapture = Channel._triggerCapture(self)

#
# Section generated by IdlC from "WebcamManager.idl"
#

import raritan.rpc
from raritan.rpc import Interface, Structure, ValueObject, Enumeration, typecheck, DecodeException
import raritan.rpc.idl

import raritan.rpc.webcam


# enumeration
class Priority(Enumeration):
    idlType = "webcam.Priority:1.0.0"
    values = ["VERY_LOW", "LOW", "NORMAL", "HIGH", "VERY_HIGH"]

Priority.VERY_LOW = Priority(0)
Priority.LOW = Priority(1)
Priority.NORMAL = Priority(2)
Priority.HIGH = Priority(3)
Priority.VERY_HIGH = Priority(4)

# value object
class WebcamEvent(raritan.rpc.idl.Event):
    idlType = "webcam.WebcamEvent:1.0.1"

    def __init__(self, webcam, information, name, source):
        super(raritan.rpc.webcam.WebcamEvent, self).__init__(source)
        typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)
        typecheck.is_struct(information, raritan.rpc.webcam.Information, AssertionError)
        typecheck.is_string(name, AssertionError)

        self.webcam = webcam
        self.information = information
        self.name = name

    def encode(self):
        json = super(raritan.rpc.webcam.WebcamEvent, self).encode()
        json['webcam'] = Interface.encode(self.webcam)
        json['information'] = raritan.rpc.webcam.Information.encode(self.information)
        json['name'] = self.name
        return json

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            webcam = Interface.decode(json['webcam'], agent),
            information = raritan.rpc.webcam.Information.decode(json['information'], agent),
            name = json['name'],
            # for idl.Event
            source = Interface.decode(json['source'], agent),
        )
        return obj

    def listElements(self):
        elements = ["webcam", "information", "name"]
        elements = elements + super(raritan.rpc.webcam.WebcamEvent, self).listElements()
        return elements

# value object
class WebcamAddedEvent(WebcamEvent):
    idlType = "webcam.WebcamAddedEvent:1.0.1"

    def __init__(self, webcam, information, name, source):
        super(raritan.rpc.webcam.WebcamAddedEvent, self).__init__(webcam, information, name, source)

    def encode(self):
        json = super(raritan.rpc.webcam.WebcamAddedEvent, self).encode()
        return json

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            # for webcam.WebcamEvent_1_0_1
            webcam = Interface.decode(json['webcam'], agent),
            information = raritan.rpc.webcam.Information.decode(json['information'], agent),
            name = json['name'],
            # for idl.Event
            source = Interface.decode(json['source'], agent),
        )
        return obj

    def listElements(self):
        elements = []
        elements = elements + super(raritan.rpc.webcam.WebcamAddedEvent, self).listElements()
        return elements

# value object
class WebcamRemovedEvent(WebcamEvent):
    idlType = "webcam.WebcamRemovedEvent:1.0.1"

    def __init__(self, webcam, information, name, source):
        super(raritan.rpc.webcam.WebcamRemovedEvent, self).__init__(webcam, information, name, source)

    def encode(self):
        json = super(raritan.rpc.webcam.WebcamRemovedEvent, self).encode()
        return json

    @classmethod
    def decode(cls, json, agent):
        obj = cls(
            # for webcam.WebcamEvent_1_0_1
            webcam = Interface.decode(json['webcam'], agent),
            information = raritan.rpc.webcam.Information.decode(json['information'], agent),
            name = json['name'],
            # for idl.Event
            source = Interface.decode(json['source'], agent),
        )
        return obj

    def listElements(self):
        elements = []
        elements = elements + super(raritan.rpc.webcam.WebcamRemovedEvent, self).listElements()
        return elements

# interface
class WebcamManager(Interface):
    idlType = "webcam.WebcamManager:2.0.1"

    NO_ERROR = 0

    ERR_INVALID_PARAM = 1

    class _getWebcams(Interface.Method):
        name = 'getWebcams'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = [Interface.decode(x0, agent) for x0 in rsp['_ret_']]
            for x0 in _ret_:
                typecheck.is_interface(x0, raritan.rpc.webcam.Webcam, DecodeException)
            return _ret_

    class _getChannel(Interface.Method):
        name = 'getChannel'

        @staticmethod
        def encode(webcam, clientType):
            typecheck.is_interface(webcam, raritan.rpc.webcam.Webcam, AssertionError)
            typecheck.is_string(clientType, AssertionError)
            args = {}
            args['webcam'] = Interface.encode(webcam)
            args['clientType'] = clientType
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            channel = Interface.decode(rsp['channel'], agent)
            typecheck.is_int(_ret_, DecodeException)
            typecheck.is_interface(channel, raritan.rpc.webcam.Channel, DecodeException)
            return (_ret_, channel)

    class _getChannels(Interface.Method):
        name = 'getChannels'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = [Interface.decode(x0, agent) for x0 in rsp['_ret_']]
            for x0 in _ret_:
                typecheck.is_interface(x0, raritan.rpc.webcam.Channel, DecodeException)
            return _ret_

    class _removeClientType(Interface.Method):
        name = 'removeClientType'

        @staticmethod
        def encode(clientType):
            typecheck.is_string(clientType, AssertionError)
            args = {}
            args['clientType'] = clientType
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_

    class _getClientTypes(Interface.Method):
        name = 'getClientTypes'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = [x0 for x0 in rsp['_ret_']]
            for x0 in _ret_:
                typecheck.is_string(x0, DecodeException)
            return _ret_

    class _getClientTypePriorities(Interface.Method):
        name = 'getClientTypePriorities'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = dict([(
                elem['key'],
                raritan.rpc.webcam.Priority.decode(elem['value']))
                for elem in rsp['_ret_']])
            return _ret_

    class _setClientTypePriorities(Interface.Method):
        name = 'setClientTypePriorities'

        @staticmethod
        def encode(priorities):
            args = {}
            args['priorities'] = [dict(
                key = k,
                value = raritan.rpc.webcam.Priority.encode(v))
                for k, v in priorities.items()]
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_

    class _getWebcamPriorities(Interface.Method):
        name = 'getWebcamPriorities'

        @staticmethod
        def encode():
            args = {}
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = dict([(
                elem['key'],
                raritan.rpc.webcam.Priority.decode(elem['value']))
                for elem in rsp['_ret_']])
            return _ret_

    class _setWebcamPriorities(Interface.Method):
        name = 'setWebcamPriorities'

        @staticmethod
        def encode(priorities):
            args = {}
            args['priorities'] = [dict(
                key = k,
                value = raritan.rpc.webcam.Priority.encode(v))
                for k, v in priorities.items()]
            return args

        @staticmethod
        def decode(rsp, agent):
            _ret_ = rsp['_ret_']
            typecheck.is_int(_ret_, DecodeException)
            return _ret_
    def __init__(self, target, agent):
        super(WebcamManager, self).__init__(target, agent)
        self.getWebcams = WebcamManager._getWebcams(self)
        self.getChannel = WebcamManager._getChannel(self)
        self.getChannels = WebcamManager._getChannels(self)
        self.removeClientType = WebcamManager._removeClientType(self)
        self.getClientTypes = WebcamManager._getClientTypes(self)
        self.getClientTypePriorities = WebcamManager._getClientTypePriorities(self)
        self.setClientTypePriorities = WebcamManager._setClientTypePriorities(self)
        self.getWebcamPriorities = WebcamManager._getWebcamPriorities(self)
        self.setWebcamPriorities = WebcamManager._setWebcamPriorities(self)
