# Do NOT edit this file!
# It was generated by IdlC class idl.json.python.ProxyAsnVisitor.

#
# Section generated from "/home/nb/builds/MEGA/px2-3.2.30-3.2.39-branch-20160511-none-release-none-pdu-raritan/fwcomponents/mkdist/tmp/px2_final/libidl_client/topofw/powerlogic/idl/ModbusDevice.idl"
#

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


# interface
class Device(Interface):
    idlType = "modbus.Device:1.0.0"

    # structure
    class DeviceID(Structure):
        idlType = "modbus.Device.DeviceID:1.0.0"
        elements = ["vendor", "code", "version", "url", "name", "model", "app"]

        def __init__(self, vendor, code, version, url, name, model, app):
            typecheck.is_string(vendor, AssertionError)
            typecheck.is_string(code, AssertionError)
            typecheck.is_string(version, AssertionError)
            typecheck.is_string(url, AssertionError)
            typecheck.is_string(name, AssertionError)
            typecheck.is_string(model, AssertionError)
            typecheck.is_string(app, AssertionError)

            self.vendor = vendor
            self.code = code
            self.version = version
            self.url = url
            self.name = name
            self.model = model
            self.app = app

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                vendor = json['vendor'],
                code = json['code'],
                version = json['version'],
                url = json['url'],
                name = json['name'],
                model = json['model'],
                app = json['app'],
            )
            return obj

        def encode(self):
            json = {}
            json['vendor'] = self.vendor
            json['code'] = self.code
            json['version'] = self.version
            json['url'] = self.url
            json['name'] = self.name
            json['model'] = self.model
            json['app'] = self.app
            return json

    class _readDeviceIdentification(Interface.Method):
        name = 'readDeviceIdentification'

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

        @staticmethod
        def decode(rsp, agent):
            _ret_ = raritan.rpc.modbus.Device.DeviceID.decode(rsp['_ret_'], agent)
            typecheck.is_struct(_ret_, raritan.rpc.modbus.Device.DeviceID, DecodeException)
            return _ret_
    def __init__(self, target, agent):
        super(Device, self).__init__(target, agent)
        self.readDeviceIdentification = Device._readDeviceIdentification(self)
