# 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/jsonrpcd/src/testrpc/idl/testrpc.idl"
#

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


# structure
class Result(Structure):
    idlType = "test.Result:1.0.0"
    elements = ["code", "errtext"]

    def __init__(self, code, errtext):
        typecheck.is_int(code, AssertionError)
        typecheck.is_string(errtext, AssertionError)

        self.code = code
        self.errtext = errtext

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

    def encode(self):
        json = {}
        json["code"] = self.code
        json["errtext"] = self.errtext
        return json


# interface
class Control(Interface):
    idlType = "test.Control:1.0.0"

    def isTestMode(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "isTestMode", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_bool(_ret_, DecodeException)
        return _ret_

    def setTestMode(self, isTestModeOn):
        agent = self.agent
        typecheck.is_bool(isTestModeOn, AssertionError)
        args = {}
        args["isTestModeOn"] = isTestModeOn
        rsp = agent.json_rpc(self.target, "setTestMode", args)


# interface
class RS232Serial(Interface):
    idlType = "test.RS232Serial:1.0.0"

    def getDeviceFiles(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getDeviceFiles", args)
        _ret_ = [x0 for x0 in rsp["_ret_"]]
        for x0 in _ret_:
            typecheck.is_string(x0, DecodeException)
        return _ret_

    def testLoop1(self, devfile):
        agent = self.agent
        typecheck.is_string(devfile, AssertionError)
        args = {}
        args["devfile"] = devfile
        rsp = agent.json_rpc(self.target, "testLoop1", args)
        _ret_ = raritan.rpc.test.Result.decode(rsp["_ret_"], agent)
        typecheck.is_struct(_ret_, raritan.rpc.test.Result, DecodeException)
        return _ret_

    def testLoop2(self, devfile):
        agent = self.agent
        typecheck.is_string(devfile, AssertionError)
        args = {}
        args["devfile"] = devfile
        rsp = agent.json_rpc(self.target, "testLoop2", args)
        _ret_ = raritan.rpc.test.Result.decode(rsp["_ret_"], agent)
        typecheck.is_struct(_ret_, raritan.rpc.test.Result, DecodeException)
        return _ret_


# interface
class FeatSerial(Interface):
    idlType = "test.FeatSerial:1.0.0"

    OK = 0

    ERR_NO_TEST_MODE = 1

    ERR_INVAL_PORT_NUM = 2

    ERR_TEST_FAILED = 3

    def getNumberOfPorts(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getNumberOfPorts", args)
        _ret_ = rsp["_ret_"]
        numPorts = rsp["numPorts"]
        typecheck.is_int(_ret_, DecodeException)
        typecheck.is_int(numPorts, DecodeException)
        return (_ret_, numPorts)

    def setPower(self, portNum, hasPower):
        agent = self.agent
        typecheck.is_int(portNum, AssertionError)
        typecheck.is_bool(hasPower, AssertionError)
        args = {}
        args["portNum"] = portNum
        args["hasPower"] = hasPower
        rsp = agent.json_rpc(self.target, "setPower", args)
        _ret_ = rsp["_ret_"]
        typecheck.is_int(_ret_, DecodeException)
        return _ret_

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

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


# interface
class AuxSerial(Interface):
    idlType = "test.AuxSerial:1.0.0"

    OK = 0

    ERR_NO_TEST_MODE = 1

    ERR_INVAL_PORT_NUM = 2

    ERR_TEST_FAILED = 3

    def getNumberOfPorts(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getNumberOfPorts", args)
        _ret_ = rsp["_ret_"]
        numPorts = rsp["numPorts"]
        typecheck.is_int(_ret_, DecodeException)
        typecheck.is_int(numPorts, DecodeException)
        return (_ret_, numPorts)

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


# interface
class Ethernet(Interface):
    idlType = "test.Ethernet:1.0.0"

    def getDevices(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getDevices", args)
        _ret_ = [x0 for x0 in rsp["_ret_"]]
        for x0 in _ret_:
            typecheck.is_string(x0, DecodeException)
        return _ret_

    # enumeration
    class Speed(Enumeration):
        idlType = "test.Ethernet.Speed:1.0.0"
        values = ["SPD_10", "SPD_100", "SPD_1000"]

    Speed.SPD_10 = Speed(0)
    Speed.SPD_100 = Speed(1)
    Speed.SPD_1000 = Speed(2)

    # enumeration
    class Duplex(Enumeration):
        idlType = "test.Ethernet.Duplex:1.0.0"
        values = ["DPX_HALF", "DPX_FULL"]

    Duplex.DPX_HALF = Duplex(0)
    Duplex.DPX_FULL = Duplex(1)

    def setParameters(self, device, speed, duplex, isAutoNeg):
        agent = self.agent
        typecheck.is_string(device, AssertionError)
        typecheck.is_enum(speed, raritan.rpc.test.Ethernet.Speed, AssertionError)
        typecheck.is_enum(duplex, raritan.rpc.test.Ethernet.Duplex, AssertionError)
        typecheck.is_bool(isAutoNeg, AssertionError)
        args = {}
        args["device"] = device
        args["speed"] = raritan.rpc.test.Ethernet.Speed.encode(speed)
        args["duplex"] = raritan.rpc.test.Ethernet.Duplex.encode(duplex)
        args["isAutoNeg"] = isAutoNeg
        rsp = agent.json_rpc(self.target, "setParameters", 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/topofw/testintf/idl/TestDisplay.idl"
#

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


# interface
class Display(Interface):
    idlType = "test.Display:1.0.1"

    # enumeration
    class Orientation(Enumeration):
        idlType = "test.Display.Orientation:1.0.0"
        values = ["NORMAL", "FLIPPED", "LEFT", "RIGHT"]

    Orientation.NORMAL = Orientation(0)
    Orientation.FLIPPED = Orientation(1)
    Orientation.LEFT = Orientation(2)
    Orientation.RIGHT = Orientation(3)

    # structure
    class Info(Structure):
        idlType = "test.Display.Info:1.0.0"
        elements = ["type", "address", "options", "orientation"]

        def __init__(self, type, address, options, orientation):
            typecheck.is_string(type, AssertionError)
            typecheck.is_string(address, AssertionError)
            typecheck.is_enum(
                orientation, raritan.rpc.test.Display.Orientation, AssertionError
            )

            self.type = type
            self.address = address
            self.options = options
            self.orientation = orientation

        @classmethod
        def decode(cls, json, agent):
            obj = cls(
                type=json["type"],
                address=json["address"],
                options=dict(
                    [(elem["key"], elem["value"]) for elem in json["options"]]
                ),
                orientation=raritan.rpc.test.Display.Orientation.decode(
                    json["orientation"]
                ),
            )
            return obj

        def encode(self):
            json = {}
            json["type"] = self.type
            json["address"] = self.address
            json["options"] = [dict(key=k, value=v) for k, v in self.options.items()]
            json["orientation"] = raritan.rpc.test.Display.Orientation.encode(
                self.orientation
            )
            return json

    def getInfo(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getInfo", args)
        _ret_ = raritan.rpc.test.Display.Info.decode(rsp["_ret_"], agent)
        typecheck.is_struct(_ret_, raritan.rpc.test.Display.Info, DecodeException)
        return _ret_

    def testSequence(self, cycleTime_ms):
        agent = self.agent
        typecheck.is_int(cycleTime_ms, AssertionError)
        args = {}
        args["cycleTime_ms"] = cycleTime_ms
        rsp = agent.json_rpc(self.target, "testSequence", args)

    # enumeration
    class TestStatus(Enumeration):
        idlType = "test.Display.TestStatus:1.0.0"
        values = ["TEST_IDLE", "TEST_BUSY", "TEST_PASSED", "TEST_FAILED"]

    TestStatus.TEST_IDLE = TestStatus(0)
    TestStatus.TEST_BUSY = TestStatus(1)
    TestStatus.TEST_PASSED = TestStatus(2)
    TestStatus.TEST_FAILED = TestStatus(3)

    def enterTestMode(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "enterTestMode", args)

    def getTestStatus(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getTestStatus", args)
        _ret_ = raritan.rpc.test.Display.TestStatus.decode(rsp["_ret_"])
        typecheck.is_enum(_ret_, raritan.rpc.test.Display.TestStatus, 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/topofw/testintf/idl/TestUnit.idl"
#

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


# interface
class Unit(Interface):
    idlType = "test.Unit:1.0.2"

    def getDisplays(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getDisplays", args)
        _ret_ = [Interface.decode(x0, agent) for x0 in rsp["_ret_"]]
        for x0 in _ret_:
            typecheck.is_interface(x0, raritan.rpc.test.Display, DecodeException)
        return _ret_

    def getButtonStates(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "getButtonStates", args)
        _ret_ = [x0 for x0 in rsp["_ret_"]]
        for x0 in _ret_:
            typecheck.is_bool(x0, DecodeException)
        return _ret_

    def setBuzzer(self, isOn):
        agent = self.agent
        typecheck.is_bool(isOn, AssertionError)
        args = {}
        args["isOn"] = isOn
        rsp = agent.json_rpc(self.target, "setBuzzer", args)

    def resetAllSlaveControllers(self):
        agent = self.agent
        args = {}
        rsp = agent.json_rpc(self.target, "resetAllSlaveControllers", args)

    def triggerSlaveControllerWatchdog(self, rs485Addr):
        agent = self.agent
        typecheck.is_int(rs485Addr, AssertionError)
        args = {}
        args["rs485Addr"] = rs485Addr
        rsp = agent.json_rpc(self.target, "triggerSlaveControllerWatchdog", args)
