// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright 2023 Raritan Inc. All rights reserved.
//
// This file was generated by IdlC from PeripheralDeviceManager.idl.

using System;
using System.Linq;
using LightJson;
using Com.Raritan.Idl;
using Com.Raritan.JsonRpc;
using Com.Raritan.Util;

#pragma warning disable 0108, 0219, 0414, 1591

namespace Com.Raritan.Idl.peripheral {
  public class DeviceManager_5_1_3 : ObjectProxy {

    static public readonly new TypeInfo typeInfo = new TypeInfo("peripheral.DeviceManager:5.1.3", null);

    public DeviceManager_5_1_3(Agent agent, string rid, TypeInfo ti) : base(agent, rid, ti) {}
    public DeviceManager_5_1_3(Agent agent, string rid) : this(agent, rid, typeInfo) {}

    public static new DeviceManager_5_1_3 StaticCast(ObjectProxy proxy) {
      return proxy == null ? null : new DeviceManager_5_1_3(proxy.Agent, proxy.Rid, proxy.StaticTypeInfo);
    }

    public const int ERR_INVALID_PARAMS = 1;

    public const int ERR_NOT_ON_SECONDARY = 2;

    public enum ZCoordMode {
      RACKUNITS,
      FREEFORM,
    }

    public class Settings : ICloneable {
      public object Clone() {
        Settings copy = new Settings();
        copy.zCoordMode = this.zCoordMode;
        copy.autoManageNewDevices = this.autoManageNewDevices;
        copy.deviceAltitude = this.deviceAltitude;
        copy.presenceDetectionTimeout = this.presenceDetectionTimeout;
        copy.defaultThresholdsMap = this.defaultThresholdsMap;
        copy.maxActivePoweredDryContacts = this.maxActivePoweredDryContacts;
        copy.muteOtherAccessControlUnit = this.muteOtherAccessControlUnit;
        return copy;
      }

      public LightJson.JsonObject Encode() {
        LightJson.JsonObject json = new LightJson.JsonObject();
        json["zCoordMode"] = (int)this.zCoordMode;
        json["autoManageNewDevices"] = this.autoManageNewDevices;
        json["deviceAltitude"] = this.deviceAltitude;
        json["presenceDetectionTimeout"] = this.presenceDetectionTimeout;
        json["defaultThresholdsMap"] = new JsonArray(this.defaultThresholdsMap.Select(_entry => (JsonValue) new JsonObject(new System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<string, LightJson.JsonValue>> {
          new System.Collections.Generic.KeyValuePair<string, JsonValue>("key", _entry.Key),
          new System.Collections.Generic.KeyValuePair<string, JsonValue>("value", _entry.Value.Encode())
        })));
        json["maxActivePoweredDryContacts"] = this.maxActivePoweredDryContacts;
        json["muteOtherAccessControlUnit"] = this.muteOtherAccessControlUnit;
        return json;
      }

      public static Settings Decode(LightJson.JsonObject json, Agent agent) {
        Settings inst = new Settings();
        inst.zCoordMode = (Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.ZCoordMode)(int)json["zCoordMode"];
        inst.autoManageNewDevices = (bool)json["autoManageNewDevices"];
        inst.deviceAltitude = (float)json["deviceAltitude"];
        inst.presenceDetectionTimeout = (int)json["presenceDetectionTimeout"];
        inst.defaultThresholdsMap = DictionaryHelper.Create(json["defaultThresholdsMap"].AsJsonArray.Select(
          _value => new System.Collections.Generic.KeyValuePair<string, Com.Raritan.Idl.sensors.NumericSensor_4_0_6.Thresholds>(_value["key"], Com.Raritan.Idl.sensors.NumericSensor_4_0_6.Thresholds.Decode(_value["value"], agent))));
        inst.maxActivePoweredDryContacts = (int)json["maxActivePoweredDryContacts"];
        inst.muteOtherAccessControlUnit = (bool)json["muteOtherAccessControlUnit"];
        return inst;
      }

