// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright 2026 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_1_0_3 : ObjectProxy {

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

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

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

    public const int ERR_INVALID_PARAMS = 1;

    public enum Events {
      EVT_KEY_SETTINGS_CHANGED,
      EVT_KEY_DEVICE_ADDED,
      EVT_KEY_DEVICE_REMOVED,
      EVT_KEY_PACKAGE_INFO_CHANGED,
    }

    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;
        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())
        })));
        return json;
      }

      public static Settings Decode(LightJson.JsonObject json, Agent agent) {
        Settings inst = new Settings();
        inst.zCoordMode = (Com.Raritan.Idl.peripheral.DeviceManager_1_0_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_3_0_1.Thresholds>(_value["key"], Com.Raritan.Idl.sensors.NumericSensor_3_0_1.Thresholds.Decode(_value["value"], agent))));
        return inst;
      }

      public Com.Raritan.Idl.peripheral.DeviceManager_1_0_3.ZCoordMode zCoordMode = Com.Raritan.Idl.peripheral.DeviceManager_1_0_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_3_0_1.Thresholds> defaultThresholdsMap = new System.Collections.Generic.Dictionary<string, Com.Raritan.Idl.sensors.NumericSensor_3_0_1.Thresholds>();
    }

    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_3_0_0.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_3_0_1.Range.Decode(json["defaultRange"], agent);
        inst.defaultDecDigits = (int)json["defaultDecDigits"];
        return inst;
      }

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

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

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

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

      public int cSumErrCnt = 0;
    }

    public class GetDeviceSlotsResult {
      public System.Collections.Generic.IEnumerable<Com.Raritan.Idl.peripheral.DeviceSlot> _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>(_result["_ret_"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.peripheral.DeviceSlot.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>(_result["_ret_"].AsJsonArray.Select(
              _value => Com.Raritan.Idl.peripheral.DeviceSlot.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 _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.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.StaticCast(ObjectProxy.Decode(_result["_ret_"], 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> _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>(_result["_ret_"].AsJsonArray.Select(
        _value => ((Com.Raritan.Idl.peripheral.Device)ValueObjectCodec.DecodeAs(_value, agent, Com.Raritan.Idl.peripheral.Device.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>(_result["_ret_"].AsJsonArray.Select(
              _value => ((Com.Raritan.Idl.peripheral.Device)ValueObjectCodec.DecodeAs(_value, agent, Com.Raritan.Idl.peripheral.Device.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> _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>(_result["_ret_"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.peripheral.PackageInfo.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>(_result["_ret_"].AsJsonArray.Select(
              _value => Com.Raritan.Idl.peripheral.PackageInfo.Decode(_value, agent)));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetSettingsResult {
      public Com.Raritan.Idl.peripheral.DeviceManager_1_0_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_1_0_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_1_0_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_1_0_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_1_0_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_1_0_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_1_0_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_1_0_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_1_0_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_1_0_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_1_0_3.DeviceTypeInfo>(_result["_ret_"].AsJsonArray.Select(
        _value => Com.Raritan.Idl.peripheral.DeviceManager_1_0_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_1_0_3.DeviceTypeInfo>(_result["_ret_"].AsJsonArray.Select(
              _value => Com.Raritan.Idl.peripheral.DeviceManager_1_0_3.DeviceTypeInfo.Decode(_value, agent)));
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

    public class GetStatisticsResult {
      public Com.Raritan.Idl.peripheral.DeviceManager_1_0_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_1_0_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_1_0_3.Statistics.Decode(_result["_ret_"], agent);
            rsp(_ret);
          } catch (Exception e) {
            if (fail != null) fail(e);
          }
        }, fail, rpcCtrl);
    }

  }
}
