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

#
# Section generated from "/home/nb/builds/MEGA/px2-3.0.0-3.0.9-branch-20140613-none-release-none-pdu-raritan/fwcomponents/mkdist/tmp/px2_final/libidl_client/serial/idl/AnalogModem.idl"
#

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

import raritan.rpc.serial


# interface
class AnalogModem(Interface):
    idlType = "serial.AnalogModem:1.0.0"

    SUCCESS = 0

    ERR_INVALID_VALUE = 1

    # structure
    class Settings(Structure):
        idlType = "serial.AnalogModem.Settings:1.0.0"
        elements = ["dialInEnabled", "ringsUntilAnswer"]

        def __init__(self, dialInEnabled, ringsUntilAnswer):
            typecheck.is_bool(dialInEnabled, AssertionError)
            typecheck.is_int(ringsUntilAnswer, AssertionError)

            self.dialInEnabled = dialInEnabled
            self.ringsUntilAnswer = ringsUntilAnswer

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                dialInEnabled=json["dialInEnabled"],
                ringsUntilAnswer=json["ringsUntilAnswer"],
            )
            return obj

        def encode(self):
            json = {}
            json["dialInEnabled"] = self.dialInEnabled
            json["ringsUntilAnswer"] = self.ringsUntilAnswer
            return json

    # value object
    class DialInEvent(raritan.rpc.idl.Event):
        idlType = "serial.AnalogModem.DialInEvent:1.0.0"

        def __init__(self, number, source):
            super(raritan.rpc.serial.AnalogModem.DialInEvent, self).__init__(source)
            typecheck.is_string(number, AssertionError)

            self.number = number

        def encode(self):
            json = super(raritan.rpc.serial.AnalogModem.DialInEvent, self).encode()
            json["number"] = self.number
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                number=json["number"],
                # for idl.Event
                source=Interface.decode(json["source"], agent),
            )
            return obj

        def listElements(self):
            elements = ["number"]
            elements = (
                elements
                + super(raritan.rpc.serial.AnalogModem.DialInEvent, self).listElements()
            )
            return elements

    # value object
    class CallReceivedEvent(DialInEvent):
        idlType = "serial.AnalogModem.CallReceivedEvent:1.0.0"

        def __init__(self, number, source):
            super(raritan.rpc.serial.AnalogModem.CallReceivedEvent, self).__init__(
                number, source
            )

        def encode(self):
            json = super(
                raritan.rpc.serial.AnalogModem.CallReceivedEvent, self
            ).encode()
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                # for serial.AnalogModem.DialInEvent
                number=json["number"],
                # for idl.Event
                source=Interface.decode(json["source"], agent),
            )
            return obj

        def listElements(self):
            elements = []
            elements = (
                elements
                + super(
                    raritan.rpc.serial.AnalogModem.CallReceivedEvent, self
                ).listElements()
            )
            return elements

    # value object
    class CallEndedEvent(DialInEvent):
        idlType = "serial.AnalogModem.CallEndedEvent:1.0.0"

        def __init__(self, disconnectedRemotely, number, source):
            super(raritan.rpc.serial.AnalogModem.CallEndedEvent, self).__init__(
                number, source
            )
            typecheck.is_bool(disconnectedRemotely, AssertionError)

            self.disconnectedRemotely = disconnectedRemotely

        def encode(self):
            json = super(raritan.rpc.serial.AnalogModem.CallEndedEvent, self).encode()
            json["disconnectedRemotely"] = self.disconnectedRemotely
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                disconnectedRemotely=json["disconnectedRemotely"],
                # for serial.AnalogModem.DialInEvent
                number=json["number"],
                # for idl.Event
                source=Interface.decode(json["source"], agent),
            )
            return obj

        def listElements(self):
            elements = ["disconnectedRemotely"]
            elements = (
                elements
                + super(
                    raritan.rpc.serial.AnalogModem.CallEndedEvent, self
                ).listElements()
            )
            return elements

    def getSettings(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getSettings", args)
        _ret_ = raritan.rpc.serial.AnalogModem.Settings.decode(rsp["_ret_"], agent)
        typecheck.is_struct(
            _ret_, raritan.rpc.serial.AnalogModem.Settings, DecodeException
        )
        return _ret_

    def setSettings(self, settings):
        agent = self.agent
        typecheck.is_struct(
            settings, raritan.rpc.serial.AnalogModem.Settings, AssertionError
        )
        args = {}
        args["settings"] = raritan.rpc.serial.AnalogModem.Settings.encode(settings)
        rsp = agent.json_rpc(self.target, "setSettings", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_


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

#
# Section generated from "/home/nb/builds/MEGA/px2-3.0.0-3.0.9-branch-20140613-none-release-none-pdu-raritan/fwcomponents/mkdist/tmp/px2_final/libidl_client/serial/idl/GsmModem.idl"
#

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

import raritan.rpc.serial


# interface
class GsmModem(Interface):
    idlType = "serial.GsmModem:1.0.1"

    SUCCESS = 0

    ERR_INVALID_VALUE = 1

    ERR_WRONG_PIN = 2

    ERR_SMS_SEND_FAILED = 3

    ERR_COMMUNICATION_FAILURE = 4

    ERR_SIM_LOCKED = 5

    ERR_WRONG_SIM_STATUS = 6

    ERR_WRONG_PUK = 7

    # enumeration
    class SimSecurityStatus(Enumeration):
        idlType = "serial.GsmModem.SimSecurityStatus:1.0.0"
        values = ["UNLOCKED", "WAITFORPIN", "WAITFORPUK", "UNKNOWN"]

    SimSecurityStatus.UNLOCKED = SimSecurityStatus(0)
    SimSecurityStatus.WAITFORPIN = SimSecurityStatus(1)
    SimSecurityStatus.WAITFORPUK = SimSecurityStatus(2)
    SimSecurityStatus.UNKNOWN = SimSecurityStatus(3)

    # structure
    class Settings(Structure):
        idlType = "serial.GsmModem.Settings:1.0.0"
        elements = ["pin", "smsc"]

        def __init__(self, pin, smsc):
            typecheck.is_string(pin, AssertionError)
            typecheck.is_string(smsc, AssertionError)

            self.pin = pin
            self.smsc = smsc

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                pin=json["pin"],
                smsc=json["smsc"],
            )
            return obj

        def encode(self):
            json = {}
            json["pin"] = self.pin
            json["smsc"] = self.smsc
            return json

    # structure
    class Information(Structure):
        idlType = "serial.GsmModem.Information:1.0.0"
        elements = [
            "imei",
            "imsi",
            "manufacturer",
            "model",
            "revision",
            "ownNumber",
            "simSmsc",
            "networkName",
            "serviceProviderName",
            "receptionLevel",
        ]

        def __init__(
            self,
            imei,
            imsi,
            manufacturer,
            model,
            revision,
            ownNumber,
            simSmsc,
            networkName,
            serviceProviderName,
            receptionLevel,
        ):
            typecheck.is_string(imei, AssertionError)
            typecheck.is_string(imsi, AssertionError)
            typecheck.is_string(manufacturer, AssertionError)
            typecheck.is_string(model, AssertionError)
            typecheck.is_string(revision, AssertionError)
            typecheck.is_string(ownNumber, AssertionError)
            typecheck.is_string(simSmsc, AssertionError)
            typecheck.is_string(networkName, AssertionError)
            typecheck.is_string(serviceProviderName, AssertionError)
            typecheck.is_int(receptionLevel, AssertionError)

            self.imei = imei
            self.imsi = imsi
            self.manufacturer = manufacturer
            self.model = model
            self.revision = revision
            self.ownNumber = ownNumber
            self.simSmsc = simSmsc
            self.networkName = networkName
            self.serviceProviderName = serviceProviderName
            self.receptionLevel = receptionLevel

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                imei=json["imei"],
                imsi=json["imsi"],
                manufacturer=json["manufacturer"],
                model=json["model"],
                revision=json["revision"],
                ownNumber=json["ownNumber"],
                simSmsc=json["simSmsc"],
                networkName=json["networkName"],
                serviceProviderName=json["serviceProviderName"],
                receptionLevel=json["receptionLevel"],
            )
            return obj

        def encode(self):
            json = {}
            json["imei"] = self.imei
            json["imsi"] = self.imsi
            json["manufacturer"] = self.manufacturer
            json["model"] = self.model
            json["revision"] = self.revision
            json["ownNumber"] = self.ownNumber
            json["simSmsc"] = self.simSmsc
            json["networkName"] = self.networkName
            json["serviceProviderName"] = self.serviceProviderName
            json["receptionLevel"] = self.receptionLevel
            return json

    # value object
    class SimSecurityStatusChangedEvent(raritan.rpc.idl.Event):
        idlType = "serial.GsmModem.SimSecurityStatusChangedEvent:1.0.0"

        def __init__(self, newSimStatus, source):
            super(
                raritan.rpc.serial.GsmModem.SimSecurityStatusChangedEvent, self
            ).__init__(source)
            typecheck.is_enum(
                newSimStatus,
                raritan.rpc.serial.GsmModem.SimSecurityStatus,
                AssertionError,
            )

            self.newSimStatus = newSimStatus

        def encode(self):
            json = super(
                raritan.rpc.serial.GsmModem.SimSecurityStatusChangedEvent, self
            ).encode()
            json["newSimStatus"] = raritan.rpc.serial.GsmModem.SimSecurityStatus.encode(
                self.newSimStatus
            )
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                newSimStatus=raritan.rpc.serial.GsmModem.SimSecurityStatus.decode(
                    json["newSimStatus"]
                ),
                # for idl.Event
                source=Interface.decode(json["source"], agent),
            )
            return obj

        def listElements(self):
            elements = ["newSimStatus"]
            elements = (
                elements
                + super(
                    raritan.rpc.serial.GsmModem.SimSecurityStatusChangedEvent, self
                ).listElements()
            )
            return elements

    # value object
    class SimPinUpdatedEvent(raritan.rpc.idl.Event):
        idlType = "serial.GsmModem.SimPinUpdatedEvent:1.0.0"

        def __init__(self, newPin, source):
            super(raritan.rpc.serial.GsmModem.SimPinUpdatedEvent, self).__init__(source)
            typecheck.is_string(newPin, AssertionError)

            self.newPin = newPin

        def encode(self):
            json = super(raritan.rpc.serial.GsmModem.SimPinUpdatedEvent, self).encode()
            json["newPin"] = self.newPin
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                newPin=json["newPin"],
                # for idl.Event
                source=Interface.decode(json["source"], agent),
            )
            return obj

        def listElements(self):
            elements = ["newPin"]
            elements = (
                elements
                + super(
                    raritan.rpc.serial.GsmModem.SimPinUpdatedEvent, self
                ).listElements()
            )
            return elements

    def getSettings(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getSettings", args)
        _ret_ = raritan.rpc.serial.GsmModem.Settings.decode(rsp["_ret_"], agent)
        typecheck.is_struct(
            _ret_, raritan.rpc.serial.GsmModem.Settings, DecodeException
        )
        return _ret_

    def setSettings(self, settings):
        agent = self.agent
        typecheck.is_struct(
            settings, raritan.rpc.serial.GsmModem.Settings, AssertionError
        )
        args = {}
        args["settings"] = raritan.rpc.serial.GsmModem.Settings.encode(settings)
        rsp = agent.json_rpc(self.target, "setSettings", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_

    def sendSms(self, recipient, text):
        agent = self.agent
        typecheck.is_string(recipient, AssertionError)
        typecheck.is_string(text, AssertionError)
        args = {}
        args["recipient"] = recipient
        args["text"] = text
        rsp = agent.json_rpc(self.target, "sendSms", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_

    def sendTestSms(self, recipient, testSettings):
        agent = self.agent
        typecheck.is_string(recipient, AssertionError)
        typecheck.is_struct(
            testSettings, raritan.rpc.serial.GsmModem.Settings, AssertionError
        )
        args = {}
        args["recipient"] = recipient
        args["testSettings"] = raritan.rpc.serial.GsmModem.Settings.encode(testSettings)
        rsp = agent.json_rpc(self.target, "sendTestSms", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_

    def getInformation(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getInformation", args)
        _ret_ = rsp["_ret_"]
        info = raritan.rpc.serial.GsmModem.Information.decode(rsp["info"], agent)
        typecheck.is_int(_ret_, DecodeException)
        typecheck.is_struct(
            info, raritan.rpc.serial.GsmModem.Information, DecodeException
        )
        return (_ret_, info)

    def getInformationWithPin(self, pin):
        agent = self.agent
        typecheck.is_string(pin, AssertionError)
        args = {}
        args["pin"] = pin
        rsp = agent.json_rpc(self.target, "getInformationWithPin", args)
        _ret_ = rsp["_ret_"]
        info = raritan.rpc.serial.GsmModem.Information.decode(rsp["info"], agent)
        typecheck.is_int(_ret_, DecodeException)
        typecheck.is_struct(
            info, raritan.rpc.serial.GsmModem.Information, DecodeException
        )
        return (_ret_, info)

    def getSimSecurityStatus(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getSimSecurityStatus", args)
        _ret_ = rsp["_ret_"]
        simStatus = raritan.rpc.serial.GsmModem.SimSecurityStatus.decode(
            rsp["simStatus"]
        )
        typecheck.is_int(_ret_, DecodeException)
        typecheck.is_enum(
            simStatus, raritan.rpc.serial.GsmModem.SimSecurityStatus, DecodeException
        )
        return (_ret_, simStatus)

    def unlockSimCard(self, puk, newPin):
        agent = self.agent
        typecheck.is_string(puk, AssertionError)
        typecheck.is_string(newPin, AssertionError)
        args = {}
        args["puk"] = puk
        args["newPin"] = newPin
        rsp = agent.json_rpc(self.target, "unlockSimCard", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_


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

#
# Section generated from "/home/nb/builds/MEGA/px2-3.0.0-3.0.9-branch-20140613-none-release-none-pdu-raritan/fwcomponents/mkdist/tmp/px2_final/libidl_client/serial/idl/SerialPort.idl"
#

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

import raritan.rpc.serial


# interface
class SerialPort(Interface):
    idlType = "serial.SerialPort:2.0.0"

    SUCCESS = 0

    ERR_INVALID_VALUE = 1

    # enumeration
    class PortState(Enumeration):
        idlType = "serial.SerialPort.PortState:1.0.0"
        values = ["CONSOLE", "ANALOGMODEM", "GSMMODEM"]

    PortState.CONSOLE = PortState(0)
    PortState.ANALOGMODEM = PortState(1)
    PortState.GSMMODEM = PortState(2)

    # enumeration
    class BaudRate(Enumeration):
        idlType = "serial.SerialPort.BaudRate:1.0.0"
        values = [
            "BR1200",
            "BR2400",
            "BR4800",
            "BR9600",
            "BR19200",
            "BR38400",
            "BR57600",
            "BR115200",
        ]

    BaudRate.BR1200 = BaudRate(0)
    BaudRate.BR2400 = BaudRate(1)
    BaudRate.BR4800 = BaudRate(2)
    BaudRate.BR9600 = BaudRate(3)
    BaudRate.BR19200 = BaudRate(4)
    BaudRate.BR38400 = BaudRate(5)
    BaudRate.BR57600 = BaudRate(6)
    BaudRate.BR115200 = BaudRate(7)

    # structure
    class State(Structure):
        idlType = "serial.SerialPort.State:1.0.0"
        elements = ["state", "deviceName"]

        def __init__(self, state, deviceName):
            typecheck.is_enum(
                state, raritan.rpc.serial.SerialPort.PortState, AssertionError
            )
            typecheck.is_string(deviceName, AssertionError)

            self.state = state
            self.deviceName = deviceName

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                state=raritan.rpc.serial.SerialPort.PortState.decode(json["state"]),
                deviceName=json["deviceName"],
            )
            return obj

        def encode(self):
            json = {}
            json["state"] = raritan.rpc.serial.SerialPort.PortState.encode(self.state)
            json["deviceName"] = self.deviceName
            return json

    # structure
    class Settings(Structure):
        idlType = "serial.SerialPort.Settings:1.0.0"
        elements = ["consoleBaudRate", "modemBaudRate"]

        def __init__(self, consoleBaudRate, modemBaudRate):
            typecheck.is_enum(
                consoleBaudRate, raritan.rpc.serial.SerialPort.BaudRate, AssertionError
            )
            typecheck.is_enum(
                modemBaudRate, raritan.rpc.serial.SerialPort.BaudRate, AssertionError
            )

            self.consoleBaudRate = consoleBaudRate
            self.modemBaudRate = modemBaudRate

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                consoleBaudRate=raritan.rpc.serial.SerialPort.BaudRate.decode(
                    json["consoleBaudRate"]
                ),
                modemBaudRate=raritan.rpc.serial.SerialPort.BaudRate.decode(
                    json["modemBaudRate"]
                ),
            )
            return obj

        def encode(self):
            json = {}
            json["consoleBaudRate"] = raritan.rpc.serial.SerialPort.BaudRate.encode(
                self.consoleBaudRate
            )
            json["modemBaudRate"] = raritan.rpc.serial.SerialPort.BaudRate.encode(
                self.modemBaudRate
            )
            return json

    # value object
    class ModemEvent(raritan.rpc.idl.Event):
        idlType = "serial.SerialPort.ModemEvent:1.0.0"

        def __init__(self, modem, source):
            super(raritan.rpc.serial.SerialPort.ModemEvent, self).__init__(source)
            typecheck.is_remote_obj(modem, AssertionError)

            self.modem = modem

        def encode(self):
            json = super(raritan.rpc.serial.SerialPort.ModemEvent, self).encode()
            json["modem"] = Interface.encode(self.modem)
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                modem=Interface.decode(json["modem"], agent),
                # for idl.Event
                source=Interface.decode(json["source"], agent),
            )
            return obj

        def listElements(self):
            elements = ["modem"]
            elements = (
                elements
                + super(raritan.rpc.serial.SerialPort.ModemEvent, self).listElements()
            )
            return elements

    # value object
    class ModemAddedEvent(ModemEvent):
        idlType = "serial.SerialPort.ModemAddedEvent:1.0.0"

        def __init__(self, modem, source):
            super(raritan.rpc.serial.SerialPort.ModemAddedEvent, self).__init__(
                modem, source
            )

        def encode(self):
            json = super(raritan.rpc.serial.SerialPort.ModemAddedEvent, self).encode()
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                # for serial.SerialPort_2_0_0.ModemEvent
                modem=Interface.decode(json["modem"], agent),
                # for idl.Event
                source=Interface.decode(json["source"], agent),
            )
            return obj

        def listElements(self):
            elements = []
            elements = (
                elements
                + super(
                    raritan.rpc.serial.SerialPort.ModemAddedEvent, self
                ).listElements()
            )
            return elements

    # value object
    class ModemRemovedEvent(ModemEvent):
        idlType = "serial.SerialPort.ModemRemovedEvent:1.0.0"

        def __init__(self, modem, source):
            super(raritan.rpc.serial.SerialPort.ModemRemovedEvent, self).__init__(
                modem, source
            )

        def encode(self):
            json = super(raritan.rpc.serial.SerialPort.ModemRemovedEvent, self).encode()
            return json

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                # for serial.SerialPort_2_0_0.ModemEvent
                modem=Interface.decode(json["modem"], agent),
                # for idl.Event
                source=Interface.decode(json["source"], agent),
            )
            return obj

        def listElements(self):
            elements = []
            elements = (
                elements
                + super(
                    raritan.rpc.serial.SerialPort.ModemRemovedEvent, self
                ).listElements()
            )
            return elements

    def getSettings(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getSettings", args)
        _ret_ = raritan.rpc.serial.SerialPort.Settings.decode(rsp["_ret_"], agent)
        typecheck.is_struct(
            _ret_, raritan.rpc.serial.SerialPort.Settings, DecodeException
        )
        return _ret_

    def setSettings(self, settings):
        agent = self.agent
        typecheck.is_struct(
            settings, raritan.rpc.serial.SerialPort.Settings, AssertionError
        )
        args = {}
        args["settings"] = raritan.rpc.serial.SerialPort.Settings.encode(settings)
        rsp = agent.json_rpc(self.target, "setSettings", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_

    def getState(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getState", args)
        _ret_ = raritan.rpc.serial.SerialPort.State.decode(rsp["_ret_"], agent)
        typecheck.is_struct(_ret_, raritan.rpc.serial.SerialPort.State, DecodeException)
        return _ret_

    def getModem(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getModem", args)
        _ret_ = Interface.decode(rsp["_ret_"], agent)
        typecheck.is_remote_obj(_ret_, DecodeException)
        return _ret_


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

#
# Section generated from "/home/nb/builds/MEGA/px2-3.0.0-3.0.9-branch-20140613-none-release-none-pdu-raritan/fwcomponents/mkdist/tmp/px2_final/libidl_client/serial/idl/PortDispatcher.idl"
#

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

# interface
class PortDispatcher(Interface):
    idlType = "serial.PortDispatcher:1.1.1"

    def getPorts(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getPorts", args)
        _ret_ = dict(
            [
                (elem["key"], Interface.decode(elem["value"], agent))
                for elem in rsp["_ret_"]
            ]
        )
        return _ret_