      public Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.ZCoordMode zCoordMode = Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.ZCoordMode.RACKUNITS;
      public bool autoManageNewDevices = false;
      public float deviceAltitude = 0.0f;
      public int presenceDetectionTimeout = 0;
      public System.Collections.Generic.IDictionary<string, Com.Raritan.Idl.sensors.NumericSensor_4_0_6.Thresholds> defaultThresholdsMap = new System.Collections.Generic.Dictionary<string, Com.Raritan.Idl.sensors.NumericSensor_4_0_6.Thresholds>();
      public int maxActivePoweredDryContacts = 0;
      public bool muteOtherAccessControlUnit = false;
    }

    public class MetaData : ICloneable {
      public object Clone() {
        MetaData copy = new MetaData();
        copy.oneWirePortCount = this.oneWirePortCount;
        copy.onboardDeviceCount = this.onboardDeviceCount;
        return copy;
      }

      public LightJson.JsonObject Encode() {
        LightJson.JsonObject json = new LightJson.JsonObject();
        json["oneWirePortCount"] = this.oneWirePortCount;
        json["onboardDeviceCount"] = this.onboardDeviceCount;
        return json;
      }

      public static MetaData Decode(LightJson.JsonObject json, Agent agent) {
        MetaData inst = new MetaData();
        inst.oneWirePortCount = (int)json["oneWirePortCount"];
        inst.onboardDeviceCount = (int)json["onboardDeviceCount"];
        return inst;
      }

      public int oneWirePortCount = 0;
      public int onboardDeviceCount = 0;
    }

    public class DeviceTypeInfo : ICloneable {
      public object Clone() {
        DeviceTypeInfo copy = new DeviceTypeInfo();
        copy.type = this.type;
        copy.isActuator = this.isActuator;
        copy.identifier = this.identifier;
        copy.name = this.name;
        copy.defaultRange = this.defaultRange;
        copy.defaultDecDigits = this.defaultDecDigits;
        return copy;
      }

      public LightJson.JsonObject Encode() {
        LightJson.JsonObject json = new LightJson.JsonObject();
        json["type"] = this.type.Encode();
        json["isActuator"] = this.isActuator;
        json["identifier"] = this.identifier;
        json["name"] = this.name;
        json["defaultRange"] = this.defaultRange.Encode();
        json["defaultDecDigits"] = this.defaultDecDigits;
        return json;
      }

      public static DeviceTypeInfo Decode(LightJson.JsonObject json, Agent agent) {
        DeviceTypeInfo inst = new DeviceTypeInfo();
        inst.type = Com.Raritan.Idl.sensors.Sensor_4_0_5.TypeSpec.Decode(json["type"], agent);
        inst.isActuator = (bool)json["isActuator"];
        inst.identifier = (string)json["identifier"];
        inst.name = (string)json["name"];
        inst.defaultRange = Com.Raritan.Idl.sensors.NumericSensor_4_0_6.Range.Decode(json["defaultRange"], agent);
        inst.defaultDecDigits = (int)json["defaultDecDigits"];
        return inst;
      }

      public Com.Raritan.Idl.sensors.Sensor_4_0_5.TypeSpec type = new Com.Raritan.Idl.sensors.Sensor_4_0_5.TypeSpec();
      public bool isActuator = false;
      public string identifier = "";
      public string name = "";
      public Com.Raritan.Idl.sensors.NumericSensor_4_0_6.Range defaultRange = new Com.Raritan.Idl.sensors.NumericSensor_4_0_6.Range();
      public int defaultDecDigits = 0;
    }

    public class FirmwareUpdateState : ICloneable {
      public object Clone() {
        FirmwareUpdateState copy = new FirmwareUpdateState();
        copy.active = this.active;
        copy.remaining = this.remaining;
        return copy;
      }

      public LightJson.JsonObject Encode() {
        LightJson.JsonObject json = new LightJson.JsonObject();
        json["active"] = this.active;
        json["remaining"] = this.remaining;
        return json;
      }

      public static FirmwareUpdateState Decode(LightJson.JsonObject json, Agent agent) {
        FirmwareUpdateState inst = new FirmwareUpdateState();
        inst.active = (bool)json["active"];
        inst.remaining = (int)json["remaining"];
        return inst;
      }

      public bool active = false;
      public int remaining = 0;
    }

    public class SettingsChangedEvent : Com.Raritan.Idl._event.UserEvent {
      static public readonly new TypeInfo typeInfo = new TypeInfo("peripheral.DeviceManager_5_1_3.SettingsChangedEvent:1.0.0", Com.Raritan.Idl._event.UserEvent.typeInfo);

      public Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Settings oldSettings = new Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Settings();
      public Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Settings newSettings = new Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Settings();
    }

    public class DeviceEvent : Com.Raritan.Idl.idl.Event {
      static public readonly new TypeInfo typeInfo = new TypeInfo("peripheral.DeviceManager_5_1_3.DeviceEvent:1.0.0", Com.Raritan.Idl.idl.Event.typeInfo);

      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.Device_7_0_0> devices = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.Device_7_0_0>();
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.Device_7_0_0> allDevices = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.Device_7_0_0>();
    }

    public class DeviceAddedEvent : Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.DeviceEvent {
      static public readonly new TypeInfo typeInfo = new TypeInfo("peripheral.DeviceManager_5_1_3.DeviceAddedEvent:1.0.0", Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.DeviceEvent.typeInfo);

    }

    public class DeviceRemovedEvent : Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.DeviceEvent {
      static public readonly new TypeInfo typeInfo = new TypeInfo("peripheral.DeviceManager_5_1_3.DeviceRemovedEvent:1.0.0", Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.DeviceEvent.typeInfo);

    }

    public class UnknownDeviceAttachedEvent : Com.Raritan.Idl.idl.Event {
      static public readonly new TypeInfo typeInfo = new TypeInfo("peripheral.DeviceManager_5_1_3.UnknownDeviceAttachedEvent:1.0.0", Com.Raritan.Idl.idl.Event.typeInfo);

      public string romCode = "";
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.PosElement_4_0_0> position = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.PosElement_4_0_0>();
    }

    public enum DeviceFirmwareUpdateState {
      UPDATE_STARTED,
      UPDATE_SUCCESSFUL,
      UPDATE_FAILED,
    }

    public class DeviceFirmwareUpdateStateChangedEvent : Com.Raritan.Idl.idl.Event {
      static public readonly new TypeInfo typeInfo = new TypeInfo("peripheral.DeviceManager_5_1_3.DeviceFirmwareUpdateStateChangedEvent:1.0.0", Com.Raritan.Idl.idl.Event.typeInfo);

      public string oldVersion = "";
      public string newVersion = "";
      public string serial = "";
      public Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.DeviceFirmwareUpdateState state = Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.DeviceFirmwareUpdateState.UPDATE_STARTED;
    }

    public class FirmwareUpdateStateChangedEvent : Com.Raritan.Idl.idl.Event {
      static public readonly new TypeInfo typeInfo = new TypeInfo("peripheral.DeviceManager_5_1_3.FirmwareUpdateStateChangedEvent:1.0.0", Com.Raritan.Idl.idl.Event.typeInfo);

      public Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.FirmwareUpdateState newState = new Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.FirmwareUpdateState();
    }

    public class PackageEvent : Com.Raritan.Idl.idl.Event {
      static public readonly new TypeInfo typeInfo = new TypeInfo("peripheral.DeviceManager_5_1_3.PackageEvent:1.0.0", Com.Raritan.Idl.idl.Event.typeInfo);

      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.PackageInfo_5_0_0> packageInfos = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.PackageInfo_5_0_0>();
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.PackageInfo_5_0_0> allPackages = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.PackageInfo_5_0_0>();
    }

    public class PackageAddedEvent : Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.PackageEvent {
      static public readonly new TypeInfo typeInfo = new TypeInfo("peripheral.DeviceManager_5_1_3.PackageAddedEvent:1.0.0", Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.PackageEvent.typeInfo);

    }

    public class PackageRemovedEvent : Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.PackageEvent {
      static public readonly new TypeInfo typeInfo = new TypeInfo("peripheral.DeviceManager_5_1_3.PackageRemovedEvent:1.0.0", Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.PackageEvent.typeInfo);

    }

    public class Statistics : ICloneable {
      public object Clone() {
        Statistics copy = new Statistics();
        copy.cSumErrCnt = this.cSumErrCnt;
        copy.fuseTripCnt = this.fuseTripCnt;
        return copy;
      }

      public LightJson.JsonObject Encode() {
        LightJson.JsonObject json = new LightJson.JsonObject();
        json["cSumErrCnt"] = this.cSumErrCnt;
        json["fuseTripCnt"] = this.fuseTripCnt;
        return json;
      }

      public static Statistics Decode(LightJson.JsonObject json, Agent agent) {
        Statistics inst = new Statistics();
        inst.cSumErrCnt = (int)json["cSumErrCnt"];
        inst.fuseTripCnt = (int)json["fuseTripCnt"];
        return inst;
      }

      public int cSumErrCnt = 0;
      public int fuseTripCnt = 0;
    }

    public class GetDeviceSlotsResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.DeviceSlot_5_0_0> _ret_;
    }

    public GetDeviceSlotsResult getDeviceSlots() {
      JsonObject _parameters = null;
      var _result = RpcCall("getDeviceSlots", _parameters);
      var _ret = new GetDeviceSlotsResult();
      _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.DeviceSlot_5_0_0>(_result["_ret_"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.peripheral.DeviceSlot_5_0_0.StaticCast(ObjectProxy.Decode(_value, agent))));
      return _ret;
    }

    public AsyncRequest getDeviceSlots(AsyncRpcResponse<GetDeviceSlotsResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getDeviceSlots(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getDeviceSlots(AsyncRpcResponse<GetDeviceSlotsResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getDeviceSlots", _parameters,
        _result => {
          try {
            var _ret = new GetDeviceSlotsResult();
            _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.DeviceSlot_5_0_0>(_result["_ret_"].AsJsonArray.Select(
              _value => Com.Raritan.Idl.peripheral.DeviceSlot_5_0_0.StaticCast(ObjectProxy.Decode(_value, agent))));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetDeviceSlotResult {
      public Com.Raritan.Idl.peripheral.DeviceSlot_5_0_0 _ret_;
    }

    public GetDeviceSlotResult getDeviceSlot(int idx) {
      var _parameters = new LightJson.JsonObject();
      _parameters["idx"] = idx;

      var _result = RpcCall("getDeviceSlot", _parameters);
      var _ret = new GetDeviceSlotResult();
      _ret._ret_ = Com.Raritan.Idl.peripheral.DeviceSlot_5_0_0.StaticCast(ObjectProxy.Decode(_result["_ret_"], agent));
      return _ret;
    }

    public AsyncRequest getDeviceSlot(int idx, AsyncRpcResponse<GetDeviceSlotResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getDeviceSlot(idx, rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getDeviceSlot(int idx, AsyncRpcResponse<GetDeviceSlotResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      var _parameters = new LightJson.JsonObject();
      try {
        _parameters["idx"] = idx;
      } catch (Exception e) {
        if (fail != null) fail(e);
      }

      return RpcCall("getDeviceSlot", _parameters,
        _result => {
          try {
            var _ret = new GetDeviceSlotResult();
            _ret._ret_ = Com.Raritan.Idl.peripheral.DeviceSlot_5_0_0.StaticCast(ObjectProxy.Decode(_result["_ret_"], agent));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetSensorHubsResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.SensorHub_2_0_2> _ret_;
    }

    public GetSensorHubsResult getSensorHubs() {
      JsonObject _parameters = null;
      var _result = RpcCall("getSensorHubs", _parameters);
      var _ret = new GetSensorHubsResult();
      _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.SensorHub_2_0_2>(_result["_ret_"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.peripheral.SensorHub_2_0_2.StaticCast(ObjectProxy.Decode(_value, agent))));
      return _ret;
    }

    public AsyncRequest getSensorHubs(AsyncRpcResponse<GetSensorHubsResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getSensorHubs(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getSensorHubs(AsyncRpcResponse<GetSensorHubsResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getSensorHubs", _parameters,
        _result => {
          try {
            var _ret = new GetSensorHubsResult();
            _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.SensorHub_2_0_2>(_result["_ret_"].AsJsonArray.Select(
              _value => Com.Raritan.Idl.peripheral.SensorHub_2_0_2.StaticCast(ObjectProxy.Decode(_value, agent))));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetDiscoveredDevicesResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.Device_7_0_0> _ret_;
    }

    public GetDiscoveredDevicesResult getDiscoveredDevices() {
      JsonObject _parameters = null;
      var _result = RpcCall("getDiscoveredDevices", _parameters);
      var _ret = new GetDiscoveredDevicesResult();
      _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.Device_7_0_0>(_result["_ret_"].AsJsonArray.Select(
        _value => ((Com.Raritan.Idl.peripheral.Device_7_0_0)ValueObjectCodec.DecodeAs(_value, agent, Com.Raritan.Idl.peripheral.Device_7_0_0.typeInfo))));
      return _ret;
    }

    public AsyncRequest getDiscoveredDevices(AsyncRpcResponse<GetDiscoveredDevicesResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getDiscoveredDevices(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getDiscoveredDevices(AsyncRpcResponse<GetDiscoveredDevicesResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getDiscoveredDevices", _parameters,
        _result => {
          try {
            var _ret = new GetDiscoveredDevicesResult();
            _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.Device_7_0_0>(_result["_ret_"].AsJsonArray.Select(
              _value => ((Com.Raritan.Idl.peripheral.Device_7_0_0)ValueObjectCodec.DecodeAs(_value, agent, Com.Raritan.Idl.peripheral.Device_7_0_0.typeInfo))));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetDiscoveredPackageInfosResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.PackageInfo_5_0_0> _ret_;
    }

    public GetDiscoveredPackageInfosResult getDiscoveredPackageInfos() {
      JsonObject _parameters = null;
      var _result = RpcCall("getDiscoveredPackageInfos", _parameters);
      var _ret = new GetDiscoveredPackageInfosResult();
      _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.PackageInfo_5_0_0>(_result["_ret_"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.peripheral.PackageInfo_5_0_0.Decode(_value, agent)));
      return _ret;
    }

    public AsyncRequest getDiscoveredPackageInfos(AsyncRpcResponse<GetDiscoveredPackageInfosResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getDiscoveredPackageInfos(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getDiscoveredPackageInfos(AsyncRpcResponse<GetDiscoveredPackageInfosResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getDiscoveredPackageInfos", _parameters,
        _result => {
          try {
            var _ret = new GetDiscoveredPackageInfosResult();
            _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.PackageInfo_5_0_0>(_result["_ret_"].AsJsonArray.Select(
              _value => Com.Raritan.Idl.peripheral.PackageInfo_5_0_0.Decode(_value, agent)));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetSettingsResult {
      public Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Settings _ret_;
    }

    public GetSettingsResult getSettings() {
      JsonObject _parameters = null;
      var _result = RpcCall("getSettings", _parameters);
      var _ret = new GetSettingsResult();
      _ret._ret_ = Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Settings.Decode(_result["_ret_"], agent);
      return _ret;
    }

    public AsyncRequest getSettings(AsyncRpcResponse<GetSettingsResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getSettings(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getSettings(AsyncRpcResponse<GetSettingsResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getSettings", _parameters,
        _result => {
          try {
            var _ret = new GetSettingsResult();
            _ret._ret_ = Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Settings.Decode(_result["_ret_"], agent);
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class SetSettingsResult {
      public int _ret_;
    }

    public SetSettingsResult setSettings(Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Settings settings) {
      var _parameters = new LightJson.JsonObject();
      _parameters["settings"] = settings.Encode();

      var _result = RpcCall("setSettings", _parameters);
      var _ret = new SetSettingsResult();
      _ret._ret_ = (int)_result["_ret_"];
      return _ret;
    }

    public AsyncRequest setSettings(Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Settings settings, AsyncRpcResponse<SetSettingsResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return setSettings(settings, rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest setSettings(Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Settings settings, AsyncRpcResponse<SetSettingsResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      var _parameters = new LightJson.JsonObject();
      try {
        _parameters["settings"] = settings.Encode();
      } catch (Exception e) {
        if (fail != null) fail(e);
      }

      return RpcCall("setSettings", _parameters,
        _result => {
          try {
            var _ret = new SetSettingsResult();
            _ret._ret_ = (int)_result["_ret_"];
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetMetaDataResult {
      public Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.MetaData _ret_;
    }

    public GetMetaDataResult getMetaData() {
      JsonObject _parameters = null;
      var _result = RpcCall("getMetaData", _parameters);
      var _ret = new GetMetaDataResult();
      _ret._ret_ = Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.MetaData.Decode(_result["_ret_"], agent);
      return _ret;
    }

    public AsyncRequest getMetaData(AsyncRpcResponse<GetMetaDataResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getMetaData(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getMetaData(AsyncRpcResponse<GetMetaDataResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getMetaData", _parameters,
        _result => {
          try {
            var _ret = new GetMetaDataResult();
            _ret._ret_ = Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.MetaData.Decode(_result["_ret_"], agent);
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetDeviceTypeInfosResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.DeviceTypeInfo> _ret_;
    }

    public GetDeviceTypeInfosResult getDeviceTypeInfos() {
      JsonObject _parameters = null;
      var _result = RpcCall("getDeviceTypeInfos", _parameters);
      var _ret = new GetDeviceTypeInfosResult();
      _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.DeviceTypeInfo>(_result["_ret_"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.DeviceTypeInfo.Decode(_value, agent)));
      return _ret;
    }

    public AsyncRequest getDeviceTypeInfos(AsyncRpcResponse<GetDeviceTypeInfosResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getDeviceTypeInfos(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getDeviceTypeInfos(AsyncRpcResponse<GetDeviceTypeInfosResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getDeviceTypeInfos", _parameters,
        _result => {
          try {
            var _ret = new GetDeviceTypeInfosResult();
            _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.DeviceTypeInfo>(_result["_ret_"].AsJsonArray.Select(
              _value => Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.DeviceTypeInfo.Decode(_value, agent)));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetFirmwareUpdateStateResult {
      public Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.FirmwareUpdateState _ret_;
    }

    public GetFirmwareUpdateStateResult getFirmwareUpdateState() {
      JsonObject _parameters = null;
      var _result = RpcCall("getFirmwareUpdateState", _parameters);
      var _ret = new GetFirmwareUpdateStateResult();
      _ret._ret_ = Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.FirmwareUpdateState.Decode(_result["_ret_"], agent);
      return _ret;
    }

    public AsyncRequest getFirmwareUpdateState(AsyncRpcResponse<GetFirmwareUpdateStateResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getFirmwareUpdateState(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getFirmwareUpdateState(AsyncRpcResponse<GetFirmwareUpdateStateResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getFirmwareUpdateState", _parameters,
        _result => {
          try {
            var _ret = new GetFirmwareUpdateStateResult();
            _ret._ret_ = Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.FirmwareUpdateState.Decode(_result["_ret_"], agent);
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetStatisticsResult {
      public Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Statistics _ret_;
    }

    public GetStatisticsResult getStatistics() {
      JsonObject _parameters = null;
      var _result = RpcCall("getStatistics", _parameters);
      var _ret = new GetStatisticsResult();
      _ret._ret_ = Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Statistics.Decode(_result["_ret_"], agent);
      return _ret;
    }

    public AsyncRequest getStatistics(AsyncRpcResponse<GetStatisticsResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getStatistics(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getStatistics(AsyncRpcResponse<GetStatisticsResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getStatistics", _parameters,
        _result => {
          try {
            var _ret = new GetStatisticsResult();
            _ret._ret_ = Com.Raritan.Idl.peripheral.DeviceManager_5_1_3.Statistics.Decode(_result["_ret_"], agent);
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetDiscoveredPackagesResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.Package_3_0_1> _ret_;
    }

    public GetDiscoveredPackagesResult getDiscoveredPackages() {
      JsonObject _parameters = null;
      var _result = RpcCall("getDiscoveredPackages", _parameters);
      var _ret = new GetDiscoveredPackagesResult();
      _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.Package_3_0_1>(_result["_ret_"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.peripheral.Package_3_0_1.StaticCast(ObjectProxy.Decode(_value, agent))));
      return _ret;
    }

    public AsyncRequest getDiscoveredPackages(AsyncRpcResponse<GetDiscoveredPackagesResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getDiscoveredPackages(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getDiscoveredPackages(AsyncRpcResponse<GetDiscoveredPackagesResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getDiscoveredPackages", _parameters,
        _result => {
          try {
            var _ret = new GetDiscoveredPackagesResult();
            _ret._ret_ = new System.Collections.Generic.List<Com.Raritan.Idl.peripheral.Package_3_0_1>(_result["_ret_"].AsJsonArray.Select(
              _value => Com.Raritan.Idl.peripheral.Package_3_0_1.StaticCast(ObjectProxy.Decode(_value, agent))));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetPortFuseResult {
      public Com.Raritan.Idl.portsmodel.PortFuse_1_0_1 _ret_;
    }

    public GetPortFuseResult getPortFuse() {
      JsonObject _parameters = null;
      var _result = RpcCall("getPortFuse", _parameters);
      var _ret = new GetPortFuseResult();
      _ret._ret_ = Com.Raritan.Idl.portsmodel.PortFuse_1_0_1.StaticCast(ObjectProxy.Decode(_result["_ret_"], agent));
      return _ret;
    }

    public AsyncRequest getPortFuse(AsyncRpcResponse<GetPortFuseResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getPortFuse(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getPortFuse(AsyncRpcResponse<GetPortFuseResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getPortFuse", _parameters,
        _result => {
          try {
            var _ret = new GetPortFuseResult();
            _ret._ret_ = Com.Raritan.Idl.portsmodel.PortFuse_1_0_1.StaticCast(ObjectProxy.Decode(_result["_ret_"], agent));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetGatewaySensorManagerResult {
      public Com.Raritan.Idl.peripheral.GatewaySensorManager _ret_;
    }

    public GetGatewaySensorManagerResult getGatewaySensorManager() {
      JsonObject _parameters = null;
      var _result = RpcCall("getGatewaySensorManager", _parameters);
      var _ret = new GetGatewaySensorManagerResult();
      _ret._ret_ = Com.Raritan.Idl.peripheral.GatewaySensorManager.StaticCast(ObjectProxy.Decode(_result["_ret_"], agent));
      return _ret;
    }

    public AsyncRequest getGatewaySensorManager(AsyncRpcResponse<GetGatewaySensorManagerResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail) {
      return getGatewaySensorManager(rsp, fail, RpcCtrl.Default);
    }

    public AsyncRequest getGatewaySensorManager(AsyncRpcResponse<GetGatewaySensorManagerResult>.SuccessHandler rsp, AsyncRpcResponse.FailureHandler fail, RpcCtrl rpcCtrl) {
      JsonObject _parameters = null;
      return RpcCall("getGatewaySensorManager", _parameters,
        _result => {
          try {
            var _ret = new GetGatewaySensorManagerResult();
            _ret._ret_ = Com.Raritan.Idl.peripheral.GatewaySensorManager.StaticCast(ObjectProxy.Decode(_result["_ret_"], agent));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

  }
}
